From a7b24118319e9a0a27c9f9c44f28014882faf25e Mon Sep 17 00:00:00 2001 From: Mats Petersson Date: Tue, 8 Oct 2024 13:11:54 +0100 Subject: [PATCH 1/2] [Flang][OpenMP]Add tests for TODOs and small changes to improve messages The bulk of this change are new tests to check that we get a "Not yet implemneted: *some stuff here*" message when using some not yet supported OpenMP functionality. For some of these cases, this also means adding additional clauses to a filter list in OpenMP.cpp - this changes nothing [to the best of my understanding] other than allowing the clause to get to the point where it can be rejected in a TODO with a more clear message. One of the TOOD filters were missing Mergeable clause, so this was also added and the existing test updated for the new more specific error message. There is no functional change intended here. --- flang/lib/Lower/OpenMP/OpenMP.cpp | 9 ++++++--- flang/test/Lower/OpenMP/Todo/reduction-inscan.f90 | 14 ++++++++++++++ flang/test/Lower/OpenMP/Todo/reduction-task.f90 | 12 ++++++++++++ .../test/Lower/OpenMP/Todo/target-inreduction.f90 | 15 +++++++++++++++ flang/test/Lower/OpenMP/Todo/task-inreduction.f90 | 15 +++++++++++++++ flang/test/Lower/OpenMP/Todo/task_mergeable.f90 | 2 +- .../OpenMP/Todo/taskgroup-task-reduction.f90 | 10 ++++++++++ flang/test/Lower/OpenMP/Todo/taskloop.f90 | 13 +++++++++++++ flang/test/Lower/OpenMP/Todo/taskwait-depend.f90 | 10 ++++++++++ flang/test/Lower/OpenMP/Todo/taskwait-nowait.f90 | 8 ++++++++ 10 files changed, 104 insertions(+), 4 deletions(-) create mode 100644 flang/test/Lower/OpenMP/Todo/reduction-inscan.f90 create mode 100644 flang/test/Lower/OpenMP/Todo/reduction-task.f90 create mode 100644 flang/test/Lower/OpenMP/Todo/target-inreduction.f90 create mode 100644 flang/test/Lower/OpenMP/Todo/task-inreduction.f90 create mode 100644 flang/test/Lower/OpenMP/Todo/taskgroup-task-reduction.f90 create mode 100644 flang/test/Lower/OpenMP/Todo/taskloop.f90 create mode 100644 flang/test/Lower/OpenMP/Todo/taskwait-depend.f90 create mode 100644 flang/test/Lower/OpenMP/Todo/taskwait-nowait.f90 diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp index 60c83586e468b..cbfe1e7235c10 100644 --- a/flang/lib/Lower/OpenMP/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP/OpenMP.cpp @@ -1255,8 +1255,8 @@ static void genTaskClauses(lower::AbstractConverter &converter, cp.processUntied(clauseOps); // TODO Support delayed privatization. - cp.processTODO( - loc, llvm::omp::Directive::OMPD_task); + cp.processTODO(loc, llvm::omp::Directive::OMPD_task); } static void genTaskgroupClauses(lower::AbstractConverter &converter, @@ -2764,7 +2764,10 @@ static void genOMP(lower::AbstractConverter &converter, lower::SymMap &symTable, !std::holds_alternative(clause.u) && !std::holds_alternative(clause.u) && !std::holds_alternative(clause.u) && - !std::holds_alternative(clause.u)) { + !std::holds_alternative(clause.u) && + !std::holds_alternative(clause.u) && + !std::holds_alternative(clause.u) && + !std::holds_alternative(clause.u)) { TODO(clauseLocation, "OpenMP Block construct clause"); } } diff --git a/flang/test/Lower/OpenMP/Todo/reduction-inscan.f90 b/flang/test/Lower/OpenMP/Todo/reduction-inscan.f90 new file mode 100644 index 0000000000000..c5f196fe09693 --- /dev/null +++ b/flang/test/Lower/OpenMP/Todo/reduction-inscan.f90 @@ -0,0 +1,14 @@ +! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s +! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s + +! CHECK: not yet implemented: Reduction modifiers are not supported +subroutine reduction_inscan() + integer :: i,j + i = 0 + + !$omp do reduction(inscan, +:i) + do j=1,10 + i = i + 1 + end do + !$omp end do +end subroutine reduction_inscan diff --git a/flang/test/Lower/OpenMP/Todo/reduction-task.f90 b/flang/test/Lower/OpenMP/Todo/reduction-task.f90 new file mode 100644 index 0000000000000..6707f65e1a4cc --- /dev/null +++ b/flang/test/Lower/OpenMP/Todo/reduction-task.f90 @@ -0,0 +1,12 @@ +! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s +! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s + +! CHECK: not yet implemented: Reduction modifiers are not supported +subroutine reduction_task() + integer :: i + i = 0 + + !$omp parallel reduction(task, +:i) + i = i + 1 + !$omp end parallel +end subroutine reduction_task diff --git a/flang/test/Lower/OpenMP/Todo/target-inreduction.f90 b/flang/test/Lower/OpenMP/Todo/target-inreduction.f90 new file mode 100644 index 0000000000000..0751c10b04f5c --- /dev/null +++ b/flang/test/Lower/OpenMP/Todo/target-inreduction.f90 @@ -0,0 +1,15 @@ +! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s +! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s + +!=============================================================================== +! `mergeable` clause +!=============================================================================== + +! CHECK: not yet implemented: Unhandled clause IN_REDUCTION in TARGET construct +subroutine omp_targer_inreduction() + integer i + i = 0 + !$omp target in_reduction(+:i) + i = i + 1 + !$omp end target +end subroutine omp_targer_inreduction diff --git a/flang/test/Lower/OpenMP/Todo/task-inreduction.f90 b/flang/test/Lower/OpenMP/Todo/task-inreduction.f90 new file mode 100644 index 0000000000000..aeed680a6dba7 --- /dev/null +++ b/flang/test/Lower/OpenMP/Todo/task-inreduction.f90 @@ -0,0 +1,15 @@ +! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s +! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s + +!=============================================================================== +! `mergeable` clause +!=============================================================================== + +! CHECK: not yet implemented: Unhandled clause IN_REDUCTION in TASK construct +subroutine omp_task_in_reduction() + integer i + i = 0 + !$omp task in_reduction(+:i) + i = i + 1 + !$omp end task +end subroutine omp_task_in_reduction diff --git a/flang/test/Lower/OpenMP/Todo/task_mergeable.f90 b/flang/test/Lower/OpenMP/Todo/task_mergeable.f90 index 13145d92ccf90..ddc27487abfe9 100644 --- a/flang/test/Lower/OpenMP/Todo/task_mergeable.f90 +++ b/flang/test/Lower/OpenMP/Todo/task_mergeable.f90 @@ -5,7 +5,7 @@ ! `mergeable` clause !=============================================================================== -! CHECK: not yet implemented: OpenMP Block construct clause +! CHECK: not yet implemented: Unhandled clause MERGEABLE in TASK construct subroutine omp_task_mergeable() !$omp task mergeable call foo() diff --git a/flang/test/Lower/OpenMP/Todo/taskgroup-task-reduction.f90 b/flang/test/Lower/OpenMP/Todo/taskgroup-task-reduction.f90 new file mode 100644 index 0000000000000..1cb471d784d76 --- /dev/null +++ b/flang/test/Lower/OpenMP/Todo/taskgroup-task-reduction.f90 @@ -0,0 +1,10 @@ +! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -o - %s -fopenmp-version=50 2>&1 | FileCheck %s +! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -o - %s -fopenmp-version=50 2>&1 | FileCheck %s + +! CHECK: not yet implemented: Unhandled clause TASK_REDUCTION in TASKGROUP construct +subroutine omp_taskgroup_task_reduction + integer :: res + !$omp taskgroup task_reduction(+:res) + res = res + 1 + !$omp end taskgroup +end subroutine omp_taskgroup_task_reduction diff --git a/flang/test/Lower/OpenMP/Todo/taskloop.f90 b/flang/test/Lower/OpenMP/Todo/taskloop.f90 new file mode 100644 index 0000000000000..aca050584cbbe --- /dev/null +++ b/flang/test/Lower/OpenMP/Todo/taskloop.f90 @@ -0,0 +1,13 @@ +! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -o - %s -fopenmp-version=50 2>&1 | FileCheck %s +! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -o - %s -fopenmp-version=50 2>&1 | FileCheck %s + +! CHECK: not yet implemented: Taskloop construct +subroutine omp_taskloop + integer :: res, i + !$omp taskloop + do i = 1, 10 + res = res + 1 + end do + !$omp end taskloop +end subroutine omp_taskloop + diff --git a/flang/test/Lower/OpenMP/Todo/taskwait-depend.f90 b/flang/test/Lower/OpenMP/Todo/taskwait-depend.f90 new file mode 100644 index 0000000000000..d1f953be8802f --- /dev/null +++ b/flang/test/Lower/OpenMP/Todo/taskwait-depend.f90 @@ -0,0 +1,10 @@ +! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -o - %s -fopenmp-version=50 2>&1 | FileCheck %s +! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -o - %s -fopenmp-version=50 2>&1 | FileCheck %s + +! CHECK: not yet implemented: Unhandled clause DEPEND in TASKWAIT construct +subroutine omp_tw_depend + integer :: res + !$omp taskwait depend(out: res) + res = res + 1 +end subroutine omp_tw_depend + diff --git a/flang/test/Lower/OpenMP/Todo/taskwait-nowait.f90 b/flang/test/Lower/OpenMP/Todo/taskwait-nowait.f90 new file mode 100644 index 0000000000000..21e8609b08ba3 --- /dev/null +++ b/flang/test/Lower/OpenMP/Todo/taskwait-nowait.f90 @@ -0,0 +1,8 @@ +! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -o - %s -fopenmp-version=51 2>&1 | FileCheck %s +! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -o - %s -fopenmp-version=51 2>&1 | FileCheck %s + +! CHECK: not yet implemented: Unhandled clause NOWAIT in TASKWAIT construct +subroutine omp_tw_nowait + !$omp taskwait nowait +end subroutine omp_tw_nowait + From 0b81c5ec05cad1223f25cabb53268141fdacfccf Mon Sep 17 00:00:00 2001 From: Mats Petersson Date: Wed, 9 Oct 2024 10:17:19 +0000 Subject: [PATCH 2/2] Fix test and typo in name --- flang/test/Lower/OpenMP/Todo/target-inreduction.f90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/flang/test/Lower/OpenMP/Todo/target-inreduction.f90 b/flang/test/Lower/OpenMP/Todo/target-inreduction.f90 index 0751c10b04f5c..e5a9cffac5a11 100644 --- a/flang/test/Lower/OpenMP/Todo/target-inreduction.f90 +++ b/flang/test/Lower/OpenMP/Todo/target-inreduction.f90 @@ -1,15 +1,15 @@ -! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s -! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -o - %s 2>&1 | FileCheck %s +! RUN: %not_todo_cmd bbc -emit-fir -fopenmp -fopenmp-version=50 -o - %s 2>&1 | FileCheck %s +! RUN: %not_todo_cmd %flang_fc1 -emit-fir -fopenmp -fopenmp-version=50 -o - %s 2>&1 | FileCheck %s !=============================================================================== ! `mergeable` clause !=============================================================================== ! CHECK: not yet implemented: Unhandled clause IN_REDUCTION in TARGET construct -subroutine omp_targer_inreduction() +subroutine omp_target_inreduction() integer i i = 0 !$omp target in_reduction(+:i) i = i + 1 !$omp end target -end subroutine omp_targer_inreduction +end subroutine omp_target_inreduction