CLENQUEUETASK(3clc)
π NAME π
clEnqueueTask β bestie, this is the one that drops a kernel onto a device and says go, girl, go.
cl_int clEnqueueTask(cl_command_queue command_queue, cl_kernel kernel,
cl_uint num_events_in_wait_list,
const cl_event *event_wait_list, cl_event *event);
This is page 3clc of the OpenCL manual, and we're about to make queueing a kernel make so much sense. π
πΈ PARAMETERS πΈ
command_queueβ a valid command-queue, no cap. Your kernel gets queued for execution on the device that's associated withcommand_queue. That's the whole vibe.kernelβ a valid kernel object. And listen: the OpenCL context associated withkerneland the one associated withcommand_queuemust be the same. Same context or it's not happening, fr fr.num_events_in_wait_list,event_wait_listβ these two specify events that need to finish before this particular command can even be executed. The rules, bestie, are very specific:- if
event_wait_listisNULL, then this particular command does not wait on any event to complete. - if
event_wait_listisNULL, thennum_events_in_wait_listmust be0. - if
event_wait_listis notNULL, the list of events pointed to byevent_wait_listmust be valid andnum_events_in_wait_listmust be greater than0. - the events specified in
event_wait_listact as synchronization points β that's their whole job, their main character moment. - the context associated with the events in
event_wait_listand the context associated withcommand_queuemust be the same. - the memory associated with
event_wait_listcan be reused or freed after the function returns. So you don't have to keep it around, she's free. π¦
- if
eventβ this returns an event object that identifies this particular kernel execution instance. Event objects are unique, and you can use them later to identify that specific kernel execution instance. But ifeventisNULL, no event gets created for this kernel execution instance at all β which means your application literally cannot query it or queue a wait for that particular kernel execution instance. So like, no receipts. π
β¨ NOTES β¨
The kernel is executed using a single work-item. That's it. One. Solo. Main character energy.
clEnqueueTask is equivalent to calling clEnqueueNDRangeKernel(3clc) with:
work_dim = 1global_work_offset = NULLglobal_work_size[0]set to1local_work_size[0]set to1
So if you already know clEnqueueNDRangeKernel, you already know her. π
π₯ ERRORS π₯
Returns CL_SUCCESS if the kernel execution was successfully queued. Slay. Otherwise you get one of these below:
CL_INVALID_PROGRAM_EXECUTABLEβ there is no successfully built program executable available for the device associated withcommand_queue. Nothing to run, bestie. πCL_INVALID_COMMAND_QUEUEβcommand_queueis not a valid command-queue.CL_INVALID_KERNELβkernelis not a valid kernel object.CL_INVALID_CONTEXTβ the context associated withcommand_queueandkernelis not the same, or the context associated withcommand_queueand the events inevent_wait_listare not the same.CL_INVALID_KERNEL_ARGSβ the kernel argument values have not been specified. Feed her, she's hungry. πCL_INVALID_WORK_GROUP_SIZEβ a work-group size is specified forkernelusing thefunctionQualifiers(3clc)((reqd_work_group_size(X, Y, Z))) qualifier in the program source, and it is not(1, 1, 1).CL_MISALIGNED_SUB_BUFFER_OFFSETβ a sub-buffer object is specified as the value for an argument that is a buffer object, and the offset specified when the sub-buffer object is created is not aligned to theCL_DEVICE_MEM_BASE_ADDR_ALIGNvalue for the device associated with the queue.CL_INVALID_IMAGE_SIZEβ an image object is specified as an argument value, and the image dimensions (image width, height, specified or compute row and/or slice pitch) are not supported by the device associated with the queue.CL_INVALID_IMAGE_FORMATβ an image object is specified as an argument value, and the image format (image channel order and data type) is not supported by the device associated with the queue.CL_OUT_OF_RESOURCESβ there is a failure to queue the execution instance ofkernelon the command-queue because of insufficient resources needed to execute the kernel.CL_MEM_OBJECT_ALLOCATION_FAILUREβ there is a failure to allocate memory for the data store associated with image or buffer objects specified as arguments tokernel.CL_INVALID_EVENT_WAIT_LISTβevent_wait_listisNULLandnum_events_in_wait_list > 0, orevent_wait_listis notNULLandnum_events_in_wait_listis0, or the event objects inevent_wait_listare not valid events.CL_OUT_OF_RESOURCESβ there is a failure to allocate resources required by the OpenCL implementation on the device.CL_OUT_OF_HOST_MEMORYβ there is a failure to allocate resources required by the OpenCL implementation on the host.
Yes, CL_OUT_OF_RESOURCES shows up twice, once for the device and once for the host. That's not a typo, that's just the lore. π
π SPECIFICATION π
OpenCL Specification[1]
π SEE ALSO π
clEnqueueNDRangeKernel(3clc), clEnqueueNativeKernel(3clc)
π AUTHORS π
The Khronos Group
π COPYRIGHT π
Copyright Β© 2007-2011 The Khronos Group Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and/or associated documentation files (the "Materials"), to deal in the Materials without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Materials, and to permit persons to whom the Materials are furnished to do so, subject to the condition that this copyright notice and permission notice shall be included in all copies or substantial portions of the Materials.
π§ NOTES π§
- OpenCL Specification β page 172, section 5.8 - Executing Kernels (updated for 1.2 rev 14)
okay that's the whole page bestie, mwah π
β this was CLENQUEUETASK(3clc), brought to you by The Khronos Group and dated 01/14/2021. Go queue something iconic. π«Άβ¨
π¦ where this page comes from
- ubuntu jammy: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- ubuntu noble: opencl-1.2-man-doc 1.0~svn33624-5 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms