I am learning to make robust code in OpenCL and facing the following kernel code:
string kernel_code =
" void kernel simple_add(global const int *A, "
" global const int *B, "
" global int *C, int n) { "
" "
" int index = get_global_id(0); "
" C[index]=A[index]+B[index]; "
" } ";
And using on purpose the following code for sending it to GPU:
Kernel ker(program, "simple_add");
ker.setArg(0, buffer_A);
ker.setArg(1, buffer_B);
ker.setArg(2, buffer_C);
ker.setArg(3, N);
q.enqueueNDRangeKernel(ker,NullRange,NDRange(32),NDRange(32));
q.finish();
The thing is, I am using more work items than is needed, so I think I should check if the index is out of bounds on the kernel code. But I am not using it and checking errors returned by enqueueNDRangeKernel or by finish is giving me CL_SUCCESS.. So, or this should not give me errors for some reason or I do not know how to get them.. What is the answer?