From 1e655b2f2550aacd768138d74ce857cc25bf9fae Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Wed, 10 May 2023 14:03:06 +0200 Subject: [PATCH] clc: rework optional subgroup feature OpenCL 3.0 core requires __opencl_c_subgroups to be set, the OpenCL cl_khr_subgroups extenions can only be enabled if and only if the driver guarentees independent forward progress between subgroups. See CL_DEVICE_SUB_GROUP_INDEPENDENT_FORWARD_PROGRESS for more information. Signed-off-by: Karol Herbst Reviewed-by: Nora Allen Reviewed-by: Alyssa Rosenzweig Part-of: --- src/compiler/clc/clc.h | 5 +++++ src/compiler/clc/clc_helpers.cpp | 4 ++++ src/gallium/frontends/rusticl/core/device.rs | 1 + src/intel/compiler/intel_clc.c | 1 + 4 files changed, 11 insertions(+) diff --git a/src/compiler/clc/clc.h b/src/compiler/clc/clc.h index a7d20e8314f..daaf8e7b289 100644 --- a/src/compiler/clc/clc.h +++ b/src/compiler/clc/clc.h @@ -58,7 +58,12 @@ struct clc_optional_features { bool images_write_3d; bool integer_dot_product; bool intel_subgroups; + /* OpenCL core subgroups */ bool subgroups; + /* OpenCL extension cl_khr_subgroups, which requires independent forward + * progress + */ + bool subgroups_ifp; }; struct clc_compile_args { diff --git a/src/compiler/clc/clc_helpers.cpp b/src/compiler/clc/clc_helpers.cpp index 65acb717f5a..412a0dbf93d 100644 --- a/src/compiler/clc/clc_helpers.cpp +++ b/src/compiler/clc/clc_helpers.cpp @@ -927,6 +927,10 @@ clc_compile_to_llvm_module(LLVMContext &llvm_ctx, c->getTargetOpts().OpenCLExtensionsAsWritten.push_back("+cl_intel_subgroups"); } if (args->features.subgroups) { + c->getTargetOpts().OpenCLExtensionsAsWritten.push_back("+__opencl_c_subgroups"); + } + if (args->features.subgroups_ifp) { + assert(args->features.subgroups); c->getTargetOpts().OpenCLExtensionsAsWritten.push_back("+cl_khr_subgroups"); } #endif diff --git a/src/gallium/frontends/rusticl/core/device.rs b/src/gallium/frontends/rusticl/core/device.rs index af9680d8620..1a76df332f3 100644 --- a/src/gallium/frontends/rusticl/core/device.rs +++ b/src/gallium/frontends/rusticl/core/device.rs @@ -901,6 +901,7 @@ impl Device { integer_dot_product: true, intel_subgroups: false, subgroups: false, + subgroups_ifp: false, } } } diff --git a/src/intel/compiler/intel_clc.c b/src/intel/compiler/intel_clc.c index c1887c130a7..6371e864017 100644 --- a/src/intel/compiler/intel_clc.c +++ b/src/intel/compiler/intel_clc.c @@ -437,6 +437,7 @@ int main(int argc, char **argv) .fp16 = true, .intel_subgroups = true, .subgroups = true, + .subgroups_ifp = true, }, .args = util_dynarray_begin(&clang_args), .num_args = util_dynarray_num_elements(&clang_args, char *),