CLENQUEUEWRITEIMAGE(3clc)
CLENQUEUEWRITEIMAGE(3clc) π
okay so bestie, welcome to the OpenCL Manual β yes the actual Khronos one, we're doing this properly β¨
β¨ NAME β¨
clEnqueueWriteImage β enqueues a command to write to an image or image array object from host memory. it's giving "put your pixels in the picture" energy π
cl_int clEnqueueWriteImage(cl_command_queue command_queue, cl_mem image,
cl_bool blocking_write, const size_t *origin,
const size_t *region, size_t input_row_pitch,
size_t input_slice_pitch, const void * ptr,
cl_uint num_events_in_wait_list,
const cl_event *event_wait_list,
cl_event *event);
π PARAMETERS π
command_queueβ the command-queue where this write command gets queued up. heads up tho:command_queueandimagehave to be created with the same OpenCL context, no mixing and matching π ββοΈimageβ a valid image or image array object. that's it, that's the whole vibe.blocking_writeβ tells you if the write is blocking or non-blocking, and this one actually matters a lot so listen up π«Ά- if
blocking_writeisCL_TRUE, the OpenCL implementation copies the data thatptrpoints to and enqueues the write command in the command-queue. onceclEnqueueWriteImagereturns, you can reuse the memoryptrpoints at. iconic, no waiting. - if
blocking_writeisCL_FALSE, the implementation will useptrto do a nonblocking write. since it's non-blocking, the implementation can just dip immediately. the memoryptrpoints to cannot be reused by the application after the call returns π theeventargument gives you back an event object you can use to query the execution status of the write command. when that write command is done, then the memoryptrpoints to can be reused. periodt.
- if
originβ defines the(x, y, z)offset in pixels in the 1D, 2D, or 3D image; or the(x, y)offset plus the image index in the image array; or the(x)offset plus the image index in the 1D image array. the rules, fr fr:- if
imageis a 2D image object,origin[2]must be0. - if
imageis a 1D image or 1D image buffer object,origin[1]andorigin[2]must be0. - if
imageis a 1D image array object,origin[2]must be0. - if
imageis a 1D image array object,origin[1]describes the image index in the 1D image array. - if
imageis a 2D image array object,origin[2]describes the image index in the 2D image array.
- if
regionβ defines the(width, height, depth)in pixels of the 1D, 2D or 3D rectangle; or the(width, height)in pixels of the 2D rectangle plus the number of images of a 2D image array; or the(width)in pixels of the 1D rectangle plus the number of images of a 1D image array. more rules, slay:- if
imageis a 2D image object,region[2]must be1. - if
imageis a 1D image or 1D image buffer object,region[1]andregion[2]must be1. - if
imageis a 1D image array object,region[2]must be1.
- if
input_row_pitchβ the length of each row in bytes. this value must be greater than or equal to the element size in bytes * width. ifrow_pitchis set to0, the appropriate row pitch gets calculated based on the size of each element in bytes multiplied by width. math but make it cute π§input_slice_pitchβ size in bytes of the 2D slice of the 3D region of a 3D image, or of each image of a 1D or 2D image array being written. this must be0ifimageis a 1D or 2D image. this value must be greater than or equal torow_pitch * height. ifslice_pitchis set to0, the appropriate slice pitch gets calculated based on therow_pitch * height. πptrβ the pointer to a buffer in host memory where image data is to be written to. that's the source, bestie.event_wait_list,num_events_in_wait_listβ specify events that need to complete before this particular command can be executed. the deets:- if
event_wait_listisNULL, then this particular command does not wait on any event to complete. - if
event_wait_listisNULL,num_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. - the context associated with events in
event_wait_listandcommand_queuemust be the same. - the memory associated with
event_wait_listcan be reused or freed after the function returns. free real estate π
- if
eventβ returns an event object that identifies this particular write command and can be used to query or queue a wait for this particular command to complete.eventcan beNULL, in which case it will not be possible for the application to query the status of this command or queue a wait for this command to complete. lowkey a tradeoff, highkey fine if you don't care.
πΈ NOTES πΈ
calling clEnqueueWriteImage to update the latest bits in a region of the image with the ptr argument value set to host_ptr + (origin[2] * image slice pitch + origin[1] * image row pitch + origin[0] * bytes per pixel), where host_ptr is a pointer to the memory region specified when the image being written is created with CL_MEM_USE_HOST_PTR, must meet the following requirements in order to avoid undefined behavior π¨ (yes we're being dramatic, this is undefined behavior, we should be dramatic):
- the host memory region being written contains the latest bits when the enqueued write command begins execution.
- the
input_row_pitchandinput_slice_pitchargument values inclEnqueueWriteImagemust be set to the image row pitch and slice pitch. - the image object is not mapped.
- the image object is not used by any command-queue until the write command has finished execution.
π ERRORS π
clEnqueueWriteImage returns CL_SUCCESS if the function is executed successfully. otherwise, it returns one of the following errors:
CL_INVALID_COMMAND_QUEUEifcommand_queueis not a valid command-queue.CL_INVALID_CONTEXTif the context associated withcommand_queueandimageare not the same, or if the context associated withcommand_queueand events inevent_wait_listare not the same.CL_INVALID_MEM_OBJECTifimageis not a valid image object.CL_INVALID_VALUEif the region being written specified byoriginandregionis out of bounds, or ifptris aNULLvalue.CL_INVALID_VALUEif values inoriginandregiondo not follow rules described in the argument description fororiginandregion.CL_INVALID_EVENT_WAIT_LISTifevent_wait_listisNULLandnum_events_in_wait_list>0, orevent_wait_listis notNULLandnum_events_in_wait_listis0, or if event objects inevent_wait_listare not valid events.CL_INVALID_IMAGE_SIZEif image dimensions (image width, height, specified or compute row and/or slice pitch) forimageare not supported by device associated with queue.CL_INVALID_IMAGE_FORMATif image format (image channel order and data type) forimageare not supported by device associated with queue.CL_MEM_OBJECT_ALLOCATION_FAILUREif there is a failure to allocate memory for data store associated withimage.CL_INVALID_OPERATIONif the device associated withcommand_queuedoes not support images (i.e.CL_DEVICE_IMAGE_SUPPORTspecified the table of allowed values forparam_nameforclGetDeviceInfo(3clc)isCL_FALSE).CL_INVALID_OPERATIONifclEnqueueWriteImageis called onimagewhich has been created withCL_MEM_HOST_WRITE_ONLYorCL_MEM_HOST_NO_ACCESS.CL_EXEC_STATUS_ERROR_FOR_EVENTS_IN_WAIT_LISTif the write operations are blocking and the execution status of any of the events inevent_wait_listis a negative integer value.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.
π¦ SPECIFICATION π¦
OpenCL Specification[1]
β SEE ALSO β
clEnqueueReadImage(3clc), clEnqueueCopyImage(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 99, section 5.3.3 - Reading, Writing and Copying Image Objects
and that's the whole page, bestie!! π«Ά written by The Khronos Group, dated 01/14/2021, and yeah this is CLENQUEUEWRITEIMAGE(3clc) β go forth and write those images, you absolute icon π
β¨
π¦ 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