Q1 arithmetic. The requirement is very simple; your program should read a square matrix of some integers from a text file (an example file given below), populate it into a proper data structure, and calculate the sum of all the numbers present in the matrix. But the calculation process should be carried out by 4 different worker threads in parallel. You can think of your matrix equally divided into 4 sections (northwest, northeast, southwest, southeast). You can also assume that the number of rows, hence the number of columns since it is a square matrix, is an integral power of 2. The results of the worker threads should be assembled, i.e. added up, to get the overall result of the program. In the meantime, the main thread should also calculate the same summation, and compare its own results with the assembled results of the worker threads. Finally, it should produce a simple output indicating whether the resulting cooperative calculation by the worker threads is correct, or not. You should take care of any synchronization requirements of the threads, and implement the proper synchronization solution whenever needed. On the other hand, you should not overly constrain the running of your threads by some unnecessary synchronizations. Possible parallelism in the hardware you will use to run your program should be exploited as much as possible. We want you to write a multithreaded program in C to do some simple matrix What type of parallelism you employed in your program to get the result? And at which points do you need to synchronize your threads, including the main thread? An example input file for a 4x4 matrix: 23 56 67 99 21 4 876 100 43 1 999 126 22 9. 86

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Must do read question carefully and answer accordingly

Q1
arithmetic. The requirement is very simple; your program should read a square matrix of some
integers from a text file (an example file given below), populate it into a proper data structure, and
calculate the sum of all the numbers present in the matrix. But the calculation process should be
carried out by 4 different worker threads in parallel. You can think of your matrix equally divided
into 4 sections (northwest, northeast, southwest, southeast). You can also assume that the number
of rows, hence the number of columns since it is a square matrix, is an integral power of 2. The
results of the worker threads should be assembled, i.e. added up, to get the overall result of the
program. In the meantime, the main thread should also calculate the same summation, and compare
its own results with the assembled results of the worker threads. Finally, it should produce a simple
output indicating whether the resulting cooperative calculation by the worker threads is correct, or
not. You should take care of any synchronization requirements of the threads, and implement the
proper synchronization solution whenever needed. On the other hand, you should not overly
constrain the running of your threads by some unnecessary synchronizations. Possible parallelism
in the hardware you will use to run your program should be exploited as much as possible.
We want you to write a multithreaded program in C to do some simple matrix
What type of parallelism you employed in your program to get the result? And at which points do
you need to synchronize your threads, including the main thread?
An example input file for a 4x4 matrix:
23
56
67
99
21
4
876
100
43
1
999
126
22
86
Transcribed Image Text:Q1 arithmetic. The requirement is very simple; your program should read a square matrix of some integers from a text file (an example file given below), populate it into a proper data structure, and calculate the sum of all the numbers present in the matrix. But the calculation process should be carried out by 4 different worker threads in parallel. You can think of your matrix equally divided into 4 sections (northwest, northeast, southwest, southeast). You can also assume that the number of rows, hence the number of columns since it is a square matrix, is an integral power of 2. The results of the worker threads should be assembled, i.e. added up, to get the overall result of the program. In the meantime, the main thread should also calculate the same summation, and compare its own results with the assembled results of the worker threads. Finally, it should produce a simple output indicating whether the resulting cooperative calculation by the worker threads is correct, or not. You should take care of any synchronization requirements of the threads, and implement the proper synchronization solution whenever needed. On the other hand, you should not overly constrain the running of your threads by some unnecessary synchronizations. Possible parallelism in the hardware you will use to run your program should be exploited as much as possible. We want you to write a multithreaded program in C to do some simple matrix What type of parallelism you employed in your program to get the result? And at which points do you need to synchronize your threads, including the main thread? An example input file for a 4x4 matrix: 23 56 67 99 21 4 876 100 43 1 999 126 22 86
Expert Solution
steps

Step by step

Solved in 4 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY