How to check for uniqness in warp

Hello I have a variable x loaded on each lane of a warp. I would like to invoke function f on a lane only if x is unique in a warp .
I tried to figure it out using voting - but I can not get an efficient design for it.

Thanks for help!

int x = some_value;
int my_lane_mask = 1<<(threadIdx.x&31);
if (__match_any_sync(0xFFFFFFFF, x) == my_lane_mask) f();

note that this works for Volta and higher GPUs, i.e. Volta, Turing, Ampere (currently).

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.