-
-
Notifications
You must be signed in to change notification settings - Fork 37
Expand file tree
/
Copy pathpgo.yaml
More file actions
130 lines (112 loc) · 4.79 KB
/
pgo.yaml
File metadata and controls
130 lines (112 loc) · 4.79 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# SPDX-FileCopyrightText: 2023 AerynOS Developers
# SPDX-License-Identifier: MPL-2.0
definitions:
- pgo_stage : "%(pgo_stage)"
actions:
# Actions required for PGO builds
- llvm_merge_s1:
description: Merge LLVM profile data, copies to combined.profdata in case there's no stage2
command: |
llvm-profdata merge --failure-mode=all -output=%(pgo_dir)/ir.profdata %(pgo_dir)/IR/default*.profraw
cp %(pgo_dir)/ir.profdata %(pgo_dir)/combined.profdata
- llvm_merge_s2:
description: Merge LLVM profile data after stage2 PGO workload
command: |
rm %(pgo_dir)/combined.profdata
llvm-profdata merge --failure-mode=all -output=%(pgo_dir)/combined.profdata %(pgo_dir)/ir.profdata %(pgo_dir)/CS/default*.profraw
- bolt_instr:
description: Instrument file with llvm-bolt
command: |
binstr(){
mv ${1} ${1}.orig
mkdir -p %(pgo_dir)/BOLT
llvm-bolt ${1}.orig -instrument --instrumentation-file=%(pgo_dir)/BOLT/$(basename ${1}) --instrumentation-file-append-pid ${2} ${3} ${4} -o ${1}
}
binstr
- bolt_merge:
description: Instrument file with llvm-bolt
command: |
bmerge(){
merge-fdata %(pgo_dir)/BOLT/$(basename ${1}).*.fdata > %(pgo_dir)/$(basename ${1}).fdata
}
bmerge
- bolt_opt:
description: Apply bolt profile
command: |
boptim(){
llvm-bolt ${1}.orig -o ${1}.bolt -data=%(pgo_dir)/$(basename ${1}).fdata -reorder-blocks=ext-tsp -reorder-functions=hfsort+ -split-functions -split-strategy=cdsplit -plt=all -peepholes=all -split-eh -dyno-stats -icf=1 -use-gnu-stack -use-old-text -update-debug-sections ${2} ${3} ${4}
cp ${1}.bolt ${1}
}
boptim
dependencies:
- binary(llvm-bolt)
- bolt_perf:
description: Collect perf data suitable for the bolt macros
command: |
bperf(){
mkdir -p %(pgo_dir)/BOLT
perf record -F 6000 -e cycles:u -j any,u -o %(pgo_dir)/BOLT/perf.data -- ${@}
}
bperf
dependencies:
- binary(perf)
- bolt_perf2bolt:
description: Convert perf data into bolt equivalent
command: |
bperf2bolt(){
cp ${1} ${1}.orig
perf2bolt -ignore-build-id -p %(pgo_dir)/BOLT/perf.data -o %(pgo_dir)/$(basename ${1}).fdata ${1}
}
bperf2bolt
tuning :
# A set of groups we can toggle from the "tune" key
# Enable pgosample
- pgosample:
enabled: pgosample
# Enable pgostage1
- pgostage1:
enabled: pgostage1
# Enable pgostage2
- pgostage2:
enabled: pgostage2
# Enable pgouse
- pgouse:
enabled: pgouse
flags :
# PGO flag options
# PGO sample flags for when workload is not comprehensive (workload builds only)
- pgosample:
llvm:
c : "-fno-profile-sample-accurate"
cxx : "-fno-profile-sample-accurate"
ld : "-fno-profile-sample-accurate"
gnu:
c : "-fprofile-partial-training"
cxx : "-fprofile-partial-training"
ld : "-fprofile-partial-training"
# PGO stage1 flags for ProfileStage1 (workload builds only)
- pgostage1:
llvm:
c : "-fprofile-generate=%(pgo_dir)/IR"
cxx : "-fprofile-generate=%(pgo_dir)/IR"
ld : "-fprofile-generate=%(pgo_dir)/IR"
gnu:
c : "-fprofile-generate -fprofile-dir=%(pgo_dir)"
cxx : "-fprofile-generate -fprofile-dir=%(pgo_dir)"
ld : "-fprofile-generate -fprofile-dir=%(pgo_dir)"
# PGO stage2 flags for ProfileStage2 (workload builds only)
- pgostage2:
llvm:
c : "-fprofile-use=%(pgo_dir)/ir.profdata -fcs-profile-generate=%(pgo_dir)/CS"
cxx : "-fprofile-use=%(pgo_dir)/ir.profdata -fcs-profile-generate=%(pgo_dir)/CS"
ld : "-fprofile-use=%(pgo_dir)/ir.profdata -fcs-profile-generate=%(pgo_dir)/CS"
# PGO final flags for ProfileUse (workload builds only)
- pgouse:
llvm:
c : "-fprofile-use=%(pgo_dir)/combined.profdata"
cxx : "-fprofile-use=%(pgo_dir)/combined.profdata"
ld : "-fprofile-use=%(pgo_dir)/combined.profdata"
gnu:
c : "-fprofile-use -fprofile-dir=%(pgo_dir) -fprofile-correction"
cxx : "-fprofile-use -fprofile-dir=%(pgo_dir) -fprofile-correction"
ld : "-fprofile-use -fprofile-dir=%(pgo_dir) -fprofile-correction"