考虑以下内核:
__kernel void histogramKernel(__global uint4 *Image, ....)
{ .
.
.
const uint mask = (uint) (NBINS-1); //NBINS=256
uint4 temp = Image[idx];
uint4 temp2 = (temp & mask);
temp = temp >> 8;
temp2 = (temp & mask);
. . .
}
认为:
4 个线程正在运行,idx=0,1,2,3 和 Image[idx]=idx+100
最后一行中 temp2 的值是多少?
更新:
假设任何合适的值
Image[0].x, Image[0].y, Image[0].z, Image[0].w
Image[1].x, Image[1].y, Image[1].z, Image[1].w
Image[2].x, Image[2].y, Image[2].z, Image[2].w
Image[3].x, Image[3].y, Image[3].z, Image[3].w