NinjaStars
NinjaStars

Reputation: 354

OpenCL Crashes with big input array

Using this example for mac Click Here

I am getting OpenCL to crash for big arrays (Put NUM_VALUE=10000). Any suggestions on why that would be?

Upvotes: 1

Views: 204

Answers (1)

Stephan van den Heuvel
Stephan van den Heuvel

Reputation: 2138

You should run the program in a debugger, like gdb to know for sure. it could be one of these allocations:

float* test_in = (float*)malloc(sizeof(cl_float) * NUM_VALUES);

void* mem_in  = gcl_malloc(sizeof(cl_float) * NUM_VALUES, test_in, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR);

void* mem_out = gcl_malloc(sizeof(cl_float) * NUM_VALUES, NULL, CL_MEM_WRITE_ONLY);

returning NULL for the memory request, as this program does not check that, causing the next access on one of these arrays to segfault.

Upvotes: 1

Related Questions