c++ - Output of CUDA program is empty -


possible duplicate:
output of cuda program not expected

i running simple cuda program:

#include <cuda_runtime.h> #include <cuda.h> #include <stdio.h>  __global__ void   display(char *t[]) {    int v = blockidx.x;   int p = blockidx.y;   int offset = v+ p*griddim.x;   t[offset] = "(";   // }  void  main() {   int c = 5;   cudagetdevicecount(&c);   cudadeviceprop prop;   cudagetdeviceproperties(&prop,0);   printf("the device name : %s\n", prop.name);   //bool value = prop.integrated;   char *x[6];   int i;   (i = 0; i<6; i++)       cudamalloc((void**)&x[i], 20*sizeof(char));    // checking meaning of grid(3,2)   dim3 grid(3,2);    display<<<grid,1>>>(x);   char y[30];   cudamemcpy(y, x[0], 20*sizeof(char), cudamemcpydevicetohost);   printf("the values :%s\n", y);   cudafree(x[0]);    getchar(); } 

i don't understand why array y still empty @ end of execution. shouldn't "("?

i've answered question here.

but i'll leave suggestion others land on question first:

in debugging cuda code, recommend adding in forced synchronization , check errors, mentioned in your other post ensure hardware setup, api setup, current weather, aren't messing things up:

/*  force thread synchronization  */ cudaerror err = cudathreadsynchronize();  /*  check , display error  */ if ( cudasuccess != err ) {     fprintf( stderr, "cuda error in file '%s' in line %i : %s.\n",              __file__, __line__, cudageterrorstring( err) ); } 

the key problem op's code x lives on cpu though it's members live on gpu. again, see answer here.


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -