I wrote a simple CUDA code with ROOT library TRandom3 included:
#include <cuda_runtime.h>
#include <iostream>
#include <stdio.h>
#include <TRandom.h>
#include <TRandom3.h>
using namespace std;
__global__ void Random(void) {
TRandom *casuale = new TRandom3();
int a = casuale -> Integer(100);
printf("%d ----> %d",a,threadIdx.x);
}
int main() {
Random <<<1,10>>>();
cudaDeviceReset();
return 0;
}
This should generate 10 integer random numbers up to 100 IN PARALLEL!
But when i compile this code i get:
casa@casa-server:~/programmi/gpu$ nvcc prova_cuda.cu -m64 -L/usr/local/lib/root -lCore -lImt -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lROOTVecOps -lTree -lTreePlayer -lRint -lPostscript -lMatrix -lPhysics -lMathCore -lThread -lMultiProc -lROOTDataFrame -lm -ldl
prova_cuda.cu(11): error: calling a __host__ function("Integer") from a __global__ function("Random") is not allowed
1 error detected in the compilation of "/tmp/tmpxft_00000d6a_00000000-8_prova_cuda.cpp1.ii".
What i have to do?