Question: If we decide to physically divide a data structure among the threads, that is , if we decide to make various members local to individual

If we decide to physically divide a data structure among the threads, that is,
if we decide to make various members local to individual threads, we need to
consider at least three issues:
a. How are the members of the data structure used by the individual threads?
b. Where and how is the data structure initialized?
c. Where and how is the data structure used after its members are computed?
We briefly looked at the first issue in the matrix-vector multiplication function.
We saw that the entire vector x was used by all of the threads, so it seemed
pretty clear that it should be shared. However, for both the matrix A and the
product vector y, just looking at (a) seemed to suggest that A and y should
have their components distributed among the threads. Lets take a closer look
at this.
What would we have to do in order to divide A and y among the threads?
Dividing y wouldnt be difficulteach thread could allocate a block of memory
that could be used for storing its assigned components. Presumably, we could
do the same for Aeach thread could allocate a block of memory for storing
4.13 Exercises 201
its assigned rows. Modify the matrix-vector multiplication program so that
it distributes both of these data structures. Can you schedule the input and
output so that the threads can read in A and print out y? How does distributing
A and y affect the run-time of the matrix-vector multiplication? (Dont include
input or output in your run-time.)

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!