I have added some printf()
statements in my CUDA program
__device__ __global__ void Kernel(float *, float * ,int );
void DeviceFunc(float *temp_
printf()
output is only displayed if the kernel finishes successfully, so check the return codes of all CUDA function calls and make sure no errors are reported.
Furthermore printf()
output is only displayed at certain points in the program. Appendix B.20.2 of the Programming Guide lists these as
<<<>>>
or cuLaunchKernel()
(at the start of the launch, and if the CUDA_LAUNCH_BLOCKING environment variable is set to 1, at the end of the launch as well),cudaDeviceSynchronize()
, cuCtxSynchronize()
, cudaStreamSynchronize()
, cuStreamSynchronize()
, cudaEventSynchronize()
, or cuEventSynchronize()
,cudaMemcpy*()
or cuMemcpy*()
,cuModuleLoad()
or cuModuleUnload()
,cudaDeviceReset()
or cuCtxDestroy()
.cudaStreamAddCallback()
or cuStreamAddCallback()
.To easily check this is your problem, put the following code after your kernel invocation:
{
cudaError_t cudaerr = cudaDeviceSynchronize();
if (cudaerr != cudaSuccess)
printf("kernel launch failed with error \"%s\".\n",
cudaGetErrorString(cudaerr));
}
You should then see either the output of your kernel or an error message.