18 int c2 = c1 - ((c1 >> 1) & 0x55555555);
19 int c4 = ((c2 >> 2) & 0x33333333) + (c2 & 0x33333333);
20 int c8 = ((c4 >> 4) + c4) & 0x0f0f0f0f;
21 int c16 = ((c8 >> 8) + c8);
23 int r = 0, i =
n - 1, t;
25 t = (c16 ) & 0x1f;
if (i >= t) { r += 16; i -= t; }
26 t = (c8 >> r) & 0x0f;
if (i >= t) { r += 8; i -= t; }
27 t = (c4 >> r) & 0x07;
if (i >= t) { r += 4; i -= t; }
28 t = (c2 >> r) & 0x03;
if (i >= t) { r += 2; i -= t; }
29 t = (c1 >> r) & 0x01;
if (i >= t) { r += 1; }
43 while (c1 && (i++ <
n)) {
int n
Number of atoms padded by WARP_SIZE.
__device__ int ffsnShift(int c1, int n)
Find the position of the n-th least significant bit set in a 32-bit integer. Returns a value from 0 t...
Definition: ffsn.h:16
__device__ int ffsnLoop(int c1, int n)
An alternative implementation of ffsn using loop.
Definition: ffsn.h:39