Skip to content

Commit b5df6a9

Browse files
authored
[mlir][openacc] Fix num_gang parser (#78792)
Nb of operand per segment is not correctly computed.
1 parent f188f45 commit b5df6a9

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

mlir/lib/Dialect/OpenACC/IR/OpenACC.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,7 @@ static ParseResult parseNumGangs(
818818
if (failed(parser.parseLBrace()))
819819
return failure();
820820

821+
int32_t crtOperandsSize = operands.size();
821822
if (failed(parser.parseCommaSeparatedList(
822823
mlir::AsmParser::Delimiter::None, [&]() {
823824
if (parser.parseOperand(operands.emplace_back()) ||
@@ -826,8 +827,7 @@ static ParseResult parseNumGangs(
826827
return success();
827828
})))
828829
return failure();
829-
830-
seg.push_back(operands.size());
830+
seg.push_back(operands.size() - crtOperandsSize);
831831

832832
if (failed(parser.parseRBrace()))
833833
return failure();

mlir/test/Dialect/OpenACC/ops.mlir

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1878,3 +1878,12 @@ func.func @acc_atomic_capture(%v: memref<i32>, %x: memref<i32>, %expr: i32) {
18781878

18791879
return
18801880
}
1881+
1882+
// -----
1883+
1884+
%c2 = arith.constant 2 : i32
1885+
%c1 = arith.constant 1 : i32
1886+
acc.parallel num_gangs({%c2 : i32} [#acc.device_type<default>], {%c1 : i32, %c1 : i32, %c1 : i32} [#acc.device_type<nvidia>]) {
1887+
}
1888+
1889+
// CHECK: acc.parallel num_gangs({%c2{{.*}} : i32} [#acc.device_type<default>], {%c1{{.*}} : i32, %c1{{.*}} : i32, %c1{{.*}} : i32} [#acc.device_type<nvidia>])

0 commit comments

Comments
 (0)