Skip to content

Commit fdb720c

Browse files
bhandarkar-pranavyuxuanchen1997
authored andcommitted
[OMPIRBuilder] - Handle dependencies in createTarget (#93977)
Summary: This patch handles dependencies specified by the `depend` clause on an OpenMP target construct. It does this much the same way clang does it by materializing an OpenMP `task` that is tagged with the dependencies. The following functions are relevant to this patch - 1) `createTarget` - This function itself is largely unchanged except that it now accepts a vector of `DependData` objects that it simply forwards to `emitTargetCall` 2) `emitTargetCall` - This function has changed now to check if an outer target-task needs to be materialized (i.e if `target` construct has `nowait` or has `depend` clause). If yes, it calls `emitTargetTask` to do all the heavy lifting for creating and dispatching the task. 3) `emitTargetTask` - Bulk of the change is here. See the large comment explaining what it does at the beginning of this function Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60251117
1 parent 2b51141 commit fdb720c

File tree

5 files changed

+730
-53
lines changed

5 files changed

+730
-53
lines changed

llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2322,6 +2322,26 @@ class OpenMPIRBuilder {
23222322
EmitFallbackCallbackTy EmitTargetCallFallbackCB, TargetKernelArgs &Args,
23232323
Value *DeviceID, Value *RTLoc, InsertPointTy AllocaIP);
23242324

2325+
/// Generate a target-task for the target construct
2326+
///
2327+
/// \param OutlinedFn The outlined device/target kernel function.
2328+
/// \param OutlinedFnID The ooulined function ID.
2329+
/// \param EmitTargetCallFallbackCB Call back function to generate host
2330+
/// fallback code.
2331+
/// \param Args Data structure holding information about the kernel arguments.
2332+
/// \param DeviceID Identifier for the device via the 'device' clause.
2333+
/// \param RTLoc Source location identifier
2334+
/// \param AllocaIP The insertion point to be used for alloca instructions.
2335+
/// \param Dependencies Vector of DependData objects holding information of
2336+
/// dependencies as specified by the 'depend' clause.
2337+
/// \param HasNoWait True if the target construct had 'nowait' on it, false
2338+
/// otherwise
2339+
InsertPointTy emitTargetTask(
2340+
Function *OutlinedFn, Value *OutlinedFnID,
2341+
EmitFallbackCallbackTy EmitTargetCallFallbackCB, TargetKernelArgs &Args,
2342+
Value *DeviceID, Value *RTLoc, InsertPointTy AllocaIP,
2343+
SmallVector<OpenMPIRBuilder::DependData> &Dependencies, bool HasNoWait);
2344+
23252345
/// Emit the arguments to be passed to the runtime library based on the
23262346
/// arrays of base pointers, pointers, sizes, map types, and mappers. If
23272347
/// ForEndCall, emit map types to be passed for the end of the region instead
@@ -2805,6 +2825,8 @@ class OpenMPIRBuilder {
28052825
/// \param BodyGenCB Callback that will generate the region code.
28062826
/// \param ArgAccessorFuncCB Callback that will generate accessors
28072827
/// instructions for passed in target arguments where neccessary
2828+
/// \param Dependencies A vector of DependData objects that carry
2829+
// dependency information as passed in the depend clause
28082830
InsertPointTy createTarget(const LocationDescription &Loc,
28092831
OpenMPIRBuilder::InsertPointTy AllocaIP,
28102832
OpenMPIRBuilder::InsertPointTy CodeGenIP,
@@ -2813,7 +2835,8 @@ class OpenMPIRBuilder {
28132835
SmallVectorImpl<Value *> &Inputs,
28142836
GenMapInfoCallbackTy GenMapInfoCB,
28152837
TargetBodyGenCallbackTy BodyGenCB,
2816-
TargetGenArgAccessorsCallbackTy ArgAccessorFuncCB);
2838+
TargetGenArgAccessorsCallbackTy ArgAccessorFuncCB,
2839+
SmallVector<DependData> Dependencies = {});
28172840

28182841
/// Returns __kmpc_for_static_init_* runtime function for the specified
28192842
/// size \a IVSize and sign \a IVSigned. Will create a distribute call

0 commit comments

Comments
 (0)