i'm brand new using opencl, , seems should simple, bear me.
i'm writing simple kernel scan array , particular value. if value found anywhere in array, i'd flag set. if value not found, flag should remain 0;
currently i'm creating cl_mem object hold int
cl_mem outputflag = clcreatebuffer(mclcontext, cl_mem_write_only, sizeof(cl_int), null, null);
setting kernel argument
clsetkernelarg(mclkernels[1],1, sizeof(cl_mem), &outputflag);
and executing kernel looks like:
__kernel void checkforhole(__global uchar *image , __global int found, uchar holevalue) { int = get_global_id(0); int j = get_global_id(1); uchar sample = image[i*j]; if (sample == holevalue) { found = 1; } }
note array 2d, though shouldn't matter.
when put printf statement inside found condition, called (the value found). when read value via:
cl_int result; errorcode = clenqueuereadbuffer(mclcommandqueue, outputflag, cl_true , 0, sizeof(cl_int), &result, 0, null, null);
i 0. there proper way set flag in opencl? nice if there way halt entire execution , return value if found.
can write bool return type kernel , return true?
thanks!
in kernel output flag should pointer int.
change kernel parameter __global int *found
i seem figure out issues writing them here....
if knows way halt execution though, or if it's possible, i'd still interested :)
Comments
Post a Comment