I am trying to create a Random generator for initialization of a vector.
The kernel function that I wrote in CUDA is as below:
__global__ void randgenvec( int *a, int t) {
int tid = blockIdx.x; // handle the data at this index
if (tid < t){
a[tid] = rand() % 100; //****ang replacement for rand() here expect cuRAND?*****
}
}
I got to know that I cant use rand()
function inside a kernel function. Is there any other function which I can replace with rand()
.
I know we have cuRAND library which we can use. But want to make my code more portable and light and cuRAND needs linker for execution, which I don't want to use.
The objective of my randomisation is to generate any int between 1 to 100.
Any other suggestion much appreciated.