I have run following code 1 and it returned some out put without error. But when I run same code with cudaMallocManaged() in code 2, it returned unhadled memory exception error (like segmentation fault in linux) in my

visual studio 2012. Please tell me what is the reason for this.

code 1

+++++++++++++

int main(){

int* data;

int* data1;

char* c1;

char* c1_d;

char* c2;

char* c2_d;

char c;

cudaMalloc((void **)&c1_d,sizeof(char)*100);

cudaMalloc((void **)&c2_d,sizeof(char)*100);

c2=(char *)malloc(sizeof(char)*100);

c1="hellloooo";

cudaMemcpy(c1_d,c1,sizeof(char)*100,cudaMemcpyHostToDevice);

kernel(c1_d,c2_d);

cudaDeviceSynchronize();

cudaMemcpy(c2,c2_d,sizeof(char)*100,cudaMemcpyDeviceToHost);

for (int i=0;i

More Vajira Thambawita's questions See All
Similar questions and discussions