Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10036,12 +10036,16 @@ OpenMPIRBuilder::createDistribute(const LocationDescription &Loc,
if (Error Err = BodyGenCB(AllocaIP, CodeGenIP))
return Err;

OutlineInfo OI;
OI.OuterAllocaBB = OuterAllocaIP.getBlock();
OI.EntryBB = AllocaBB;
OI.ExitBB = ExitBB;
// When using target we use different runtime functions which require a
// callback.
if (Config.isTargetDevice()) {
OutlineInfo OI;
OI.OuterAllocaBB = OuterAllocaIP.getBlock();
OI.EntryBB = AllocaBB;
OI.ExitBB = ExitBB;

addOutlineInfo(std::move(OI));
addOutlineInfo(std::move(OI));
}
Builder.SetInsertPoint(ExitBB, ExitBB->begin());

return Builder.saveIP();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ llvm.func @cancel_distribute_parallel_do(%lb : i32, %ub : i32, %step : i32) {
// CHECK: omp.region.cont6:
// CHECK: br label %omp.region.cont4
// CHECK: omp.region.cont4:
// CHECK: br label %distribute.exit.exitStub
// CHECK: br label %omp.par.exit.exitStub
// CHECK: omp_loop.body:
// CHECK: %[[VAL_111:.*]] = add i32 %{{.*}}, %{{.*}}
// CHECK: %[[VAL_112:.*]] = mul i32 %[[VAL_111]], %{{.*}}
Expand All @@ -52,6 +52,6 @@ llvm.func @cancel_distribute_parallel_do(%lb : i32, %ub : i32, %step : i32) {
// CHECK: omp_loop.inc:
// CHECK: %[[VAL_100:.*]] = add nuw i32 %{{.*}}, 1
// CHECK: br label %omp_loop.header
// CHECK: distribute.exit.exitStub:
// CHECK: omp.par.exit.exitStub:
// CHECK: ret void

22 changes: 5 additions & 17 deletions mlir/test/Target/LLVMIR/openmp-distribute-private.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ llvm.func @_QQmain() {
// CHECK: }

// CHECK: define internal void @[[TEAMS_FUNC]]({{.*}}) {
// CHECK: call void @[[DIST_FUNC:.*]]()
// CHECK-NEXT: br label %distribute.exit
// CHECK: }

// CHECK: define internal void @[[DIST_FUNC]]() {
// CHECK: %[[PRIV_VAR_ALLOC:.*]] = alloca float, align 4
// CHECK: %[[IV_ALLOC:.*]] = alloca i32, align 4

Expand Down Expand Up @@ -78,29 +73,22 @@ llvm.func @_QQmain() {

// CHECK-LABEL: define void @_QQmain() {
// CHECK: %[[SHARED_VAR_ALLOC:.*]] = alloca float, i64 1, align 4
// CHECK: %[[SHARED_VAR_PTR:.*]] = getelementptr { ptr }, ptr %[[DIST_PARAM:.*]], i32 0, i32 0
// CHECK: store ptr %[[SHARED_VAR_ALLOC]], ptr %[[SHARED_VAR_PTR]], align 8
// CHECK: call void @[[DIST_FUNC:.*]](ptr %[[DIST_PARAM]])
// CHECK-NEXT: br label %distribute.exit
// CHECK: }

// CHECK: define internal void @[[DIST_FUNC]](ptr %[[DIST_ARG:.*]]) {
// CHECK: %[[SHARED_VAR_GEP:.*]] = getelementptr { ptr }, ptr %[[DIST_ARG]], i32 0, i32 0
// CHECK: %[[SHARED_VAR_PTR2:.*]] = load ptr, ptr %[[SHARED_VAR_GEP]], align 8
// CHECK: distribute.alloca:
// CHECK: %[[PRIV_VAR_ALLOC:.*]] = alloca float, align 4

// CHECK: omp.private.copy:
// CHECK-NEXT: %[[SHARED_VAR_VAL:.*]] = load float, ptr %[[SHARED_VAR_PTR2]], align 4
// CHECK-NEXT: %[[SHARED_VAR_VAL:.*]] = load float, ptr %[[SHARED_VAR_ALLOC]], align 4
// CHECK-NEXT: store float %[[SHARED_VAR_VAL]], ptr %[[PRIV_VAR_ALLOC]], align 4

// CHECK: omp.loop_nest.region:
// CHECK-NEXT: store float 0x40091EB860000000, ptr %[[PRIV_VAR_ALLOC]], align 4

// CHECK: omp_loop.after:
// CHECK-NEXT: br label %omp.region.cont

// CHECK: omp.region.cont:
// CHECK-NEXT: call void @foo_free(ptr %[[PRIV_VAR_ALLOC]])

// CHECK: omp.loop_nest.region:
// CHECK-NEXT: store float 0x40091EB860000000, ptr %[[PRIV_VAR_ALLOC]], align 4
// CHECK: }


10 changes: 1 addition & 9 deletions mlir/test/Target/LLVMIR/openmp-llvm.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -3339,12 +3339,6 @@ llvm.func @distribute() {
}

// CHECK-LABEL: define void @distribute
// CHECK: call void @[[OUTLINED:.*]]({{.*}})
// CHECK-NEXT: br label %[[EXIT:.*]]
// CHECK: [[EXIT]]:
// CHECK: ret void

// CHECK: define internal void @[[OUTLINED]]({{.*}})
// CHECK: %[[LASTITER:.*]] = alloca i32
// CHECK: %[[LB:.*]] = alloca i64
// CHECK: %[[UB:.*]] = alloca i64
Expand Down Expand Up @@ -3381,9 +3375,7 @@ llvm.func @distribute_wsloop(%lb : i32, %ub : i32, %step : i32) {
// CHECK: call void{{.*}}@__kmpc_fork_call({{.*}}, ptr @[[OUTLINED_PARALLEL:.*]],

// CHECK: define internal void @[[OUTLINED_PARALLEL]]
// CHECK: call void @[[OUTLINED_DISTRIBUTE:.*]]({{.*}})

// CHECK: define internal void @[[OUTLINED_DISTRIBUTE]]
// CHECK: distribute.alloca:
// CHECK: %[[LASTITER:.*]] = alloca i32
// CHECK: %[[LB:.*]] = alloca i32
// CHECK: %[[UB:.*]] = alloca i32
Expand Down
3 changes: 0 additions & 3 deletions mlir/test/Target/LLVMIR/openmp-target-generic-spmd.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ module attributes {omp.is_target_device = false, omp.target_triples = ["amdgcn-a
// HOST: call void{{.*}}@__kmpc_fork_teams({{.*}}, ptr @[[TEAMS_OUTLINE:.*]], {{.*}})

// HOST: define internal void @[[TEAMS_OUTLINE]]
// HOST: call void @[[DISTRIBUTE_OUTLINE:.*]]({{.*}})

// HOST: define internal void @[[DISTRIBUTE_OUTLINE]]
// HOST: call void @__kmpc_for_static_init{{.*}}(ptr {{.*}}, i32 {{.*}}, i32 92, ptr {{.*}}, ptr {{.*}}, ptr {{.*}}, ptr {{.*}}, i32 {{.*}}, i32 {{.*}})
// HOST: call void (ptr, i32, ptr, ...) @__kmpc_fork_call({{.*}}, ptr @[[PARALLEL_OUTLINE:.*]], {{.*}})

Expand Down
3 changes: 0 additions & 3 deletions mlir/test/Target/LLVMIR/openmp-target-spmd.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ module attributes {omp.is_target_device = false, omp.target_triples = ["amdgcn-a
// HOST: call void{{.*}}@__kmpc_fork_call({{.*}}, ptr @[[PARALLEL_OUTLINE:.*]], {{.*}})

// HOST: define internal void @[[PARALLEL_OUTLINE]]
// HOST: call void @[[DISTRIBUTE_OUTLINE:.*]]({{.*}})

// HOST: define internal void @[[DISTRIBUTE_OUTLINE]]
// HOST: call void @__kmpc_dist_for_static_init{{.*}}(ptr {{.*}}, i32 {{.*}}, i32 34, ptr {{.*}}, ptr {{.*}}, ptr {{.*}}, ptr {{.*}}, ptr {{.*}}, i32 {{.*}}, i32 {{.*}})

//--- device.mlir
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,20 @@
// Check that omp.simd as a leaf of a composite construct still generates
// the appropriate loop vectorization attribute.

// CHECK-LABEL: define internal void @test_teams_distribute_parallel_do_simd..omp_par.2
// CHECK-LABEL: define internal void @test_teams_distribute_parallel_do_simd..omp_par.1
// CHECK: teams.body:
// CHECK: omp.teams.region:

// CHECK-LABEL: define internal void @test_teams_distribute_parallel_do_simd..omp_par.1
// CHECK-LABEL: define internal void @test_teams_distribute_parallel_do_simd..omp_par
// CHECK: omp.par.entry:
// CHECK: omp.par.region:
// CHECK: distribute.exit:

// CHECK-LABEL: define internal void @test_teams_distribute_parallel_do_simd..omp_par
// CHECK: distribute.body:
// CHECK: omp.distribute.region:
// CHECK: omp_loop.header:
// CHECK: omp_loop.inc:
// CHECK-NEXT: %omp_loop.next = add nuw i32 %omp_loop.iv, 1
// CHECK-NEXT: br label %omp_loop.header, !llvm.loop ![[LOOP_ATTR:.*]]
// CHECK: omp.par.exit.exitStub:

// CHECK: ![[LOOP_ATTR]] = distinct !{![[LOOP_ATTR]], ![[LPAR:.*]], ![[LVEC:.*]]}
// CHECK: ![[LPAR]] = !{!"llvm.loop.parallel_accesses", ![[PAR_ACC:.*]]}
Expand Down
Loading