When i compile with nvcc -arch=sm_21 --compile stampa.cu -o stampa.o …
i obtain the error: error: calling a host function(“mexPrintf”) from a global function(“stampa”) is not allowed
I have Matlab and i compiling this code within matlab…I use Linux.
This is the command that i use to compile it within matlab (in bold):
<b>nvcc --compile stampa.cu -o stampa.o --compiler-options -fPIC -I/home/matlab/r2014a/extern/include -arch=sm_20</b>
stampa.cu(15): error: calling a __host__ function("mexPrintf") from a __global__ function("stampa") is not allowed
1 error detected in the compilation of "/tmp/tmpxft_00004662_00000000-6_stampa.cpp1.ii".
<b>mex ('stampa.o', '-L/usr/local/cuda-5.0/lib64', '-lcudart')</b>
Building with 'gcc'.
Error using mex
gcc: error: stampa.o: No such file or directory
matlab is intercepting the printf function in your CUDA kernel, and replacing it with it’s own printf function (mexPrintf) which is not usable within a CUDA kernel.
This may be of interest:
simplePrintf
This CUDA Runtime API sample is a very basic sample that implements how to use the printf function in the device code. Specifically, for devices with compute capability less than 2.0, the function cuPrintf is called; otherwise, printf can be used directly.
I have a compute capability 2.1