Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1784,8 +1784,8 @@ void CGOpenMPRuntimeGPU::emitReduction(

llvm::OpenMPIRBuilder::InsertPointTy AfterIP =
cantFail(OMPBuilder.createReductionsGPU(
OmpLoc, AllocaIP, CodeGenIP, ReductionInfos, false, TeamsReduction,
llvm::OpenMPIRBuilder::ReductionGenCBKind::Clang,
OmpLoc, AllocaIP, CodeGenIP, ReductionInfos, /*IsByRef=*/{}, false,
TeamsReduction, llvm::OpenMPIRBuilder::ReductionGenCBKind::Clang,
CGF.getTarget().getGridValue(),
C.getLangOpts().OpenMPCUDAReductionBufNum, RTLoc));
CGF.Builder.restoreIP(AfterIP);
Expand Down
3 changes: 2 additions & 1 deletion flang/include/flang/Optimizer/Dialect/FIROps.td
Original file line number Diff line number Diff line change
Expand Up @@ -3743,7 +3743,8 @@ def fir_DeclareReductionOp : fir_Op<"declare_reduction", [IsolatedFromAbove,
}];

let arguments = (ins SymbolNameAttr:$sym_name,
TypeAttr:$type);
TypeAttr:$type,
OptionalAttr<TypeAttr>:$byref_element_type);

let regions = (region MaxSizedRegion<1>:$allocRegion,
AnyRegion:$initializerRegion,
Expand Down
10 changes: 9 additions & 1 deletion flang/lib/Lower/Support/ReductionProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -573,10 +573,18 @@ OpType ReductionProcessor::createDeclareReduction(

mlir::OpBuilder modBuilder(module.getBodyRegion());
mlir::Type valTy = fir::unwrapRefType(type);
// For by-ref reductions, we want to keep track of the
// boxed/referenced/allocated type. For example, a for `real, allocatable`
// variable, `real` should be stored.
mlir::TypeAttr boxedTy{};

if (!isByRef)
type = valTy;

decl = OpType::create(modBuilder, loc, reductionOpName, type);
if (isByRef)
boxedTy = mlir::TypeAttr::get(fir::unwrapPassByRefType(valTy));

decl = OpType::create(modBuilder, loc, reductionOpName, type, boxedTy);
createReductionAllocAndInitRegions(converter, loc, decl, redId, type,
isByRef);

Expand Down
3 changes: 2 additions & 1 deletion flang/lib/Optimizer/OpenMP/DoConcurrentConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,8 @@ class DoConcurrentConversion
if (!ompReducer) {
ompReducer = mlir::omp::DeclareReductionOp::create(
rewriter, firReducer.getLoc(), ompReducerName,
firReducer.getTypeAttr().getValue());
firReducer.getTypeAttr().getValue(),
firReducer.getByrefElementTypeAttr());

cloneFIRRegionToOMP(rewriter, firReducer.getAllocRegion(),
ompReducer.getAllocRegion());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ subroutine red_and_delayed_private
! CHECK-SAME: @[[PRIVATIZER_SYM:.*]] : i32

! CHECK-LABEL: omp.declare_reduction
! CHECK-SAME: @[[REDUCTION_SYM:.*]] : !fir.ref<i32> alloc
! CHECK-SAME: @[[REDUCTION_SYM:.*]] : !fir.ref<i32> attributes {byref_element_type = i32} alloc

! CHECK-LABEL: _QPred_and_delayed_private
! CHECK: omp.parallel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ program reduce

end program

! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_heap_Uxi32 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> alloc {
! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_heap_Uxi32 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> attributes {byref_element_type = !fir.array<?xi32>} alloc {
! CHECK: %[[VAL_10:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>>
! CHECK: omp.yield(%[[VAL_10]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>)
! CHECK-LABEL: } init {
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Lower/OpenMP/parallel-reduction-array-lb.f90
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ program reduce

end program

! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_3x2xi32 : !fir.ref<!fir.box<!fir.array<3x2xi32>>> alloc {
! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_3x2xi32 : !fir.ref<!fir.box<!fir.array<3x2xi32>>> {{.*}} alloc {
! CHECK: %[[VAL_15:.*]] = fir.alloca !fir.box<!fir.array<3x2xi32>>
! CHECK: omp.yield(%[[VAL_15]] : !fir.ref<!fir.box<!fir.array<3x2xi32>>>)
! CHECK-LABEL: } init {
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Lower/OpenMP/parallel-reduction-array.f90
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ program reduce
print *,i
end program

! CPU-LABEL: omp.declare_reduction @add_reduction_byref_box_3xi32 : !fir.ref<!fir.box<!fir.array<3xi32>>> alloc {
! CPU-LABEL: omp.declare_reduction @add_reduction_byref_box_3xi32 : !fir.ref<!fir.box<!fir.array<3xi32>>> attributes {byref_element_type = !fir.array<3xi32>} alloc {
! CPU: %[[VAL_8:.*]] = fir.alloca !fir.box<!fir.array<3xi32>>
! CPU: omp.yield(%[[VAL_8]] : !fir.ref<!fir.box<!fir.array<3xi32>>>)
! CPU-LABEL: } init {
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Lower/OpenMP/parallel-reduction-array2.f90
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ program reduce
print *,i
end program

! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_3xi32 : !fir.ref<!fir.box<!fir.array<3xi32>>> alloc {
! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_3xi32 : !fir.ref<!fir.box<!fir.array<3xi32>>> {{.*}} alloc {
! CHECK: %[[VAL_8:.*]] = fir.alloca !fir.box<!fir.array<3xi32>>
! CHECK: omp.yield(%[[VAL_8]] : !fir.ref<!fir.box<!fir.array<3xi32>>>)
! CHECK-LABEL: } init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ program reduce

end program

! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_ptr_Uxi32 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>> alloc {
! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_ptr_Uxi32 : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>> attributes {byref_element_type = !fir.array<?xi32>} alloc {
! CHECK: %[[VAL_3:.*]] = fir.alloca !fir.box<!fir.ptr<!fir.array<?xi32>>>
! CHECK: omp.yield(%[[VAL_3]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>)
! CHECK-LABEL: } init {
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Lower/OpenMP/parallel-reduction3.f90
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
! RUN: bbc -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s
! RUN: %flang_fc1 -emit-hlfir -fopenmp -o - %s 2>&1 | FileCheck %s

! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_Uxi32 : !fir.ref<!fir.box<!fir.array<?xi32>>> alloc {
! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_Uxi32 : !fir.ref<!fir.box<!fir.array<?xi32>>> {{.*}} alloc {
! CHECK: %[[VAL_8:.*]] = fir.alloca !fir.box<!fir.array<?xi32>>
! CHECK: omp.yield(%[[VAL_8]] : !fir.ref<!fir.box<!fir.array<?xi32>>>)
! CHECK-LABEL: } init {
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Lower/OpenMP/reduction-array-intrinsic.f90
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ subroutine max_array_reduction(l, r)
!$omp end parallel
end subroutine

! CHECK-LABEL: omp.declare_reduction @max_byref_box_Uxi32 : !fir.ref<!fir.box<!fir.array<?xi32>>> alloc {
! CHECK-LABEL: omp.declare_reduction @max_byref_box_Uxi32 : !fir.ref<!fir.box<!fir.array<?xi32>>> {{.*}} alloc {
! CHECK: %[[VAL_3:.*]] = fir.alloca !fir.box<!fir.array<?xi32>>
! CHECK: omp.yield(%[[VAL_3]] : !fir.ref<!fir.box<!fir.array<?xi32>>>)
! CHECK-LABEL: } init {
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Lower/OpenMP/sections-array-reduction.f90
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ subroutine sectionsReduction(x)
end subroutine


! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_Uxf32 : !fir.ref<!fir.box<!fir.array<?xf32>>> alloc {
! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_Uxf32 : !fir.ref<!fir.box<!fir.array<?xf32>>> {{.*}} alloc {
! [...]
! CHECK: omp.yield
! CHECK-LABEL: } init {
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Lower/OpenMP/taskgroup-task-array-reduction.f90
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
! RUN: bbc -emit-hlfir -fopenmp -fopenmp-version=50 -o - %s 2>&1 | FileCheck %s
! RUN: %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=50 -o - %s 2>&1 | FileCheck %s

! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_Uxf32 : !fir.ref<!fir.box<!fir.array<?xf32>>> alloc {
! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_Uxf32 : !fir.ref<!fir.box<!fir.array<?xf32>>> {{.*}} alloc {
! [...]
! CHECK: omp.yield
! CHECK-LABEL: } init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ program reduce15
print *,"min: ", mins
end program

! CHECK-LABEL: omp.declare_reduction @min_byref_box_heap_Uxi32 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> alloc {
! CHECK-LABEL: omp.declare_reduction @min_byref_box_heap_Uxi32 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> {{.*}} alloc {
! CHECK: %[[VAL_3:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>>
! CHECK: omp.yield(%[[VAL_3]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>)
! CHECK-LABEL: } init {
Expand Down Expand Up @@ -93,7 +93,7 @@ program reduce15
! CHECK: omp.yield
! CHECK: }

! CHECK-LABEL: omp.declare_reduction @max_byref_box_heap_Uxi32 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> alloc {
! CHECK-LABEL: omp.declare_reduction @max_byref_box_heap_Uxi32 : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> {{.*}} alloc {
! CHECK: %[[VAL_3:.*]] = fir.alloca !fir.box<!fir.heap<!fir.array<?xi32>>>
! CHECK: omp.yield(%[[VAL_3]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>)
! CHECK-LABEL: } init {
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Lower/OpenMP/wsloop-reduction-allocatable.f90
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ program reduce

end program

! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_heap_i32 : !fir.ref<!fir.box<!fir.heap<i32>>> alloc {
! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_heap_i32 : !fir.ref<!fir.box<!fir.heap<i32>>> attributes {byref_element_type = i32} alloc {
! CHECK: %[[VAL_2:.*]] = fir.alloca !fir.box<!fir.heap<i32>>
! CHECK: omp.yield(%[[VAL_2]] : !fir.ref<!fir.box<!fir.heap<i32>>>)
! CHECK-LABEL: } init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ subroutine reduce(r)
end subroutine
end program

! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_Uxf64 : !fir.ref<!fir.box<!fir.array<?xf64>>> alloc {
! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_Uxf64 : !fir.ref<!fir.box<!fir.array<?xf64>>> {{.*}} alloc {
! CHECK: %[[VAL_8:.*]] = fir.alloca !fir.box<!fir.array<?xf64>>
! CHECK: omp.yield(%[[VAL_8]] : !fir.ref<!fir.box<!fir.array<?xf64>>>)
! CHECK-LABEL: } init {
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Lower/OpenMP/wsloop-reduction-array-lb.f90
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ program reduce
!$omp end parallel do
end program

! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_2xi32 : !fir.ref<!fir.box<!fir.array<2xi32>>> alloc {
! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_2xi32 : !fir.ref<!fir.box<!fir.array<2xi32>>> {{.*}} alloc {
! CHECK: } combiner {
! CHECK: ^bb0(%[[ARG0:.*]]: !fir.ref<!fir.box<!fir.array<2xi32>>>, %[[ARG1:.*]]: !fir.ref<!fir.box<!fir.array<2xi32>>>):
! CHECK: %[[ARR0:.*]] = fir.load %[[ARG0]] : !fir.ref<!fir.box<!fir.array<2xi32>>>
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Lower/OpenMP/wsloop-reduction-array-lb2.f90
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ subroutine sub(a, lb, ub)

end program

! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_Uxi32 : !fir.ref<!fir.box<!fir.array<?xi32>>> alloc {
! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_Uxi32 : !fir.ref<!fir.box<!fir.array<?xi32>>> {{.*}} alloc {
! CHECK: } combiner {
! CHECK: ^bb0(%[[ARG0:.*]]: !fir.ref<!fir.box<!fir.array<?xi32>>>, %[[ARG1:.*]]: !fir.ref<!fir.box<!fir.array<?xi32>>>):
! CHECK: %[[ARR0:.*]] = fir.load %[[ARG0]] : !fir.ref<!fir.box<!fir.array<?xi32>>>
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Lower/OpenMP/wsloop-reduction-array.f90
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ program reduce
print *,r
end program

! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_2xi32 : !fir.ref<!fir.box<!fir.array<2xi32>>> alloc {
! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_2xi32 : !fir.ref<!fir.box<!fir.array<2xi32>>> attributes {byref_element_type = !fir.array<2xi32>} alloc {
! CHECK: %[[VAL_8:.*]] = fir.alloca !fir.box<!fir.array<2xi32>>
! CHECK: omp.yield(%[[VAL_8]] : !fir.ref<!fir.box<!fir.array<2xi32>>>)
! CHECK-LABEL: } init {
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Lower/OpenMP/wsloop-reduction-array2.f90
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ program reduce
print *,r
end program

! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_2xi32 : !fir.ref<!fir.box<!fir.array<2xi32>>> alloc {
! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_2xi32 : !fir.ref<!fir.box<!fir.array<2xi32>>> {{.*}} alloc {
! CHECK: %[[VAL_8:.*]] = fir.alloca !fir.box<!fir.array<2xi32>>
! CHECK: omp.yield(%[[VAL_8]] : !fir.ref<!fir.box<!fir.array<2xi32>>>)
! CHECK-LABEL: } init {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ program main

endprogram

! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_3x3xf64 : !fir.ref<!fir.box<!fir.array<3x3xf64>>> alloc {
! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_3x3xf64 : !fir.ref<!fir.box<!fir.array<3x3xf64>>> {{.*}} alloc {
! CHECK: %[[VAL_3:.*]] = fir.alloca !fir.box<!fir.array<3x3xf64>>
! CHECK: omp.yield(%[[VAL_3]] : !fir.ref<!fir.box<!fir.array<3x3xf64>>>)
! CHECK-LABEL: } init {
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Lower/OpenMP/wsloop-reduction-pointer.f90
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ program reduce_pointer
deallocate(v)
end program

! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_ptr_i32 : !fir.ref<!fir.box<!fir.ptr<i32>>> alloc {
! CHECK-LABEL: omp.declare_reduction @add_reduction_byref_box_ptr_i32 : !fir.ref<!fir.box<!fir.ptr<i32>>> {{.*}} alloc {
! CHECK: %[[VAL_3:.*]] = fir.alloca !fir.box<!fir.ptr<i32>>
! CHECK: omp.yield(%[[VAL_3]] : !fir.ref<!fir.box<!fir.ptr<i32>>>)
! CHECK-LABEL: } init {
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Lower/do_concurrent_reduce_allocatable.f90
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ subroutine do_concurrent_allocatable
end do
end subroutine

! CHECK: fir.declare_reduction @[[RED_OP:.*]] : ![[RED_TYPE:.*]] alloc {
! CHECK: fir.declare_reduction @[[RED_OP:.*]] : ![[RED_TYPE:.*]] attributes {byref_element_type = !fir.array<?x?xf32>} alloc {
! CHECK: %[[ALLOC:.*]] = fir.alloca
! CHECK: fir.yield(%[[ALLOC]] : ![[RED_TYPE]])
! CHECK: } init {
Expand Down
53 changes: 40 additions & 13 deletions llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -1448,17 +1448,22 @@ class OpenMPIRBuilder {
ReductionInfo(Type *ElementType, Value *Variable, Value *PrivateVariable,
EvalKind EvaluationKind, ReductionGenCBTy ReductionGen,
ReductionGenClangCBTy ReductionGenClang,
ReductionGenAtomicCBTy AtomicReductionGen)
ReductionGenAtomicCBTy AtomicReductionGen,
Type *ByRefAllocatedType = nullptr,
Type *ByRefElementType = nullptr)
: ElementType(ElementType), Variable(Variable),
PrivateVariable(PrivateVariable), EvaluationKind(EvaluationKind),
ReductionGen(ReductionGen), ReductionGenClang(ReductionGenClang),
AtomicReductionGen(AtomicReductionGen) {}
AtomicReductionGen(AtomicReductionGen),
ByRefAllocatedType(ByRefAllocatedType),
ByRefElementType(ByRefElementType) {}
ReductionInfo(Value *PrivateVariable)
: ElementType(nullptr), Variable(nullptr),
PrivateVariable(PrivateVariable), EvaluationKind(EvalKind::Scalar),
ReductionGen(), ReductionGenClang(), AtomicReductionGen() {}

/// Reduction element type, must match pointee type of variable.
/// Reduction element type, must match pointee type of variable. For by-ref
/// reductions, this would be just an opaque `ptr`.
Type *ElementType;

/// Reduction variable of pointer type.
Expand All @@ -1485,6 +1490,18 @@ class OpenMPIRBuilder {
/// reduction. If null, the implementation will use the non-atomic version
/// along with the appropriate synchronization mechanisms.
ReductionGenAtomicCBTy AtomicReductionGen;

/// For by-ref reductions, we need to keep track of 2 extra types that are
/// potentially different:
/// * The allocated type is the type of the storage allocated by the
/// reduction op's `alloc` region. For example, for allocatables and arrays,
/// this type would be the descriptor/box struct.
Type *ByRefAllocatedType;
/// * The by-ref element type is the type of the actual storage needed for
/// the data of the allocatable or array. For example, an float allocatable
/// of would need some float storage to store intermediate reduction
/// results.
Type *ByRefElementType;
};

enum class CopyAction : unsigned {
Expand Down Expand Up @@ -1529,14 +1546,15 @@ class OpenMPIRBuilder {

/// Function to shuffle over the value from the remote lane.
void shuffleAndStore(InsertPointTy AllocaIP, Value *SrcAddr, Value *DstAddr,
Type *ElementType, Value *Offset,
Type *ReductionArrayTy);
Type *ElementType, Value *Offset, Type *ReductionArrayTy,
bool IsByRefElem);

/// Emit instructions to copy a Reduce list, which contains partially
/// aggregated values, in the specified direction.
void emitReductionListCopy(
InsertPointTy AllocaIP, CopyAction Action, Type *ReductionArrayTy,
ArrayRef<ReductionInfo> ReductionInfos, Value *SrcBase, Value *DestBase,
ArrayRef<bool> IsByRef,
CopyOptionsTy CopyOptions = {nullptr, nullptr, nullptr});

/// Emit a helper that reduces data across two OpenMP threads (lanes)
Expand Down Expand Up @@ -1610,11 +1628,13 @@ class OpenMPIRBuilder {
/// \param ReduceFn The reduction function.
/// \param FuncAttrs Optional param to specify any function attributes that
/// need to be copied to the new function.
/// \param IsByRef For each reduction clause, whether the reduction is by-ref
/// or not.
///
/// \return The ShuffleAndReduce function.
Function *emitShuffleAndReduceFunction(
ArrayRef<OpenMPIRBuilder::ReductionInfo> ReductionInfos,
Function *ReduceFn, AttributeList FuncAttrs);
Function *ReduceFn, AttributeList FuncAttrs, ArrayRef<bool> IsByRef);

/// Helper function for CreateCanonicalScanLoops to create InputLoop
/// in the firstGen and Scan Loop in the SecondGen
Expand Down Expand Up @@ -1674,12 +1694,14 @@ class OpenMPIRBuilder {
/// \param ReductionInfos Array type containing the ReductionOps.
/// \param FuncAttrs Optional param to specify any function attributes that
/// need to be copied to the new function.
/// \param IsByRef For each reduction clause, whether the reduction is by-ref
/// or not.
///
/// \return The InterWarpCopy function.
Expected<Function *>
emitInterWarpCopyFunction(const LocationDescription &Loc,
ArrayRef<ReductionInfo> ReductionInfos,
AttributeList FuncAttrs);
AttributeList FuncAttrs, ArrayRef<bool> IsByRef);

/// This function emits a helper that copies all the reduction variables from
/// the team into the provided global buffer for the reduction variables.
Expand Down Expand Up @@ -1773,6 +1795,7 @@ class OpenMPIRBuilder {
/// \return The reduction function.
Expected<Function *> createReductionFunction(
StringRef ReducerName, ArrayRef<ReductionInfo> ReductionInfos,
ArrayRef<bool> IsByRef,
ReductionGenCBKind ReductionGenCBKind = ReductionGenCBKind::MLIR,
AttributeList FuncAttrs = {});

Expand Down Expand Up @@ -2025,11 +2048,14 @@ class OpenMPIRBuilder {
/// reduction variables.
/// \param AllocaIP An insertion point suitable for allocas usable
/// in reductions.
/// \param CodeGenIP An insertion point suitable for code
/// generation. \param ReductionInfos A list of info on each reduction
/// variable. \param IsNoWait Optional flag set if the reduction is
/// marked as
/// nowait.
/// \param CodeGenIP An insertion point suitable for code
/// generation.
/// \param ReductionInfos A list of info on each reduction
/// variable.
/// \param IsNoWait Optional flag set if the reduction is
/// marked as nowait.
/// \param IsByRef For each reduction clause, whether the reduction is by-ref
/// or not.
/// \param IsTeamsReduction Optional flag set if it is a teams
/// reduction.
/// \param GridValue Optional GPU grid value.
Expand All @@ -2039,7 +2065,8 @@ class OpenMPIRBuilder {
LLVM_ABI InsertPointOrErrorTy createReductionsGPU(
const LocationDescription &Loc, InsertPointTy AllocaIP,
InsertPointTy CodeGenIP, ArrayRef<ReductionInfo> ReductionInfos,
bool IsNoWait = false, bool IsTeamsReduction = false,
ArrayRef<bool> IsByRef, bool IsNoWait = false,
bool IsTeamsReduction = false,
ReductionGenCBKind ReductionGenCBKind = ReductionGenCBKind::MLIR,
std::optional<omp::GV> GridValue = {}, unsigned ReductionBufNum = 1024,
Value *SrcLocInfo = nullptr);
Expand Down
Loading