what does the width parameter of function __shfl_up(int var, unsigned int delta, int width) mean?

StackOverflow https://stackoverflow.com/questions/23469448

  •  15-07-2023
  •  | 
  •  

Question

What does the width parameter in __shfl_up(int var, unsigned int delta, int width = warpSize) mean? Assuming that var equals 4 in lane 4 and var equals 8 in lane 8. if I call __shfl_up(var, 4, 8) in lane 8, what it is returning?

Was it helpful?

Solution

The width parameter divides warpSize(typically 32) into partitions and each has width elements. Let's suppose the caller's warp id is laneId. calling __shfl_up(var, offset, width) will calculate source lane id, srclaneId = (laneId % width) - offset. if srclaneId is between 0 and width-1(inclusive) and the thread of srclaneId is active(see Active thread in a warp), __shfl_up(var, offset, width) returns the value of srclaneId's var, otherwise returns the value of laneid's var. In addition width must be power-of-2 (i.e. 2, 4, 8, 16 or 32).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top