Question: need code in C using pthreads only (not using openMP) Part 3 Given is a matrix of NxN integers (you create this). The matrix is

 need code in C using pthreads only (not using openMP) Part

need code in C using pthreads only (not using openMP)

Part 3 Given is a matrix of NxN integers (you create this). The matrix is initialized to random values between 1 and 10 inclusive. The problem is to calculate the distribution of values, i.e., the number of elements that are 1, the number that are 2, etc. Divide the work up among P worker processes (threads). The matrix is shared by the workers. You may NOT assume that N is a multiple of P. Divide the matrix into almost P equal-size strips of rows. Each worker will ONLY calculate the distribution of its strip(s). When all workers have completed their tasks, only one worker should accumulate and print the distributions. Use the C rand number function with seed to generate psuedo-random numbers. The values of N and P should be read as command-ine arguments. Write the results to standard output. Run experiments for N between 64- 1000 and P between, 2 to 64. (NOTE: for serial code, P-1) N and P are command line args Describe your results. What do you observe? Why? Create tabular results (can add more rows if needed)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!