0
$\begingroup$

Can anyone help me understanding this exercise?

We define the SIMD utilization of a program run on a GPU as the fraction of SIMD lanes that are kept busy with active threads during the run of a program. The following code segment is run on a GPU. Each thread executes a single iteration of the shown loop. Assume that the data values of the arrays A and B are already in vector registers so there are no loads and stores in this program. (Hint: Notice that there are 2 instructions in each thread.) A warp in the GPU consists of 32 threads, there are 32 SIMD lanes in the GPU. Assume that each instruction takes the same amount of time to execute.

for (i = 0; i < N; i++) { if (A[i] % 3 == 0) { A[i] = A[i] * B[i]; } }

I know should determine whether this can yield a SIMD Utilisation of 100%. My answer would be YES.

We can achieve this if each element in array A is divisible by three. (Assume A.length is 32. Then ((32*2)/32*2))*100 = 100%)

The master solution agrees to up to this point, but it also says, that we can yield a SIMD Utilisation of 100% if all elements of array A is not divisible by three. My question would be why? My thought is: When all the elements of A is not divisible by three, then each thread would execute one instruction: (32/(32*2))*100 = 50% ?

Thank you!

$\endgroup$
0
$\begingroup$

If this is real program on real GPU, then CUDA f.e. may perform multiplication always and then conditionally copy the result to A[i]. It may be more efficient to perform 2-4 extra instructions when A[i]%3!=0 rather than perform conditional jump around unneeded statements.

So probably the point is that you forgot about predicated statement execution.

$\endgroup$
0
$\begingroup$

Of course you can easily use all the lanes, but then you throw lots of the results away. How you count this is up to you. Do you count calculating the product as utilisation if you then throw the result away? Mostly a matter of opinion.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.