diff --git a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp index 3c9831120351e..c4ab5e0033d04 100644 --- a/flang/lib/Lower/OpenMP/ClauseProcessor.cpp +++ b/flang/lib/Lower/OpenMP/ClauseProcessor.cpp @@ -153,10 +153,13 @@ genDependKindAttr(lower::AbstractConverter &converter, pbKind = mlir::omp::ClauseTaskDepend::taskdependinout; break; case omp::clause::DependenceType::Mutexinoutset: + pbKind = mlir::omp::ClauseTaskDepend::taskdependmutexinoutset; + break; case omp::clause::DependenceType::Inoutset: + pbKind = mlir::omp::ClauseTaskDepend::taskdependinoutset; + break; case omp::clause::DependenceType::Depobj: - TODO(currentLocation, - "INOUTSET, MUTEXINOUTSET and DEPOBJ dependence-types"); + TODO(currentLocation, "DEPOBJ dependence-type"); break; case omp::clause::DependenceType::Sink: case omp::clause::DependenceType::Source: diff --git a/flang/test/Lower/OpenMP/Todo/depend-clause-depobj.f90 b/flang/test/Lower/OpenMP/Todo/depend-clause-depobj.f90 index 3bc730f849192..4e98d77d0bb3e 100644 --- a/flang/test/Lower/OpenMP/Todo/depend-clause-depobj.f90 +++ b/flang/test/Lower/OpenMP/Todo/depend-clause-depobj.f90 @@ -1,7 +1,7 @@ !RUN: %not_todo_cmd bbc -emit-hlfir -fopenmp -fopenmp-version=52 -o - %s 2>&1 | FileCheck %s !RUN: %not_todo_cmd %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 -o - %s 2>&1 | FileCheck %s -!CHECK: not yet implemented: INOUTSET, MUTEXINOUTSET and DEPOBJ dependence-types +!CHECK: not yet implemented: DEPOBJ dependence-type subroutine f00(x) integer :: x diff --git a/flang/test/Lower/OpenMP/Todo/depend-clause-inoutset.f90 b/flang/test/Lower/OpenMP/Todo/depend-clause-inoutset.f90 deleted file mode 100644 index 160893fccdc5f..0000000000000 --- a/flang/test/Lower/OpenMP/Todo/depend-clause-inoutset.f90 +++ /dev/null @@ -1,11 +0,0 @@ -!RUN: %not_todo_cmd bbc -emit-hlfir -fopenmp -fopenmp-version=52 -o - %s 2>&1 | FileCheck %s -!RUN: %not_todo_cmd %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 -o - %s 2>&1 | FileCheck %s - -!CHECK: not yet implemented: INOUTSET, MUTEXINOUTSET and DEPOBJ dependence-types -subroutine f00(x) - integer :: x - !$omp task depend(inoutset: x) - x = x + 1 - !$omp end task -end - diff --git a/flang/test/Lower/OpenMP/Todo/depend-clause-mutexinoutset.f90 b/flang/test/Lower/OpenMP/Todo/depend-clause-mutexinoutset.f90 deleted file mode 100644 index 17cc3894c548f..0000000000000 --- a/flang/test/Lower/OpenMP/Todo/depend-clause-mutexinoutset.f90 +++ /dev/null @@ -1,11 +0,0 @@ -!RUN: %not_todo_cmd bbc -emit-hlfir -fopenmp -fopenmp-version=52 -o - %s 2>&1 | FileCheck %s -!RUN: %not_todo_cmd %flang_fc1 -emit-hlfir -fopenmp -fopenmp-version=52 -o - %s 2>&1 | FileCheck %s - -!CHECK: not yet implemented: INOUTSET, MUTEXINOUTSET and DEPOBJ dependence-types -subroutine f00(x) - integer :: x - !$omp task depend(mutexinoutset: x) - x = x + 1 - !$omp end task -end - diff --git a/flang/test/Lower/OpenMP/task.f90 b/flang/test/Lower/OpenMP/task.f90 index 6e525a044b011..f5591bd9d8609 100644 --- a/flang/test/Lower/OpenMP/task.f90 +++ b/flang/test/Lower/OpenMP/task.f90 @@ -144,6 +144,18 @@ subroutine task_depend_multi_task() x = x + 12 !CHECK: omp.terminator !$omp end task + !CHECK: omp.task depend(taskdependmutexinoutset -> %{{.+}} : !fir.ref) + !$omp task depend(mutexinoutset : x) + !CHECK: arith.subi + x = x - 12 + !CHECK: omp.terminator + !$omp end task + !CHECK: omp.task depend(taskdependinoutset -> %{{.+}} : !fir.ref) + !$omp task depend(inoutset : x) + !CHECK: arith.subi + x = x - 12 + !CHECK: omp.terminator + !$omp end task end subroutine task_depend_multi_task !=============================================================================== diff --git a/mlir/include/mlir/Dialect/OpenMP/OpenMPEnums.td b/mlir/include/mlir/Dialect/OpenMP/OpenMPEnums.td index b1a9e3330522b..2091c0c76dff7 100644 --- a/mlir/include/mlir/Dialect/OpenMP/OpenMPEnums.td +++ b/mlir/include/mlir/Dialect/OpenMP/OpenMPEnums.td @@ -108,14 +108,15 @@ def ClauseRequiresAttr : OpenMP_EnumAttr; def ClauseTaskDependIn : I32EnumAttrCase<"taskdependin", 0>; def ClauseTaskDependOut : I32EnumAttrCase<"taskdependout", 1>; def ClauseTaskDependInOut : I32EnumAttrCase<"taskdependinout", 2>; - -def ClauseTaskDepend : OpenMP_I32EnumAttr< - "ClauseTaskDepend", - "depend clause in a target or task construct", [ - ClauseTaskDependIn, - ClauseTaskDependOut, - ClauseTaskDependInOut - ]>; +def ClauseTaskDependMutexInOutSet + : I32EnumAttrCase<"taskdependmutexinoutset", 3>; +def ClauseTaskDependInOutSet : I32EnumAttrCase<"taskdependinoutset", 4>; + +def ClauseTaskDepend + : OpenMP_I32EnumAttr< + "ClauseTaskDepend", "depend clause in a target or task construct", + [ClauseTaskDependIn, ClauseTaskDependOut, ClauseTaskDependInOut, + ClauseTaskDependMutexInOutSet, ClauseTaskDependInOutSet]>; def ClauseTaskDependAttr : OpenMP_EnumAttr { diff --git a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp index 060113c412324..9a30266103b15 100644 --- a/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp +++ b/mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp @@ -1701,6 +1701,12 @@ buildDependData(std::optional dependKinds, OperandRange dependVars, case mlir::omp::ClauseTaskDepend::taskdependinout: type = llvm::omp::RTLDependenceKindTy::DepInOut; break; + case mlir::omp::ClauseTaskDepend::taskdependmutexinoutset: + type = llvm::omp::RTLDependenceKindTy::DepMutexInOutSet; + break; + case mlir::omp::ClauseTaskDepend::taskdependinoutset: + type = llvm::omp::RTLDependenceKindTy::DepInOutSet; + break; }; llvm::Value *depVal = moduleTranslation.lookupValue(std::get<0>(dep)); llvm::OpenMPIRBuilder::DependData dd(type, depVal->getType(), depVal); diff --git a/mlir/test/Target/LLVMIR/openmp-llvm.mlir b/mlir/test/Target/LLVMIR/openmp-llvm.mlir index 5f8bdf8afdf78..44e32c3f35f9b 100644 --- a/mlir/test/Target/LLVMIR/openmp-llvm.mlir +++ b/mlir/test/Target/LLVMIR/openmp-llvm.mlir @@ -2590,6 +2590,34 @@ llvm.func @omp_task_attrs() -> () attributes { // CHECK: store i64 8, ptr %[[dep_arr_addr_0_size]], align 4 // CHECK: %[[dep_arr_addr_0_kind:.+]] = getelementptr inbounds nuw %struct.kmp_dep_info, ptr %[[dep_arr_addr_0]], i32 0, i32 2 // CHECK: store i8 1, ptr %[[dep_arr_addr_0_kind]], align 1 +// ----- +// dependence_type: Out +// CHECK: %[[DEP_ARR_ADDR1:.+]] = alloca [1 x %struct.kmp_dep_info], align 8 +// CHECK: %[[DEP_ARR_ADDR_1:.+]] = getelementptr inbounds [1 x %struct.kmp_dep_info], ptr %[[DEP_ARR_ADDR1]], i64 0, i64 0 +// [...] +// CHECK: %[[DEP_TYPE_1:.+]] = getelementptr inbounds nuw %struct.kmp_dep_info, ptr %[[DEP_ARR_ADDR_1]], i32 0, i32 2 +// CHECK: store i8 3, ptr %[[DEP_TYPE_1]], align 1 +// ----- +// dependence_type: Inout +// CHECK: %[[DEP_ARR_ADDR2:.+]] = alloca [1 x %struct.kmp_dep_info], align 8 +// CHECK: %[[DEP_ARR_ADDR_2:.+]] = getelementptr inbounds [1 x %struct.kmp_dep_info], ptr %[[DEP_ARR_ADDR2]], i64 0, i64 0 +// [...] +// CHECK: %[[DEP_TYPE_2:.+]] = getelementptr inbounds nuw %struct.kmp_dep_info, ptr %[[DEP_ARR_ADDR_2]], i32 0, i32 2 +// CHECK: store i8 3, ptr %[[DEP_TYPE_2]], align 1 +// ----- +// dependence_type: Mutexinoutset +// CHECK: %[[DEP_ARR_ADDR3:.+]] = alloca [1 x %struct.kmp_dep_info], align 8 +// CHECK: %[[DEP_ARR_ADDR_3:.+]] = getelementptr inbounds [1 x %struct.kmp_dep_info], ptr %[[DEP_ARR_ADDR3]], i64 0, i64 0 +// [...] +// CHECK: %[[DEP_TYPE_3:.+]] = getelementptr inbounds nuw %struct.kmp_dep_info, ptr %[[DEP_ARR_ADDR_3]], i32 0, i32 2 +// CHECK: store i8 4, ptr %[[DEP_TYPE_3]], align 1 +// ----- +// dependence_type: Inoutset +// CHECK: %[[DEP_ARR_ADDR4:.+]] = alloca [1 x %struct.kmp_dep_info], align 8 +// CHECK: %[[DEP_ARR_ADDR_4:.+]] = getelementptr inbounds [1 x %struct.kmp_dep_info], ptr %[[DEP_ARR_ADDR4]], i64 0, i64 0 +// [...] +// CHECK: %[[DEP_TYPE_4:.+]] = getelementptr inbounds nuw %struct.kmp_dep_info, ptr %[[DEP_ARR_ADDR_4]], i32 0, i32 2 +// CHECK: store i8 8, ptr %[[DEP_TYPE_4]], align 1 llvm.func @omp_task_with_deps(%zaddr: !llvm.ptr) { // CHECK: %[[omp_global_thread_num:.+]] = call i32 @__kmpc_global_thread_num({{.+}}) // CHECK: %[[task_data:.+]] = call ptr @__kmpc_omp_task_alloc @@ -2604,6 +2632,18 @@ llvm.func @omp_task_with_deps(%zaddr: !llvm.ptr) { llvm.store %double, %valaddr : i32, !llvm.ptr omp.terminator } + omp.task depend(taskdependout -> %zaddr : !llvm.ptr) { + omp.terminator + } + omp.task depend(taskdependinout -> %zaddr : !llvm.ptr) { + omp.terminator + } + omp.task depend(taskdependmutexinoutset -> %zaddr : !llvm.ptr) { + omp.terminator + } + omp.task depend(taskdependinoutset -> %zaddr : !llvm.ptr) { + omp.terminator + } llvm.return }