CLCREATESUBDEVICES(3clc)
π CLCREATESUBDEVICES π
okay bestie, welcome to CLCREATESUBDEVICES(3clc) from the OpenCL Manual β this is the one where you take one big device and βοΈ partition it into a lil squad of sub-devices. no cap, it's giving main character energy for real.
β¨ NAME β¨
clCreateSubDevices β creates an array of sub-devices, and each one references a non-intersecting set of compute units inside in_device. like, nobody's stepping on anybody's toes here, everyone gets their own lil zone π«Ά
cl_int clCreateSubDevices(cl_device_id in_device,
const cl_device_partition_property *properties,
cl_uint num_devices,
cl_device_id *out_devices,
cl_uint *num_devices_ret);
π PARAMETERS π
in_deviceβ the device you wanna partition. the one getting sliced and diced πpropertiesβ tells everyone howin_deviceis gonna be partitioned, described by a partition name plus its matching value. each partition name is immediately followed by the corresponding desired value, and the list is terminated with0. the supported partitioning schemes are listed below π and heads up: only one of the listed partitioning schemes can be specified inproperties. pick one, bestie, not all of them.CL_DEVICE_PARTITION_EQUALLY(unsigned int) β split the aggregate device into as many smaller aggregate devices as can be created, each containingncompute units. the valuenis passed as the value accompanying this property. and ifndoes not divide evenly intoCL_DEVICE_PARTITION_MAX_COMPUTE_UNITS, then the remaining compute units are not used. leftovers, sad πCL_DEVICE_PARTITION_BY_COUNTS(unsigned int) β this property is followed by aCL_DEVICE_PARTITION_BY_COUNTS_LIST_ENDterminated list of compute unit counts. for each nonzero countmin the list, a sub-device is created withmcompute units in it.CL_DEVICE_PARTITION_BY_COUNTS_LIST_ENDis defined to be0.- the number of non-zero count entries in the list may not exceed
CL_DEVICE_PARTITION_MAX_SUB_DEVICES. - the total number of compute units specified may not exceed
CL_DEVICE_PARTITION_MAX_COMPUTE_UNITS.
- the number of non-zero count entries in the list may not exceed
CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN(cl_device_affinity_domain) β split the device into smaller aggregate devices containing one or more compute units that all share part of a cache hierarchy. the value accompanying this property may be drawn from this list:CL_DEVICE_AFFINITY_DOMAIN_NUMAβ split the device into sub-devices comprised of compute units that share a NUMA node.CL_DEVICE_AFFINITY_DOMAIN_L4_CACHEβ split the device into sub-devices comprised of compute units that share a level 4 data cache.CL_DEVICE_AFFINITY_DOMAIN_L3_CACHEβ split the device into sub-devices comprised of compute units that share a level 3 data cache.CL_DEVICE_AFFINITY_DOMAIN_L2_CACHEβ split the device into sub-devices comprised of compute units that share a level 2 data cache.CL_DEVICE_AFFINITY_DOMAIN_L1_CACHEβ split the device into sub-devices comprised of compute units that share a level 1 data cache.CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLEβ split the device along the next partitionable affinity domain. the implementation shall find the first level along which the device or sub-device may be further subdivided in the order NUMA, L4, L3, L2, L1, and partition the device into sub-devices comprised of compute units that share memory subsystems at this level.
and the user may determine what happened by calling clGetDeviceInfo(3clc) (CL_DEVICE_PARTITION_TYPE) on the sub-devices. so you can always find out which level got picked, iykyk π
num_devicesβ size of the memory pointed to byout_devices, specified as the number ofcl_device_identries.out_devicesβ the buffer where the OpenCL sub-devices will be returned. ifout_devicesisNULL, this argument is ignored. ifout_devicesis notNULL,num_devicesmust be greater than or equal to the number of sub-devices that device may be partitioned into according to the partitioning scheme specified inproperties. so like, size it right or it's gonna be a whole situation πnum_devices_retβ returns the number of sub-devices that device may be partitioned into according to the partitioning scheme specified inproperties. ifnum_devices_retisNULL, it is ignored. perfectly fine to passNULL, she's just not gonna tell you the count π
π NOTES π
so what's actually happening here? clCreateSubDevices creates an array of sub-devices that each reference a non-intersecting set of compute units within in_device, according to a partition scheme given by properties. πΈ
and here's the slay part: the output sub-devices may be used in every way that the root (or parent) device can be used, including:
- creating contexts,
- building programs,
- further calls to
clCreateSubDevices, - and creating command-queues. π
when a command-queue is created against a sub-device, the commands enqueued on the queue are executed only on the sub-device. no leaking, no sharing, it stays in its lane fr fr β¨
bestie this is only part 1, don't go anywhere π
π₯ ERRORS π₯
okay so like, the happy path? Returns CL_SUCCESS when the partition is created successfully. That's it, that's the dream. π«Ά
But if it's not giving success, bestie, it returns a null value and drops the tea in errcode_ret instead. And the possible error values are:
CL_INVALID_DEVICEβ ifin_deviceis not valid. like, that device? not real. πCL_INVALID_VALUEβ if the values you put inpropertiesare not valid, or if the values inpropertiesare valid but the device just doesn't support them. valid but unsupported, the audacity. πCL_INVALID_VALUEβ ifout_devicesis notNULLandnum_devicesis less than the number of sub-devices created by the partition scheme. not enough room in the car, babes. πCL_DEVICE_PARTITION_FAILEDβ if the partition name is supported by the implementation, butin_devicecould not be further partitioned. it wanted to, it just couldn't. πCL_INVALID_DEVICE_PARTITION_COUNTβ if the partition name specified inpropertiesisCL_DEVICE_PARTITION_BY_COUNTSand:- the number of sub-devices requested exceeds
CL_DEVICE_PARTITION_MAX_SUB_DEVICES, or - the total number of compute units requested exceeds
CL_DEVICE_PARTITION_MAX_COMPUTE_UNITSforin_device, or - the number of compute units requested for one or more sub-devices is less than zero, or
- the number of sub-devices requested exceeds
CL_DEVICE_PARTITION_MAX_COMPUTE_UNITSforin_device. π
- the number of sub-devices requested exceeds
CL_OUT_OF_RESOURCESβ if there's a failure to allocate resources required by the OpenCL implementation on the device.CL_OUT_OF_HOST_MEMORYβ if there's a failure to allocate resources required by the OpenCL implementation on the host.
π Example π
here's a few lil examples showing how to specify partition properties in the properties argument to clCreateSubDevices. stan a demo. β¨
Want to partition a device containing 16 compute units into two sub-devices, each containing 8 compute units? Pass the following in properties:
{ CL_DEVICE_PARTITION_EQUALLY, 8, 0 }
Want to partition a device with four compute units into two sub-devices β one sub-device containing 3 compute units and the other sub-device 1 compute unit? Pass the following in the properties argument:
{ CL_DEVICE_PARTITION_BY_COUNTS, 3, 1,
CL_DEVICE_PARTITION_BY_COUNTS_LIST_END,
0 }
Want to split a device along the outermost cache line (if any)? Pass the following in the properties argument:
{
CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN,
CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE,
0 }
periodt. π
π SPECIFICATION π
OpenCL Specification[1] π¦
and yes bestie, [1] is the footnote β page 49, section 4.3 - Partitioning a Device. iykyk. π
π SEE ALSO π
π AUTHORS π
The Khronos Group β icons only, no notes. π«Ά
π 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.
and that's the whole page, bestie!! πβ¨π The Khronos Group wrote this one, dated 01/14/2021, and it lives in the manual as CLCREATESUBDEVICES(3clc). go forth and partition responsibly. π¦πΈπ
π¦ 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