Examlex

Solved

Consider the Following Code That Adds Two Matrices a and B

question 10

Essay

Consider the following code that adds two matrices A and B and stores the result in a matrix C:
for (i= 0 to 15) {
for (j= 0 to 63) {
C[i][j] = A[i][j] + B[i][j];
}
}
If we had a quad-core multiprocessor, where the elements of the matrices A, B, C are stored in row major order, which one of the following two parallelizations is better and why ? What about when they are stored in column major order ?
(a) For each Pk in {0, 1, 2, 3}:
for (i= 0 to 15) {
for (j= Pk*15 + Pk to (Pk+1)*15 + Pk)
{
// Inner Loop Parallelization C[i][j] = A[i][j] + B[i][j];
}
}
(b) For each Pk in {0, 1, 2, 3}:
for (i= Pk*3 + Pk to (Pk+1)*3 + Pk) {
// Outer Loop Parallelization for (j= 0 to 63) {
C[i][j] = A[i][j] + B[i][j];
}
}


Definitions:

Monopolistic Competition

A market structure characterized by many firms offering differentiated products or services.

Long-Run Equilibrium

A state in which all firms in a market or industry are making normal profits, with no incentive for entry or exit, and all resources are optimally allocated.

Long-Run Equilibrium

A market condition where all inputs can be adjusted, firms are entering and exiting the market, and no economic profits are made, leading to a state of perfect competition.

Monopolistic Competition

An economic setup in which numerous firms offer products that are alike but not the same, enabling competition to revolve around quality, pricing, and promotional strategies.

Related Questions