Skip to content

Commit 5dbb30d

Browse files
authored
[MLIR][OpenMP] Better error reporting for unsupported nowait (#78551)
Provides some context for failing to generate LLVM IR for `target enter|exit|update` directives when `nowait` is provided. This is directly helpful for flang users since they would get this error message if they tried to use `nowait`. Before that we had a very generic message. This is a follow-up to #78269, please only review the latest commit (the one with the same commit message as the PR title).
1 parent e21b0b0 commit 5dbb30d

File tree

2 files changed

+45
-3
lines changed

2 files changed

+45
-3
lines changed

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1884,7 +1884,8 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
18841884
})
18851885
.Case([&](omp::EnterDataOp enterDataOp) {
18861886
if (enterDataOp.getNowait())
1887-
return failure();
1887+
return (LogicalResult)(enterDataOp.emitError(
1888+
"`nowait` is not supported yet"));
18881889

18891890
if (auto ifExprVar = enterDataOp.getIfExpr())
18901891
ifCond = moduleTranslation.lookupValue(ifExprVar);
@@ -1900,7 +1901,8 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
19001901
})
19011902
.Case([&](omp::ExitDataOp exitDataOp) {
19021903
if (exitDataOp.getNowait())
1903-
return failure();
1904+
return (LogicalResult)(exitDataOp.emitError(
1905+
"`nowait` is not supported yet"));
19041906

19051907
if (auto ifExprVar = exitDataOp.getIfExpr())
19061908
ifCond = moduleTranslation.lookupValue(ifExprVar);
@@ -1917,7 +1919,8 @@ convertOmpTargetData(Operation *op, llvm::IRBuilderBase &builder,
19171919
})
19181920
.Case([&](omp::UpdateDataOp updateDataOp) {
19191921
if (updateDataOp.getNowait())
1920-
return failure();
1922+
return (LogicalResult)(updateDataOp.emitError(
1923+
"`nowait` is not supported yet"));
19211924

19221925
if (auto ifExprVar = updateDataOp.getIfExpr())
19231926
ifCond = moduleTranslation.lookupValue(ifExprVar);
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// RUN: not mlir-translate -mlir-to-llvmir -split-input-file %s 2>&1 | FileCheck %s
2+
3+
llvm.func @_QPopenmp_target_data_update() {
4+
%0 = llvm.mlir.constant(1 : i64) : i64
5+
%1 = llvm.alloca %0 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFopenmp_target_dataEi"} : (i64) -> !llvm.ptr
6+
%2 = omp.map_info var_ptr(%1 : !llvm.ptr, i32) map_clauses(to) capture(ByRef) -> !llvm.ptr {name = ""}
7+
8+
// CHECK: error: `nowait` is not supported yet
9+
omp.target_update_data motion_entries(%2 : !llvm.ptr) nowait
10+
11+
llvm.return
12+
}
13+
14+
// -----
15+
16+
llvm.func @_QPopenmp_target_data_enter() {
17+
%0 = llvm.mlir.constant(1 : i64) : i64
18+
%1 = llvm.alloca %0 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFopenmp_target_dataEi"} : (i64) -> !llvm.ptr
19+
%2 = omp.map_info var_ptr(%1 : !llvm.ptr, i32) map_clauses(to) capture(ByRef) -> !llvm.ptr {name = ""}
20+
21+
// CHECK: error: `nowait` is not supported yet
22+
omp.target_enter_data map_entries(%2 : !llvm.ptr) nowait
23+
24+
llvm.return
25+
}
26+
27+
28+
// -----
29+
30+
llvm.func @_QPopenmp_target_data_exit() {
31+
%0 = llvm.mlir.constant(1 : i64) : i64
32+
%1 = llvm.alloca %0 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array<i32: 0, 0>, uniq_name = "_QFopenmp_target_dataEi"} : (i64) -> !llvm.ptr
33+
%2 = omp.map_info var_ptr(%1 : !llvm.ptr, i32) map_clauses(from) capture(ByRef) -> !llvm.ptr {name = ""}
34+
35+
// CHECK: error: `nowait` is not supported yet
36+
omp.target_exit_data map_entries(%2 : !llvm.ptr) nowait
37+
38+
llvm.return
39+
}

0 commit comments

Comments
 (0)