Computers and Technology

You are given a skeleton sequential program for matrix multiplication below: #include
#include
#include
#define M 500
#define N 500
int main(int argc, char *argv) {
//set number of threads here
omp_set_num_threads(8);
int i, j, k;
double sum;
double **A, **B, **C;
A = malloc(M*sizeof(double *));
B = malloc(M*sizeof(double *));
C = malloc(M*sizeof(double *));
for (i = 0; i < M; i++) {
A[i] = malloc(N*sizeof(double));
B[i] = malloc(N*sizeof(double));
C[i] = malloc(N*sizeof(double));
}
double start, end;
for (i = 0; i < M; i++) {
for (j = 0; j < N; j++) {
A[i][j] = j*1;
B[i][j] = i*j+2;
C[i][j] = j-i*2;
}
}
start = omp_get_wtime();
for (i = 0; i < M; i++) {
for (j = 0; j < N; j++) {
sum = 0;
for (k=0; k < M; k++) {
sum += A[i][k]*B[k][j];
}
C[i][j] = sum;
}
}
end = omp_get_wtime();
printf("Time of computation: %f\n", end-start);
}
You are to parallelize this algorithm in three different ways:
Add the necessary pragma to parallelize the outer for loop
Remove the pragma for the outer for loop and create a pragma for the middle for loop
3. Add the necessary pragmas to parallelize both the outer and middle for loops
and collect timing data given 2 thread, 4 threads, 8 threads, 16 threads, 32 threads and three matrix sizes. You
will find that when you run the same program several times, the timing values can vary significantly. Therefore
for each set of conditions, collect five data values and average them. Use a spreadsheet program either from MS Office or OpenOffice to collect and store your data and perform the necessary calculations and illustrate the results visually with Charts.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 08:10, josued123321
Alook-up table used to convert pixel values to output values on a monitor. essentially, all pixels with a value of 190 or above are shown as white (i. e. 255), and all values with a value of 63 or less are shown as black (i. e. 0). in between the pixels are scaled so that a pixel with a value p is converted to a pixel of value 2/127 −+3969). if a pixel has a value of 170 originally, what value will be used to display the pixel on the monitor? if a value of 110 is used to display the pixel on the monitor, what was the original value of the pixel?
Answers: 1
image
Computers and Technology, 23.06.2019 02:30, reyne36
Rafael needs to add a title row to a table that he has inserted in word. what should he do? use the alignment options. use the merge and center option for all the cells in the top row. use the merge and center option on the first two cells in the top row. none of the above
Answers: 3
image
Computers and Technology, 23.06.2019 11:30, kyraj21
Which excel file extension stores automated steps for repetitive tasks?
Answers: 1
image
Computers and Technology, 23.06.2019 13:00, dimondqueen511
Which one of the following voltages should never be measured directly with a vom? a. 1200 v b. 500 v c. 800 v d. 100v
Answers: 2
Do you know the correct answer?
You are given a skeleton sequential program for matrix multiplication below: #include
#inclu...

Questions in other subjects:

Konu
English, 02.03.2022 23:50
Konu
History, 02.03.2022 23:50