[llvm] [mlir] [openmp] [mlir][llvmir][OpenMP] Translate affinity clause in task construct to llvmir (PR #182223)
Tom Eccles via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 10 04:17:06 PDT 2026
================
@@ -2558,10 +2565,55 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createTask(
if (!Affinities.empty()) {
Function *RegAffFn = getOrCreateRuntimeFunctionPtr(
OMPRTL___kmpc_omp_reg_task_with_affinity);
- for (const auto &Affinity : Affinities) {
- createRuntimeFunctionCall(RegAffFn, {Ident, ThreadID, TaskData,
- Affinity.Count, Affinity.Info});
+
+ Value *TotalAffinityCount = Builder.getInt32(0);
+ for (const auto &Affinity : Affinities)
+ TotalAffinityCount = Builder.CreateAdd(
+ TotalAffinityCount,
+ Builder.CreateIntCast(Affinity.Count, Builder.getInt32Ty(),
+ /*isSigned=*/false));
+
+ Value *AffinityInfo = Affinities.front().Info;
+ if (Affinities.size() > 1) {
+ StructType *KmpTaskAffinityInfoTy = getKmpTaskAffinityInfoTy();
+ Value *AffinityInfoElemSize = Builder.getInt64(
+ M.getDataLayout().getTypeAllocSize(KmpTaskAffinityInfoTy));
+ Value *PackedAffinityInfo = Builder.CreateAlloca(
+ KmpTaskAffinityInfoTy, TotalAffinityCount, "omp.affinity_list");
----------------
tblah wrote:
Please use `findAllocaInsertPoint` so that we can (as much as possible) hoist allocas into the entry block.
https://github.com/llvm/llvm-project/pull/182223
More information about the llvm-commits
mailing list