Skip to content

Commit 47bcc02

Browse files
committed
Revert "[llvm][mlir][OpenMP] Support translation for linear clause in omp.wsloop and omp.simd (llvm#139386)"
This reverts commit 290b32a.
1 parent 4521158 commit 47bcc02

File tree

11 files changed

+85
-310
lines changed

11 files changed

+85
-310
lines changed

flang/lib/Lower/OpenMP/ClauseProcessor.cpp

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,52 +1235,6 @@ bool ClauseProcessor::processIsDevicePtr(
12351235
});
12361236
}
12371237

1238-
<<<<<<< HEAD
1239-
=======
1240-
bool ClauseProcessor::processLinear(mlir::omp::LinearClauseOps &result) const {
1241-
lower::StatementContext stmtCtx;
1242-
return findRepeatableClause<
1243-
omp::clause::Linear>([&](const omp::clause::Linear &clause,
1244-
const parser::CharBlock &) {
1245-
auto &objects = std::get<omp::ObjectList>(clause.t);
1246-
static std::vector<mlir::Attribute> typeAttrs;
1247-
1248-
if (!result.linearVars.size())
1249-
typeAttrs.clear();
1250-
1251-
for (const omp::Object &object : objects) {
1252-
semantics::Symbol *sym = object.sym();
1253-
const mlir::Value variable = converter.getSymbolAddress(*sym);
1254-
result.linearVars.push_back(variable);
1255-
mlir::Type ty = converter.genType(*sym);
1256-
typeAttrs.push_back(mlir::TypeAttr::get(ty));
1257-
}
1258-
result.linearVarTypes =
1259-
mlir::ArrayAttr::get(&converter.getMLIRContext(), typeAttrs);
1260-
if (objects.size()) {
1261-
if (auto &mod =
1262-
std::get<std::optional<omp::clause::Linear::StepComplexModifier>>(
1263-
clause.t)) {
1264-
mlir::Value operand =
1265-
fir::getBase(converter.genExprValue(toEvExpr(*mod), stmtCtx));
1266-
result.linearStepVars.append(objects.size(), operand);
1267-
} else if (std::get<std::optional<omp::clause::Linear::LinearModifier>>(
1268-
clause.t)) {
1269-
mlir::Location currentLocation = converter.getCurrentLocation();
1270-
TODO(currentLocation, "Linear modifiers not yet implemented");
1271-
} else {
1272-
// If nothing is present, add the default step of 1.
1273-
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
1274-
mlir::Location currentLocation = converter.getCurrentLocation();
1275-
mlir::Value operand = firOpBuilder.createIntegerConstant(
1276-
currentLocation, firOpBuilder.getI32Type(), 1);
1277-
result.linearStepVars.append(objects.size(), operand);
1278-
}
1279-
}
1280-
});
1281-
}
1282-
1283-
>>>>>>> 290b32a699ae
12841238
bool ClauseProcessor::processLink(
12851239
llvm::SmallVectorImpl<DeclareTargetCaptureInfo> &result) const {
12861240
return findRepeatableClause<omp::clause::Link>(

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,7 +1642,8 @@ static void genSimdClauses(
16421642
cp.processReduction(loc, clauseOps, reductionSyms);
16431643
cp.processSafelen(clauseOps);
16441644
cp.processSimdlen(clauseOps);
1645-
cp.processLinear(clauseOps);
1645+
1646+
cp.processTODO<clause::Linear>(loc, llvm::omp::Directive::OMPD_simd);
16461647
}
16471648

16481649
static void genSingleClauses(lower::AbstractConverter &converter,
@@ -1838,9 +1839,9 @@ static void genWsloopClauses(
18381839
cp.processOrdered(clauseOps);
18391840
cp.processReduction(loc, clauseOps, reductionSyms);
18401841
cp.processSchedule(stmtCtx, clauseOps);
1841-
cp.processLinear(clauseOps);
18421842

1843-
cp.processTODO<clause::Allocate>(loc, llvm::omp::Directive::OMPD_do);
1843+
cp.processTODO<clause::Allocate, clause::Linear>(
1844+
loc, llvm::omp::Directive::OMPD_do);
18441845
}
18451846

18461847
//===----------------------------------------------------------------------===//
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
! This test checks lowering of OpenMP do simd linear() pragma
2+
3+
! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
4+
! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s
5+
subroutine testDoSimdLinear(int_array)
6+
integer :: int_array(:)
7+
!CHECK: not yet implemented: Unhandled clause LINEAR in SIMD construct
8+
!$omp do simd linear(int_array)
9+
do index_ = 1, 10
10+
end do
11+
!$omp end do simd
12+
13+
end subroutine testDoSimdLinear
14+

flang/test/Lower/OpenMP/simd-linear.f90

Lines changed: 0 additions & 57 deletions
This file was deleted.

flang/test/Lower/OpenMP/wsloop-linear.f90

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
! This test checks lowering of OpenMP DO Directive (Worksharing)
22
! with linear clause
3-
<<<<<<< HEAD
43
! XFAIL: *
5-
=======
6-
7-
>>>>>>> 290b32a699ae
84
! RUN: %flang_fc1 -fopenmp -emit-hlfir %s -o - 2>&1 | FileCheck %s
95

106
!CHECK: %[[X_alloca:.*]] = fir.alloca i32 {bindc_name = "x", uniq_name = "_QFsimple_linearEx"}
@@ -22,10 +18,6 @@ subroutine simple_linear
2218
y = x + 2
2319
end do
2420
!$omp end do
25-
<<<<<<< HEAD
26-
=======
27-
!CHECK: } {linear_var_types = [i32]}
28-
>>>>>>> 290b32a699ae
2921
end subroutine
3022

3123

@@ -44,10 +36,6 @@ subroutine linear_step
4436
y = x + 2
4537
end do
4638
!$omp end do
47-
<<<<<<< HEAD
48-
=======
49-
!CHECK: } {linear_var_types = [i32]}
50-
>>>>>>> 290b32a699ae
5139
end subroutine
5240

5341
!CHECK: %[[A_alloca:.*]] = fir.alloca i32 {bindc_name = "a", uniq_name = "_QFlinear_exprEa"}
@@ -66,8 +54,4 @@ subroutine linear_expr
6654
y = x + 2
6755
end do
6856
!$omp end do
69-
<<<<<<< HEAD
70-
=======
71-
!CHECK: } {linear_var_types = [i32]}
72-
>>>>>>> 290b32a699ae
7357
end subroutine

mlir/include/mlir/Dialect/OpenMP/OpenMPClauses.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
include "mlir/Dialect/OpenMP/OpenMPOpBase.td"
2323
include "mlir/Interfaces/SideEffectInterfaces.td"
2424
include "mlir/IR/SymbolInterfaces.td"
25-
include "mlir/IR/BuiltinAttributes.td"
2625

2726
//===----------------------------------------------------------------------===//
2827
// V5.2: [6.3] `align` clause
@@ -777,9 +776,10 @@ class OpenMP_LinearClauseSkip<
777776
bit description = false, bit extraClassDeclaration = false
778777
> : OpenMP_Clause<traits, arguments, assemblyFormat, description,
779778
extraClassDeclaration> {
780-
let arguments = (ins Variadic<AnyType>:$linear_vars,
781-
Variadic<I32>:$linear_step_vars,
782-
OptionalAttr<ArrayAttr>:$linear_var_types);
779+
let arguments = (ins
780+
Variadic<AnyType>:$linear_vars,
781+
Variadic<I32>:$linear_step_vars
782+
);
783783

784784
let optAssemblyFormat = [{
785785
`linear` `(`

mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2862,7 +2862,6 @@ void WsloopOp::build(OpBuilder &builder, OperationState &state,
28622862
ArrayRef<NamedAttribute> attributes) {
28632863
build(builder, state, /*allocate_vars=*/{}, /*allocator_vars=*/{},
28642864
/*linear_vars=*/ValueRange(), /*linear_step_vars=*/ValueRange(),
2865-
/*linear_var_types*/ nullptr,
28662865
/*nowait=*/false, /*order=*/nullptr, /*order_mod=*/nullptr,
28672866
/*ordered=*/nullptr, /*private_vars=*/{}, /*private_syms=*/nullptr,
28682867
/*private_needs_barrier=*/false,
@@ -2881,8 +2880,8 @@ void WsloopOp::build(OpBuilder &builder, OperationState &state,
28812880
WsloopOp::build(
28822881
builder, state,
28832882
/*allocate_vars=*/{}, /*allocator_vars=*/{}, clauses.linearVars,
2884-
clauses.linearStepVars, clauses.linearVarTypes, clauses.nowait,
2885-
clauses.order, clauses.orderMod, clauses.ordered, clauses.privateVars,
2883+
clauses.linearStepVars, clauses.nowait, clauses.order, clauses.orderMod,
2884+
clauses.ordered, clauses.privateVars,
28862885
makeArrayAttr(ctx, clauses.privateSyms), clauses.privateNeedsBarrier,
28872886
clauses.reductionMod, clauses.reductionVars,
28882887
makeDenseBoolArrayAttr(ctx, clauses.reductionByref),
@@ -2927,16 +2926,17 @@ LogicalResult WsloopOp::verifyRegions() {
29272926
void SimdOp::build(OpBuilder &builder, OperationState &state,
29282927
const SimdOperands &clauses) {
29292928
MLIRContext *ctx = builder.getContext();
2930-
SimdOp::build(
2931-
builder, state, clauses.alignedVars,
2932-
makeArrayAttr(ctx, clauses.alignments), clauses.ifExpr,
2933-
clauses.linearVars, clauses.linearStepVars, clauses.linearVarTypes,
2934-
clauses.nontemporalVars, clauses.order, clauses.orderMod,
2935-
clauses.privateVars, makeArrayAttr(ctx, clauses.privateSyms),
2936-
clauses.privateNeedsBarrier, clauses.reductionMod, clauses.reductionVars,
2937-
makeDenseBoolArrayAttr(ctx, clauses.reductionByref),
2938-
makeArrayAttr(ctx, clauses.reductionSyms), clauses.safelen,
2939-
clauses.simdlen);
2929+
// TODO Store clauses in op: linearVars, linearStepVars
2930+
SimdOp::build(builder, state, clauses.alignedVars,
2931+
makeArrayAttr(ctx, clauses.alignments), clauses.ifExpr,
2932+
/*linear_vars=*/{}, /*linear_step_vars=*/{},
2933+
clauses.nontemporalVars, clauses.order, clauses.orderMod,
2934+
clauses.privateVars, makeArrayAttr(ctx, clauses.privateSyms),
2935+
clauses.privateNeedsBarrier, clauses.reductionMod,
2936+
clauses.reductionVars,
2937+
makeDenseBoolArrayAttr(ctx, clauses.reductionByref),
2938+
makeArrayAttr(ctx, clauses.reductionSyms), clauses.safelen,
2939+
clauses.simdlen);
29402940
}
29412941

29422942
LogicalResult SimdOp::verify() {

0 commit comments

Comments
 (0)