C Specification
To create sub-devices partitioning an OpenCL device, call the function:
// Provided by CL_VERSION_1_2
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);
| clCreateSubDevices is missing before version 1.2. |
Parameters
-
in_device is the device to be partitioned.
-
properties specifies how in_device is to be partitioned, described by a partition name and its corresponding value. Each partition name is immediately followed by the corresponding desired value. The list is terminated with 0. The list of supported partitioning schemes is described in the Sub-device Partition table. Only one of the listed partitioning schemes can be specified in properties.
-
num_devices is the size of memory pointed to by out_devices specified as the number of
cl_device_entries.id -
out_devices is the buffer where the OpenCL sub-devices will be returned. If out_devices is
NULL, this argument is ignored. If out_devices is notNULL, num_devices must be greater than or equal to the number of sub-devices that device may be partitioned into according to the partitioning scheme specified in properties. -
num_devices_ret returns the number of sub-devices that device may be partitioned into according to the partitioning scheme specified in properties. If num_devices_ret is
NULL, it is ignored.
Description
clCreateSubDevices creates an array of sub-devices that each reference a non-intersecting set of compute units within in_device, according to the partition scheme given by properties. 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.
| Partition Property | Partition Value | Description |
|---|---|---|
missing before version 1.2. |
|
Split the aggregate device into as many smaller aggregate devices as
can be created, each containing n compute units.
The value n is passed as the value accompanying this property.
If n does not divide evenly into
|
missing before version 1.2. |
|
This property is followed by a list of compute unit counts
terminated with 0 or The number of non-zero count entries in the list may not exceed
The total number of compute units specified may not exceed
|
missing before version 1.2. |
|
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 the following list: The user may determine what happened by calling
clGetDeviceInfo( |
clCreateSubDevices returns CL_SUCCESS if the partition is created
successfully.
Otherwise, it returns a NULL value with the following error values
returned in errcode_ret:
-
CL_INVALID_DEVICE -
if in_device is not a valid device
-
-
CL_INVALID_VALUE -
if values specified in properties are not valid
-
if values specified in properties are valid but not are supported by in_device
-
if out_devices is not
NULLand num_devices is less than the number of sub-devices created by the partition scheme
-
-
CL_DEVICE_PARTITION_ FAILED -
if the partition name is supported by the implementation but in_device could not be further partitioned
-
-
CL_INVALID_DEVICE_ PARTITION_ COUNT -
if the partition name specified in properties is
CL_DEVICE_and the number of sub-devices requested exceedsPARTITION_ BY_ COUNTS CL_DEVICE_PARTITION_ MAX_ SUB_ DEVICES -
if the total number of compute units requested exceeds
CL_DEVICE_for in_deviceMAX_ COMPUTE_ UNITS -
if the number of compute units requested for one or more sub-devices is less than zero
-
if the number of sub-devices requested for one or more sub-devices exceeds
CL_DEVICE_for in_deviceMAX_ COMPUTE_ UNITS
-
-
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
-
A few examples that describe how to specify partition properties in properties argument to clCreateSubDevices are given below:
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 } // 0 terminates the property list
To partition a device with four compute units into two sub-devices with one sub-device containing 3 compute units and the other sub-device 1 compute unit, pass the following in properties argument:
{ CL_DEVICE_PARTITION_BY_COUNTS,
3, 1, CL_DEVICE_PARTITION_BY_COUNTS_LIST_END,
0 } // 0 terminates the property list
To split a device along the outermost cache line (if any), pass the following in properties argument:
{ CL_DEVICE_PARTITION_BY_AFFINITY_DOMAIN,
CL_DEVICE_AFFINITY_DOMAIN_NEXT_PARTITIONABLE,
0 } // 0 terminates the property list
Document Notes
For more information, see the OpenCL Specification
This page is extracted from the OpenCL Specification. Fixes and changes should be made to the Specification, not directly.