Since CUDA 9 the shfl instructions are deprecated and should be replaced by shfl_sync.
But how should i replace them, when they behave differently?
Code Example:
__global__
static void shflTest(){
int tid = threadIdx.x;
float value = tid + 0.1f;
int* ivalue = reinterpret_cast<int*>(&value);
//use the integer shfl
int ix = __shfl(ivalue[0],5,32);
int iy = __shfl_sync(ivalue[0],5,32);
float x = reinterpret_cast<float*>(&ix)[0];
float y = reinterpret_cast<float*>(&iy)[0];
if(tid == 0){
printf("shfl tmp %d %d\n",ix,iy);
printf("shfl final %f %f\n",x,y);
}
}
int main()
{
shflTest<<<1,32>>>();
cudaDeviceSynchronize();
return 0;
}
Output:
shfl tmp 1084437299 5
shfl final 5.100000 0.000000