cuPrintf()

Hi,

I am trying to use cuPrintf() in a very simple program below, but I am getting following error.

#include "utils/cuPrintf.cu"

#include "stdio.h"

__global__ void device_greetings(void){

        cuPrintf("Hello world, form the device %d \n",5);

}

int main(){

        //greet from the host

        printf("Helo world, from the host\n");

//intitialize cuPrintf

        cudaPrintfInit();

//launch the kernel with a single thread

        device_greetings<<<1,1>>>();

//display the device's greetings

        cudaPrintfDisplay();

//clean up

        cudaPrintfEnd();

return 0;

}

On compilation, I am getting this

utils/cuPrintf.cu(395): error: calling a host function from a __device__/__global__ function is only allowed in device emulation mode

          detected during instantiation of "int cuPrintf(const char *, T1) [with T1=int]" 

hello.cu(4): here

1 error detected in the compilation of "/tmp/tmpxft_000027c1_00000000-4_hello.cpp1.ii".

Any Idea?

Hi.

My O/P:
Helo world, from the host
Hello world, form the device 5

use " #include "cuPrintf.cu "
instead of "#include “utils/cuPrintf.cu”

Download cuPrintf.cu file from : http://code.google.com/p/qcadesigner-cuda/source/browse/trunk/proveCUDA/cuPrintf.cu?spec=svn12&r=12

and cuPrintf.cuh file from : http://stanford-cs193g-sp2010.googlecode.com/svn/trunk/tutorials/util/cuPrintf.cuh
(if required)

Compilation: nvcc prog_name.cu

All the best.