clc: handle all optional subgroup extensions

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38015>
This commit is contained in:
Karol Herbst 2025-09-03 21:52:08 +02:00 committed by Marge Bot
parent 1c87c79893
commit 2e2b86c64f
2 changed files with 28 additions and 4 deletions

View file

@ -72,9 +72,15 @@ struct clc_optional_features {
* progress
*/
bool subgroups_ifp;
bool subgroups_ballot;
bool subgroups_clustered;
bool subgroups_extended_types;
bool subgroups_named_barrier;
bool subgroups_non_uniform_arithmetic;
bool subgroups_non_uniform_vote;
bool subgroups_rotate;
bool subgroups_shuffle;
bool subgroups_shuffle_relative;
bool subgroups_ballot;
};
struct clc_compile_args {

View file

@ -1024,15 +1024,33 @@ clc_compile_to_llvm_module(LLVMContext &llvm_ctx,
}
if (args->features.subgroups) {
c->getTargetOpts().OpenCLExtensionsAsWritten.push_back("+__opencl_c_subgroups");
if (args->features.subgroups_ballot) {
c->getPreprocessorOpts().addMacroDef("cl_khr_subgroup_ballot=1");
}
if (args->features.subgroups_clustered) {
c->getPreprocessorOpts().addMacroDef("cl_khr_subgroup_clustered_reduce=1");
}
if (args->features.subgroups_extended_types) {
c->getPreprocessorOpts().addMacroDef("cl_khr_subgroup_extended_types=1");
}
if (args->features.subgroups_named_barrier) {
c->getPreprocessorOpts().addMacroDef("cl_khr_subgroup_named_barrier=1");
}
if (args->features.subgroups_non_uniform_arithmetic) {
c->getPreprocessorOpts().addMacroDef("cl_khr_subgroup_non_uniform_arithmetic=1");
}
if (args->features.subgroups_non_uniform_vote) {
c->getPreprocessorOpts().addMacroDef("cl_khr_subgroup_non_uniform_vote=1");
}
if (args->features.subgroups_rotate) {
c->getPreprocessorOpts().addMacroDef("cl_khr_subgroup_rotate=1");
}
if (args->features.subgroups_shuffle) {
c->getPreprocessorOpts().addMacroDef("cl_khr_subgroup_shuffle=1");
}
if (args->features.subgroups_shuffle_relative) {
c->getPreprocessorOpts().addMacroDef("cl_khr_subgroup_shuffle_relative=1");
}
if (args->features.subgroups_ballot) {
c->getPreprocessorOpts().addMacroDef("cl_khr_subgroup_ballot=1");
}
}
if (args->features.subgroups_ifp) {
assert(args->features.subgroups);