File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -70,6 +70,21 @@ else()
7070 add_compile_options ($<$<NOT :$<CONFIG :Debug >>:-O3 >)
7171endif ()
7272
73+ find_package (OpenMP REQUIRED )
74+
75+ # Check for LTO support (which in CMake is lumped in with IPO).
76+ include (CheckIPOSupported )
77+ check_ipo_supported (RESULT HAVE_IPO )
78+
79+ # Helper function for setting LTO flag (but only if the config is not debug).
80+ function (enable_lto target_name )
81+ if (HAVE_IPO)
82+ set_property (TARGET ${target_name} PROPERTY
83+ INTERPROCEDURAL_OPTIMIZATION $<NOT :$<CONFIG :Debug >>
84+ )
85+ endif ()
86+ endfunction ()
87+
7388# Always build the basic part.
7489add_subdirectory (pybind_interface/basic )
7590add_subdirectory (pybind_interface/decide )
Original file line number Diff line number Diff line change @@ -48,18 +48,10 @@ HIPCCFLAGS := $(BASE_HIPCCFLAGS) $(HIPCCFLAGS)
4848
4949LTO_FLAGS := -flto=auto
5050USING_CLANG := $(shell $(CXX ) --version | grep -isq clang && echo "true")
51- ifeq ($(USING_CLANG ) ," true" )
51+ ifeq ($(USING_CLANG ) ,true)
5252 LTO_FLAGS := -flto
5353endif
5454
55- # Test if OpenMP header files are available and we can link with the library.
56- OMP_CHECK_CMD := echo "int main() { return 0; }" | \
57- $(CXX ) -fopenmp -x c++ - -o /dev/null 2>/dev/null
58- HAVE_OPENMP := $(shell $(OMP_CHECK_CMD ) && echo "true")
59- ifeq ($(HAVE_OPENMP ) ,true)
60- OPENMP_FLAGS := -fopenmp
61- endif
62-
6355ifdef DEBUG
6456 DEBUG_FLAGS := -g -O0
6557 CXXFLAGS += $(DEBUG_FLAGS )
Original file line number Diff line number Diff line change @@ -17,8 +17,11 @@ project(qsim)
1717
1818if (MSVC )
1919 add_compile_options (/arch:AVX2 /openmp )
20+ # Add /O2 to any configuration that is NOT Debug.
21+ # This prevents a conflict with /RTC1 in DEBUG builds.
22+ add_compile_options ($<$<NOT :$<CONFIG :Debug >>:/O2 >)
2023else ()
21- add_compile_options (-mavx2 -mfma -flto=auto )
24+ add_compile_options (-mavx2 -mfma -O3 )
2225 execute_process (
2326 COMMAND bash --noprofile -c "grep -qs bmi2 /proc/cpuinfo"
2427 RESULT_VARIABLE _EXIT_CODE
@@ -46,4 +49,6 @@ endif()
4649include (../GetPybind11.cmake )
4750pybind11_add_module (qsim_avx2 pybind_main_avx2.cpp )
4851
49- target_link_libraries (qsim_avx2 PRIVATE qsim_openmp_config )
52+ target_link_libraries (qsim_avx2 PUBLIC OpenMP::OpenMP_CXX )
53+
54+ enable_lto (qsim_avx2 )
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ project(qsim)
1818if (MSVC )
1919 add_compile_options (/arch:AVX512 /openmp )
2020else ()
21- add_compile_options (-mavx512f -mbmi2 -flto=auto )
21+ add_compile_options (-mavx512f -mbmi2 -O3 )
2222endif ()
2323
2424if (APPLE )
@@ -39,4 +39,6 @@ endif()
3939include (../GetPybind11.cmake )
4040pybind11_add_module (qsim_avx512 pybind_main_avx512.cpp )
4141
42- target_link_libraries (qsim_avx512 PRIVATE qsim_openmp_config )
42+ target_link_libraries (qsim_avx512 PUBLIC OpenMP::OpenMP_CXX )
43+
44+ enable_lto (qsim_avx512 )
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ project(qsim)
1818if (MSVC )
1919 add_compile_options (/openmp )
2020else ()
21- add_compile_options (-flto=auto )
21+ add_compile_options (-O3 )
2222endif ()
2323
2424if (APPLE )
@@ -39,4 +39,6 @@ endif()
3939include (../GetPybind11.cmake )
4040pybind11_add_module (qsim_basic pybind_main_basic.cpp )
4141
42- target_link_libraries (qsim_basic PRIVATE qsim_openmp_config )
42+ target_link_libraries (qsim_basic PUBLIC OpenMP::OpenMP_CXX )
43+
44+ enable_lto (qsim_basic )
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ project(qsim)
1818if (MSVC )
1919 add_compile_options (/openmp )
2020else ()
21- add_compile_options (-msse4 -flto=auto )
21+ add_compile_options (-msse4 -O3 )
2222endif ()
2323
2424if (APPLE )
@@ -39,4 +39,6 @@ endif()
3939include (../GetPybind11.cmake )
4040pybind11_add_module (qsim_sse pybind_main_sse.cpp )
4141
42- target_link_libraries (qsim_sse PRIVATE qsim_openmp_config )
42+ target_link_libraries (qsim_sse PUBLIC OpenMP::OpenMP_CXX )
43+
44+ enable_lto (qsim_sse )
You can’t perform that action at this time.
0 commit comments