Files
TheRock/compiler/amd-llvm/mlir/test/Target/LLVMIR/omptarget-multi-block-reduction.mlir
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

91 lines
3.2 KiB
MLIR

// RUN: mlir-translate -mlir-to-llvmir %s | FileCheck %s
// Verifies that the IR builder can handle reductions with multi-block combiner
// regions on the GPU.
module attributes {dlti.dl_spec = #dlti.dl_spec<"dlti.alloca_memory_space" = 5 : ui64, "dlti.global_memory_space" = 1 : ui64>, llvm.target_triple = "amdgcn-amd-amdhsa", omp.is_gpu = true, omp.is_target_device = true} {
llvm.func @bar() {}
llvm.func @baz() {}
omp.declare_reduction @add_reduction_byref_box_5xf32 : !llvm.ptr attributes {byref_element_type = !llvm.array<5 x f32>} alloc {
%0 = llvm.mlir.constant(1 : i64) : i64
%1 = llvm.alloca %0 x !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8, array<1 x array<3 x i64>>)> : (i64) -> !llvm.ptr<5>
%2 = llvm.addrspacecast %1 : !llvm.ptr<5> to !llvm.ptr
omp.yield(%2 : !llvm.ptr)
} init {
^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr):
omp.yield(%arg1 : !llvm.ptr)
} combiner {
^bb0(%arg0: !llvm.ptr, %arg1: !llvm.ptr):
llvm.call @bar() : () -> ()
llvm.br ^bb3
^bb3: // pred: ^bb1
llvm.call @baz() : () -> ()
omp.yield(%arg0 : !llvm.ptr)
} data_ptr_ptr {
^bb0(%arg0: !llvm.ptr):
%0 = llvm.getelementptr %arg0[0, 0] : (!llvm.ptr) -> !llvm.ptr, !llvm.struct<(ptr, i64, i32, i8, i8, i8, i8)>
omp.yield(%0 : !llvm.ptr)
}
llvm.func @foo_() {
%c1 = llvm.mlir.constant(1 : i64) : i64
%10 = llvm.alloca %c1 x !llvm.array<5 x f32> {bindc_name = "x"} : (i64) -> !llvm.ptr<5>
%11 = llvm.addrspacecast %10 : !llvm.ptr<5> to !llvm.ptr
%74 = omp.map.info var_ptr(%11 : !llvm.ptr, !llvm.array<5 x f32>) map_clauses(tofrom) capture(ByRef) -> !llvm.ptr {name = "x"}
omp.target map_entries(%74 -> %arg0 : !llvm.ptr) {
%c1_2 = llvm.mlir.constant(1 : i32) : i32
%c10 = llvm.mlir.constant(10 : i32) : i32
omp.teams reduction(byref @add_reduction_byref_box_5xf32 %arg0 -> %arg2 : !llvm.ptr) {
omp.parallel {
omp.distribute {
omp.wsloop {
omp.loop_nest (%arg5) : i32 = (%c1_2) to (%c10) inclusive step (%c1_2) {
omp.yield
}
} {omp.composite}
} {omp.composite}
omp.terminator
} {omp.composite}
omp.terminator
}
omp.terminator
}
llvm.return
}
}
// CHECK: call void @__kmpc_parallel_60({{.*}}, i32 1, i32 -1, i32 -1,
// CHECK-SAME: ptr @[[PAR_OUTLINED:.*]], ptr null, ptr %{{.*}}, i64 1, i32 0)
// CHECK: define internal void @[[PAR_OUTLINED]]{{.*}} {
// CHECK: .omp.reduction.then:
// CHECK: br label %omp.reduction.nonatomic.body
// CHECK: omp.reduction.nonatomic.body:
// CHECK: call void @bar()
// CHECK: br label %[[BODY_2ND_BB:.*]]
// CHECK: [[BODY_2ND_BB]]:
// CHECK: call void @baz()
// CHECK: br label %[[CONT_BB:.*]]
// CHECK: [[CONT_BB]]:
// CHECK-NEXT: %[[RED_RHS:.*]] = phi ptr [ %{{.*}}, %{{.*}} ]
// CHECK: }
// CHECK: define internal void @"{{.*}}$reduction$reduction_func"(ptr noundef %0, ptr noundef %1) #0 {
// CHECK: br label %omp.reduction.nonatomic.body
// CHECK: [[BODY_2ND_BB:.*]]:
// CHECK: call void @baz()
// CHECK: br label %omp.region.cont
// CHECK: omp.reduction.nonatomic.body:
// CHECK: call void @bar()
// CHECK: br label %[[BODY_2ND_BB]]
// CHECK: }