Hi everybody! I am trying to compile and run the sample code about Julia set from Sanders’ book CUDA by example on a Fedora 14 X86_64 architecture. I got some errors, part of which I solved, part I didn’t and I’d like you to help me with.
I compile using the following command
nvcc -I/usr/local/cuda/include/ -I/path-to-sanders-book-code/common -L/usr/local/cuda/lib64 -lcuda -lcudart -lglut -o cuda03.exe cuda03.cu
and I get the following errors
In file included from /path-to-sanders-book-code/common/gl_helper.h:44,
from
/path-to-sanders-book-code/common/cpu_bitmap.h:20,
from cuda03.cu:2:
/path-to-sanders-book-code/common/GL/glut.h:151:1: warning: "APIENTRY" redefined
In file included from
/path-to-sanders-book-code/common/GL/glut.h:137,
from
/path-to-sanders-book-code/common/gl_helper.h:44,
from
/path-to-sanders-book-code/common/cpu_bitmap.h:20,
from cuda03.cu:2:
/usr/include/GL/gl.h:113:1: warning: this is the location of the previous definition
/path-to-sanders-book-code/common/GL/glut.h(158): warning: omission of exception specification is incompatible with previous function "exit"
/usr/include/stdlib.h(544): here
cuda03.cu(27): error: calling a host function("cuComplex::cuComplex") from a __device__/__global__ function("julia") is not allowed
cuda03.cu(28): error: calling a host function("cuComplex::cuComplex") from a __device__/__global__ function("julia") is not allowed
cuda03.cu(33): error: calling a host function("cuComplex::cuComplex") from a __device__/__global__ function("julia") is not allowed
cuda03.cu(33): error: calling a host function("cuComplex::cuComplex") from a __device__/__global__ function("julia") is not allowed
4 errors detected in the compilation of "/tmp/tmpxft_00003670_00000000-4_cuda03.cpp1.ii".
Ok, the last four are easy to solve, I just put the device specifier where needed (cuComplex constructor).
The first error refer to multiple definitions. Since the compiler says the variable APIENTRY is already defined in /usr/include/GL/gl.h, I just comment the define statement in the file /path-to-sanders-book-code/common/GL/glut.h, row 151
/* non-Win32 case. */
/* Define APIENTRY and CALLBACK to nothing if we aren't on Win32. */
//# define APIENTRY
# define GLUT_APIENTRY_DEFINED
# define CALLBACK
/* Define GLUTAPI and GLUTCALLBACK as below if we aren't on Win32. */
# define GLUTAPI extern
# define GLUTCALLBACK
/* Prototype exit for the non-Win32 case (see above). */
extern void exit(int);
#endif
Now, I do the same for the second error
/path-to-sanders-book-code/common/GL/glut.h(158): warning: omission of exception specification is incompatible with previous function "exit"
/usr/include/stdlib.h(544): here
Hence I comment out the row 158 in the former file (glut.h)
/* non-Win32 case. */
/* Define APIENTRY and CALLBACK to nothing if we aren't on Win32. */
//# define APIENTRY
# define GLUT_APIENTRY_DEFINED
# define CALLBACK
/* Define GLUTAPI and GLUTCALLBACK as below if we aren't on Win32. */
# define GLUTAPI extern
# define GLUTCALLBACK
/* Prototype exit for the non-Win32 case (see above). */
//extern void exit(int);
#endif
Now the example compiles. However, at runtime I only get a window with a black screen and I don’t see the snapshot I am supposed to see.
Any suggestion??
Thanks,
Guido
Edit
I solved my black screen problem. So basically, I can get rid of the warnings by doing what I have already said and then I realized I had a small typing error in the code, but was fundamental.
In the routine: device int julia I had
if(a.magnitude2() < 1000) return 0;
Instead of
if(a.magnitude2() > 1000) return 0;
Hence my set was empty, hence the black screen.
Cheers,
Guido