Caution in use of MTGP32 generator for CURAND 5.5

Function curand (curandStateMtgp32_t *state) may not return the desired random number sequence
when one or more inactive threads exist in a block mainly due to conditonal branch and loop.

cause: Unless each thread in a block calls curand( ) as many times as the others do in each designated interval,
the corresponding position(s) of a state does not update properly.

improper example:

__global__ void generate_kernel(curandStateMtgp32 *state, int n, int *result)
{
    int id = threadIdx.x + blockIdx.x * 32;
    int N_thr = blockDim.x * gridDim.x;
    unsigned int x;
    /* Generate pseudo-random unsigned ints */
    for(int i = 0; i < n; i++) {
    	if(id % 32 < 31){
    	    x = curand(&state[blockIdx.x]);
        	result[id + i * N_thr] = x % 10;
        }
    }
}

proper example:

__global__ void generate_kernel(curandStateMtgp32 *state,  int n, int *result)
{
    int id = threadIdx.x + blockIdx.x * 32;
    int N_thr = blockDim.x * gridDim.x;
    unsigned int x;
    /* Generate pseudo-random unsigned ints */
    for(int i = 0; i < n; i++) {
    	x = curand(&state[blockIdx.x]); 	    
    	if(id % 32 < 31){
        	result[id + i * N_thr] = x % 10;
        }
    }
}

results:
We executed these programs with 32 threads in one block and the identical seed. The first 294
numbers are identical for the two generated sequences. But, as seen below, the 2000th number
and beyond are quite different each other (each number denotes absolute value of difference
between corresponding numbers).

225, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
257, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
289, 0,0,0,0,0,0,5,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0

929, 0,0,0,0,3,2,4,0,0,0,0,2,6,1,4,0,0,0,0,0,0,0,0,0,0,0,0,3,8,4,8,0
961, 0,0,0,0,0,4,2,6,0,0,0,1,6,9,2,0,0,0,0,0,8,0,0,0,0,0,0,2,6,2,6,0
993, 0,0,1,6,3,2,6,0,0,0,0,6,6,4,2,0,0,0,0,0,6,8,0,0,0,0,0,4,6,3,4,0

2881, 5,6,0,1,0,1,7,8,5,5,1,2,2,2,1,5,0,1,0,5,2,6,3,2,4,2,4,1,1,8,7,0
2913, 3,8,1,0,3,5,8,1,2,2,6,1,4,2,0,1,1,2,5,2,5,2,2,5,3,1,1,2,4,6,7,0
2945, 1,4,5,1,1,2,2,3,9,7,3,4,5,6,2,5,2,8,2,0,4,3,1,0,0,8,9,7,4,8,4,0