Skip to content

Commit 867d353

Browse files
authored
[OpenMP][flang] Support GPU team-reductions on allocatables (llvm#169651)
Extends the work started in llvm#165714 by supporting team reductions. Similar to what was done in llvm#165714, this PR introduces proper allocations, loads, and stores for by-ref reductions in teams-related callbacks: * `_omp_reduction_list_to_global_copy_func`, * `_omp_reduction_list_to_global_reduce_func`, * `_omp_reduction_global_to_list_copy_func`, and * `_omp_reduction_global_to_list_reduce_func`.
1 parent 728cada commit 867d353

File tree

4 files changed

+285
-57
lines changed

4 files changed

+285
-57
lines changed

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,9 +1768,10 @@ class OpenMPIRBuilder {
17681768
/// need to be copied to the new function.
17691769
///
17701770
/// \return The ListToGlobalCopy function.
1771-
Function *emitListToGlobalCopyFunction(ArrayRef<ReductionInfo> ReductionInfos,
1772-
Type *ReductionsBufferTy,
1773-
AttributeList FuncAttrs);
1771+
Expected<Function *>
1772+
emitListToGlobalCopyFunction(ArrayRef<ReductionInfo> ReductionInfos,
1773+
Type *ReductionsBufferTy,
1774+
AttributeList FuncAttrs, ArrayRef<bool> IsByRef);
17741775

17751776
/// This function emits a helper that copies all the reduction variables from
17761777
/// the team into the provided global buffer for the reduction variables.
@@ -1785,9 +1786,10 @@ class OpenMPIRBuilder {
17851786
/// need to be copied to the new function.
17861787
///
17871788
/// \return The GlobalToList function.
1788-
Function *emitGlobalToListCopyFunction(ArrayRef<ReductionInfo> ReductionInfos,
1789-
Type *ReductionsBufferTy,
1790-
AttributeList FuncAttrs);
1789+
Expected<Function *>
1790+
emitGlobalToListCopyFunction(ArrayRef<ReductionInfo> ReductionInfos,
1791+
Type *ReductionsBufferTy,
1792+
AttributeList FuncAttrs, ArrayRef<bool> IsByRef);
17911793

17921794
/// This function emits a helper that reduces all the reduction variables from
17931795
/// the team into the provided global buffer for the reduction variables.
@@ -1806,10 +1808,11 @@ class OpenMPIRBuilder {
18061808
/// need to be copied to the new function.
18071809
///
18081810
/// \return The ListToGlobalReduce function.
1809-
Function *
1811+
Expected<Function *>
18101812
emitListToGlobalReduceFunction(ArrayRef<ReductionInfo> ReductionInfos,
18111813
Function *ReduceFn, Type *ReductionsBufferTy,
1812-
AttributeList FuncAttrs);
1814+
AttributeList FuncAttrs,
1815+
ArrayRef<bool> IsByRef);
18131816

18141817
/// This function emits a helper that reduces all the reduction variables from
18151818
/// the team into the provided global buffer for the reduction variables.
@@ -1828,10 +1831,11 @@ class OpenMPIRBuilder {
18281831
/// need to be copied to the new function.
18291832
///
18301833
/// \return The GlobalToListReduce function.
1831-
Function *
1834+
Expected<Function *>
18321835
emitGlobalToListReduceFunction(ArrayRef<ReductionInfo> ReductionInfos,
18331836
Function *ReduceFn, Type *ReductionsBufferTy,
1834-
AttributeList FuncAttrs);
1837+
AttributeList FuncAttrs,
1838+
ArrayRef<bool> IsByRef);
18351839

18361840
/// Get the function name of a reduction function.
18371841
std::string getReductionFuncName(StringRef Name) const;

0 commit comments

Comments
 (0)