L'appel d'une fonction à partir de la fonction globale

Comment dois-je acces 'do_sth' fonction "imprimer" de la fonction (voir le code)? Pourquoi il y a " N " (regardez le code) variable/constante visible pour les GPU sans l'aide de cudaMemcpy?

 __device__ void do_sth(char *a, int N)
 {
         int idx = blockIdx.x * blockDim.x + threadIdx.x;
         if(idx < N)
         {       
                 a[idx] = a[idx]; 
         }
 }


 __global__ void print(char *a, int N) 
 {     
         //question_1: why there is an access to N, it is now in GPU memory, how?
         int idx = blockIdx.x * blockDim.x + threadIdx.x;

         //do_sth<<<nblock2,blocksize2>>>(a,N); //error_1: a host function call can not be configured
         //do_sth(&&a,N); //error_2: expected an expression

         if(idx<N)
         {       
                 a[idx]=a[idx];
         }
 }
  • Votre question est vague, veuillez préciser
InformationsquelleAutor Damian | 2011-03-10