This is an archive of the discontinued LLVM Phabricator instance.

Cmake config for Propeller Optimized Clang
Needs RevisionPublic

Authored by tmsriram on Dec 16 2022, 4:11 PM.

Details

Summary

Config to build a Propeller Optimized Clang.

I added a config to build clang with Propeller (without PGO). I will follow this up with a PGO + Propeller config. This collects profiles by building clang again. It automatically checks for perf PMU + LBR support. The profile conversion tool, create_llvm_prof, can be pointed at by setting variable: -DPATH_TO_CREATE_LLVM_PROF=

Doing the following will build a Propeller optimized clang:

$ cmake -G Ninja -DPATH_TO_CREATE_LLVM_PROF=/bin/create_llvm_prof -C ../llvm-project/clang/cmake/caches/Propeller.cmake ../llvm-project/llvm
$ ninja propeller-opt-binary

The optimized binary is in: tools/clang/propeller-artifacts/propeller-optimized-clang/bin/clang

Building Propeller with clang requires branch sampling support from the processor's PMU. This assumes that the config is being run on an Intel machine. If this is being run on an AMD machine, the perf command needs to be changed by setting the following variable:

-DPROPELLER_PERF_PROFILE_COLLECTION_PREFIX=

I measured a 20% performance speedup in building clang using a Propeller optimized clang.

Diff Detail

Event Timeline

tmsriram created this revision.Dec 16 2022, 4:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 16 2022, 4:11 PM
Herald added a subscriber: wenlei. · View Herald Transcript
tmsriram requested review of this revision.Dec 16 2022, 4:11 PM
tmsriram updated this revision to Diff 483689.Dec 16 2022, 4:17 PM

Add Propeller.cmake config

tmsriram updated this revision to Diff 483691.Dec 16 2022, 4:22 PM

Added more comments.

amharc requested changes to this revision.Dec 27 2022, 7:14 AM

I think that clang/cmake/caches/README.txt should be updated too, with a description of how to use it (which would be more permanent than the revision summary).

clang/CMakeLists.txt
1041–1048

I think this unnecessarily depends on the CMake generator being Ninja (and not e.g. Unix makefiles). What about modifying ExternalProject_Add(clang-propeller-profiles below to also include a BUILD_COMMAND which would start with ${PROPELLER_PERF_PROFILE_COLLECTION_PREFIX} -o ${PROPELLER_PERF_DATA} -- ${CMAKE_COMMAND} --build?

1058–1062

The indentation here seems to be a bit off.

1148–1157

Shouldn't these be indented? (and other CMAKE_ARGS instances too)

clang/cmake/caches/Propeller.cmake
10

Do we know if cycles:u behaves better than br_inst_retired:near_taken:u? The latter would at least theoretically provide (near) uniform sampling of branches.

This revision now requires changes to proceed.Dec 27 2022, 7:14 AM