Skip to content

Commit c732774

Browse files
cyyeverfacebook-github-bot
authored andcommitted
Add interprocedural optimization option (#4457)
Summary: Pull Request resolved: #4457 X-link: facebookresearch/FBGEMM#1515 Add IPO option to enable link time optimization, which is disabled by default. AVX files use inline asm code and can't be parsed by lto implementations, so they are excluded. CUDA code is also excluded. This optimization has reduced libfbgemm.a from 80Mb to 64Mb on my host, using GCC 15. We have attempts to enable link time optimization on PyTorch, fixing FBGEMM builds is the important prerequisite. Pull Request resolved: #4452 Reviewed By: cthi Differential Revision: D77912148 Pulled By: q10 fbshipit-source-id: 8ad52ad4c556020e69a39166c867248024a04917
1 parent c580216 commit c732774

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ option(FBGEMM_BUILD_TESTS "Build fbgemm unit tests" ON)
105105
option(FBGEMM_BUILD_BENCHMARKS "Build fbgemm benchmarks" ON)
106106
option(FBGEMM_BUILD_DOCS "Build fbgemm documentation" OFF)
107107
option(FBGEMM_BUILD_FBGEMM_GPU "Build fbgemm_gpu library" OFF)
108+
option(FBGEMM_USE_IPO "Build fbgemm with interprocedural optimization" OFF)
108109
option(DISABLE_FBGEMM_AUTOVEC "Disable FBGEMM Autovec" OFF)
109110

110111
if(FBGEMM_BUILD_TESTS)
@@ -420,3 +421,12 @@ endif()
420421
if(NOT HAVE_GNU_F2H_IEEE)
421422
add_definitions(-DMISSING_GNU_F2H_IEEE)
422423
endif()
424+
425+
if(FBGEMM_USE_IPO)
426+
include(CheckIPOSupported)
427+
check_ipo_supported()
428+
set_property(TARGET fbgemm_generic PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
429+
set_property(TARGET fbgemm_avx2 PROPERTY INTERPROCEDURAL_OPTIMIZATION FALSE)
430+
set_property(TARGET fbgemm_avx512 PROPERTY INTERPROCEDURAL_OPTIMIZATION FALSE)
431+
set_property(TARGET fbgemm_autovec PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
432+
endif()

0 commit comments

Comments
 (0)