google / ml-compiler-opt

Infrastructure for Machine Learning Guided Optimization (MLGO) in LLVM.
Apache License 2.0
629 stars 93 forks source link

Why “-static” affects the test results of the model #331

Closed 18liumin closed 1 month ago

18liumin commented 10 months ago

use -enable-ml-inliner=release cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=${PWD}/install -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DTEST_SUITE_COLLECT_COMPILE_TIME=OFF -DCMAKE_C_FLAGS="'-fuse-ld=lld -static -mllvm -enable-ml-inliner=release'" -DCMAKE_CXX_FLAGS="'-fuse-ld=lld - -static -mllvm -enable-ml-inliner=release'" -DTEST_SUITE_SPE C2017_ROOT=/usr1/project/cpu2017 -C ../test-suite/cmake/caches/Oz.cmake /usr1/project/llvm-install/test-suite

no -enable-ml-inliner=release cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=${PWD}/install -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DTEST_SUITE_COLLECT_COMPILE_TIME=OFF -DCMAKE_C_FLAGS="'-fuse-ld=lld -static '" -DCMAKE_CXX_FLAGS="'-fuse-ld=lld -static l'" -DTEST_SUITE_SPEC2017_ROOT=/usr1/project/cpu2017 -C ../test-suite/cmake/caches/Oz.cmake /usr1/project/llvm-install/test-suite

example1 (base) @szvphis6315984:~/project/llvm-install$ llvm-size test-build-model/602.gcc_s text data bss dec hex filename 8439896 458417 1170152 10068465 99a1f1 test-build-model/602.gcc_s (base) @szvphis6315984:~/project/llvm-install$ llvm-size test-build-no-model/602.gcc_s text data bss dec hex filename 8360512 458377 1170152 9989041 986bb1 test-build-no-model/602.gcc_s

example2 (base) @szvphis6315984:~/project/llvm-install$ llvm-size test-build-model/526.blender_r text data bss dec hex filename 11232454 4918192 450328 16600974 fd4f8e test-build-model/526.blender_r (base) @szvphis6315984:~/project/llvm-install$ llvm-size test-build-no-model/526.blender_r text data bss dec hex filename 11101990 4917904 450296 16470190 fb50ae test-build-no-model/526.blender_r

use -enable-ml-inliner=release cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=${PWD}/install -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DTEST_SUITE_COLLECT_COMPILE_TIME=OFF -DCMAKE_C_FLAGS="'-fuse-ld=lld -mllvm -enable-ml-inliner=release'" -DCMAKE_CXX_FLAGS="'-fuse-ld=lld - -static -mllvm -enable-ml-inliner=release'" -DTEST_SUITE_SPE C2017_ROOT=/usr1/project/cpu2017 -C ../test-suite/cmake/caches/Oz.cmake /usr1/project/llvm-install/test-suite

no -enable-ml-inliner=release cmake -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_PREFIX=${PWD}/install -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DTEST_SUITE_COLLECT_COMPILE_TIME=OFF -DCMAKE_C_FLAGS="'-fuse-ld=lld '" -DCMAKE_CXX_FLAGS="'-fuse-ld=lld '" -DTEST_SUITE_SPEC2017_ROOT=/usr1/project/cpu2017 -C ../test-suite/cmake/caches/Oz.cmake /usr1/project/llvm-install/test-suite

example1 (base) @szvphis6315984:~/project/llvm-install$ llvm-size test-build-model/602.gcc_s text data bss dec hex filename 8115390 435600 1146560 9697550 93f90e test-build-model/602.gcc_s (base) @szvphis6315984:~/project/llvm-install$ llvm-size test-build-no-model/602.gcc_s text data bss dec hex filename 8360512 458377 1170152 9989041 986bb1 test-build-no-model/602.gcc_s

example2 (base) @szvphis6315984:~/project/llvm-install$ llvm-size test-build-model/526.blender_r text data bss dec hex filename 12605733 4866844 414112 17886689 110ede1 test-build-model/526.blender_r (base) @szvphis6315984:~/project/llvm-install$ llvm-size test-build-no-model/526.blender_r text data bss dec hex filename 11101990 4917904 450296 16470190 fb50ae test-build-no-model/526.blender_r

mtrofin commented 10 months ago

Most probably the model wasn't one trained on a corpus representative to what you're validating on - what model did you use? See also Issue #310, this comment.

If you're using the latest model we released, that was trained on predominantly C++ systems/server-side code, which looks nothing like spec. Works well on clang though.

About -static - not sure; so the absolute difference between base and experiment changes when you pass -static?

18liumin commented 10 months ago

Most probably the model wasn't one trained on a corpus representative to what you're validating on - what model did you use? See also Issue #310, this comment.

If you're using the latest model we released, that was trained on predominantly C++ systems/server-side code, which looks nothing like spec. Works well on clang though.

About -static - not sure; so the absolute difference between base and experiment changes when you pass -static?

yes, With static linking, the model results will be worse. With dynamic linking, the model results will be better