Question: bIn this course, we will use C for the OpenMP, GPU and MPI programming. This exercise will refresh your memory about C programming. Please write

bIn this course, we will use C for the OpenMP, GPU and MPI programming. This exercise will refresh your memory about C programming. Please write a serial C program to do the matrix-vector multiplication.
Implementation requirements:
Because the input matrix and vector can be very large, you must use dynamic memory allocation (i.e., malloc and free) to store them in the heap. If your implementation stores the input matrix, the input vector, or the output vector in the stack, we will deduct 10 points.
There are many ways to store the matrix in a dynamically allocated 2-dimensional array in C, including (a) using the row-major order or column-major order in a 1-dimentional array or (b) using an array of pointers to a set of 1-dimensional arrays. In this exercise, please store the matrix in a dynamically allocated 1-dimensional array in the row-major order (5 points).
To help you meeting the two implementation requirements, we have provided a toy C program that dynamically allocates a 2D array stored by row-major order. This C program is called array_allocation.c under the Problem_2 sub-directory.
Your matrix-vector multiplication program should take two input files, one for the input matrix and the other one for the input vector. All the numbers are integers. The two input files are provided in the comma-separated values (CSV) format. To prevent the numbers from running out of range, please declare the type of all variables as long int. The output vector should be saved in a CSV file.
Your program should be run using the following command line:
serial_mult_mat_vec file_1.csv n_row_1 n_col_1 file_2.csv n_row_2 result_vector.csv

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!