llvm-project/mlir/test/Target/LLVMIR/openmp-taskloop-final.mlir
Jack Styles b7c17ab957
[MLIR][OpenMP] Add Initial Taskloop Clause Support (#174623)
Following on from the work to implement MLIR -> LLVM IR Translation for
Taskloop, this adds support for the following clauses to be used
alongside taskloop:
- if
- grainsize
- num_tasks
- untied
- Nogroup
- Final
- Mergeable
- Priority

These clauses are ones which work directly through the relevant OpenMP
Runtime functions, so their information just needed collecting from the
relevant location and passing through to the appropriate runtime
function.

Remaining clauses retain their TODO message as they have not yet been
implemented.
2026-01-09 10:34:03 +00:00

40 lines
1.5 KiB
MLIR

// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s
omp.private {type = private} @_QFtestEi_private_i32 : i32
omp.private {type = firstprivate} @_QFtestEa_firstprivate_i32 : i32 copy {
^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr):
%0 = llvm.load %arg0 : !llvm.ptr -> i32
llvm.store %0, %arg1 : i32, !llvm.ptr
omp.yield(%arg1 : !llvm.ptr)
}
llvm.func @_QPtest() {
%0 = llvm.mlir.constant(1 : i64) : i64
%1 = llvm.alloca %0 x i32 {bindc_name = "i"} : (i64) -> !llvm.ptr
%3 = llvm.alloca %0 x i32 {bindc_name = "a"} : (i64) -> !llvm.ptr
%6 = llvm.mlir.constant(20 : i32) : i32
llvm.store %6, %3 : i32, !llvm.ptr
%7 = llvm.mlir.constant(1 : i32) : i32
%8 = llvm.mlir.constant(5 : i32) : i32
%9 = llvm.mlir.constant(1 : i32) : i32
%true = llvm.mlir.constant(true) : i1
omp.taskloop final(%true) private(@_QFtestEa_firstprivate_i32 %3 -> %arg0, @_QFtestEi_private_i32 %1 -> %arg1 : !llvm.ptr, !llvm.ptr) {
omp.loop_nest (%arg2) : i32 = (%7) to (%8) inclusive step (%9) {
llvm.store %arg2, %arg1 : i32, !llvm.ptr
%10 = llvm.load %arg0 : !llvm.ptr -> i32
%11 = llvm.mlir.constant(1 : i32) : i32
%12 = llvm.add %10, %11 : i32
llvm.store %12, %arg0 : i32, !llvm.ptr
omp.yield
}
}
llvm.return
}
// CHECK: %[[omp_global_thread_num:.*]] = call i32 @__kmpc_global_thread_num(ptr @1)
// CHECK: %[[VAL:.*]] = call ptr @__kmpc_omp_task_alloc(ptr @1, i32 %[[omp_global_thread_num]], i32 3, i64 40, i64 32, ptr @_QPtest..omp_par)
// -----