summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarol Herbst <kherbst@redhat.com>2024-01-24 11:51:27 +0100
committerEric Engestrom <eric@engestrom.ch>2024-01-24 14:22:24 +0000
commitd25222c73fe676405e127605b7eb8b0f5f4be531 (patch)
tree48e387bd5bc14dd030021232673ee6708783ffb9
parent3f1d5726cc97931a169efb4483e7755fddeb6340 (diff)
rusticl/kernel: check that local size on dispatch doesn't exceed limits
Cc: mesa-stable Signed-off-by: Karol Herbst <kherbst@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27232> (cherry picked from commit eca4f0f632b1e3e6e24bd12ee5f00522eb7d0fdb)
-rw-r--r--.pick_status.json2
-rw-r--r--src/gallium/frontends/rusticl/api/kernel.rs12
2 files changed, 12 insertions, 2 deletions
diff --git a/.pick_status.json b/.pick_status.json
index e278a0ccac5..2ce6ab3af98 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -4,7 +4,7 @@
"description": "rusticl/kernel: check that local size on dispatch doesn't exceed limits",
"nominated": true,
"nomination_type": 0,
- "resolution": 0,
+ "resolution": 1,
"main_sha": null,
"because_sha": null,
"notes": null
diff --git a/src/gallium/frontends/rusticl/api/kernel.rs b/src/gallium/frontends/rusticl/api/kernel.rs
index 9ae240e7c0f..89496b788e0 100644
--- a/src/gallium/frontends/rusticl/api/kernel.rs
+++ b/src/gallium/frontends/rusticl/api/kernel.rs
@@ -535,11 +535,14 @@ fn enqueue_ndrange_kernel(
let device_bits = q.device.address_bits();
let device_max = u64::MAX >> (u64::BITS - device_bits);
+ let mut threads = 0;
for i in 0..work_dim as usize {
let lws = local_work_size[i];
let gws = global_work_size[i];
let gwo = global_work_offset[i];
+ threads *= lws;
+
// CL_INVALID_WORK_ITEM_SIZE if the number of work-items specified in any of
// local_work_size[0], … local_work_size[work_dim - 1] is greater than the corresponding
// values specified by
@@ -580,6 +583,14 @@ fn enqueue_ndrange_kernel(
}
}
+ // CL_INVALID_WORK_GROUP_SIZE if local_work_size is specified and the total number of work-items
+ // in the work-group computed as local_work_size[0] × … local_work_size[work_dim - 1] is greater
+ // than the value specified by CL_KERNEL_WORK_GROUP_SIZE in the Kernel Object Device Queries
+ // table.
+ if threads != 0 && threads > k.max_threads_per_block(q.device) {
+ return Err(CL_INVALID_WORK_GROUP_SIZE);
+ }
+
// If global_work_size is NULL, or the value in any passed dimension is 0 then the kernel
// command will trivially succeed after its event dependencies are satisfied and subsequently
// update its completion event.
@@ -598,7 +609,6 @@ fn enqueue_ndrange_kernel(
create_and_queue(q, CL_COMMAND_NDRANGE_KERNEL, evs, event, false, cb)
//• CL_INVALID_WORK_GROUP_SIZE if local_work_size is specified and is not consistent with the required number of sub-groups for kernel in the program source.
- //• CL_INVALID_WORK_GROUP_SIZE if local_work_size is specified and the total number of work-items in the work-group computed as local_work_size[0] × … local_work_size[work_dim - 1] is greater than the value specified by CL_KERNEL_WORK_GROUP_SIZE in the Kernel Object Device Queries table.
//• CL_MISALIGNED_SUB_BUFFER_OFFSET if a sub-buffer object is specified as the value for an argument that is a buffer object and the offset specified when the sub-buffer object is created is not aligned to CL_DEVICE_MEM_BASE_ADDR_ALIGN value for device associated with queue. This error code
//• CL_INVALID_IMAGE_SIZE if an image object is specified as an argument value and the image dimensions (image width, height, specified or compute row and/or slice pitch) are not supported by device associated with queue.
//• CL_IMAGE_FORMAT_NOT_SUPPORTED if an image object is specified as an argument value and the image format (image channel order and data type) is not supported by device associated with queue.