Skip to content

Commit d9859ad

Browse files
tstellarGroverkss
authored andcommitted
[Clang][perf-training] Do build of libLLVMSupport for perf training (llvm#111625)
This adds a build of the libLLVMSupport to the lit suite that is used for generating profile data. This helps to improve both PGO and BOLT optimization of clang over the existing hello world training program. I considered building all of LLVM instead of just libLLVMSupport, but there is only a marginal increase in performance for PGO only builds when training with a build of all of LLVM, and I didn't think it was enough to justify the increased build times given that it is the default configuration. The benchmark[1] I did showed that using libLLVMSupport for training gives a 1.35 +- 0.02 speed up for clang optimized with PGO + BOLT vs just 1.05 +- 0.01 speed up when training with hello world. For comparison, training with a full LLVM build gave a speed up of 1.35 +- 0.1. Raw data: | PGO Training | BOLT Training | Speed Up | Error Range | | ------------ | ------------- | -------- | ----------- | | LLVM Support | LLVM Support | 1.35 | 0.02 | | LLVM All | LLVM All | 1.34 | 0.01 | | LLVM Support | Hello World | 1.29 | 0.02 | | LLVM All | PGO-ONLY | 1.27 | 0.02 | | LLVM Support | PGO-ONLY | 1.22 | 0.02 | | Hello World | Hello World | 1.05 | 0.01 | | Hello World | PGO-ONLY | 1.03 | 0.01 | Time it takes to generate profile data (on a 64-core system): | Training Data | PGO | BOLT | | ------------- | ----- | ----- | | LLVM All | 1090s | 3239s | | LLVM Support | 91s | 655s | | Hello World | 2s | 9s | [1] Benchmark was compiling SemaDecl.cpp
1 parent cccff9b commit d9859ad

File tree

5 files changed

+15
-1
lines changed

5 files changed

+15
-1
lines changed

clang/utils/perf-training/bolt.lit.cfg

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@ config.substitutions.append(("%clang_cpp", f" {config.clang} --driver-mode=g++ "
4949
config.substitutions.append(("%clang_skip_driver", config.clang))
5050
config.substitutions.append(("%clang", config.clang))
5151
config.substitutions.append(("%test_root", config.test_exec_root))
52+
config.substitutions.append(('%cmake_generator', config.cmake_generator))
53+
config.substitutions.append(('%cmake', config.cmake_exe))
54+
config.substitutions.append(('%llvm_src_dir', config.llvm_src_dir))

clang/utils/perf-training/bolt.lit.site.cfg.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ config.python_exe = "@Python3_EXECUTABLE@"
1111
config.clang_obj_root = path(r"@CLANG_BINARY_DIR@")
1212
config.clang_bolt_mode = "@CLANG_BOLT@"
1313
config.clang_bolt_name = "@CLANG_BOLT_INSTRUMENTED@"
14+
config.cmake_exe = "@CMAKE_COMMAND@"
15+
config.llvm_src_dir ="@CMAKE_SOURCE_DIR@"
16+
config.cmake_generator ="@CMAKE_GENERATOR@"
1417

1518
# Let the main config do the real work.
1619
lit_config.load_config(config, "@CLANG_SOURCE_DIR@/utils/perf-training/bolt.lit.cfg")

clang/utils/perf-training/lit.cfg

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ config.test_format = lit.formats.ShTest(use_lit_shell == "0")
3434
config.substitutions.append( ('%clang_cpp_skip_driver', ' %s %s %s ' % (cc1_wrapper, config.clang, sysroot_flags)))
3535
config.substitutions.append( ('%clang_cpp', ' %s --driver-mode=g++ %s ' % (config.clang, sysroot_flags)))
3636
config.substitutions.append( ('%clang_skip_driver', ' %s %s %s ' % (cc1_wrapper, config.clang, sysroot_flags)))
37-
config.substitutions.append( ('%clang', ' %s %s ' % (config.clang, sysroot_flags) ) )
37+
config.substitutions.append( ('%clang', '%s %s ' % (config.clang, sysroot_flags) ) )
3838
config.substitutions.append( ('%test_root', config.test_exec_root ) )
39+
config.substitutions.append( ('%cmake_generator', config.cmake_generator ) )
40+
config.substitutions.append( ('%cmake', config.cmake_exe ) )
41+
config.substitutions.append( ('%llvm_src_dir', config.llvm_src_dir ) )
3942

4043
config.environment['LLVM_PROFILE_FILE'] = 'perf-training-%4m.profraw'
4144

clang/utils/perf-training/lit.site.cfg.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@"
88
config.test_source_root = "@CLANG_PGO_TRAINING_DATA@"
99
config.target_triple = "@LLVM_TARGET_TRIPLE@"
1010
config.python_exe = "@Python3_EXECUTABLE@"
11+
config.cmake_exe = "@CMAKE_COMMAND@"
12+
config.llvm_src_dir ="@CMAKE_SOURCE_DIR@"
13+
config.cmake_generator ="@CMAKE_GENERATOR@"
1114

1215
# Let the main config do the real work.
1316
lit_config.load_config(config, "@CLANG_SOURCE_DIR@/utils/perf-training/lit.cfg")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
RUN: %cmake -G %cmake_generator -B %t -S %llvm_src_dir -DCMAKE_C_COMPILER=%clang -DCMAKE_CXX_COMPILER=%clang -DCMAKE_CXX_FLAGS="--driver-mode=g++" -DCMAKE_BUILD_TYPE=Release
2+
RUN: %cmake --build %t -v --target LLVMSupport

0 commit comments

Comments
 (0)