Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,21 @@ else()
add_compile_options($<$<NOT:$<CONFIG:Debug>>:-O3>)
endif()

find_package(OpenMP REQUIRED)

# Check for LTO support (which in CMake is lumped in with IPO).
include(CheckIPOSupported)
check_ipo_supported(RESULT HAVE_IPO)

# Helper function for setting LTO flag (but only if the config is not debug).
function(enable_lto target_name)
if(HAVE_IPO)
set_property(TARGET ${target_name} PROPERTY
INTERPROCEDURAL_OPTIMIZATION $<NOT:$<CONFIG:Debug>>
)
endif()
endfunction()

# Always build the basic part.
add_subdirectory(pybind_interface/basic)
add_subdirectory(pybind_interface/decide)
Expand Down
10 changes: 1 addition & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,10 @@ HIPCCFLAGS := $(BASE_HIPCCFLAGS) $(HIPCCFLAGS)

LTO_FLAGS := -flto=auto
USING_CLANG := $(shell $(CXX) --version | grep -isq clang && echo "true")
ifeq ($(USING_CLANG),"true")
ifeq ($(USING_CLANG),true)
LTO_FLAGS := -flto
endif

# Test if OpenMP header files are available and we can link with the library.
OMP_CHECK_CMD := echo "int main() { return 0; }" | \
$(CXX) -fopenmp -x c++ - -o /dev/null 2>/dev/null
HAVE_OPENMP := $(shell $(OMP_CHECK_CMD) && echo "true")
ifeq ($(HAVE_OPENMP),true)
OPENMP_FLAGS := -fopenmp
endif

ifdef DEBUG
DEBUG_FLAGS := -g -O0
CXXFLAGS += $(DEBUG_FLAGS)
Expand Down
9 changes: 7 additions & 2 deletions pybind_interface/avx2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ project(qsim)

if(MSVC)
add_compile_options(/arch:AVX2 /openmp)
# Add /O2 to any configuration that is NOT Debug.
# This prevents a conflict with /RTC1 in DEBUG builds.
add_compile_options($<$<NOT:$<CONFIG:Debug>>:/O2>)
else()
add_compile_options(-mavx2 -mfma -flto=auto)
add_compile_options(-mavx2 -mfma -O3)
execute_process(
COMMAND bash --noprofile -c "grep -qs bmi2 /proc/cpuinfo"
RESULT_VARIABLE _EXIT_CODE
Expand Down Expand Up @@ -46,4 +49,6 @@ endif()
include(../GetPybind11.cmake)
pybind11_add_module(qsim_avx2 pybind_main_avx2.cpp)

target_link_libraries(qsim_avx2 PRIVATE qsim_openmp_config)
target_link_libraries(qsim_avx2 PUBLIC OpenMP::OpenMP_CXX)

enable_lto(qsim_avx2)
6 changes: 4 additions & 2 deletions pybind_interface/avx512/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ project(qsim)
if(MSVC)
add_compile_options(/arch:AVX512 /openmp)
else()
add_compile_options(-mavx512f -mbmi2 -flto=auto)
add_compile_options(-mavx512f -mbmi2 -O3)
endif()

if(APPLE)
Expand All @@ -39,4 +39,6 @@ endif()
include(../GetPybind11.cmake)
pybind11_add_module(qsim_avx512 pybind_main_avx512.cpp)

target_link_libraries(qsim_avx512 PRIVATE qsim_openmp_config)
target_link_libraries(qsim_avx512 PUBLIC OpenMP::OpenMP_CXX)

enable_lto(qsim_avx512)
6 changes: 4 additions & 2 deletions pybind_interface/basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ project(qsim)
if(MSVC)
add_compile_options(/openmp)
else()
add_compile_options(-flto=auto)
add_compile_options(-O3)
endif()

if(APPLE)
Expand All @@ -39,4 +39,6 @@ endif()
include(../GetPybind11.cmake)
pybind11_add_module(qsim_basic pybind_main_basic.cpp)

target_link_libraries(qsim_basic PRIVATE qsim_openmp_config)
target_link_libraries(qsim_basic PUBLIC OpenMP::OpenMP_CXX)

enable_lto(qsim_basic)
6 changes: 4 additions & 2 deletions pybind_interface/sse/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ project(qsim)
if(MSVC)
add_compile_options(/openmp)
else()
add_compile_options(-msse4 -flto=auto)
add_compile_options(-msse4 -O3)
endif()

if(APPLE)
Expand All @@ -39,4 +39,6 @@ endif()
include(../GetPybind11.cmake)
pybind11_add_module(qsim_sse pybind_main_sse.cpp)

target_link_libraries(qsim_sse PRIVATE qsim_openmp_config)
target_link_libraries(qsim_sse PUBLIC OpenMP::OpenMP_CXX)

enable_lto(qsim_sse)
Loading