Comment utilisons-nous cuPrintf()?

Que devons-nous faire pour utiliser cuPrintf()? (appareil de calcul de la capacité de 1.2, Ubuntu 12) je ne pouvais pas trouver "cuPrintf.cu" et "cudaPrintf.cuh", j'ai donc téléchargé de leur code et de les inclure:

#include "cuPrintf.cuh"
#include "cuPrintf.cu"

Par la manière dont c'est le reste du code:

__global__ void hello_kernel (float f) {
printf ("Thread number %d. f = %d\n", threadIdx.x, f);
}

    int main () {
    dim3 gridSize = dim3 (1);
    dim3 blockSize = dim3 (16);
    cudaPrintfInit ();
    hello_kernel <<< gridSize, blockSize >>> (1.2345f);
    cudaPrintfDisplay (stdout, true);
    cudaPrintfEnd ();
    return (0);
}

Mais nvcc donne toujours une erreur:

max@max-Lenovo-G560:~/CUDA/matrixMult$ nvcc printfTest.cu -o printfTest

printfTest.cu(5): error: calling a __host__ function("printf") from a __global__
function("hello_kernel") is not allowed

Merci!

appel cuPrintf dans votre noyau ne printf

OriginalL'auteur Max | 2012-11-28