Skip to content

Assignment for Parallel and Distributed Computing 2014 course at Todai.

Notifications You must be signed in to change notification settings

gladnik/ParallelAndDistributedComputing

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ParallelAndDistributedComputing

Assignment for Parallel and Distributed Computing 2014 course at Todai.

Implement a program that multiplies matrices in sequential and parallel way, compare performance of 1, 2, 4 threads.

  1. C++ source code is here.
int i, j, k;
omp_set_num_threads(4);
#pragma omp parallel for shared (matrixA, matrixB, matrixC) private (i, j, k)
for (i = 0; i < m; i++)
{
   for (k = 0; k < q; k++)
   {
   	float sum = 0;
   	for (j = 0; j < n; j++)
   	{
   		sum += matrixA[i][j] * matrixB[j][k]; 
   	}
   	matrixC[i][k] = sum;
   }
}
   ```

2. C# source code is [here](https://github.com/gladnik/ParallelAndDistributedComputing/blob/master/MatrixMultiplicationCS/MatrixMultiplicationCS/MatrixMultiplication.cs).

```C#
ParallelOptions options = new ParallelOptions();
options.MaxDegreeOfParallelism = 2;
Parallel.For(0, m, options, i =>
{
   for (int k = 0; k < q; k++)
   {
   	float sum = 0;
   	for (int j = 0; j < n; j++)
   	{
   		sum += matrixA[i, j] * matrixB[j, k];
   	}
   	matrixC[i, k] = sum;
   }
});

About

Assignment for Parallel and Distributed Computing 2014 course at Todai.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published