0

Could someone please advise me on how to implement fork() in a parallel processing (multiplying) of a 2d array....I have been at this for far too long..

here is my code

for (int i = 0; i < rowCol[0]; i++ ) result[i] = (float*)malloc ( rowCol[1] * sizeof(float) );
	int i = 0;
	int j = 0;
	int k = 0;
	
	for(i = 0; i < rowCol[0]; i++) 
	{
		for( j = 0; j <rowCol[3]; j++)
		{		
			result[i][j] = 0;
			for( k = 0; k < rowCol[1]; k++)
			{
				result[i][j] += (matrix1[i][k] * matrix2[k][j]);

			}
			
		}
	}

Any step in the right direction would be greatly appreciated

Thanks

Edited by Nick Evan: Fixed tags

3
Contributors
8
Replies
9
Views
7 Years
Discussion Span
Last Post by abhimanipal
0

H there, actually it is a requirement for this assignment....out of curiosity, how would you implement with threads...

0

H there, actually it is a requirement for this assignment....out of curiosity, how would you implement with threads...

If your having problems with fork() then threads should probably wait. One question, how are you coordinating the calculating and passing of data between the two processes(parent and forked child)..

0

I am trying to use waitpid but not sure what exactly is going on.....

0

How many child processes do you have to create ?
In the sense, you create 1 child process, it does the computation and sends the result back
Or the more complicated scenario
Each child computes only 1 row of the result matrix and you have to create as many children as their are rows

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.