Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion MatMul/matmul.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
#define NCA 15 /* number of columns in matrix A */
#define NCB 7 /* number of columns in matrix B */



int main (int argc, char *argv[])
{
int tid, nthreads, i, j, k, chunk;
Expand All @@ -24,7 +26,9 @@ double a[NRA][NCA], /* matrix A to be multiplied */

chunk = 10; /* set loop iteration chunk size */

/*** Spawn a parallel region explicitly scoping all variables ***/


/*** Spawn a parallel region explicitly scoping all variables hope this works ***/
#pragma omp parallel shared(a,b,c,nthreads,chunk) private(tid,i,j,k)
{
tid = omp_get_thread_num();
Expand All @@ -47,6 +51,8 @@ chunk = 10; /* set loop iteration chunk size */
for (i=0; i<NRA; i++)
for (j=0; j<NCB; j++)
c[i][j]= 0;



/*** Do matrix multiply sharing iterations on outer loop ***/
/*** Display who does which iterations for demonstration purposes ***/
Expand All @@ -60,6 +66,8 @@ chunk = 10; /* set loop iteration chunk size */
c[i][j] += a[i][k] * b[k][j];
}
} /*** End of parallel region ***/



/*** Print results ***/
printf("******************************************************\n");
Expand Down