OpenCL Device Fission: Split One GPU into Sub-Devices
Partition one OpenCL compute device into sub-devices with clCreateSubDevices—logical queue isolation, not hardware security.
05 Dec 2025, 17:45 UTC

One GPU, two kernels, no clean boundary
You have one GPU and two kernels that keep stepping on each other. You could create separate platforms or contexts, but on a single device that often duplicates setup and still shares the same silicon. OpenCL 1.2 offers a narrower tool: device fission. It lets a host program split one compute device into multiple sub-devices, each with its own command-queue boundary, while remaining inside one parent device and context model.
This post explains when fission helps, how to verify driver support, and a C example that divides a device equally into two sub-devices. It also covers where fission stops short: logical isolation is not a hardware security boundary.
Query fission support before you split
Not every driver advertises fission. Call clGetDeviceInfo on the parent device and check:
CL_DEVICE_PARTITION_MAX_SUB_DEVICES: the maximum number of sub-devices the driver can create from this device.CL_DEVICE_PARTITION_AFFINITY_DOMAINS: a bitmask of supported schemes, such asCL_DEVICE_PARTITION_EQUALLY,CL_DEVICE_PARTITION_BY_COUNTS, or affinity domains tied to L1/L2 cache or NUMA nodes.
If either query fails or returns zero, do not proceed. OpenCL 1.1 and earlier do not have clCreateSubDevices, so confirm the platform reports OpenCL 1.2 or later.
Worked example: split one device into two
Run this in your host application, not on the device. It requires normal process privileges; no root or special driver access is needed beyond what OpenCL already requires. Replace parent_device with your discovered cl_device_id.
cl_int err;
cl_uint num_sub_devices = 2;
cl_device_id sub_devices[2];
err = clCreateSubDevices(
parent_device,
(const cl_device_partition_property[]) {
CL_DEVICE_PARTITION_EQUALLY,
2,
0
},
2,
sub_devices,
&num_sub_devices
);
if (err != CL_SUCCESS || num_sub_devices == 0) {
/* handle failure: driver may return fewer sub-devices or CL_INVALID_VALUE */
}
Expected checks:
errequalsCL_SUCCESS.num_sub_devicesis 2, or fewer if the driver could not satisfy the request.- Query
CL_DEVICE_PARENT_DEVICEon each result; it should returnparent_device. - Query
CL_DEVICE_COMPUTE_UNITSon the parent and each sub-device; the values should roughly account for the parent's units, though drivers may reserve some.
Then create separate command queues:
cl_command_queue queue_a = clCreateCommandQueue(context, sub_devices[0], 0, &err); cl_command_queue queue_b = clCreateCommandQueue(context, sub_devices[1], 0, &err);
Buffers and images must be created against a context that includes the sub-device, or explicitly associated, before enqueuing kernels on those queues. A context built only from the parent device may not accept a sub-device queue depending on the driver; create the context with the sub-device in its device list when in doubt.
Trade-offs and limitations
Fission happens inside a single device. Sub-devices share the same physical silicon, so you get logical scheduling isolation, not guaranteed performance isolation or a hardware security boundary. One sub-device can still affect another through shared memory bandwidth, caches, or power and thermal limits.
A partition request can fail or return fewer sub-devices than requested when counts or affinity constraints cannot be met. Always check err and num_sub_devices, and do not assume the split matches your request exactly.
Practical check: after partitioning, compare CL_DEVICE_COMPUTE_UNITS on parent and children, and confirm CL_DEVICE_PARENT_DEVICE points back to the original device. If the numbers do not add up, the driver is reserving units or adjusted the partition scheme.
Closing checklist
- Query
CL_DEVICE_PARTITION_MAX_SUB_DEVICESandCL_DEVICE_PARTITION_AFFINITY_DOMAINS. - Call
clCreateSubDeviceswith your chosen scheme and inspect the returned count. - Verify
CL_DEVICE_PARENT_DEVICEand compute-unit distribution. - Create contexts and queues that explicitly include the sub-devices.
- Treat sub-devices as logical partitions for queue isolation, not as separate secure hardware.
Release each sub-device with clReleaseDevice when you are done. This frees the OpenCL object; it does not change the physical hardware.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.