================
@@ -119,9 +119,25 @@ GenericKernelTy::getKernelLaunchEnvironment(
KernelArgs.Version < OMP_KERNEL_ARG_MIN_VERSION_WITH_DYN_PTR)
return nullptr;
- if ((!KernelEnvironment.Configuration.ReductionDataSize ||
- !KernelEnvironment.Configuration.ReductionBufferLength) &&
- KernelArgs.DynCGroupMem == 0)
+ const auto &RedCfg = KernelEnvironment.Configuration;
+ // ReductionDataSize is the single source of truth for whether a teams-
+ // reduction buffer is needed; ReductionBufferLength is only a static
+ // upper bound on the number of teams and is meaningless without a
+ // non-zero data size. Reject the malformed combination explicitly so we
+ // never hand the device a null ReductionBuffer that the reduction
+ // runtime would then dereference.
+ if (RedCfg.ReductionBufferLength && !RedCfg.ReductionDataSize)
+ return Plugin::error(ErrorCode::INVALID_BINARY,
+ "kernel environment has a non-zero "
+ "ReductionBufferLength but ReductionDataSize is 0");
+ const bool NeedsReductionBuffer = RedCfg.ReductionDataSize != 0;
+ if (NeedsReductionBuffer && KernelArgs.Version < OMP_KERNEL_ARG_VERSION)
+ return Plugin::error(ErrorCode::INVALID_BINARY,
+ "kernel was built against an older OpenMP "
+ "kernel-launch-environment ABI (v%u); current "
+ "runtime requires v%u for cross-team reductions",
+ KernelArgs.Version, OMP_KERNEL_ARG_VERSION);
----------------
jdoerfert wrote:
Earlier you talked about backwards compatibility but here you error out. I'm a
little confused. Could you clarify what compatibilities you are trying to
preserve, and which ones will error?
https://github.com/llvm/llvm-project/pull/195102
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits