[PATCH] D127037: [OpenMP][IRBuilder] 'omp target enter data' support.
Raghu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 3 17:12:03 PDT 2022
raghavendhra created this revision.
Herald added subscribers: rogfer01, guansong, hiraditya, yaxunl.
Herald added a project: All.
raghavendhra requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, sstefan1.
Herald added a project: LLVM.
Initial support for stand-alone omp target enter data directive without any clauses.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D127037
Files:
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===================================================================
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -3672,6 +3672,45 @@
return OS.str().str();
}
+void OpenMPIRBuilder::createTargetEnterData(
+ const LocationDescription &Loc, Value *Device, Value *IfConditionValue,
+ Value *NumDependences, Value *DependenceAddress, bool HaveNowaitClause) {
+ if (!updateToLocation(Loc))
+ return;
+
+ llvm::Value *PointerNum = nullptr;
+ llvm::Value *BasePointersArrayArg = nullptr;
+ llvm::Value *PointersArrayArg = nullptr;
+ llvm::Value *SizesArrayArg = nullptr;
+ llvm::Value *MapTypesArrayArg = nullptr;
+ if (Device == nullptr)
+ Device = ConstantInt::get(Int32, -1);
+ if (HaveNowaitClause) {
+ // TODO : More support for nowait clause needed to be added here along
+ // with noALiasDep details.
+ llvm::Value *noAliasDepNum = nullptr;
+ llvm::Value *noAliasDepList = nullptr;
+ if (NumDependences == nullptr) {
+ NumDependences = ConstantInt::get(Int32, 0);
+ PointerType *PointerTypeVar = Type::getInt8PtrTy(M.getContext());
+ DependenceAddress = ConstantPointerNull::get(PointerTypeVar);
+ }
+ Value *Args[] = {Device, PointerNum, BasePointersArrayArg,
+ PointersArrayArg, SizesArrayArg, MapTypesArrayArg,
+ NumDependences, DependenceAddress, noAliasDepNum,
+ noAliasDepList};
+ Builder.CreateCall(
+ getOrCreateRuntimeFunctionPtr(OMPRTL___tgt_target_data_begin_nowait),
+ Args);
+ } else {
+ // TODO : More support needs to be added to mapping.
+ Value *Args[] = {Device, PointerNum, BasePointersArrayArg,
+ PointersArrayArg, SizesArrayArg, MapTypesArrayArg};
+ Builder.CreateCall(
+ getOrCreateRuntimeFunctionPtr(OMPRTL___tgt_target_data_begin), Args);
+ }
+}
+
Constant *OpenMPIRBuilder::getOrCreateOMPInternalVariable(
llvm::Type *Ty, const llvm::Twine &Name, unsigned AddressSpace) {
// TODO: Replace the twine arg with stringref to get rid of the conversion
Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===================================================================
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -413,6 +413,10 @@
VoidPtr, Int32, VoidPtrPtr, VoidPtrPtr, Int64Ptr, Int64Ptr,
VoidPtrPtr, VoidPtrPtr, Int32, Int32, Int32, VoidPtr, Int32, VoidPtr)
__OMP_RTL(__tgt_register_requires, false, Void, Int64)
+__OMP_RTL(__tgt_target_data_begin, false, Void, Int64, Int32, VoidPtrPtr,
+ VoidPtrPtr, Int64Ptr, Int64Ptr)
+__OMP_RTL(__tgt_target_data_begin_nowait, false, Void, Int64, Int32, VoidPtrPtr,
+ VoidPtrPtr, Int64Ptr, Int64Ptr, Int32, VoidPtr, Int32, VoidPtr)
__OMP_RTL(__tgt_target_data_begin_mapper, false, Void, IdentPtr, Int64, Int32, VoidPtrPtr,
VoidPtrPtr, Int64Ptr, Int64Ptr, VoidPtrPtr, VoidPtrPtr)
__OMP_RTL(__tgt_target_data_begin_nowait_mapper, false, Void, IdentPtr, Int64, Int32,
Index: llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
===================================================================
--- llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -618,6 +618,14 @@
/// \param Loc The location where the taskyield directive was encountered.
void createTaskyield(const LocationDescription &Loc);
+ /// Generator for '#omp target enter data'
+ ///
+ /// \param Loc The location where the target enter data directive was
+ /// encountered.
+ void createTargetEnterData(const LocationDescription &Loc, Value *Device,
+ Value *IfConditionValue, Value *NumDependences,
+ Value *DependenceAddress, bool HaveNowaitClause);
+
/// Generator for `#omp task`
///
/// \param Loc The location where the task construct was encountered.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127037.434212.patch
Type: text/x-patch
Size: 4050 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220604/eeeca1b0/attachment.bin>
More information about the llvm-commits
mailing list