Код не работает.Но когда я комментирую atomicAdd
в следующем коде, код работает.
В чем причина?
Где я могу получить код гистограммы для массива с плавающей запятой?
__global__ void calculateHistogram(float *devD, int* retHis)
{
int globalLi = getCurrentThread(); //get the thread ID
if(globalLi>=0 && globalLi<Rd*Cd*Dd)
{
int r=0,c=0,d=0;
GetInd2Sub(globalLi, Rd, Cd, r, c, d); //some calculations to get r,c,d
if(r>=stYd && r<edYd && c>=stXd && c<edXd && d>=stZd && d<edZd)
{
//calculate the histogram
int indexInHis = GetBinNo(devD[globalLi]); //get the bin number in the histogram
atomicAdd(&retHis[indexInHis],1); //when I comment this line the code works
}
}
}