Yash
Yash

Reputation: 699

how to explicitely set work - dimension in pyopencl?

When writing OpenCL host program in C++ we use the following API to call the OpenCL kernel:

cl_int clEnqueueNDRangeKernel (     cl_command_queue command_queue,
    cl_kernel kernel,
    cl_uint work_dim,
    const size_t *global_work_offset,
    const size_t *global_work_size,
    const size_t *local_work_size,
    cl_uint num_events_in_wait_list,
    const cl_event *event_wait_list,
    cl_event *event)

Here the third argument sets the work dimension. Where as in python using pyopencl, we call the kernel as part of the program as:

<program_name>.<kernel_name>( <command_queue>, <Global_work_size>,
                              <Local_work_size>, <Parameters_to_kernel.....> )

for example:

event = program.square( queue, A.shape, None, 
                        A_buf, B_buf, cl.LocalMemory( A.size), np.int32(COUNT) )

So how to set the "work_dim" explicitly in python using pyopencl?

Upvotes: 2

Views: 867

Answers (1)

Jonathan Dursi
Jonathan Dursi

Reputation: 50927

You don't. work_dim is passed in the C/C++ OpenCL API so that the library can know the size of the one-d arrays global_work_offset, etc; in PyOpenCL, those sizes be inferred from the objects passed as global_size, local_size, and global_offset.

Upvotes: 2

Related Questions