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
163 lines
6.3 KiB
MLIR
163 lines
6.3 KiB
MLIR
// RUN: fir-opt --bufferize-hlfir %s | FileCheck %s
|
|
|
|
// Checks that we correctly identify when to use the lowering to
|
|
// omp.workshare.loop_wrapper
|
|
|
|
// CHECK-LABEL: @should_parallelize_0
|
|
// CHECK: omp.workshare.loop_wrapper
|
|
func.func @should_parallelize_0(%arg: !fir.ref<!fir.array<42xi32>>, %idx : index) {
|
|
omp.workshare {
|
|
%c42 = arith.constant 42 : index
|
|
%c1_i32 = arith.constant 1 : i32
|
|
%shape = fir.shape %c42 : (index) -> !fir.shape<1>
|
|
%array:2 = hlfir.declare %arg(%shape) {uniq_name = "array"} : (!fir.ref<!fir.array<42xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<42xi32>>, !fir.ref<!fir.array<42xi32>>)
|
|
%elemental = hlfir.elemental %shape unordered : (!fir.shape<1>) -> !hlfir.expr<42xi32> {
|
|
^bb0(%i: index):
|
|
hlfir.yield_element %c1_i32 : i32
|
|
}
|
|
hlfir.assign %elemental to %array#0 : !hlfir.expr<42xi32>, !fir.ref<!fir.array<42xi32>>
|
|
hlfir.destroy %elemental : !hlfir.expr<42xi32>
|
|
omp.terminator
|
|
}
|
|
return
|
|
}
|
|
|
|
// CHECK-LABEL: @should_parallelize_1
|
|
// CHECK: omp.workshare.loop_wrapper
|
|
func.func @should_parallelize_1(%arg: !fir.ref<!fir.array<42xi32>>, %idx : index) {
|
|
omp.parallel {
|
|
omp.workshare {
|
|
%c42 = arith.constant 42 : index
|
|
%c1_i32 = arith.constant 1 : i32
|
|
%shape = fir.shape %c42 : (index) -> !fir.shape<1>
|
|
%array:2 = hlfir.declare %arg(%shape) {uniq_name = "array"} : (!fir.ref<!fir.array<42xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<42xi32>>, !fir.ref<!fir.array<42xi32>>)
|
|
%elemental = hlfir.elemental %shape unordered : (!fir.shape<1>) -> !hlfir.expr<42xi32> {
|
|
^bb0(%i: index):
|
|
hlfir.yield_element %c1_i32 : i32
|
|
}
|
|
hlfir.assign %elemental to %array#0 : !hlfir.expr<42xi32>, !fir.ref<!fir.array<42xi32>>
|
|
hlfir.destroy %elemental : !hlfir.expr<42xi32>
|
|
omp.terminator
|
|
}
|
|
omp.terminator
|
|
}
|
|
return
|
|
}
|
|
|
|
|
|
// CHECK-LABEL: @should_not_parallelize_0
|
|
// CHECK-NOT: omp.workshare.loop_wrapper
|
|
func.func @should_not_parallelize_0(%arg: !fir.ref<!fir.array<42xi32>>, %idx : index) {
|
|
omp.workshare {
|
|
omp.single {
|
|
%c42 = arith.constant 42 : index
|
|
%c1_i32 = arith.constant 1 : i32
|
|
%shape = fir.shape %c42 : (index) -> !fir.shape<1>
|
|
%array:2 = hlfir.declare %arg(%shape) {uniq_name = "array"} : (!fir.ref<!fir.array<42xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<42xi32>>, !fir.ref<!fir.array<42xi32>>)
|
|
%elemental = hlfir.elemental %shape unordered : (!fir.shape<1>) -> !hlfir.expr<42xi32> {
|
|
^bb0(%i: index):
|
|
hlfir.yield_element %c1_i32 : i32
|
|
}
|
|
hlfir.assign %elemental to %array#0 : !hlfir.expr<42xi32>, !fir.ref<!fir.array<42xi32>>
|
|
hlfir.destroy %elemental : !hlfir.expr<42xi32>
|
|
omp.terminator
|
|
}
|
|
omp.terminator
|
|
}
|
|
return
|
|
}
|
|
|
|
// CHECK-LABEL: @should_not_parallelize_1
|
|
// CHECK-NOT: omp.workshare.loop_wrapper
|
|
func.func @should_not_parallelize_1(%arg: !fir.ref<!fir.array<42xi32>>, %idx : index) {
|
|
omp.workshare {
|
|
omp.critical {
|
|
%c42 = arith.constant 42 : index
|
|
%c1_i32 = arith.constant 1 : i32
|
|
%shape = fir.shape %c42 : (index) -> !fir.shape<1>
|
|
%array:2 = hlfir.declare %arg(%shape) {uniq_name = "array"} : (!fir.ref<!fir.array<42xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<42xi32>>, !fir.ref<!fir.array<42xi32>>)
|
|
%elemental = hlfir.elemental %shape unordered : (!fir.shape<1>) -> !hlfir.expr<42xi32> {
|
|
^bb0(%i: index):
|
|
hlfir.yield_element %c1_i32 : i32
|
|
}
|
|
hlfir.assign %elemental to %array#0 : !hlfir.expr<42xi32>, !fir.ref<!fir.array<42xi32>>
|
|
hlfir.destroy %elemental : !hlfir.expr<42xi32>
|
|
omp.terminator
|
|
}
|
|
omp.terminator
|
|
}
|
|
return
|
|
}
|
|
|
|
// CHECK-LABEL: @should_not_parallelize_2
|
|
// CHECK-NOT: omp.workshare.loop_wrapper
|
|
func.func @should_not_parallelize_2(%arg: !fir.ref<!fir.array<42xi32>>, %idx : index) {
|
|
omp.workshare {
|
|
omp.parallel {
|
|
%c42 = arith.constant 42 : index
|
|
%c1_i32 = arith.constant 1 : i32
|
|
%shape = fir.shape %c42 : (index) -> !fir.shape<1>
|
|
%array:2 = hlfir.declare %arg(%shape) {uniq_name = "array"} : (!fir.ref<!fir.array<42xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<42xi32>>, !fir.ref<!fir.array<42xi32>>)
|
|
%elemental = hlfir.elemental %shape unordered : (!fir.shape<1>) -> !hlfir.expr<42xi32> {
|
|
^bb0(%i: index):
|
|
hlfir.yield_element %c1_i32 : i32
|
|
}
|
|
hlfir.assign %elemental to %array#0 : !hlfir.expr<42xi32>, !fir.ref<!fir.array<42xi32>>
|
|
hlfir.destroy %elemental : !hlfir.expr<42xi32>
|
|
omp.terminator
|
|
}
|
|
omp.terminator
|
|
}
|
|
return
|
|
}
|
|
|
|
// CHECK-LABEL: @should_not_parallelize_3
|
|
// CHECK-NOT: omp.workshare.loop_wrapper
|
|
func.func @should_not_parallelize_3(%arg: !fir.ref<!fir.array<42xi32>>, %idx : index) {
|
|
omp.workshare {
|
|
omp.parallel {
|
|
omp.workshare {
|
|
omp.parallel {
|
|
%c42 = arith.constant 42 : index
|
|
%c1_i32 = arith.constant 1 : i32
|
|
%shape = fir.shape %c42 : (index) -> !fir.shape<1>
|
|
%array:2 = hlfir.declare %arg(%shape) {uniq_name = "array"} : (!fir.ref<!fir.array<42xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<42xi32>>, !fir.ref<!fir.array<42xi32>>)
|
|
%elemental = hlfir.elemental %shape unordered : (!fir.shape<1>) -> !hlfir.expr<42xi32> {
|
|
^bb0(%i: index):
|
|
hlfir.yield_element %c1_i32 : i32
|
|
}
|
|
hlfir.assign %elemental to %array#0 : !hlfir.expr<42xi32>, !fir.ref<!fir.array<42xi32>>
|
|
hlfir.destroy %elemental : !hlfir.expr<42xi32>
|
|
omp.terminator
|
|
}
|
|
omp.terminator
|
|
}
|
|
omp.terminator
|
|
}
|
|
omp.terminator
|
|
}
|
|
return
|
|
}
|
|
|
|
// CHECK-LABEL: @should_not_parallelize_4
|
|
// CHECK-NOT: omp.workshare.loop_wrapper
|
|
func.func @should_not_parallelize_4(%arg: !fir.ref<!fir.array<42xi32>>, %idx : index) {
|
|
omp.workshare {
|
|
^bb1:
|
|
%c42 = arith.constant 42 : index
|
|
%c1_i32 = arith.constant 1 : i32
|
|
%shape = fir.shape %c42 : (index) -> !fir.shape<1>
|
|
%array:2 = hlfir.declare %arg(%shape) {uniq_name = "array"} : (!fir.ref<!fir.array<42xi32>>, !fir.shape<1>) -> (!fir.ref<!fir.array<42xi32>>, !fir.ref<!fir.array<42xi32>>)
|
|
%elemental = hlfir.elemental %shape unordered : (!fir.shape<1>) -> !hlfir.expr<42xi32> {
|
|
^bb0(%i: index):
|
|
hlfir.yield_element %c1_i32 : i32
|
|
}
|
|
hlfir.assign %elemental to %array#0 : !hlfir.expr<42xi32>, !fir.ref<!fir.array<42xi32>>
|
|
hlfir.destroy %elemental : !hlfir.expr<42xi32>
|
|
cf.br ^bb2
|
|
^bb2:
|
|
omp.terminator
|
|
}
|
|
return
|
|
}
|