CLENQUEUEFILLBUFFER(3clc)

πŸ“¦
version 1.0~svn33624 Β· 3 versions
, in ubuntu jammy, ubuntu noble

πŸ’– 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 with command_queue and buffer must 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's pattern_size bytes big. this pattern is gonna fill a region in buffer that starts at offset and is size bytes in size. the data pattern must be a scalar or vector integer or floating-point data type. like, for example: if buffer is getting filled with a pattern of float4 values, then pattern is a pointer to a cl_float4 value and pattern_size is sizeof(cl_float4). 🌸 the maximum value of pattern_size is 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 with pattern can be reused or freed after the function returns. go off, free your memory. πŸ”₯
  • offset β€” the location, in bytes, of the region being filled in buffer. and it must be a multiple of pattern_size. the math is mathing or it isn't. πŸ™ˆ
  • size β€” the size, in bytes, of the region being filled in buffer. also must be a multiple of pattern_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. if event_wait_list is NULL, then this command doesn't wait on any event to complete. and if event_wait_list is NULL, then num_events_in_wait_list must be 0. if event_wait_list is not NULL, then the list of events pointed to by event_wait_list must be valid and num_events_in_wait_list must be greater than 0. the events in event_wait_list act as synchronization points. the context associated with the events in event_wait_list and command_queue must be the same. and the memory associated with event_wait_list can 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. event can be NULL, 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 β€” if event_wait_list and the event arguments are not NULL, then the event argument should not refer to an element of the event_wait_list array. 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_QUEUE if command_queue is not a valid command-queue.
  • CL_INVALID_CONTEXT if the context associated with command_queue and buffer are not the same, or if the context associated with command_queue and events in event_wait_list are not the same.
  • CL_INVALID_MEM_OBJECT if buffer is not a valid buffer object.
  • CL_INVALID_VALUE if offset or offset + size require accessing elements outside the buffer buffer object respectively.
  • CL_INVALID_VALUE if pattern is NULL, or if pattern_size is 0, or if pattern_size is not one of {1, 2, 4, 8, 16, 32, 64, 128}. (memorize that set, bestie, it's the whole vibe check πŸ”₯)
  • CL_INVALID_VALUE if offset and size are not a multiple of pattern_size.
  • CL_INVALID_EVENT_WAIT_LIST if event_wait_list is NULL and num_events_in_wait_list > 0, or event_wait_list is not NULL and num_events_in_wait_list is 0, or if event objects in event_wait_list are not valid events.
  • CL_MISALIGNED_SUB_BUFFER_OFFSET if buffer is a sub-buffer object and the offset specified when the sub-buffer object was created is not aligned to the CL_DEVICE_MEM_BASE_ADDR_ALIGN value for the device associated with queue.
  • CL_MEM_OBJECT_ALLOCATION_FAILURE if there is a failure to allocate memory for the data store associated with buffer.
  • CL_OUT_OF_RESOURCES if there is a failure to allocate resources required by the OpenCL implementation on the device.
  • CL_OUT_OF_HOST_MEMORY if 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 Β© 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 πŸ“

  1. 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