You should check for returned error code after each opencl call. (a previous failed operation can cause this)
You can try to run your program with valgrind (this might give out a lot of unrelated messages also).
I would guess one of the variables you supply to clEnqueueMapBuffer is wrong. Maybe you might have given wrong size?
Can you provide a small test case/code where you have this problem?
I map an error code ( number -30 )with cl.h file. It mean invalid value in variables. Debug print address and size of them represent correct value.
- First step for create buffer. I need to move data on buffer name buffer_input to buffer_output. Buffer_elements defines size 254 characters.
114 cl_mem buffer_input = clCreateBuffer(platdevices->context,
115 CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,
116 sizeof(char) * buffer_elements * platdevices->num_devices,
120 cl_mem buffer_output = clCreateBuffer(platdevices->context,
121 CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,
122 sizeof(char) * buffer_elements * platdevices->num_devices,
- Second step, Code across some step OpenCL mechanism initializing.
70 cl_mem mem_copy = platdevices->mem_copy_buffers->back();
71 void * mapped_memory = clEnqueueMapBuffer(platdevices->queues.back(),
76 sizeof(char) * buffer_elements * platdevices->num_devices,
If Library can be set debug mode in order to see an internal value of clEnqueueMapBuffer, It's very good for testing code
I recommend check the results stored in &err because when something invalid occurs and memory is not actually allocated, your program just continue working until you tell it to map something from a place which doesnt exist, only then it will crash.
after every call which takes &err.
if (err != CL_SUCCESS) exit;
- is all you need to debug your code ( sure between if and exit, print the code )
Programs declare try-catch function support error code. Testing buffer by initial size of buffer more than 254 (char scalar type). It's represent error code -30. My view ,It's look like non deterministic state for creating and mapping buffer.
82 if(err != CL_SUCCESS)
83 throw clutil_exception(err, "clEnqueueMapBuffer");
84 }catch(std::runtime_error ex)
86 std::cout<< ex.what() <<std::endl;
My question. Is possibly of declare buffer in context over size of input data? Buffer should be specify size more than input data.
Debug with gdb and backtrace command line represent below.
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff7fd5700 (LWP 16444)]
0x00007ffff457f323 in ?? () from /opt/AMDAPP/lib/x86_64/libamdocl64.so
#0 0x00007ffff457f323 in ?? () from /opt/AMDAPP/lib/x86_64/libamdocl64.so
#1 0x00007ffff457f39f in ?? () from /opt/AMDAPP/lib/x86_64/libamdocl64.so
#2 0x00007ffff459dc94 in ?? () from /opt/AMDAPP/lib/x86_64/libamdocl64.so
#3 0x00007ffff457acc8 in ?? () from /opt/AMDAPP/lib/x86_64/libamdocl64.so
#4 0x00007ffff457b96e in ?? () from /opt/AMDAPP/lib/x86_64/libamdocl64.so
#5 0x00007ffff45877be in ?? () from /opt/AMDAPP/lib/x86_64/libamdocl64.so
#6 0x00007ffff458e80d in ?? () from /opt/AMDAPP/lib/x86_64/libamdocl64.so
#7 0x00007ffff70d7e9a in start_thread (arg=0x7ffff7fd5700) at pthread_create.c:308
#8 0x00007ffff73df4bd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:112
#9 0x0000000000000000 in ?? ()
It is difficult to say without looking at your code, are you sure your string is long enough? why dont you use str.size() ? are you running on cpu or gpu ?