parallel processing - Getting rid of data dependency -
i have code:
for(i=0; i<size; i++) { d[i] = d[i-1] + v[i]; }
when parallel processing loop, have data dependency , initiation interval becomes 2 meaning have:
initiation interval:2
|load v[i-1]|load d[i-2]| add |store d[i-1]| | | | load v[i]|load d[i-1] | add | store d[i] |
i not want stall in between.
initiation interval:1
|load v[i-1]|load d[i-2]| add |store d[i-1]| | |load v[i] |load d[i-1]| add | store d[i] |
this not possible since d[i-1] not stored yet.
how make initiation interval 1 changing code?
you cannot reduce gap.
also (loop unrolling) not efficient way of parallel processing kind of loop. loop looks prefix-sum operation. there fast parallel algorithms , implementations available prefix-sum. example, this question
Comments
Post a Comment