Demande d'explications sur le concept de réduction de vecteur
bonsoir à tous le monde
Dans un exemple du livre cuda by example, j'ai pas compris ce code :
Code:
1 2 3 4 5 6 7
| int i = blockDim.x/2;
while (i != 0) {
if (cacheIndex < i)
cache[cacheIndex] += cache[cacheIndex + i];
__syncthreads();
i /= 2;
} |
j'ai pas compris pourquoi il a besoin de int i = blockDim.x/2;
alors il dit :
Citation:
The general idea is that each thread will add two of the values in cache[] and
store the result back to cache[].
pourquoi ne pas utiliser int i=thread.x/2
Merci