diff options
author | Alexey Bataev <a.bataev@hotmail.com> | 2020-05-04 16:19:31 -0400 |
---|---|---|
committer | Alexey Bataev <a.bataev@hotmail.com> | 2020-06-04 16:29:33 -0400 |
commit | bd1c03d7b7c8bdd80b534cf2fa956c36a2f8249f (patch) | |
tree | 013c9d852d25ca17589a48bdd2c56468479ec811 /clang/lib/CodeGen/CodeGenFunction.h | |
parent | a07c08f74fafcbf196cda4b20f0761538fca3dbe (diff) | |
download | llvm-bd1c03d7b7c8bdd80b534cf2fa956c36a2f8249f.zip llvm-bd1c03d7b7c8bdd80b534cf2fa956c36a2f8249f.tar.gz llvm-bd1c03d7b7c8bdd80b534cf2fa956c36a2f8249f.tar.bz2 |
[OPENMP50]Codegen for inscan reductions in worksharing directives.
Summary:
Implemented codegen for reduction clauses with inscan modifiers in
worksharing constructs.
Emits the code for the directive with inscan reductions.
The code is the following:
```
size num_iters = <num_iters>;
<type> buffer[num_iters];
for (i: 0..<num_iters>) {
<input phase>;
buffer[i] = red;
}
for (int k = 0; k != ceil(log2(num_iters)); ++k)
for (size cnt = last_iter; cnt >= pow(2, k); --k)
buffer[i] op= buffer[i-pow(2,k)];
for (0..<num_iters>) {
red = InclusiveScan ? buffer[i] : buffer[i-1];
<scan phase>;
}
```
Reviewers: jdoerfert
Subscribers: yaxunl, guansong, arphaman, cfe-commits, caomhin
Tags: #clang
Differential Revision: https://reviews.llvm.org/D79948
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.h | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index e3dd462..2b0ebad 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -673,6 +673,32 @@ public: llvm::BasicBlock *getInvokeDestImpl(); + /// Parent loop-based directive for scan directive. + const OMPExecutableDirective *OMPParentLoopDirectiveForScan = nullptr; + llvm::BasicBlock *OMPBeforeScanBlock = nullptr; + llvm::BasicBlock *OMPAfterScanBlock = nullptr; + llvm::BasicBlock *OMPScanExitBlock = nullptr; + llvm::BasicBlock *OMPScanDispatch = nullptr; + bool OMPFirstScanLoop = false; + + /// Manages parent directive for scan directives. + class ParentLoopDirectiveForScanRegion { + CodeGenFunction &CGF; + const OMPExecutableDirective &ParentLoopDirectiveForScan; + + public: + ParentLoopDirectiveForScanRegion( + CodeGenFunction &CGF, + const OMPExecutableDirective &ParentLoopDirectiveForScan) + : CGF(CGF), + ParentLoopDirectiveForScan(*CGF.OMPParentLoopDirectiveForScan) { + CGF.OMPParentLoopDirectiveForScan = &ParentLoopDirectiveForScan; + } + ~ParentLoopDirectiveForScanRegion() { + CGF.OMPParentLoopDirectiveForScan = &ParentLoopDirectiveForScan; + } + }; + template <class T> typename DominatingValue<T>::saved_type saveValueInCond(T value) { return DominatingValue<T>::save(*this, value); @@ -3201,7 +3227,8 @@ public: /// proper codegen in internal captured statement. /// void EmitOMPReductionClauseInit(const OMPExecutableDirective &D, - OMPPrivateScope &PrivateScope); + OMPPrivateScope &PrivateScope, + bool ForInscan = false); /// Emit final update of reduction values to original variables at /// the end of the directive. /// @@ -3260,6 +3287,7 @@ public: void EmitOMPTaskgroupDirective(const OMPTaskgroupDirective &S); void EmitOMPFlushDirective(const OMPFlushDirective &S); void EmitOMPDepobjDirective(const OMPDepobjDirective &S); + void EmitOMPScanDirective(const OMPScanDirective &S); void EmitOMPOrderedDirective(const OMPOrderedDirective &S); void EmitOMPAtomicDirective(const OMPAtomicDirective &S); void EmitOMPTargetDirective(const OMPTargetDirective &S); |