Skip to content

Commit 10cb0f6

Browse files
[PGO][Offload] Make PGO GPU tests atomic
1 parent 0489447 commit 10cb0f6

File tree

2 files changed

+26
-24
lines changed

2 files changed

+26
-24
lines changed

offload/test/offloading/gpupgo/pgo1.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
// RUN: %libomptarget-compile-generic -fcreate-profile \
2-
// RUN: -Xarch_device -fprofile-generate
2+
// RUN: -Xarch_device -fprofile-generate \
3+
// RUN: -Xarch_device -fprofile-update=atomic
34
// RUN: env LLVM_PROFILE_FILE=%basename_t.llvm.profraw \
45
// RUN: %libomptarget-run-generic 2>&1
56
// RUN: llvm-profdata show --all-functions --counts \
67
// RUN: %target_triple.%basename_t.llvm.profraw | \
78
// RUN: %fcheck-generic --check-prefix="LLVM-PGO"
89

910
// RUN: %libomptarget-compile-generic -fcreate-profile \
10-
// RUN: -Xarch_device -fprofile-instr-generate
11+
// RUN: -Xarch_device -fprofile-instr-generate \
12+
// RUN: -Xarch_device -fprofile-update=atomic
1113
// RUN: env LLVM_PROFILE_FILE=%basename_t.clang.profraw \
1214
// RUN: %libomptarget-run-generic 2>&1
1315
// RUN: llvm-profdata show --all-functions --counts \
@@ -23,18 +25,20 @@ int test2(int a) { return a * 2; }
2325
int main() {
2426
int m = 2;
2527
#pragma omp target
26-
for (int i = 0; i < 10; i++) {
27-
m = test1(m);
28-
for (int j = 0; j < 2; j++) {
29-
m = test2(m);
28+
{
29+
for (int i = 0; i < 10; i++) {
30+
m = test1(m);
31+
for (int j = 0; j < 2; j++) {
32+
m = test2(m);
33+
}
3034
}
3135
}
3236
}
3337

3438
// LLVM-PGO-LABEL: __omp_offloading_{{[_0-9a-zA-Z]*}}_main_{{[_0-9a-zA-Z]*}}:
3539
// LLVM-PGO: Hash: {{0[xX][0-9a-fA-F]+}}
3640
// LLVM-PGO: Counters: 4
37-
// LLVM-PGO: Block counts: [20, 10, 2, 1]
41+
// LLVM-PGO: Block counts: [20, 10, {{.*}}, 1]
3842

3943
// LLVM-PGO-LABEL: test1:
4044
// LLVM-PGO: Hash: {{0[xX][0-9a-fA-F]+}}
@@ -53,14 +57,10 @@ int main() {
5357
// LLVM-PGO-SAME: 3
5458
// LLVM-PGO-LABEL: Maximum function count:
5559
// LLVM-PGO-SAME: 20
56-
// LLVM-PGO-LABEL: Maximum internal block count:
57-
// LLVM-PGO-SAME: 10
5860

5961
// CLANG-PGO-LABEL: __omp_offloading_{{[_0-9a-zA-Z]*}}_main_{{[_0-9a-zA-Z]*}}:
6062
// CLANG-PGO: Hash: {{0[xX][0-9a-fA-F]+}}
61-
// CLANG-PGO: Counters: 3
62-
// CLANG-PGO: Function count: 0
63-
// CLANG-PGO: Block counts: [11, 20]
63+
// CLANG-PGO: Block counts: [10, 20]
6464

6565
// CLANG-PGO-LABEL: test1:
6666
// CLANG-PGO: Hash: {{0[xX][0-9a-fA-F]+}}
@@ -78,7 +78,5 @@ int main() {
7878
// CLANG-PGO-SAME: Front-end
7979
// CLANG-PGO-LABEL: Functions shown:
8080
// CLANG-PGO-SAME: 3
81-
// CLANG-PGO-LABEL: Maximum function count:
82-
// CLANG-PGO-SAME: 20
8381
// CLANG-PGO-LABEL: Maximum internal block count:
8482
// CLANG-PGO-SAME: 20

offload/test/offloading/gpupgo/pgo2.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
// RUN: %libomptarget-compile-generic -fprofile-generate
1+
// RUN: %libomptarget-compile-generic -fprofile-generate \
2+
// RUN: -fprofile-update=atomic
23
// RUN: env LLVM_PROFILE_FILE=%basename_t.llvm.profraw \
34
// RUN: %libomptarget-run-generic 2>&1
45
// RUN: llvm-profdata show --all-functions --counts \
@@ -8,7 +9,8 @@
89
// RUN: %target_triple.%basename_t.llvm.profraw \
910
// RUN: | %fcheck-generic --check-prefix="LLVM-DEVICE"
1011

11-
// RUN: %libomptarget-compile-generic -fprofile-instr-generate
12+
// RUN: %libomptarget-compile-generic -fprofile-instr-generate \
13+
// RUN: -fprofile-update=atomic
1214
// RUN: env LLVM_PROFILE_FILE=%basename_t.clang.profraw \
1315
// RUN: %libomptarget-run-generic 2>&1
1416
// RUN: llvm-profdata show --all-functions --counts \
@@ -18,7 +20,8 @@
1820
// RUN: %target_triple.%basename_t.clang.profraw | \
1921
// RUN: %fcheck-generic --check-prefix="CLANG-DEV"
2022

21-
// RUN: %libomptarget-compile-generic -Xarch_host -fprofile-generate
23+
// RUN: %libomptarget-compile-generic -Xarch_host -fprofile-generate \
24+
// RUN: -fprofile-update=atomic
2225
// RUN: env LLVM_PROFILE_FILE=%basename_t.nogpu.profraw \
2326
// RUN: %libomptarget-run-generic 2>&1
2427
// RUN: llvm-profdata show --all-functions --counts \
@@ -27,7 +30,7 @@
2730
// RUN: not test -e %target_triple.%basename_t.nogpu.profraw
2831

2932
// RUN: %libomptarget-compile-generic -Xarch_host -fprofile-generate \
30-
// RUN: -Xarch_device -fprofile-instr-generate
33+
// RUN: -Xarch_device -fprofile-instr-generate -fprofile-update=atomic
3134
// RUN: env LLVM_PROFILE_FILE=%basename_t.hidf.profraw \
3235
// RUN: %libomptarget-run-generic 2>&1
3336
// RUN: llvm-profdata show --all-functions --counts \
@@ -38,7 +41,7 @@
3841
// RUN: | %fcheck-generic --check-prefix="CLANG-DEV"
3942

4043
// RUN: %libomptarget-compile-generic -Xarch_device -fprofile-generate \
41-
// RUN: -Xarch_host -fprofile-instr-generate
44+
// RUN: -Xarch_host -fprofile-instr-generate -fprofile-update=atomic
4245
// RUN: env LLVM_PROFILE_FILE=%basename_t.hfdi.profraw \
4346
// RUN: %libomptarget-run-generic 2>&1
4447
// RUN: llvm-profdata show --all-functions --counts \
@@ -59,8 +62,10 @@ int main() {
5962

6063
int device_var = 1;
6164
#pragma omp target
62-
for (int i = 0; i < 10; i++) {
63-
device_var *= i;
65+
{
66+
for (int i = 0; i < 10; i++) {
67+
device_var *= i;
68+
}
6469
}
6570
}
6671

@@ -78,7 +83,7 @@ int main() {
7883
// LLVM-DEVICE-LABEL: __omp_offloading_{{[_0-9a-zA-Z]*}}_main_{{[_0-9a-zA-Z]*}}:
7984
// LLVM-DEVICE: Hash: {{0[xX][0-9a-fA-F]+}}
8085
// LLVM-DEVICE: Counters: 3
81-
// LLVM-DEVICE: Block counts: [10, 2, 1]
86+
// LLVM-DEVICE: Block counts: [10, {{.*}}, 1]
8287
// LLVM-DEVICE: Instrumentation level: IR
8388

8489
// CLANG-HOST-LABEL: main:
@@ -97,6 +102,5 @@ int main() {
97102
// CLANG-DEV-LABEL: __omp_offloading_{{[_0-9a-zA-Z]*}}_main_{{[_0-9a-zA-Z]*}}:
98103
// CLANG-DEV: Hash: {{0[xX][0-9a-fA-F]+}}
99104
// CLANG-DEV: Counters: 2
100-
// CLANG-DEV: Function count: 0
101-
// CLANG-DEV: Block counts: [11]
105+
// CLANG-DEV: Block counts: [10]
102106
// CLANG-DEV: Instrumentation level: Front-end

0 commit comments

Comments
 (0)