diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2018-10-01 16:20:57 +0000 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2018-10-01 16:20:57 +0000 |
commit | e79451a5171e20c5da16a7f1a619c8851b9c574c (patch) | |
tree | 05399c6d6edc365e32b2c9ddf765605e54846c57 /clang/lib | |
parent | 5187efcfabead2309d21b13a380181d36e31bb18 (diff) | |
download | bcm5719-llvm-e79451a5171e20c5da16a7f1a619c8851b9c574c.tar.gz bcm5719-llvm-e79451a5171e20c5da16a7f1a619c8851b9c574c.zip |
[OPENMP][NVPTX] Handle `requires datasharing` flag correctly with
lightweight runtime.
The datasharing flag must be set to `1` when executing SPMD-mode compatible directive with reduction|lastprivate clauses.
llvm-svn: 343492
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp index 833b145f045..96cf6c1173b 100644 --- a/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp +++ b/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp @@ -1207,6 +1207,10 @@ void CGOpenMPRuntimeNVPTX::emitSPMDKernel(const OMPExecutableDirective &D, IsOffloadEntry, CodeGen); } +static void +getDistributeLastprivateVars(const OMPExecutableDirective &D, + llvm::SmallVectorImpl<const ValueDecl *> &Vars); + void CGOpenMPRuntimeNVPTX::emitSPMDEntryHeader( CodeGenFunction &CGF, EntryFunctionState &EST, const OMPExecutableDirective &D) { @@ -1219,11 +1223,33 @@ void CGOpenMPRuntimeNVPTX::emitSPMDEntryHeader( // Initialize the OMP state in the runtime; called by all active threads. bool RequiresFullRuntime = CGM.getLangOpts().OpenMPCUDAForceFullRuntime || !supportsLightweightRuntime(CGF.getContext(), D); + // Check if we have inner distribute + lastprivate|reduction clauses. + bool RequiresDatasharing = RequiresFullRuntime; + if (!RequiresDatasharing) { + const OMPExecutableDirective *TD = &D; + if (!isOpenMPTeamsDirective(TD->getDirectiveKind()) && + !isOpenMPParallelDirective(TD->getDirectiveKind())) { + const Stmt *S = getSingleCompoundChild( + TD->getInnermostCapturedStmt()->getCapturedStmt()->IgnoreContainers( + /*IgnoreCaptured=*/true)); + TD = cast<OMPExecutableDirective>(S); + } + if (!isOpenMPDistributeDirective(TD->getDirectiveKind()) && + !isOpenMPParallelDirective(TD->getDirectiveKind())) { + const Stmt *S = getSingleCompoundChild( + TD->getInnermostCapturedStmt()->getCapturedStmt()->IgnoreContainers( + /*IgnoreCaptured=*/true)); + TD = cast<OMPExecutableDirective>(S); + } + if (isOpenMPDistributeDirective(TD->getDirectiveKind())) + RequiresDatasharing = TD->hasClausesOfKind<OMPLastprivateClause>() || + TD->hasClausesOfKind<OMPReductionClause>(); + } llvm::Value *Args[] = { getThreadLimit(CGF, /*IsInSPMDExecutionMode=*/true), /*RequiresOMPRuntime=*/ Bld.getInt16(RequiresFullRuntime ? 1 : 0), - /*RequiresDataSharing=*/Bld.getInt16(RequiresFullRuntime ? 1 : 0)}; + /*RequiresDataSharing=*/Bld.getInt16(RequiresDatasharing ? 1 : 0)}; CGF.EmitRuntimeCall( createNVPTXRuntimeFunction(OMPRTL_NVPTX__kmpc_spmd_kernel_init), Args); |