From 2bb4783a08b5b39fa7429cad68fe5ed9ef52d37a Mon Sep 17 00:00:00 2001 From: Ryan Stocks Date: Thu, 26 Sep 2024 22:20:12 +0800 Subject: [PATCH] Moved obara saika compile flags override --- src/CMakeLists.txt | 16 ++++++++++++++++ .../host/obara_saika/CMakeLists.txt | 9 --------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7e51e9fa..6dc291fc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -224,3 +224,19 @@ install( FILES # Install Custom Find Modules include( ${linalg-cmake-modules_SOURCE_DIR}/LinAlgModulesMacros.cmake ) install_linalg_modules( INSTALL_CONFIGDIR ) + +# This allows specifying a lower compiler optimization level for NVHPC which fails to compile with the -O3 flag whilst leaving the remaining flags unchanged +if (DEFINED GAUXC_OBARA_SAIKA_COMPILE_OPTIMIZATION_OPTIONS) + get_target_property(default_compile_options gauxc COMPILE_OPTIONS) + get_target_property(gauxc_sources gauxc SOURCES) + set_target_properties(gauxc PROPERTIES COMPILE_OPTIONS "") + set_source_files_properties(${gauxc_sources} PROPERTIES COMPILE_OPTIONS "${default_compile_options}") + + file(GLOB OB_HOST_SRC_FILES ${CMAKE_CURRENT_LIST_DIR}/xc_integrator/local_work_driver/host/obara_saika/src/*.cxx) + set(adjusted_compile_options ${default_compile_options}) + foreach (flag "[\\/\\-]O3" "[\\/\\-]Ofast" "[\\/\\-]fast") + string(REGEX REPLACE ${flag} ${GAUXC_OBARA_SAIKA_COMPILE_OPTIMIZATION_OPTIONS} adjusted_compile_options "${adjusted_compile_options}") + endforeach() + message("-- Setting Obara-Saika COMPILE_OPTIONS to: ${adjusted_compile_options}") + set_source_files_properties(${OB_HOST_SRC_FILES} PROPERTIES COMPILE_OPTIONS "${adjusted_compile_options}") +endif() diff --git a/src/xc_integrator/local_work_driver/host/obara_saika/CMakeLists.txt b/src/xc_integrator/local_work_driver/host/obara_saika/CMakeLists.txt index 7da96629..c37f0ebe 100644 --- a/src/xc_integrator/local_work_driver/host/obara_saika/CMakeLists.txt +++ b/src/xc_integrator/local_work_driver/host/obara_saika/CMakeLists.txt @@ -30,15 +30,6 @@ set( GAUXC_OBARA_SAIKA_HOST_SRC src/chebyshev_boys_computation.cxx ) -# This is required for compilation with NVHPC as it crashes with the O3 optimization flag -if (DEFINED GAUXC_OBARA_SAIKA_COMPILE_OPTIMIZATION_OPTIONS) - foreach (flag "[\\/\\-]O3" "[\\/\\-]Ofast" "[\\/\\-]fast") - string(REGEX REPLACE ${flag} ${GAUXC_OBARA_SAIKA_COMPILE_OPTIMIZATION_OPTIONS} CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") - endforeach() - message("Setting Obara-Saika CMAKE_CXX_FLAGS_RELEASE to: ${CMAKE_CXX_FLAGS_RELEASE}") -endif() - - target_sources( gauxc PRIVATE ${GAUXC_OBARA_SAIKA_HOST_SRC} ) target_include_directories( gauxc PUBLIC $