hi, there,
I am new to Cuda.
get an error as below :
error: calling a host function from a
device/global function is only allowed in device emulation
mode
printf(“num = %d”,num);
the function printf can’t be compiled if it is used in the Device Side ?
If so , how can I use the device emulation mode ?
thanks in advance , guys
Yes, printf does not make sense in device code (the GPU code is not able to call a operating system function or library routine).
To get emulator binaries, add -deviceemu to the nvcc command line.
Peter
Biene
4
Hi Stefan,
you don not need to edit anything in the makefile, when you are using the common.mk from the cuda SDK. you just have to type on the command line
make emu=1
If you would like to enable debug mode as well just type on the command line
make emu=1 dbg=1
In the makefile from the SDK it looks like
NVCCFLAGS += -deviceemu
CUDACCFLAGS +=
BINSUBDIR := emu$(BINSUBDIR)
# consistency, makes developing easier
CXXFLAGS += -D__DEVICE_EMULATION__
CFLAGS += -D__DEVICE_EMULATION__
when you are enabling the emulation mode.
Biene