aboutsummaryrefslogtreecommitdiff
path: root/offload/test/offloading/gpupgo/pgo_device_and_host.c
blob: 3e95791ce9a508c72756ee22eb07d8ca6772a7b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// RUN: %libomptarget-compile-generic -fprofile-generate
// RUN: env LLVM_PROFILE_FILE=%basename_t.llvm.profraw \
// RUN:     %libomptarget-run-generic 2>&1
// RUN: %profdata show --all-functions --counts \
// RUN:     %basename_t.llvm.profraw | %fcheck-generic \
// RUN:     --check-prefix="LLVM-HOST"
// RUN: %profdata show --all-functions --counts \
// RUN:     %target_triple.%basename_t.llvm.profraw \
// RUN:     | %fcheck-generic --check-prefix="LLVM-DEVICE"

// RUN: %libomptarget-compile-generic -fprofile-instr-generate
// RUN: env LLVM_PROFILE_FILE=%basename_t.clang.profraw \
// RUN:     %libomptarget-run-generic 2>&1
// RUN: %profdata show --all-functions --counts \
// RUN:     %basename_t.clang.profraw | %fcheck-generic \
// RUN:     --check-prefix="CLANG-HOST"
// RUN: %profdata show --all-functions --counts \
// RUN:     %target_triple.%basename_t.clang.profraw | \
// RUN:     %fcheck-generic --check-prefix="CLANG-DEV"

// RUN: %libomptarget-compile-generic -Xarch_host -fprofile-generate
// RUN: env LLVM_PROFILE_FILE=%basename_t.nogpu.profraw \
// RUN:     %libomptarget-run-generic 2>&1
// RUN: %profdata show --all-functions --counts \
// RUN:     %basename_t.nogpu.profraw | %fcheck-generic \
// RUN:     --check-prefix="LLVM-HOST"
// RUN: not test -e %target_triple.%basename_t.nogpu.profraw

// RUN: %libomptarget-compile-generic -Xarch_host -fprofile-generate \
// RUN:     -Xarch_device -fprofile-instr-generate
// RUN: env LLVM_PROFILE_FILE=%basename_t.hidf.profraw \
// RUN:     %libomptarget-run-generic 2>&1
// RUN: %profdata show --all-functions --counts \
// RUN:     %basename_t.hidf.profraw | %fcheck-generic \
// RUN:     --check-prefix="LLVM-HOST"
// RUN: %profdata show --all-functions --counts \
// RUN:     %target_triple.%basename_t.hidf.profraw \
// RUN:     | %fcheck-generic --check-prefix="CLANG-DEV"

// RUN: %libomptarget-compile-generic -Xarch_device -fprofile-generate \
// RUN:     -Xarch_host -fprofile-instr-generate
// RUN: env LLVM_PROFILE_FILE=%basename_t.hfdi.profraw \
// RUN:     %libomptarget-run-generic 2>&1
// RUN: %profdata show --all-functions --counts \
// RUN:     %basename_t.hfdi.profraw | %fcheck-generic \
// RUN:     --check-prefix="CLANG-HOST"
// RUN: %profdata show --all-functions --counts \
// RUN:     %target_triple.%basename_t.hfdi.profraw \
// RUN:     | %fcheck-generic --check-prefix="LLVM-DEVICE"

// REQUIRES: amdgpu
// REQUIRES: pgo

int main() {
  int host_var = 0;
  for (int i = 0; i < 20; i++) {
    host_var += i;
  }

  int device_var = 1;
#pragma omp target
  {
    for (int i = 0; i < 10; i++) {
      device_var *= i;
    }
  }
}

// LLVM-HOST-LABEL: main:
// LLVM-HOST: Hash: {{0[xX][0-9a-fA-F]+}}
// LLVM-HOST: Counters: 3
// LLVM-HOST: Block counts: [20, 1, 0]

// LLVM-HOST-LABEL: __omp_offloading_{{[_0-9a-zA-Z]*}}_main_{{[_0-9a-zA-Z]*}}:
// LLVM-HOST: Hash: {{0[xX][0-9a-fA-F]+}}
// LLVM-HOST: Counters: 2
// LLVM-HOST: Block counts: [0, 0]
// LLVM-HOST: Instrumentation level: IR

// LLVM-DEVICE-LABEL: __omp_offloading_{{[_0-9a-zA-Z]*}}_main_{{[_0-9a-zA-Z]*}}:
// LLVM-DEVICE: Hash: {{0[xX][0-9a-fA-F]+}}
// LLVM-DEVICE: Counters: 3
// LLVM-DEVICE: Block counts: [10, {{.*}}, 1]
// LLVM-DEVICE: Instrumentation level: IR

// CLANG-HOST-LABEL: main:
// CLANG-HOST: Hash: {{0[xX][0-9a-fA-F]+}}
// CLANG-HOST: Counters: 2
// CLANG-HOST: Function count: 1
// CLANG-HOST: Block counts: [20]

// CLANG-HOST-LABEL: __omp_offloading_{{[_0-9a-zA-Z]*}}_main_{{[_0-9a-zA-Z]*}}:
// CLANG-HOST: Hash: {{0[xX][0-9a-fA-F]+}}
// CLANG-HOST: Counters: 2
// CLANG-HOST: Function count: 0
// CLANG-HOST: Block counts: [0]
// CLANG-HOST: Instrumentation level: Front-end

// CLANG-DEV-LABEL: __omp_offloading_{{[_0-9a-zA-Z]*}}_main_{{[_0-9a-zA-Z]*}}:
// CLANG-DEV: Hash: {{0[xX][0-9a-fA-F]+}}
// CLANG-DEV: Counters: 2
// CLANG-DEV: Block counts: [10]
// CLANG-DEV: Instrumentation level: Front-end