|
| 1 | +!===----------------------------------------------------------------------===! |
| 2 | +! This directory can be used to add Integration tests involving multiple |
| 3 | +! stages of the compiler (for eg. from Fortran to LLVM IR). It should not |
| 4 | +! contain executable tests. We should only add tests here sparingly and only |
| 5 | +! if there is no other way to test. Repeat this message in each test that is |
| 6 | +! added to this directory and sub-directories. |
| 7 | +!===----------------------------------------------------------------------===! |
| 8 | + |
| 9 | +!RUN: %flang_fc1 -emit-llvm -fopenmp %s -o - | FileCheck %s |
| 10 | + |
| 11 | +!CHECK-DAG: define void @_copy_box_Uxi32(ptr %{{.*}}, ptr %{{.*}}) |
| 12 | +!CHECK-DAG: define void @_copy_10xi32(ptr %{{.*}}, ptr %{{.*}}) |
| 13 | +!CHECK-DAG: define void @_copy_i64(ptr %{{.*}}, ptr %{{.*}}) |
| 14 | +!CHECK-DAG: define void @_copy_box_Uxi64(ptr %{{.*}}, ptr %{{.*}}) |
| 15 | +!CHECK-DAG: define void @_copy_f32(ptr %{{.*}}, ptr %{{.*}}) |
| 16 | +!CHECK-DAG: define void @_copy_2x3xf32(ptr %{{.*}}, ptr %{{.*}}) |
| 17 | +!CHECK-DAG: define void @_copy_z32(ptr %{{.*}}, ptr %{{.*}}) |
| 18 | +!CHECK-DAG: define void @_copy_10xz32(ptr %{{.*}}, ptr %{{.*}}) |
| 19 | +!CHECK-DAG: define void @_copy_l32(ptr %{{.*}}, ptr %{{.*}}) |
| 20 | +!CHECK-DAG: define void @_copy_5xl32(ptr %{{.*}}, ptr %{{.*}}) |
| 21 | +!CHECK-DAG: define void @_copy_c8x8(ptr %{{.*}}, ptr %{{.*}}) |
| 22 | +!CHECK-DAG: define void @_copy_10xc8x8(ptr %{{.*}}, ptr %{{.*}}) |
| 23 | +!CHECK-DAG: define void @_copy_c16x5(ptr %{{.*}}, ptr %{{.*}}) |
| 24 | +!CHECK-DAG: define void @_copy_rec__QFtest_typesTdt(ptr %{{.*}}, ptr %{{.*}}) |
| 25 | +!CHECK-DAG: define void @_copy_box_heap_Uxi32(ptr %{{.*}}, ptr %{{.*}}) |
| 26 | +!CHECK-DAG: define void @_copy_box_ptr_Uxc8x9(ptr %{{.*}}, ptr %{{.*}}) |
| 27 | + |
| 28 | +!CHECK-LABEL: define void @_copy_i32( |
| 29 | +!CHECK-SAME: ptr %[[DST:.*]], ptr %[[SRC:.*]]) { |
| 30 | +!CHECK-NEXT: %[[SRC_VAL:.*]] = load i32, ptr %[[SRC]] |
| 31 | +!CHECK-NEXT: store i32 %[[SRC_VAL]], ptr %[[DST]] |
| 32 | +!CHECK-NEXT: ret void |
| 33 | +!CHECK-NEXT: } |
| 34 | + |
| 35 | +!CHECK-LABEL: define internal void @test_scalar_..omp_par({{.*}}) |
| 36 | +!CHECK: %[[I:.*]] = alloca i32, i64 1 |
| 37 | +!CHECK: %[[J:.*]] = alloca i32, i64 1 |
| 38 | +!CHECK: %[[DID_IT:.*]] = alloca i32 |
| 39 | +!CHECK: store i32 0, ptr %[[DID_IT]] |
| 40 | +!CHECK: %[[THREAD_NUM1:.*]] = call i32 @__kmpc_global_thread_num(ptr @[[LOC:.*]]) |
| 41 | +!CHECK: %[[RET:.*]] = call i32 @__kmpc_single({{.*}}) |
| 42 | +!CHECK: %[[NOT_ZERO:.*]] = icmp ne i32 %[[RET]], 0 |
| 43 | +!CHECK: br i1 %[[NOT_ZERO]], label %[[OMP_REGION_BODY:.*]], label %[[OMP_REGION_END:.*]] |
| 44 | + |
| 45 | +!CHECK: [[OMP_REGION_END]]: |
| 46 | +!CHECK: %[[THREAD_NUM2:.*]] = call i32 @__kmpc_global_thread_num(ptr @[[LOC:.*]]) |
| 47 | +!CHECK: %[[DID_IT_VAL:.*]] = load i32, ptr %[[DID_IT]] |
| 48 | +!CHECK: call void @__kmpc_copyprivate(ptr @[[LOC]], i32 %[[THREAD_NUM2]], i64 0, ptr %[[I]], ptr @_copy_i32, i32 %[[DID_IT_VAL]]) |
| 49 | +!CHECK: %[[THREAD_NUM3:.*]] = call i32 @__kmpc_global_thread_num(ptr @[[LOC]]) |
| 50 | +!CHECK: %[[DID_IT_VAL2:.*]] = load i32, ptr %[[DID_IT]] |
| 51 | +!CHECK: call void @__kmpc_copyprivate(ptr @[[LOC]], i32 %[[THREAD_NUM3]], i64 0, ptr %[[J]], ptr @_copy_i32, i32 %[[DID_IT_VAL2]]) |
| 52 | + |
| 53 | +!CHECK: [[OMP_REGION_BODY]]: |
| 54 | +!CHECK: br label %[[OMP_SINGLE_REGION:.*]] |
| 55 | +!CHECK: [[OMP_SINGLE_REGION]]: |
| 56 | +!CHECK: store i32 11, ptr %[[I]] |
| 57 | +!CHECK: store i32 22, ptr %[[J]] |
| 58 | +!CHECK: br label %[[OMP_REGION_CONT3:.*]] |
| 59 | +!CHECK: [[OMP_REGION_CONT3:.*]]: |
| 60 | +!CHECK: store i32 1, ptr %[[DID_IT]] |
| 61 | +!CHECK: call void @__kmpc_end_single(ptr @[[LOC]], i32 %[[THREAD_NUM1]]) |
| 62 | +!CHECK: br label %[[OMP_REGION_END]] |
| 63 | +subroutine test_scalar() |
| 64 | + integer :: i, j |
| 65 | + |
| 66 | + !$omp parallel private(i, j) |
| 67 | + !$omp single |
| 68 | + i = 11 |
| 69 | + j = 22 |
| 70 | + !$omp end single copyprivate(i, j) |
| 71 | + !$omp end parallel |
| 72 | +end subroutine |
| 73 | + |
| 74 | +subroutine test_types(a, n) |
| 75 | + integer :: a(:), n |
| 76 | + integer(4) :: i4, i4a(10) |
| 77 | + integer(8) :: i8, i8a(n) |
| 78 | + real :: r, ra(2, 3) |
| 79 | + complex :: z, za(10) |
| 80 | + logical :: l, la(5) |
| 81 | + character(kind=1, len=8) :: c1, c1a(10) |
| 82 | + character(kind=2, len=5) :: c2 |
| 83 | + |
| 84 | + type dt |
| 85 | + integer :: i |
| 86 | + real :: r |
| 87 | + end type |
| 88 | + type(dt) :: t |
| 89 | + |
| 90 | + integer, allocatable :: aloc(:) |
| 91 | + character(kind=1, len=9), pointer :: ptr(:) |
| 92 | + |
| 93 | + !$omp parallel private(a, i4, i4a, i8, i8a, r, ra, z, za, l, la, c1, c1a, c2, t, aloc, ptr) |
| 94 | + !$omp single |
| 95 | + !$omp end single copyprivate(a, i4, i4a, i8, i8a, r, ra, z, za, l, la, c1, c1a, c2, t, aloc, ptr) |
| 96 | + !$omp end parallel |
| 97 | +end subroutine |
0 commit comments