1// RUN: %libomptarget-compile-generic -fprofile-generate
2// RUN: env LLVM_PROFILE_FILE=%basename_t.llvm.profraw \
3// RUN: %libomptarget-run-generic 2>&1
4// RUN: %profdata show --all-functions --counts \
5// RUN: %basename_t.llvm.profraw | %fcheck-generic \
6// RUN: --check-prefix="LLVM-HOST"
7// RUN: %profdata show --all-functions --counts \
8// RUN: %target_triple.%basename_t.llvm.profraw \
9// RUN: | %fcheck-generic --check-prefix="LLVM-DEVICE"
10
11// RUN: %libomptarget-compile-generic -fprofile-instr-generate
12// RUN: env LLVM_PROFILE_FILE=%basename_t.clang.profraw \
13// RUN: %libomptarget-run-generic 2>&1
14// RUN: %profdata show --all-functions --counts \
15// RUN: %basename_t.clang.profraw | %fcheck-generic \
16// RUN: --check-prefix="CLANG-HOST"
17// RUN: %profdata show --all-functions --counts \
18// RUN: %target_triple.%basename_t.clang.profraw | \
19// RUN: %fcheck-generic --check-prefix="CLANG-DEV"
20
21// RUN: %libomptarget-compile-generic -Xarch_host -fprofile-generate
22// RUN: env LLVM_PROFILE_FILE=%basename_t.nogpu.profraw \
23// RUN: %libomptarget-run-generic 2>&1
24// RUN: %profdata show --all-functions --counts \
25// RUN: %basename_t.nogpu.profraw | %fcheck-generic \
26// RUN: --check-prefix="LLVM-HOST"
27// RUN: not test -e %target_triple.%basename_t.nogpu.profraw
28
29// RUN: %libomptarget-compile-generic -Xarch_host -fprofile-generate \
30// RUN: -Xarch_device -fprofile-instr-generate
31// RUN: env LLVM_PROFILE_FILE=%basename_t.hidf.profraw \
32// RUN: %libomptarget-run-generic 2>&1
33// RUN: %profdata show --all-functions --counts \
34// RUN: %basename_t.hidf.profraw | %fcheck-generic \
35// RUN: --check-prefix="LLVM-HOST"
36// RUN: %profdata show --all-functions --counts \
37// RUN: %target_triple.%basename_t.hidf.profraw \
38// RUN: | %fcheck-generic --check-prefix="CLANG-DEV"
39
40// RUN: %libomptarget-compile-generic -Xarch_device -fprofile-generate \
41// RUN: -Xarch_host -fprofile-instr-generate
42// RUN: env LLVM_PROFILE_FILE=%basename_t.hfdi.profraw \
43// RUN: %libomptarget-run-generic 2>&1
44// RUN: %profdata show --all-functions --counts \
45// RUN: %basename_t.hfdi.profraw | %fcheck-generic \
46// RUN: --check-prefix="CLANG-HOST"
47// RUN: %profdata show --all-functions --counts \
48// RUN: %target_triple.%basename_t.hfdi.profraw \
49// RUN: | %fcheck-generic --check-prefix="LLVM-DEVICE"
50
51// REQUIRES: amdgpu
52// REQUIRES: pgo
53
54int main() {
55 int host_var = 0;
56 for (int i = 0; i < 20; i++) {
57 host_var += i;
58 }
59
60 int device_var = 1;
61#pragma omp target
62 {
63 for (int i = 0; i < 10; i++) {
64 device_var *= i;
65 }
66 }
67}
68
69// LLVM-HOST-LABEL: main:
70// LLVM-HOST: Hash: {{0[xX][0-9a-fA-F]+}}
71// LLVM-HOST: Counters: 3
72// LLVM-HOST: Block counts: [20, 1, 0]
73
74// LLVM-HOST-LABEL: __omp_offloading_{{[_0-9a-zA-Z]*}}_main_{{[_0-9a-zA-Z]*}}:
75// LLVM-HOST: Hash: {{0[xX][0-9a-fA-F]+}}
76// LLVM-HOST: Counters: 2
77// LLVM-HOST: Block counts: [0, 0]
78// LLVM-HOST: Instrumentation level: IR
79
80// LLVM-DEVICE-LABEL: __omp_offloading_{{[_0-9a-zA-Z]*}}_main_{{[_0-9a-zA-Z]*}}:
81// LLVM-DEVICE: Hash: {{0[xX][0-9a-fA-F]+}}
82// LLVM-DEVICE: Counters: 3
83// LLVM-DEVICE: Block counts: [10, {{.*}}, 1]
84// LLVM-DEVICE: Instrumentation level: IR
85
86// CLANG-HOST-LABEL: main:
87// CLANG-HOST: Hash: {{0[xX][0-9a-fA-F]+}}
88// CLANG-HOST: Counters: 2
89// CLANG-HOST: Function count: 1
90// CLANG-HOST: Block counts: [20]
91
92// CLANG-HOST-LABEL: __omp_offloading_{{[_0-9a-zA-Z]*}}_main_{{[_0-9a-zA-Z]*}}:
93// CLANG-HOST: Hash: {{0[xX][0-9a-fA-F]+}}
94// CLANG-HOST: Counters: 2
95// CLANG-HOST: Function count: 0
96// CLANG-HOST: Block counts: [0]
97// CLANG-HOST: Instrumentation level: Front-end
98
99// CLANG-DEV-LABEL: __omp_offloading_{{[_0-9a-zA-Z]*}}_main_{{[_0-9a-zA-Z]*}}:
100// CLANG-DEV: Hash: {{0[xX][0-9a-fA-F]+}}
101// CLANG-DEV: Counters: 2
102// CLANG-DEV: Block counts: [10]
103// CLANG-DEV: Instrumentation level: Front-end
104

source code of offload/test/offloading/gpupgo/pgo_device_and_host.c