Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 matrixvector 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
Exercises
its assigned rows. Modify the matrixvector 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 runtime of the matrixvector multiplication? Dont include
input or output in your runtime.
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