Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

In 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Next Generation Databases NoSQLand Big Data

Authors: Guy Harrison

1st Edition

1484213300, 978-1484213308

More Books

Students also viewed these Databases questions