-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[MLIR][OpenMP] Lowering nontemporal clause to LLVM IR for SIMD directive #118751
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a7a4859
[MLIR][OpenMP] Lowering nontemporal clause to LLVM IR for SIMD directive
kaviya2510 53cc229
[MLIR][OpenMP] Created callback function for adding the metadata of n…
kaviya2510 9da1f5e
Merge branch 'main' into nt_to_llvmir
kaviya2510 a8278b3
Merge branch 'main' into nt_to_llvmir
kaviya2510 a95b791
Lowering Nontemporal clause to LLVM IR: Added a Flang pass lower-nont…
kaviya2510 5a46828
Merge branch 'main' into nt_to_llvmir
kaviya2510 37fc0bc
Addressed review comments : Added nontemporal attribute to fir.load a…
kaviya2510 1802fcd
Addressed review comments: Modified getBaseOperand()function and adde…
kaviya2510 bd814bd
Merge branch 'main' into nt_to_llvmir
kaviya2510 095a557
Added a TODO for hanlding nontemporal inside atomic construct and add…
kaviya2510 b976685
Merge branch 'main' into nt_to_llvmir
kaviya2510 bfb590f
Added a comment in LowerNontemporal.cpp
kaviya2510 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
//===- LowerNontemporal.cpp -------------------------------------------===// | ||
// | ||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
// See https://llvm.org/LICENSE.txt for license information. | ||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
// | ||
//===----------------------------------------------------------------------===// | ||
// | ||
// Add nontemporal attributes to load and stores of variables marked as | ||
// nontemporal. | ||
// | ||
//===----------------------------------------------------------------------===// | ||
#include "flang/Optimizer/Dialect/FIROpsSupport.h" | ||
#include "flang/Optimizer/OpenMP/Passes.h" | ||
#include "mlir/Dialect/OpenMP/OpenMPDialect.h" | ||
using namespace mlir; | ||
namespace flangomp { | ||
#define GEN_PASS_DEF_LOWERNONTEMPORALPASS | ||
#include "flang/Optimizer/OpenMP/Passes.h.inc" | ||
} // namespace flangomp | ||
namespace { | ||
class LowerNontemporalPass | ||
: public flangomp::impl::LowerNontemporalPassBase<LowerNontemporalPass> { | ||
void addNonTemporalAttr(omp::SimdOp simdOp) { | ||
if (!simdOp.getNontemporalVars().empty()) { | ||
llvm::SmallVector<mlir::Value> nontemporalOrigVars; | ||
kaviya2510 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
mlir::OperandRange nontemporals = simdOp.getNontemporalVars(); | ||
kaviya2510 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
for (mlir::Value nontemporal : nontemporals) { | ||
kaviya2510 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
nontemporalOrigVars.push_back(nontemporal); | ||
kaviya2510 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
std::function<mlir::Value(mlir::Value)> getBaseOperand = | ||
[&](mlir::Value operand) -> mlir::Value { | ||
if (mlir::isa<fir::DeclareOp>(operand.getDefiningOp())) | ||
return operand; | ||
else if (auto arrayCoorOp = llvm::dyn_cast<fir::ArrayCoorOp>( | ||
operand.getDefiningOp())) { | ||
return getBaseOperand(arrayCoorOp.getMemref()); | ||
} else if (auto boxAddrOp = llvm::dyn_cast<fir::BoxAddrOp>( | ||
operand.getDefiningOp())) { | ||
return getBaseOperand(boxAddrOp.getVal()); | ||
} else if (auto loadOp = | ||
llvm::dyn_cast<fir::LoadOp>(operand.getDefiningOp())) { | ||
return getBaseOperand(loadOp.getMemref()); | ||
} else { | ||
return operand; | ||
} | ||
}; | ||
simdOp->walk([&](Operation *op) { | ||
mlir::Value Operand = nullptr; | ||
kaviya2510 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (auto loadOp = llvm::dyn_cast<fir::LoadOp>(op)) { | ||
Operand = loadOp.getMemref(); | ||
} else if (auto storeOp = llvm::dyn_cast<fir::StoreOp>(op)) { | ||
Operand = storeOp.getMemref(); | ||
} | ||
if (Operand && !(fir::isAllocatableType(Operand.getType()) || | ||
fir::isPointerType((Operand.getType())))) { | ||
Operand = getBaseOperand(Operand); | ||
if (is_contained(nontemporalOrigVars, Operand)) { | ||
// Set the attribute | ||
op->setAttr("nontemporal", UnitAttr::get(op->getContext())); | ||
kaviya2510 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} | ||
}); | ||
} | ||
} | ||
void runOnOperation() override { | ||
Operation *op = getOperation(); | ||
op->walk([&](omp::SimdOp simdOp) { addNonTemporalAttr(simdOp); }); | ||
} | ||
}; | ||
} // namespace |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
! Test nontemporal clause | ||
! RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-version=50 %s -o - | FileCheck %s | ||
! RUN: bbc -emit-fir -fopenmp -fopenmp-version=50 %s -o - | FileCheck %s | ||
|
||
|
||
! CHECK-LABEL: func @_QPsimd_with_nontemporal_clause | ||
subroutine simd_with_nontemporal_clause(n) | ||
! CHECK: %[[A_DECL:.*]] = fir.declare %{{.*}} {uniq_name = "_QFsimd_with_nontemporal_clauseEa"} : (!fir.ref<i32>) -> !fir.ref<i32> | ||
! CHECK: %[[C_DECL:.*]] = fir.declare %{{.*}} {uniq_name = "_QFsimd_with_nontemporal_clauseEc"} : (!fir.ref<i32>) -> !fir.ref<i32> | ||
integer :: i, n | ||
integer :: A, B, C | ||
! CHECK: omp.simd nontemporal(%[[A_DECL]], %[[C_DECL]] : !fir.ref<i32>, !fir.ref<i32>) private(@_QFsimd_with_nontemporal_clauseEi_private_i32 %8 -> %arg1 : !fir.ref<i32>) { | ||
! CHECK-NEXT: omp.loop_nest (%{{.*}}) : i32 = (%{{.*}}) to (%{{.*}}) inclusive step (%{{.*}}) { | ||
!$OMP SIMD NONTEMPORAL(A, C) | ||
do i = 1, n | ||
! CHECK: %[[LOAD:.*]] = fir.load %[[A_DECL]] {nontemporal} : !fir.ref<i32> | ||
C = A + B | ||
! CHECK: %[[ADD_VAL:.*]] = arith.addi %{{.*}}, %{{.*}} : i32 | ||
! CHECK: fir.store %[[ADD_VAL]] to %[[C_DECL]] {nontemporal} : !fir.ref<i32> | ||
end do | ||
!$OMP END SIMD | ||
end subroutine | ||
|
||
! CHECK-LABEL: func.func @_QPsimd_nontemporal_allocatable | ||
subroutine simd_nontemporal_allocatable(x, y) | ||
integer, allocatable :: x(:) | ||
integer :: y | ||
allocate(x(100)) | ||
! CHECK: %[[X_DECL:.*]] = fir.declare %{{.*}} dummy_scope %{{.*}} {fortran_attrs = #fir.var_attrs<allocatable>, | ||
! CHECK-SAME: uniq_name = "_QFsimd_nontemporal_allocatableEx"} : (!fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>, !fir.dscope) -> !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> | ||
! CHECK: omp.simd nontemporal(%[[X_DECL]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>>) private(@_QFsimd_nontemporal_allocatableEi_private_i32 %2 -> %arg2 : !fir.ref<i32>) { | ||
! CHECK: omp.loop_nest (%{{.*}}) : i32 = (%{{.*}}) to (%{{.*}}) inclusive step (%{{.*}}) { | ||
!$omp simd nontemporal(x) | ||
do i=1,100 | ||
! CHECK: %[[VAL1:.*]] = fir.load %[[X_DECL]] : !fir.ref<!fir.box<!fir.heap<!fir.array<?xi32>>>> | ||
! CHECK: %[[BOX_ADDR:.*]] = fir.box_addr %[[VAL1]] : (!fir.box<!fir.heap<!fir.array<?xi32>>>) -> !fir.heap<!fir.array<?xi32>> | ||
! CHECK: %[[ARR_COOR:.*]] = fir.array_coor %[[BOX_ADDR]](%{{.*}}) %{{.*}} : (!fir.heap<!fir.array<?xi32>>, !fir.shapeshift<1>, i64) -> !fir.ref<i32> | ||
! CHECK: %[[VAL2:.*]] = fir.load %[[ARR_COOR]] {nontemporal} : !fir.ref<i32> | ||
x(i) = x(i) + y | ||
! CHECK: fir.store %{{.*}} to %{{.*}} {nontemporal} : !fir.ref<i32> | ||
end do | ||
!$omp end simd | ||
end subroutine | ||
|
||
! CHECK-LABEL: func.func @_QPsimd_nontemporal_pointers | ||
subroutine simd_nontemporal_pointers(a, c) | ||
integer :: b, i | ||
integer :: n | ||
integer, pointer, intent(in):: a(:) | ||
integer, pointer, intent(out) :: c(:) | ||
! CHECK: %[[A_DECL:.*]] = fir.declare %{{.*}} dummy_scope %{{.*}} {fortran_attrs = #fir.var_attrs<intent_in, pointer>, | ||
! CHECK-SAME: uniq_name = "_QFsimd_nontemporal_pointersEa"} : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>, !fir.dscope) -> !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>> | ||
! CHECK: %[[C_DECL:.*]] = fir.declare %{{.*}} dummy_scope %{{.*}} {fortran_attrs = #fir.var_attrs<intent_out, pointer>, | ||
! CHECK-SAME: uniq_name = "_QFsimd_nontemporal_pointersEc"} : (!fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>>, !fir.dscope) -> !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>> | ||
!$OMP SIMD NONTEMPORAL(a,c) | ||
do i = 1, n | ||
! CHECK: %[[VAL1:.*]] = fir.load %[[A_DECL]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>> | ||
! CHECK: %[[VAL2:.*]] = fir.array_coor %[[VAL1]](%{{.*}}) %{{.*}} : (!fir.box<!fir.ptr<!fir.array<?xi32>>>, !fir.shift<1>, i64) -> !fir.ref<i32> | ||
! CHECK: %[[VAL3:.*]] = fir.load %[[VAL2]] {nontemporal} : !fir.ref<i32> | ||
c(i) = a(i) + b | ||
! CHECK: %[[VAL4:.*]] = fir.load %[[C_DECL]] : !fir.ref<!fir.box<!fir.ptr<!fir.array<?xi32>>>> | ||
! CHECK: %[[VAL5:.*]] = fir.array_coor %[[VAL4]](%{{.*}}) %{{.*}} : (!fir.box<!fir.ptr<!fir.array<?xi32>>>, !fir.shift<1>, i64) -> !fir.ref<i32> | ||
! CHECK: fir.store %{{.*}} to %[[VAL5]] {nontemporal} : !fir.ref<i32> | ||
end do | ||
!$OMP END SIMD | ||
end subroutine | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s | ||
|
||
// ----- | ||
// CHECK-LABEL: @simd_nontemporal | ||
llvm.func @simd_nontemporal() { | ||
%0 = llvm.mlir.constant(10 : i64) : i64 | ||
%1 = llvm.mlir.constant(1 : i64) : i64 | ||
%2 = llvm.alloca %1 x i64 : (i64) -> !llvm.ptr | ||
%3 = llvm.alloca %1 x i64 : (i64) -> !llvm.ptr | ||
//CHECK: %[[A_ADDR:.*]] = alloca i64, i64 1, align 8 | ||
//CHECK: %[[B_ADDR:.*]] = alloca i64, i64 1, align 8 | ||
//CHECK: %[[B:.*]] = load i64, ptr %[[B_ADDR]], align 4, !nontemporal !1, !llvm.access.group !2 | ||
//CHECK: store i64 %[[B]], ptr %[[A_ADDR]], align 4, !nontemporal !1, !llvm.access.group !2 | ||
omp.simd nontemporal(%2, %3 : !llvm.ptr, !llvm.ptr) { | ||
omp.loop_nest (%arg0) : i64 = (%1) to (%0) inclusive step (%1) { | ||
%4 = llvm.load %3 {nontemporal}: !llvm.ptr -> i64 | ||
llvm.store %4, %2 {nontemporal} : i64, !llvm.ptr | ||
omp.yield | ||
} | ||
} | ||
llvm.return | ||
} | ||
|
||
// ----- | ||
|
||
//CHECK-LABEL: define void @_QPtest(ptr %0, ptr %1) { | ||
llvm.func @_QPtest(%arg0: !llvm.ptr {fir.bindc_name = "n"}, %arg1: !llvm.ptr {fir.bindc_name = "a"}) { | ||
%0 = llvm.mlir.constant(1 : i32) : i32 | ||
%1 = llvm.alloca %0 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)> {alignment = 8 : i64} : (i32) -> !llvm.ptr | ||
%2 = llvm.alloca %0 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)> {alignment = 8 : i64} : (i32) -> !llvm.ptr | ||
%3 = llvm.mlir.constant(1 : i64) : i64 | ||
%4 = llvm.alloca %3 x i32 {bindc_name = "i", pinned} : (i64) -> !llvm.ptr | ||
%6 = llvm.load %arg0 : !llvm.ptr -> i32 | ||
// CHECK: %[[A_VAL1:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8 | ||
// CHECK: %[[A_VAL2:.*]] = alloca { ptr, i64, i32, i8, i8, i8, i8, [1 x [3 x i64]] }, align 8 | ||
omp.simd nontemporal(%arg1 : !llvm.ptr) { | ||
omp.loop_nest (%arg2) : i32 = (%0) to (%6) inclusive step (%0) { | ||
llvm.store %arg2, %4 : i32, !llvm.ptr | ||
// CHECK: call void @llvm.memcpy.p0.p0.i32(ptr %[[A_VAL2]], ptr %1, i32 48, i1 false) | ||
%7 = llvm.mlir.constant(48 : i32) : i32 | ||
"llvm.intr.memcpy"(%2, %arg1, %7) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () | ||
%8 = llvm.load %4 : !llvm.ptr -> i32 | ||
%9 = llvm.sext %8 : i32 to i64 | ||
%10 = llvm.getelementptr %2[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)> | ||
%11 = llvm.load %10 : !llvm.ptr -> !llvm.ptr | ||
%12 = llvm.mlir.constant(0 : index) : i64 | ||
%13 = llvm.getelementptr %2[0, 7, %12, 0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)> | ||
%14 = llvm.load %13 : !llvm.ptr -> i64 | ||
%15 = llvm.getelementptr %2[0, 7, %12, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)> | ||
%16 = llvm.load %15 : !llvm.ptr -> i64 | ||
%17 = llvm.getelementptr %2[0, 7, %12, 2] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)> | ||
%18 = llvm.load %17 : !llvm.ptr -> i64 | ||
%19 = llvm.mlir.constant(0 : i64) : i64 | ||
%20 = llvm.sub %9, %14 overflow<nsw> : i64 | ||
%21 = llvm.mul %20, %3 overflow<nsw> : i64 | ||
%22 = llvm.mul %21, %3 overflow<nsw> : i64 | ||
%23 = llvm.add %22,%19 overflow<nsw> : i64 | ||
%24 = llvm.mul %3, %16 overflow<nsw> : i64 | ||
// CHECK: %[[VAL1:.*]] = getelementptr float, ptr {{.*}}, i64 %{{.*}} | ||
// CHECK: %[[LOAD_A:.*]] = load float, ptr %[[VAL1]], align 4, !nontemporal | ||
// CHECK: %[[RES:.*]] = fadd contract float %[[LOAD_A]], 2.000000e+01 | ||
%25 = llvm.getelementptr %11[%23] : (!llvm.ptr, i64) -> !llvm.ptr, f32 | ||
%26 = llvm.load %25 {nontemporal} : !llvm.ptr -> f32 | ||
%27 = llvm.mlir.constant(2.000000e+01 : f32) : f32 | ||
%28 = llvm.fadd %26, %27 {fastmathFlags = #llvm.fastmath<contract>} : f32 | ||
// CHECK: call void @llvm.memcpy.p0.p0.i32(ptr %[[A_VAL1]], ptr %1, i32 48, i1 false) | ||
%29 = llvm.mlir.constant(48 : i32) : i32 | ||
"llvm.intr.memcpy"(%1, %arg1, %29) <{isVolatile = false}> : (!llvm.ptr, !llvm.ptr, i32) -> () | ||
%30 = llvm.load %4 : !llvm.ptr -> i32 | ||
%31 = llvm.sext %30 : i32 to i64 | ||
%32 = llvm.getelementptr %1[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)> | ||
%33 = llvm.load %32 : !llvm.ptr -> !llvm.ptr | ||
%34 = llvm.mlir.constant(0 : index) : i64 | ||
%35 = llvm.getelementptr %1[0, 7, %34, 0] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)> | ||
%36 = llvm.load %35 : !llvm.ptr -> i64 | ||
%37 = llvm.getelementptr %1[0, 7, %34, 1] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)> | ||
%38 = llvm.load %37 : !llvm.ptr -> i64 | ||
%39 = llvm.getelementptr %1[0, 7, %34, 2] : (!llvm.ptr, i64) -> !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)> | ||
%40 = llvm.load %39 : !llvm.ptr -> i64 | ||
%41 = llvm.sub %31, %36 overflow<nsw> : i64 | ||
%42 = llvm.mul %41, %3 overflow<nsw> : i64 | ||
%43 = llvm.mul %42, %3 overflow<nsw> : i64 | ||
%44 = llvm.add %43,%19 overflow<nsw> : i64 | ||
%45 = llvm.mul %3, %38 overflow<nsw> : i64 | ||
// CHECK: %[[VAL2:.*]] = getelementptr float, ptr %{{.*}}, i64 %{{.*}} | ||
// CHECK: store float %[[RES]], ptr %[[VAL2]], align 4, !nontemporal | ||
%46 = llvm.getelementptr %33[%44] : (!llvm.ptr, i64) -> !llvm.ptr, f32 | ||
llvm.store %28, %46 {nontemporal} : f32, !llvm.ptr | ||
omp.yield | ||
} | ||
} | ||
llvm.return | ||
} | ||
|
||
// ----- | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not run this on
omp::SimdOp
? Running it on functions is wasteful because many functions will not contain a simd op and runs the risk of missing any simd ops which are not nested inside of functions (I can't see how that would happen currently but we have had problems before lowering non-function (but function-like) operations such asomp.declare_reduction
because subsequent passes incorrectly assumed all operations were nested inside of functions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am applying this pass specifically to omp::simdOp, not to all operations within the function. All the nontemporal examples that I referred so far have omp.simd nested inside a function, so I run the pass at the function level, look for omp::simdOp and only add the attribute when such an operation(omp::simdop) is present.
Could you please share an example that explains the scenario "omp.simd" op is not nested inside function?
That would help me to understand better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was only a hypothetical example - I can't think of a case where we would do simd not inside of a function either.
Still, changing this to
should be a better fit with the intention of the pass, because it will not modify anything outside of the simd op
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Theoretically, it could be inside one of the declaration operations (Private, Reduction operations).
BTW, why was this change not made?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re: declaration operations: It could be but I thought that would be so unlikely that it would be better to only make that (minimal) change if it was ever needed.
Re: this thread: Kaviya and I were unable to get it working. It turns out that the MLIR pass manager doesn't allow for arbitrary nesting: only 1 level deep. So you can run a func.func pass on a pass manager for a module because the func.func is a direct descendant. But it couldn't be done for simd because that could be anywhere in the operation tree. I should have posted an update here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Tom!
@kiranchandramohan -- Tom has covered all the points here.