Setting up cuPrintf

Just a note, I am a noob so I may describe things a bit strange… you have been warned :-)

I just got access to the cuPrintf library and am trying to get it set up and running. I couldn’t figure out exactly which directory to put the files in for general access by any code, so I just dumped them into the same folder as all my source code. This seemed to fix the first hurdle, but if anybody could help me I’d love to put it in one place and not have to have a copy in every source code folder. I am running Mac OSX 10.6.7 with CUDA 4.0, so I believe the files should go somewhere in one of the following:


    /Developer/CUDA/C/common/src (there isn’t really a space before CUDA, don’t know why it is showing up like that on this one line…)


    other ideas?

BTW, I renamed the standard install folder “GPU Computing” to “CUDA” for convenience.

Anyways, with the and .cuh files in the source code folder, I tried to get the command to work. I see in the documentation and on various forums that cuPrintf has to be initialized by the host before it can be used by the kernels. It also says to put the #include “” in the device code (option 2 in the documentation). I also copied the sample initialization code from the documentation. So in my .cpp file I have


main( int argc, char** argv) 



		testKernel<<< 2, 3 >>>(10);

		cudaPrintfDisplay(stdout, true);


//Other stuff


and in the main kernel .cu file I have

#include ""

__global__ void testKernel(int val)


     cuPrintf(“Value is: %d\n”, val);


With this setup I get the following error:

So I assume this means that the cuPrintf initialization calls are done before the #include “”. So I move this statement from the .cu file to the .cpp file and get

It is a bigger text, so as a noob I assume it is worse (though I know it’s not necessarily the case, it is still my initial reaction). So I think “Ok, this didn’t work, let’s try another approach” and move the #include back to the .cu file and embed the 4 initialization lines into an extern “C” function inside the .cu file that is called from the main() function in the .cpp. I figure this extern “C” is still executed on the host and everything will be declared in the same .cu file, so this should work, right? Here is the error message this time:

where line 57 is the #include statement.

So now I am stuck, I really would like to use this function to make sure I am passing in the variables I think I am, but I don’t know where to put what to make it work. It seems other people are having issues with calling it more than once or with sending the function too big of data, which sound like LOVELY issues for me! Anybody care to get me far enough to have these issues?

My other current post ( explains in more detail what I need the cuPrintf for.

Any help on either post would be greatly appreciated!