The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

web05 (1) [Avatar] Offline

Comments/suggestions on section 3.6.3 "A Simple One-Dimensional Example"

In the following code snippet :

int i = get_global_id(0);
result[i] = dot(matrix[i], vector[0])

The reader assumes that for the first work item the variable i takes a value of 0, for the second work item i takes a value of 1, etc.
He/she also assumes that since there are 4 work items, each work item will be passed only a fourth of the original matrix.

Taking the second work items (with i=1) as an example, he/she then wonders how result[1] = dot(matrix[1], vector[0]) means :
mutltiply matrix[4:7] with the vector.

I feel that it would be useful to elaborate on how the global id relate to the indexes in the original matrix (and also on the consequences of the partitioning on the second argument: the 0 in vector[0] needs explaining).

Overall, I enjoy reading the book which is quite clear.