CLENQUEUEMIGRATEMEMO(3clc)
β¨ CLENQUEUEMIGRATEMEMO β¨
okay bestie, gather round π you're reading a page from the OpenCL Manual, section 3clc, and it's all about clEnqueueMigrateMemObjects β the girlboss function that tells OpenCL which device your memory objects should be living on. no cap, this one's a banger.
πΈ NAME πΈ
clEnqueueMigrateMemObjects β enqueues a command to indicate which device a set of memory objects should be associated with. literally that's it. that's the job. π
π¦ SYNOPSIS π¦
cl_int clEnqueueMigrateMemObjects(cl_command_queue command_queue,
cl_uint num_mem_objects,
const cl_mem *mem_objects,
cl_mem_migration_flags flags,
cl_uint num_events_in_wait_list,
const cl_event *event_wait_list,
cl_event *event);
look at her. seven arguments. main character energy fr fr π
π PARAMETERS π
command_queueβ a valid command-queue. the memory objects you pass inmem_objectsget migrated to the OpenCL device that's chillin' with thiscommand_queue, OR to the host if you specifiedCL_MIGRATE_MEM_OBJECT_HOST. pick your fighter π«num_mem_objectsβ the number of memory objects you're passing inmem_objects. count them, bestie, don't guess π’mem_objectsβ a pointer to a list of memory objects. the whole squad π«Άflagsβ a bit-field that specifies your migration options. here's the tea on what values it can take:CL_MIGRATE_MEM_OBJECT_HOSTβ this flag says the specified set of memory objects are to be migrated to the host, regardless of the target command-queue. host said "come here" and the command-queue doesn't get a vote πCL_MIGRATE_MEM_OBJECT_CONTENT_UNDEFINEDβ this flag says the contents of the set of memory objects are undefined after migration. the specified set of memory objects are migrated to the device associated withcommand_queuewithout incurring the overhead of migrating their contents. it's giving "move the box but don't bother packing it" π¦π
event_wait_list,num_events_in_wait_listβ these specify events that need to complete before this particular command can even be executed. ifevent_wait_listisNULL, then this particular command does not wait on any event to complete. ifevent_wait_listisNULL,num_events_in_wait_listmust be0. ifevent_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 inevent_wait_listact as synchronization points. the context associated with events inevent_wait_listandcommand_queuemust be the same. the memory associated withevent_wait_listcan be reused or freed after the function returns. so like, free it whenever, she's not holding onto it πeventβ returns an event object that identifies this particular 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. if theevent_wait_listand theeventarguments are notNULL, theeventargument should not refer to an element of theevent_wait_listarray. don't make her point at herself, that's weird π
π NOTES π
this section describes a mechanism for assigning which device an OpenCL memory object resides. a user may wish to have more explicit control over the location of their memory objects on creation. this could be used to:
- Ensure that an object is allocated on a specific device prior to usage.
- Preemptively migrate an object from one device to another.
Typically, memory objects are implicitly migrated to a device for which enqueued commands, using the memory object, are targeted. clEnqueueMigrateMemObjects allows this migration to be explicitly performed ahead of the dependent commands. This allows a user to preemptively change the association of a memory object, through regular command queue scheduling, in order to prepare for another upcoming command. This also permits an application to overlap the placement of memory objects with other unrelated operations before these memory objects are needed potentially hiding transfer latencies. Once the event, returned from clEnqueueMigrateMemObjects, has been marked CL_COMPLETE the memory objects specified in mem_objects have been successfully migrated to the device associated with command_queue. The migrated memory object shall remain resident on the device until another command is enqueued that either implicitly or explicitly migrates it away.
clEnqueueMigrateMemObjects can also be used to direct the initial placement of a memory object, after creation, possibly avoiding the initial overhead of instantiating the object on the first enqueued command to use it.
The user is responsible for managing the event dependencies, associated with this command, in order to avoid overlapping access to memory objects. Improperly specified event dependencies passed to clEnqueueMigrateMemObjects could result in undefined results.
π¨ bestie listen: you are responsible for managing the event dependencies. improperly specified event dependencies could result in undefined results. that's the scary kind of undefined. be careful, okay? π«
π₯ ERRORS π₯
clEnqueueMigrateMemObjects returns CL_SUCCESS if the function is executed successfully. otherwise, it returns one of the following errors:
CL_INVALID_COMMAND_QUEUEifcommand_queueis not a validcommand_queue.CL_INVALID_CONTEXTif the context associated withcommand_queueand memory objects inmemobjare not the same or if the context associated withcommand_queueand events inevent_wait_listare not the same.CL_INVALID_MEM_OBJECTif any of the memory objects inmem_objsis not a valid memory object.CL_INVALID_VALUEifnum_mem_objectsis zero or ifmem_objectsisNULL.CL_INVALID_VALUEifflagsis not0or is not any of the values described in the table above.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_MEM_OBJECT_ALLOCATION_FAILUREif there is a failure to allocate memory for the specified set of memory objects inmem_objects.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 π
clEnqueueMapBuffer(3clc), clEnqueueMapImage(3clc)
go read those next, they're also iconic iykyk πβ¨
π 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 (the footnote one) π§
- OpenCL Specification β page 123, section 5.4.4 - Migrating Memory Objects
and that's a wrap on the whole page, bestie π this edition of the OpenCL Manual was brought to you by The Khronos Group, dated 01/14/2021, filed under CLENQUEUEMIGRATEMEMO(3clc). go migrate something responsibly. mwah π
π¦ 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