I want to do matrix multiplication using multiple processes via fork and using shared memory with each of the process computing one row for small sized matrix but with higher sized matrices it is not possible to create a process for each row . So It should compute a block of rows determined by the size. For example upto 10 rows it should calculate one row per process and after that say for 20 rows one process should calculate 4 rows each. I am unable to program it as I can take row number as number of processes. Suppose I take number of processes constant say 8 then each block would have N/8 rows.But then size of matrix should be multiple of 8, and number of processes should be variable.Suppose it has 6 CPUs , Can I take number of processes to be constant i e 6 .What can be the right approach ? How should I write it ?
0
votes
1 Answers
0
votes
Here's some example code which demonstrates matrix mult. in pthreads. I found it almost instantly in a search engine. It shows a method for doing what you describe.
http://www.cs.arizona.edu/classes/cs422/spring13/examples/matmult-dyn.c
You'll probably need to do some fine tuning of it to determine what is the best approach.
You probably should also read this article: http://aristeia.com/TalkNotes/PDXCodeCamp2010.pdf