[llvm] [mlir] [Flang] [OpenMP] Add LLVM lowering support for PRIORITY in TASK (PR #120710)
Thirumalai Shaktivel via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 25 20:19:33 PST 2024
================
@@ -1958,6 +1963,30 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createTask(
SharedsSize);
}
+ if (Priority) {
+ //
+ // The return type of "__kmpc_omp_task_alloc" is "kmp_task_t *",
+ // we populate the priority information into the "kmp_task_t" here
+ //
+ // The struct "kmp_task_t" definition is available in kmp.h
+ // kmp_task_t = { shareds, routine, part_id, data1, data2 }
+ // data2 is used for priority
+ //
+ Type *Int32Ty = Builder.getInt32Ty();
+ // kmp_task_t* => { ptr }
+ Type *taskPtr = StructType::get(VoidPtr);
+ Value *taskGEP = Builder.CreateInBoundsGEP(
+ taskPtr, TaskData,
+ {ConstantInt::get(Int32Ty, 0), ConstantInt::get(Int32Ty, 0)});
+ // kmp_task_t => { ptr, ptr, i32, ptr, ptr }
+ Type *taskStructType = StructType::get(
+ VoidPtr, VoidPtr, Builder.getInt32Ty(), VoidPtr, VoidPtr);
+ Value *priorityData = Builder.CreateInBoundsGEP(
+ taskStructType, taskGEP,
+ {ConstantInt::get(Int32Ty, 0), ConstantInt::get(Int32Ty, 4)});
+ Builder.CreateStore(Priority, priorityData);
----------------
Thirumalai-Shaktivel wrote:
> Is this sufficient because priority is the first field of kmp_cmplrdata
Yes, because I checked whether the priority value is passed to runtime by printing the value inside the `__kmpc_omp_task`, and it prints the correct value.
But, after thinking about this, we should indeed index through kmp_cmplrdata_t (which might fix some bugs in the future.)
https://github.com/llvm/llvm-project/pull/120710
More information about the llvm-commits
mailing list