CLENQUEUEFILLBUFFER(3clc)
π CLENQUEUEFILLBUFFER π
okay bestie, welcome to the 3clc corner of the OpenCL Manual, pull up a chair π«Ά
β¨ NAME β¨
clEnqueueFillBuffer β she enqueues a command that fills a buffer object with a pattern, and that pattern has a pattern size, and yes both of those numbers matter, iykyk π
cl_int clEnqueueFillBuffer(cl_command_queue command_queue,
cl_mem buffer, const void *pattern,
size_t pattern_size, size_t offset,
size_t size, cl_uint num_events_in_wait_list,
const cl_event *event_wait_list,
cl_event *event);
π PARAMETERS π
command_queueβ this is the command-queue where the fill command gets queued, no biggie. β¨ BUT: the OpenCL context that's associated withcommand_queueandbuffermust be the same. literally non-negotiable.bufferβ a valid buffer object. that's it, that's the vibe. π¦patternβ a pointer to the data pattern, and it'spattern_sizebytes big. thispatternis gonna fill a region inbufferthat starts atoffsetand issizebytes in size. the data pattern must be a scalar or vector integer or floating-point data type. like, for example: ifbufferis getting filled with a pattern offloat4values, thenpatternis a pointer to acl_float4value andpattern_sizeissizeof(cl_float4). πΈ the maximum value ofpattern_sizeis the size of the largest integer or floating-point vector data type that the OpenCL device supports, so don't get cute with it. oh and also? the memory associated withpatterncan be reused or freed after the function returns. go off, free your memory. π₯offsetβ the location, in bytes, of the region being filled inbuffer. and it must be a multiple ofpattern_size. the math is mathing or it isn't. πsizeβ the size, in bytes, of the region being filled inbuffer. also must be a multiple ofpattern_size. see above, bestie. πevent_wait_list,num_events_in_wait_listβ these specify the events that need to finish before this particular command can even be executed. ifevent_wait_listisNULL, then this command doesn't wait on any event to complete. and ifevent_wait_listisNULL, thennum_events_in_wait_listmust be 0. ifevent_wait_listis notNULL, then the list of events pointed to byevent_wait_listmust be valid andnum_events_in_wait_listmust be greater than 0. the events inevent_wait_listact as synchronization points. the context associated with the events inevent_wait_listandcommand_queuemust be the same. and the memory associated withevent_wait_listcan be reused or freed after the function returns. β¨eventβ returns an event object that identifies this particular write command, and you can use it to query or queue a wait for this particular command to complete.eventcan beNULL, in which case the application will not be able to query the status of this command or queue a wait for it to complete.clEnqueueBarrierWithWaitList(3clc)can be used instead. π«Ά and hey β ifevent_wait_listand theeventarguments are notNULL, then theeventargument should not refer to an element of theevent_wait_listarray. that's giving messy, don't do it.
π NOTES π
So she enqueues a command to fill a buffer object with a pattern of a given pattern size. and here's the tea β: the usage information that says whether the memory object can be read or written by a kernel and/or the host β the stuff given by the cl_mem_flags argument value that was specified when buffer was created β is ignored by clEnqueueFillBuffer. she doesn't care. she's above it. periodt. π
π ERRORS π
clEnqueueFillBuffer returns CL_SUCCESS if the function is executed successfully. otherwise she returns one of the following errors, and honestly, mood:
CL_INVALID_COMMAND_QUEUEifcommand_queueis not a valid command-queue.CL_INVALID_CONTEXTif the context associated withcommand_queueandbufferare not the same, or if the context associated withcommand_queueand events inevent_wait_listare not the same.CL_INVALID_MEM_OBJECTifbufferis not a valid buffer object.CL_INVALID_VALUEifoffsetoroffset + sizerequire accessing elements outside thebufferbuffer object respectively.CL_INVALID_VALUEifpatternisNULL, or ifpattern_sizeis 0, or ifpattern_sizeis not one of{1, 2, 4, 8, 16, 32, 64, 128}. (memorize that set, bestie, it's the whole vibe check π₯)CL_INVALID_VALUEifoffsetandsizeare not a multiple ofpattern_size.CL_INVALID_EVENT_WAIT_LISTifevent_wait_listisNULLandnum_events_in_wait_list> 0, orevent_wait_listis notNULLandnum_events_in_wait_listis 0, or if event objects inevent_wait_listare not valid events.CL_MISALIGNED_SUB_BUFFER_OFFSETifbufferis a sub-buffer object and theoffsetspecified when the sub-buffer object was created is not aligned to theCL_DEVICE_MEM_BASE_ADDR_ALIGNvalue for the device associated withqueue.CL_MEM_OBJECT_ALLOCATION_FAILUREif there is a failure to allocate memory for the data store associated withbuffer.CL_OUT_OF_RESOURCESif there is a failure to allocate resources required by the OpenCL implementation on the device.CL_OUT_OF_HOST_MEMORYif there is a failure to allocate resources required by the OpenCL implementation on the host.
ngl every single one of these is a "read the list twice" situation. she does not do vibes-based error handling. π
β SPECIFICATION β
OpenCL Specification[1]
π§ SEE ALSO π§
clEnqueueBarrierWithWaitList(3clc) β your girl when event is NULL, remember?
π 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 84, section 5.2.2 - Reading, Writing and Copying Buffer Objects. go read it, it's right there. π
and that's the whole page, bestie!! this one came straight from The Khronos Group, dated 01/14/2021, filed under CLENQUEUEFILLBUFFER(3clc) β¨ go fill some buffers, align your offsets, and slay π
π
π¦ 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