Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started