I am writing this code for CUDA. I am facing Segfault at CudaMalloc for int* at d_runs
int* d_runs;
BYTE* d_min;
BYTE* d_max;
BYTE* d_rawDataByte[size];
/Allocate space for device copies
cudaMalloc((void**)&d_runs, size*sizeof(int));
cudaMemcpy(d_runs, &_runs[0], size*sizeof(int), cudaMemcpyHostToDevice);
cudaMalloc((void **)&d_min, size*sizeof(BYTE));
cudaMemcpy(d_min, _min, size*sizeof(BYTE), cudaMemcpyHostToDevice);
cudaMalloc((void **)&d_max, size*sizeof(BYTE));
cudaMemcpy(d_max, _max, size*sizeof(BYTE), cudaMemcpyHostToDevice);
cudaMalloc((void**)&d_rawDataByte, size*sizeof(BYTE *));
size=1000.
Edit: Ok. I have changed BYTE* d_rawDataByte[size] to BYTE** d_rawDataByte
cudaError_t rc = cudaMalloc((void **)&d_min, size*sizeof(BYTE));
if (rc != cudaSuccess)
std::cout<<"Could not allocate memory: " <<rc;
cudaMemcpy(d_min, _min, size*sizeof(BYTE), cudaMemcpyHostToDevice);
Still the problem persists. Infact, none of the cudaMalloc is behaving properly. I am getting Segfault in every one of them.