59
59
FLAGS = flags .FLAGS
60
60
61
61
default_test_descriptions = [
62
- './compiler_opt/tools/chromium_test_descriptions/base_perftests.json' ,
63
- './compiler_opt/tools/chromium_test_descriptions/browser_tests.json' ,
64
- './compiler_opt/tools/chromium_test_descriptions/components_perftests.json'
62
+ './compiler_opt/tools/chromium_test_descriptions/base_perftests.json' ,
63
+ './compiler_opt/tools/chromium_test_descriptions/browser_tests.json' ,
64
+ './compiler_opt/tools/chromium_test_descriptions/components_perftests.json'
65
65
]
66
66
67
- flags .DEFINE_multi_string ('test_description' , default_test_descriptions ,
68
- '(Can be defined multiple times) A path to a test'
69
- 'description JSON file containing the test executable'
70
- 'and the tests to run' )
67
+ flags .DEFINE_multi_string (
68
+ 'test_description' , default_test_descriptions ,
69
+ '(Can be defined multiple times) A path to a test'
70
+ 'description JSON file containing the test executable'
71
+ 'and the tests to run' )
71
72
flags .DEFINE_boolean ('compile_tests' , True ,
72
73
'Whether or not to compile the tests from scratch' )
73
74
flags .DEFINE_enum ('advisor' , None , ['release' , 'default' ],
80
81
'The path to your llvm build' )
81
82
flags .DEFINE_boolean ('compile_llvm' , True ,
82
83
'whether or not to compile llvm using the new model' )
83
- flags .DEFINE_boolean ('llvm_use_incremental' , True ,
84
- 'whether or not to use an incremental build while'
85
- 'compiling llvm' )
84
+ flags .DEFINE_boolean (
85
+ 'llvm_use_incremental' , True ,
86
+ 'whether or not to use an incremental build while'
87
+ 'compiling llvm' )
86
88
flags .DEFINE_string ('llvm_source_path' , '/llvm-project' ,
87
89
'The root path of your local llvm-project checkout' )
88
90
flags .DEFINE_string ('model_path' , '' ,
89
91
'The path to the model to use when compiling llvm' )
90
- flags .DEFINE_string ('tensorflow_c_lib_path' , '/tmp/tensorflow' ,
91
- 'The path to an extracted copy of the tensorflow c library' )
92
- flags .DEFINE_string ('chromium_build_path' , './out/Release' ,
93
- 'The chromium build path, relative to the chromium source'
94
- 'directory' )
92
+ flags .DEFINE_string (
93
+ 'tensorflow_c_lib_path' , '/tmp/tensorflow' ,
94
+ 'The path to an extracted copy of the tensorflow c library' )
95
+ flags .DEFINE_string (
96
+ 'chromium_build_path' , './out/Release' ,
97
+ 'The chromium build path, relative to the chromium source'
98
+ 'directory' )
95
99
flags .DEFINE_string ('output_file' , 'output.json' ,
96
100
'The path to the output file (in JSON format)' )
97
- flags .DEFINE_integer ('num_threads' , 1 ,
98
- 'The number of threads to use when running benchmarks.'
99
- 'Should be used with caution' )
100
- flags .DEFINE_multi_string ('perf_counters' ,
101
- ['mem_uops_retired.all_loads' ,
102
- 'mem_uops_retired.all_stores' ],
103
- 'The performance counters to use' )
104
-
105
- def build_chromium_tests (regalloc_advisor : str ,
106
- chromium_build_path : str ,
107
- chromium_source_path : str ,
108
- depot_tools_path : str ,
109
- llvm_build_path : str ,
110
- tests_to_build : List [str ]):
101
+ flags .DEFINE_integer (
102
+ 'num_threads' , 1 , 'The number of threads to use when running benchmarks.'
103
+ 'Should be used with caution' )
104
+ flags .DEFINE_multi_string (
105
+ 'perf_counters' ,
106
+ ['mem_uops_retired.all_loads' , 'mem_uops_retired.all_stores' ],
107
+ 'The performance counters to use' )
108
+
109
+
110
+ def build_chromium_tests (regalloc_advisor : str , chromium_build_path : str ,
111
+ chromium_source_path : str , depot_tools_path : str ,
112
+ llvm_build_path : str , tests_to_build : List [str ]):
111
113
"""Builds the chromium test suite
112
114
113
115
This function will build the specified chromium tests using the specified
@@ -139,16 +141,11 @@ def build_chromium_tests(regalloc_advisor: str,
139
141
f'-mllvm -regalloc-enable-advisor={ regalloc_advisor } '
140
142
141
143
gn_args = [
142
- 'is_official_build=true' ,
143
- 'use_thin_lto=false' ,
144
- 'is_cfi=false' ,
145
- 'use_cfi_icall=false' ,
146
- 'use_cfi_cast=false' ,
147
- 'clang_use_chrome_plugins=false' ,
148
- 'is_debug=false' ,
149
- 'symbol_level=0' ,
150
- 'custom_toolchain=\\ \" //build/toolchain/linux/unbundle:default\\ \" ' ,
151
- 'host_toolchain=\\ \" //build/toolchain/linux/unbundle:default\\ \" '
144
+ 'is_official_build=true' , 'use_thin_lto=false' , 'is_cfi=false' ,
145
+ 'use_cfi_icall=false' , 'use_cfi_cast=false' ,
146
+ 'clang_use_chrome_plugins=false' , 'is_debug=false' , 'symbol_level=0' ,
147
+ 'custom_toolchain=\\ \" //build/toolchain/linux/unbundle:default\\ \" ' ,
148
+ 'host_toolchain=\\ \" //build/toolchain/linux/unbundle:default\\ \" '
152
149
]
153
150
154
151
gn_args_string = '--args="'
@@ -157,22 +154,23 @@ def build_chromium_tests(regalloc_advisor: str,
157
154
gn_args_string += '"'
158
155
159
156
gn_config_command = 'gn gen ' + chromium_build_path + ' ' + gn_args_string
160
- with subprocess .Popen (gn_config_command ,
161
- env = new_environment ,
162
- cwd = chromium_source_path ,
163
- shell = True ) as gn_config_process :
157
+ with subprocess .Popen (
158
+ gn_config_command ,
159
+ env = new_environment ,
160
+ cwd = chromium_source_path ,
161
+ shell = True ) as gn_config_process :
164
162
gn_config_process .wait ()
165
163
166
164
ninja_compile_command = ['autoninja' , '-C' , chromium_build_path ]
167
165
ninja_compile_command .extend (tests_to_build )
168
- with subprocess .Popen (ninja_compile_command ,
169
- env = new_environment ,
170
- cwd = chromium_source_path ) as ninja_compile_process :
166
+ with subprocess .Popen (
167
+ ninja_compile_command , env = new_environment ,
168
+ cwd = chromium_source_path ) as ninja_compile_process :
171
169
ninja_compile_process .wait ()
172
170
173
- def run_tests ( tests_to_run : List [ Dict [ str , Union [ str , List [ str ]]]],
174
- chromium_absolute_build_path : str ,
175
- num_threads : int ,
171
+
172
+ def run_tests ( tests_to_run : List [ Dict [ str , Union [ str , List [ str ]]]] ,
173
+ chromium_absolute_build_path : str , num_threads : int ,
176
174
perf_counters : List [str ]):
177
175
"""A utility to run a set of chromium tests
178
176
@@ -194,12 +192,12 @@ def run_tests(tests_to_run: List[Dict[str,Union[str, List[str]]]],
194
192
for test in tests_to_run :
195
193
executable_path = os .path .join (chromium_absolute_build_path ,
196
194
test ['executable' ])
197
- test_data .extend (gtest_executable_utils .run_test_suite (test ,
198
- executable_path ,
199
- perf_counters ,
200
- num_threads ))
195
+ test_data .extend (
196
+ gtest_executable_utils .run_test_suite (test , executable_path ,
197
+ perf_counters , num_threads ))
201
198
return test_data
202
199
200
+
203
201
def main (_ ):
204
202
test_descriptions = []
205
203
for test_description in FLAGS .test_description :
@@ -211,32 +209,24 @@ def main(_):
211
209
test_executables .append (test_description ['executable' ])
212
210
213
211
if FLAGS .compile_llvm :
214
- benchmarking_utils .build_llvm (FLAGS .model_path ,
215
- FLAGS .llvm_use_incremental ,
216
- FLAGS .llvm_build_path ,
217
- FLAGS .llvm_source_path ,
212
+ benchmarking_utils .build_llvm (FLAGS .model_path , FLAGS .llvm_use_incremental ,
213
+ FLAGS .llvm_build_path , FLAGS .llvm_source_path ,
218
214
FLAGS .tensorflow_c_lib_path )
219
215
220
216
if FLAGS .compile_tests :
221
- build_chromium_tests (FLAGS .advisor ,
222
- FLAGS .chromium_build_path ,
223
- FLAGS .chromium_src_path ,
224
- FLAGS .depot_tools_path ,
225
- FLAGS .llvm_build_path ,
226
- test_executables )
217
+ build_chromium_tests (FLAGS .advisor , FLAGS .chromium_build_path ,
218
+ FLAGS .chromium_src_path , FLAGS .depot_tools_path ,
219
+ FLAGS .llvm_build_path , test_executables )
227
220
228
221
chromium_absolute_build_path = os .path .join (FLAGS .chromium_src_path ,
229
222
FLAGS .chromium_build_path )
230
- test_data = run_tests (test_descriptions ,
231
- chromium_absolute_build_path ,
232
- FLAGS .num_threads ,
233
- FLAGS .perf_counters )
223
+ test_data = run_tests (test_descriptions , chromium_absolute_build_path ,
224
+ FLAGS .num_threads , FLAGS .perf_counters )
234
225
235
226
with open (FLAGS .output_file , 'w' , encoding = 'UTF-8' ) as output_file :
236
- output_data = {
237
- 'benchmarks' : test_data
238
- }
227
+ output_data = {'benchmarks' : test_data }
239
228
output_file .write (json .dumps (output_data , indent = 4 ))
240
229
230
+
241
231
if __name__ == '__main__' :
242
232
app .run (main )
0 commit comments