Hello
I read the manual “CUDA Toolkit 4.0 CURAND Guide PG-05328-040_v01 | January 2011”
From : CUDA Toolkit Documentation
When I compile the source from my PC so I have to change path of cuda.h and curand.h
/*
* This program uses the host CURAND API to generate 100
* pseudorandom floats .
*/
# include "stdio.h"
# include "stdlib.h"
# include "../include/cuda.h"
# include "../include/curand.h"
# define CUDA_CALL (x) do { if ((x) != cudaSuccess ) { \
printf (" Error at %s:%d\n", __FILE__ , __LINE__ );\
return EXIT_FAILURE ;}} while (0)
# define CURAND_CALL (x) do { if ((x) != CURAND_STATUS_SUCCESS ) { \
printf (" Error at %s:%d\n", __FILE__ , __LINE__ ); \
return EXIT_FAILURE ;}} while (0)
int main (int argc , char * argv [])
{
size_t n = 100;
size_t i;
curandGenerator_t gen;
float * devData , * hostData ;
/* Allocate n floats on host */
hostData = ( float *) calloc (n, sizeof ( float ));
/* Allocate n floats on device */
CUDA_CALL ( cudaMalloc (( void **)& devData , n * sizeof ( float ))); //HERE IS 26TH line
/* Create pseudo - random number generator */
CURAND_CALL ( curandCreateGenerator (& gen , CURAND_RNG_PSEUDO_DEFAULT ));
/* Set seed */
CURAND_CALL ( curandSetPseudoRandomGeneratorSeed (gen , 1234)); //HERE IS 32TH LINE
/* Generate n floats on device */
CURAND_CALL ( curandGenerateUniform (gen , devData , n));
/* Copy device memory to host */
CUDA_CALL ( cudaMemcpy ( hostData , devData , n * sizeof ( float ),
cudaMemcpyDeviceToHost ));
/* Show result */
for(i = 0; i < n; i++) {
printf ("%1.4 f ", hostData [i]);
}
printf ("\ n");
/* Cleanup */
CURAND_CALL ( curandDestroyGenerator (gen));
CUDA_CALL ( cudaFree ( devData ));
free ( hostData );
return EXIT_SUCCESS ;
}
I wonder the result.
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\sarit>nvcc -arch=sm_13 c
udarand.cu
cudarand.cu
cudarand.cu(26): error: identifier "x" is undefined
cudarand.cu(26): error: expected a ";"
cudarand.cu(29): error: expected a ";"
cudarand.cu(32): error: expected a ";"
cudarand.cu(35): error: expected a ";"
cudarand.cu(38): error: expected a ";"
cudarand.cu(45): warning: unrecognized character escape sequence
cudarand.cu(48): error: expected a ";"
cudarand.cu(49): error: expected a ";"
cudarand.cu(19): warning: variable "gen" was declared but never referenced
cudarand.cu(20): warning: variable "devData" was declared but never referenced
8 errors detected in the compilation of "C:/Users/7-64/AppData/Local/Temp/tmpxft
_00000498_00000000-6_cudarand.cpp1.ii".
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\sarit>
Here is my nvcc version. (If need)
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v4.0\sarit>nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2011 NVIDIA Corporation
Built on Fri_May_13_01:41:59_PDT_2011
Cuda compilation tools, release 4.0, V0.2.1221
There is a “x” in the argument. So what does this mean ?
cudarand.cu(26): error: identifier "x" is undefined
I deleted “ULL” at 32th line, even it does not relevant to 8 erros.
The line number has been shortened in order to view in compact page.
Where should I start to figure out the problem ?
Any help would be appreciated.