Skip to content

Commit bf1fe6e

Browse files
authored
[mlir][OpenMP] Reintroduce TODO for translation of linear clause (#143531)
Reintroduce a TODO for linear clause translation unless corner issues (like linear variables being entities other than `alloca`, and support for linear variables of types other than integer) are solved.
1 parent b21be0e commit bf1fe6e

File tree

3 files changed

+13
-88
lines changed

3 files changed

+13
-88
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,7 @@ static LogicalResult checkImplementationStatus(Operation &op) {
432432
})
433433
.Case([&](omp::WsloopOp op) {
434434
checkAllocate(op, result);
435+
checkLinear(op, result);
435436
checkOrder(op, result);
436437
checkReduction(op, result);
437438
})

mlir/test/Target/LLVMIR/openmp-llvm.mlir

Lines changed: 0 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -358,94 +358,6 @@ llvm.func @wsloop_simple(%arg0: !llvm.ptr) {
358358

359359
// -----
360360

361-
// CHECK-LABEL: wsloop_linear
362-
363-
// CHECK: {{.*}} = alloca i32, i64 1, align 4
364-
// CHECK: %[[Y:.*]] = alloca i32, i64 1, align 4
365-
// CHECK: %[[X:.*]] = alloca i32, i64 1, align 4
366-
367-
// CHECK: entry:
368-
// CHECK: %[[LINEAR_VAR:.*]] = alloca i32, align 4
369-
// CHECK: %[[LINEAR_RESULT:.*]] = alloca i32, align 4
370-
// CHECK: br label %omp_loop.preheader
371-
372-
// CHECK: omp_loop.preheader:
373-
// CHECK: %[[LOAD:.*]] = load i32, ptr %[[X]], align 4
374-
// CHECK: store i32 %[[LOAD]], ptr %[[LINEAR_VAR]], align 4
375-
// CHECK: %omp_global_thread_num = call i32 @__kmpc_global_thread_num(ptr @2)
376-
// CHECK: call void @__kmpc_barrier(ptr @1, i32 %omp_global_thread_num)
377-
378-
// CHECK: omp_loop.body:
379-
// CHECK: %[[LOOP_IV:.*]] = add i32 %omp_loop.iv, {{.*}}
380-
// CHECK: %[[LINEAR_LOAD:.*]] = load i32, ptr %[[LINEAR_VAR]], align 4
381-
// CHECK: %[[MUL:.*]] = mul i32 %[[LOOP_IV]], 1
382-
// CHECK: %[[ADD:.*]] = add i32 %[[LINEAR_LOAD]], %[[MUL]]
383-
// CHECK: store i32 %[[ADD]], ptr %[[LINEAR_RESULT]], align 4
384-
// CHECK: br label %omp.loop_nest.region
385-
386-
// CHECK: omp.loop_nest.region:
387-
// CHECK: %[[LINEAR_LOAD:.*]] = load i32, ptr %[[LINEAR_RESULT]], align 4
388-
// CHECK: %[[ADD:.*]] = add i32 %[[LINEAR_LOAD]], 2
389-
// CHECK: store i32 %[[ADD]], ptr %[[Y]], align 4
390-
391-
// CHECK: omp_loop.exit:
392-
// CHECK: call void @__kmpc_for_static_fini(ptr @2, i32 %omp_global_thread_num4)
393-
// CHECK: %omp_global_thread_num5 = call i32 @__kmpc_global_thread_num(ptr @2)
394-
// CHECK: call void @__kmpc_barrier(ptr @3, i32 %omp_global_thread_num5)
395-
// CHECK: br label %omp_loop.linear_finalization
396-
397-
// CHECK: omp_loop.linear_finalization:
398-
// CHECK: %[[LAST_ITER:.*]] = load i32, ptr %p.lastiter, align 4
399-
// CHECK: %[[CMP:.*]] = icmp ne i32 %[[LAST_ITER]], 0
400-
// CHECK: br i1 %[[CMP]], label %omp_loop.linear_lastiter_exit, label %omp_loop.linear_exit
401-
402-
// CHECK: omp_loop.linear_lastiter_exit:
403-
// CHECK: %[[LINEAR_RESULT_LOAD:.*]] = load i32, ptr %[[LINEAR_RESULT]], align 4
404-
// CHECK: store i32 %[[LINEAR_RESULT_LOAD]], ptr %[[X]], align 4
405-
// CHECK: br label %omp_loop.linear_exit
406-
407-
// CHECK: omp_loop.linear_exit:
408-
// CHECK: %omp_global_thread_num6 = call i32 @__kmpc_global_thread_num(ptr @2)
409-
// CHECK: call void @__kmpc_barrier(ptr @1, i32 %omp_global_thread_num6)
410-
// CHECK: br label %omp_loop.after
411-
412-
llvm.func @wsloop_linear() {
413-
%0 = llvm.mlir.constant(1 : i64) : i64
414-
%1 = llvm.alloca %0 x i32 {bindc_name = "i", pinned} : (i64) -> !llvm.ptr
415-
%2 = llvm.mlir.constant(1 : i64) : i64
416-
%3 = llvm.alloca %2 x i32 {bindc_name = "y"} : (i64) -> !llvm.ptr
417-
%4 = llvm.mlir.constant(1 : i64) : i64
418-
%5 = llvm.alloca %4 x i32 {bindc_name = "x"} : (i64) -> !llvm.ptr
419-
%6 = llvm.mlir.constant(1 : i64) : i64
420-
%7 = llvm.alloca %6 x i32 {bindc_name = "i"} : (i64) -> !llvm.ptr
421-
%8 = llvm.mlir.constant(2 : i32) : i32
422-
%9 = llvm.mlir.constant(10 : i32) : i32
423-
%10 = llvm.mlir.constant(1 : i32) : i32
424-
%11 = llvm.mlir.constant(1 : i64) : i64
425-
%12 = llvm.mlir.constant(1 : i64) : i64
426-
%13 = llvm.mlir.constant(1 : i64) : i64
427-
%14 = llvm.mlir.constant(1 : i64) : i64
428-
omp.wsloop linear(%5 = %10 : !llvm.ptr) {
429-
omp.loop_nest (%arg0) : i32 = (%10) to (%9) inclusive step (%10) {
430-
llvm.store %arg0, %1 : i32, !llvm.ptr
431-
%15 = llvm.load %5 : !llvm.ptr -> i32
432-
%16 = llvm.add %15, %8 : i32
433-
llvm.store %16, %3 : i32, !llvm.ptr
434-
%17 = llvm.add %arg0, %10 : i32
435-
%18 = llvm.icmp "sgt" %17, %9 : i32
436-
llvm.cond_br %18, ^bb1, ^bb2
437-
^bb1: // pred: ^bb0
438-
llvm.store %17, %1 : i32, !llvm.ptr
439-
llvm.br ^bb2
440-
^bb2: // 2 preds: ^bb0, ^bb1
441-
omp.yield
442-
}
443-
}
444-
llvm.return
445-
}
446-
447-
// -----
448-
449361
// CHECK-LABEL: @wsloop_inclusive_1
450362
llvm.func @wsloop_inclusive_1(%arg0: !llvm.ptr) {
451363
%0 = llvm.mlir.constant(42 : index) : i64

mlir/test/Target/LLVMIR/openmp-todo.mlir

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,18 @@ llvm.func @wsloop_allocate(%lb : i32, %ub : i32, %step : i32, %x : !llvm.ptr) {
511511

512512
// -----
513513

514+
llvm.func @wsloop_linear(%lb : i32, %ub : i32, %step : i32, %x : !llvm.ptr) {
515+
// expected-error@below {{not yet implemented: Unhandled clause linear in omp.wsloop operation}}
516+
// expected-error@below {{LLVM Translation failed for operation: omp.wsloop}}
517+
omp.wsloop linear(%x = %step : !llvm.ptr) {
518+
omp.loop_nest (%iv) : i32 = (%lb) to (%ub) step (%step) {
519+
omp.yield
520+
}
521+
}
522+
llvm.return
523+
}
524+
525+
// -----
514526
llvm.func @wsloop_order(%lb : i32, %ub : i32, %step : i32) {
515527
// expected-error@below {{not yet implemented: Unhandled clause order in omp.wsloop operation}}
516528
// expected-error@below {{LLVM Translation failed for operation: omp.wsloop}}

0 commit comments

Comments
 (0)