opencl - clSetKernelArg returning error code -49 -


i have written following c++ code. @ clsetkernelarg( kernel, 8, sizeof( cl_mem ), (void *) &mob_whdis );, returns error code -49, , don't understand why. else runs properly. can me?

cl_mem mob_x = null; cl_mem mob_y = null; cl_mem mob_z = null; cl_mem mob_wat = null; cl_mem mob_pol = null; cl_mem mob_fsw = null; cl_mem mob_nop = null; cl_mem mob_nofsw = null; cl_mem mob_whdis = null; cl_mem mob_watwp = null; cl_mem mob_watp = null; cl_mem mob_distp = null; cl_mem mob_watww = null; cl_mem mob_watw = null; cl_mem mob_distw = null; cl_program program = null; cl_kernel kernel = null; cl_uint ret_num_devices; cl_uint ret_num_platforms; cl_int err; float whdis=3.5; mob_x = clcreatebuffer( context, cl_mem_read_write, na * sizeof(float), null, &err ); mob_y = clcreatebuffer( context, cl_mem_read_write, na * sizeof(float), null, &err ); mob_z = clcreatebuffer( context, cl_mem_read_write, na * sizeof(float), null, &err ); mob_wat = clcreatebuffer( context, cl_mem_read_write, * sizeof(int), null, &err ); mob_pol = clcreatebuffer( context, cl_mem_read_write, nop * sizeof(int), null, &err ); mob_fsw = clcreatebuffer( context, cl_mem_read_write, * sizeof(int), null, &err ); mob_nop = clcreatebuffer( context, cl_mem_read_write, sizeof(int), null, &err ); mob_nofsw = clcreatebuffer( context, cl_mem_read_write, sizeof(int), null, &err ); mob_whdis =  clcreatebuffer( context, cl_mem_read_write, sizeof(float), null, &err ); mob_watwp = clcreatebuffer( context, cl_mem_read_write, sizeof(int) * * 40, null, &err ); mob_watp = clcreatebuffer( context, cl_mem_read_write, sizeof(int) * * 40, null, &err ); mob_distp = clcreatebuffer( context, cl_mem_read_write, sizeof(float) * * 40, null, &err ); mob_watww = clcreatebuffer( context, cl_mem_read_write, sizeof(int) * * 40, null, &err ); mob_watw = clcreatebuffer( context, cl_mem_read_write, sizeof(int) * * 40, null, &err ); mob_distw = clcreatebuffer( context, cl_mem_read_write, sizeof(float) * * 40, null, &err ); err = clenqueuewritebuffer( command_queue, mob_x, cl_true, 0, na * sizeof(float), x, 0, null, null ); err = clenqueuewritebuffer( command_queue, mob_y, cl_true, 0, na * sizeof(float), y, 0, null, null ); err = clenqueuewritebuffer( command_queue, mob_z, cl_true, 0, na * sizeof(float), z, 0, null, null ); err = clenqueuewritebuffer( command_queue, mob_wat, cl_true, 0, * sizeof(int), wat, 0, null, null ); err = clenqueuewritebuffer( command_queue, mob_pol, cl_true, 0, nop * sizeof(int), pol, 0, null, null ); err = clenqueuewritebuffer( command_queue, mob_fsw, cl_true, 0, * sizeof(int), fsw, 0, null, null ); err = clenqueuewritebuffer( command_queue, mob_nop, cl_true, 0, sizeof(int), &nop, 0, null, null ); err = clenqueuewritebuffer( command_queue, mob_nofsw, cl_true, 0, sizeof(int), &nofsw, 0, null, null ); err = clenqueuewritebuffer( command_queue, mob_whdis, cl_true, 0, sizeof(float), &whdis, 0, null, null ); err_check( err, "clsetkernelarg" ); err = clsetkernelarg( kernel, 0, sizeof( cl_mem ), (void *) &mob_x ); err = clsetkernelarg( kernel, 1, sizeof( cl_mem ), (void *) &mob_y ); err = clsetkernelarg( kernel, 2, sizeof( cl_mem ), (void *) &mob_z ); err = clsetkernelarg( kernel, 3, sizeof( cl_mem ), (void *) &mob_wat ); err = clsetkernelarg( kernel, 4, sizeof( cl_mem ), (void *) &mob_pol ); err = clsetkernelarg( kernel, 5, sizeof( cl_mem ), (void *) &mob_fsw ); err = clsetkernelarg( kernel, 6, sizeof( cl_mem ), (void *) &mob_nop ); err = clsetkernelarg( kernel, 7, sizeof( cl_mem ), (void *) &mob_nofsw ); err = clsetkernelarg( kernel, 8, sizeof( cl_mem ), (void *) &mob_whdis );      // step 11: execute opencl kernel in data parallel size_t worksize[] = { now, 1, 1 }; clenqueuendrangekernel( command_queue, kernel, 1, null, worksize, 0, 0, 0, 0 ); err_check( err, "clenqueuendrangekernel" ); // step 12: read (transfer result) memory buffer 

the error -49 cl_invalid_arg_index. should check opencl kernel source arguments.

also, in code should clcreateprogramwithsource opencl source code of program, clbuildprogram compile , link it, , use clcreatekernel valid kernel reference. , can use clsetkernelarg properly.


Comments