functions like curand_init and curand_normal_double are part of the curand Device API:
http://docs.nvidia.com/cuda/curand/device-api-overview.html#device-api-overview
When I said “host” generation I was referring to usage of the curand Host API:
http://docs.nvidia.com/cuda/curand/host-api-overview.html#host-api-overview
As stated in the first sentence of the Device API section:
"To use the device API, include the file curand_kernel.h in files that define kernels that use cuRAND device functions. "
AFAIK there is no support for calling device API functions from host code. If you have a functional code that demonstrates such usage, I’d certainly be interested in seeing it. Trivial attempts to build a host code around what you have shown produce expected errors for me:
$ cat t61.cu
#include <curand_kernel.h>
#include <curand.h>
#define GRID_SIZE 1
#define BLOCK_SIZE 1
#define numSimulations (GRID_SIZE*BLOCK_SIZE)
int main(){
curandStateMRG32k3a* devStates = (curandStateMRG32k3a*)malloc(BLOCK_SIZE * GRID_SIZE * sizeof(curandStateMRG32k3a));
int seed = 1;
for (int i = 0; i < numSimulations; i++) { curand_init(seed, i, 0, &(devStates[i])); }
int index = 0;
double z;
curandStateMRG32k3a localState = devStates[index];
z = curand_normal_double(&localState);
devStates[index] = localState;
}
$ nvcc -arch=sm_61 -o t61 t61.cu
t61.cu(13): warning: variable "z" was set but never used
t61.cu(10): error: calling a __device__ function("curand_init") from a __host__ function("main") is not allowed
t61.cu(15): error: calling a __device__ function("curand_normal_double") from a __host__ function("main") is not allowed
t61.cu(13): warning: variable "z" was set but never used
2 errors detected in the compilation of "/tmp/tmpxft_00007811_00000000-5_t61.cpp4.ii".
$