jeudi 16 décembre 2021

print char of words in CUDA kernal

I have passed a char array to the Cuda kernel. Essentially the variable "sites" contains sentences organized into an array format. To check if it has been copied and to identify how to access them in the kernel I tried printing them using the following code.

__global__ void cuda_theta_L(float N, char **sites, int num_Segregrating_sites)
{
     int tid = threadIdx.x + blockIdx.x * blockDim.x;

     while (tid < num_Segregrating_sites)
     {
          printf("%d\n", tid);
          printf("%s \n", sites[tid]);
          tid += blockDim.x * gridDim.x;
     }
}

However, it does not print the text. The Cuda error is "kernel launch failed with error "an illegal memory access was encountered"."

I am new to CUDA programming, so a detailed explanation would be greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire