problem(please help)
hi there..
well im new in unix world however i like it and i feel im good on it
anyway i am stuck in a problem and try to solve it but i need some help
its about multithreading
please help me and make me one of your member family
please as soon as possible
thnx
{{
Write a C language program to implement multithreaded matrix multiplication using Pthreads
• Create a separate worker thread to compute each row of the result matrix, instead of a thread for each element.
• Do not initialize the contents of the A and B matrices statically. The A and B matrices will be initialized by reading data from an input file (see notes below).
• Be able to process multiple sets of input matrices by continuing to read data in the specified format (described below) until you encounter an input line containing a single hash mark (‘#’) instead of an integer value for M (first dimension of the A matrix). If any other character than a hash mark is specified, output an error message and terminate the program with a non-zero return code. Each set of data processed must be labeled to indicate which set of data is being output (e.g., Set 1, Set 2, etc).
The input file will be an ASCII file containing numbers that define the dimensions and contents of the A and B matrices for which a matrix product is to be computed. The first line of the input file will contain two numbers specifying the dimensions of the A matrix (M x K). Following that will be M lines, each with K numbers, representing the elements of matrix A. Next will be a line with two numbers specifying the dimensions of the B matrix (K x N). And following that will be K lines, each with N numbers, representing the elements of matrix B. For example, suppose that matrix A has 2 rows and 3 columns and matrix B has 3 rows and 4 columns, as follows:
A B
1 2 3 3 5 7 9
4 5 6 8 6 4 2
4 3 2 1
The lines in the input file would be as follows:
2 3
1 2 3
4 5 6
3 4
3 5 7 9
8 6 4 2
4 3 2 1
program should print the contents of matrix A and matrix B. It should then print lines showing the thread ID numbers for the worker threads it creates. Then it should
print the contents of the result matrix C. The output from program for the above input should look similar to the following:
Set 1 Matrix A:
1 2 3
4 5 6
Set 1 Matrix B:
3 5 7 9
8 6 4 2
4 3 2 1
Created worker thread 15823744 for row 0
Created worker thread 26375040 for row 1
Set 1 Matrix C = A x B:
31 26 21 16
76 68 60 52
matrices will have a most 10 rows and 10 columns
Notes:
• Thread ID value is actually an address of an opaque thread data structure that is implementation dependent on each OS version . To get to the actual thread number would make program non-portable! That is, the actual Id number is saved in different places in the data structure on different systems
• you must create at least two threads, running at the same time, before you will see a different address (Thread ID) listed
}}
|