arrays - OpenCL - For Loops and Relationship with GlobalWorkSize -


while reading on code had couple of questions popped head.

let's assume had globalworksize of 1 million elements in array.

assume purpose of kernel take summation of 100 elements @ time , store these values in output. ex) first time kernel sum elements 0-99, 1-100, 2-101 , on. summed values stored in array.

now know there 1 million elements, when pass clenqueuendrangekernel, mean kernel execute close 1 million times?

i noticed loop in kernel loops 1 hundred elements, value stored in array. examining loop, 1 think after 100 elements stop. how computer know when have reached 1 million elements? because passed parameter in clenqueuendrangekernel , @ atomic level knows more elements need processed?

the device has no way know there 1 million elements in array. if set global_work_size 1 million last 99 kernels happily overindex array may or may not seg fault depending on device.

when call clenqueuendrangekernel api call worksize of n information sent device , device execute anough uniform sized workgroups untill has executed kernel n times.

hope answers question.


Comments