I have a text char array, filled with words from a text file.
For example
text[0] = "one";
,
text[1] = "two";
and so on.
All array elements equal to thread count. I want to print all text array to screen, using CUDA. I try to print using following code, but it does not work. I'm pretty confused how to pass an array like text[][]
to a CUDA kernel function.
#define MAX_SIZE 100
#define elements 20
__global__ void calculate(char *d_text) {
int idx = threadIdx.x;
printf("test %s /n", d_text[idx]);
}
int main() {
char text[MAX_SIZE][MAX_SIZE]; // have text array with words
char *d_text;
cudaMalloc((void **)&d_data, DATA_BYTES);
cudaMemcpy(d_text, text, STRING_BYTES, cudaMemcpyHostToDevice);
calculate << < 1, elements >> > (d_text);
cudaDeviceSynchronize();
}