xref: /llvm-project/flang/test/Lower/OpenMP/parallel-sections.f90 (revision bfeebda3b1cc1a05e435e94f54bf2d2a2570b4e2)
1! REQUIRES: openmp_runtime
2
3!RUN: %flang_fc1 -emit-hlfir %openmp_flags %s -o - | FileCheck %s
4
5!===============================================================================
6! Parallel sections construct
7!===============================================================================
8
9!CHECK: func @_QPomp_parallel_sections
10subroutine omp_parallel_sections(x, y)
11  integer, intent(inout) :: x, y
12  !CHECK: omp.parallel {
13  !CHECK: omp.sections {
14  !$omp parallel sections
15    !CHECK: omp.section {
16    !$omp section
17      !CHECK: fir.load
18      !CHECK: arith.addi
19      !CHECK: hlfir.assign
20      x = x + 12
21      !CHECK: omp.terminator
22    !CHECK: omp.section {
23    !$omp section
24      !CHECK: fir.load
25      !CHECK: arith.subi
26      !CHECK: hlfir.assign
27      y = y - 5
28      !CHECK: omp.terminator
29  !CHECK: omp.terminator
30  !CHECK: omp.terminator
31  !$omp end parallel sections
32end subroutine omp_parallel_sections
33
34!===============================================================================
35! Parallel sections construct with allocate clause
36!===============================================================================
37
38!CHECK: func @_QPomp_parallel_sections
39subroutine omp_parallel_sections_allocate(x, y)
40  use omp_lib
41  integer, intent(inout) :: x, y
42  !CHECK: omp.parallel
43  !CHECK: %[[allocator_1:.*]] = arith.constant 4 : i64
44  !CHECK: omp.sections allocate(%[[allocator_1]] : i64 -> %{{.*}} : !fir.ref<i32>) {
45  !$omp parallel sections allocate(omp_high_bw_mem_alloc: x) private(x, y)
46    !CHECK: omp.section {
47    !$omp section
48      x = x + 12
49      !CHECK: omp.terminator
50    !CHECK: omp.section {
51    !$omp section
52      y = y + 5
53      !CHECK: omp.terminator
54  !CHECK: omp.terminator
55  !CHECK: omp.terminator
56  !$omp end parallel sections
57end subroutine omp_parallel_sections_allocate
58