From 0b933277a1a0186ed4d5e2c9eb3dc392be80aaa1 Mon Sep 17 00:00:00 2001 From: suvarchal Date: Thu, 21 Sep 2023 00:48:54 +0200 Subject: [PATCH 1/2] parms doesn't necessarily need blas, if cmake doesn't find it then ignore blas --- lib/parms/CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/parms/CMakeLists.txt b/lib/parms/CMakeLists.txt index 3cb7b48cf..0fedf9d16 100644 --- a/lib/parms/CMakeLists.txt +++ b/lib/parms/CMakeLists.txt @@ -14,12 +14,19 @@ if(${BUILD_FESOM_AS_LIBRARY}) else() add_library(${PROJECT_NAME} ${all_sources}) endif() + +if(${BLAS_FOUND}) target_compile_definitions(${PROJECT_NAME} PRIVATE PARMS USE_MPI REAL=double DBL FORTRAN_UNDERSCORE VOID_POINTER_SIZE_8 HAS_BLAS) +target_link_libraries(${PROJECT_NAME} INTERFACE ${BLAS_C_LIBRARIES} $ENV{UBUNTU_BLAS_LIBRARY}) +else() +target_compile_definitions(${PROJECT_NAME} PRIVATE PARMS USE_MPI REAL=double DBL FORTRAN_UNDERSCORE VOID_POINTER_SIZE_8) +target_link_libraries(${PROJECT_NAME} INTERFACE $ENV{UBUNTU_BLAS_LIBRARY}) +endif() + target_include_directories(${PROJECT_NAME} PRIVATE ${src_home}/src/../include ${src_home}/src/include INTERFACE ${src_home}/src/../include ) -target_link_libraries(${PROJECT_NAME} INTERFACE ${BLAS_C_LIBRARIES} $ENV{UBUNTU_BLAS_LIBRARY}) if(${CMAKE_C_COMPILER_ID} STREQUAL "Intel") target_compile_options(${PROJECT_NAME} PRIVATE -no-prec-div -no-prec-sqrt -fast-transcendentals -fp-model precise) if(${FESOM_PLATFORM_STRATEGY} STREQUAL levante.dkrz.de ) From 80db75a367775e32d41041bb167ba5fc641b2b03 Mon Sep 17 00:00:00 2001 From: suvarchal Date: Thu, 21 Sep 2023 01:13:32 +0200 Subject: [PATCH 2/2] skip blas when not found and use standard discovery for BLAS as default --- lib/parms/CMakeLists.txt | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/parms/CMakeLists.txt b/lib/parms/CMakeLists.txt index 0fedf9d16..7f85d5eef 100644 --- a/lib/parms/CMakeLists.txt +++ b/lib/parms/CMakeLists.txt @@ -6,7 +6,10 @@ project(parms C) set(src_home ${CMAKE_CURRENT_LIST_DIR}) # path to src directory starting from the dir containing our CMakeLists.txt file(GLOB all_sources ${src_home}/src/*.c ${src_home}/src/DDPQ/*.c) -include("${CMAKE_CURRENT_LIST_DIR}/../../cmake/FindBLAS.cmake") +find_package(BLAS) # standard way to find blas +if( NOT BLAS_FOUND) # try older way to find blas + include("${CMAKE_CURRENT_LIST_DIR}/../../cmake/FindBLAS.cmake") +endif() # create our library (set its name to name of this project) if(${BUILD_FESOM_AS_LIBRARY}) @@ -16,11 +19,13 @@ else() endif() if(${BLAS_FOUND}) -target_compile_definitions(${PROJECT_NAME} PRIVATE PARMS USE_MPI REAL=double DBL FORTRAN_UNDERSCORE VOID_POINTER_SIZE_8 HAS_BLAS) -target_link_libraries(${PROJECT_NAME} INTERFACE ${BLAS_C_LIBRARIES} $ENV{UBUNTU_BLAS_LIBRARY}) + message("BLAS FOUND ---------------------------") + target_compile_definitions(${PROJECT_NAME} PRIVATE PARMS USE_MPI REAL=double DBL FORTRAN_UNDERSCORE VOID_POINTER_SIZE_8 HAS_BLAS) + target_link_libraries(${PROJECT_NAME} INTERFACE ${BLAS_C_LIBRARIES} $ENV{UBUNTU_BLAS_LIBRARY}) else() -target_compile_definitions(${PROJECT_NAME} PRIVATE PARMS USE_MPI REAL=double DBL FORTRAN_UNDERSCORE VOID_POINTER_SIZE_8) -target_link_libraries(${PROJECT_NAME} INTERFACE $ENV{UBUNTU_BLAS_LIBRARY}) + message("BLAS NOT FOUND ***********************") + target_compile_definitions(${PROJECT_NAME} PRIVATE PARMS USE_MPI REAL=double DBL FORTRAN_UNDERSCORE VOID_POINTER_SIZE_8) + target_link_libraries(${PROJECT_NAME} INTERFACE $ENV{UBUNTU_BLAS_LIBRARY}) endif() target_include_directories(${PROJECT_NAME} @@ -28,7 +33,8 @@ target_include_directories(${PROJECT_NAME} INTERFACE ${src_home}/src/../include ) if(${CMAKE_C_COMPILER_ID} STREQUAL "Intel") - target_compile_options(${PROJECT_NAME} PRIVATE -no-prec-div -no-prec-sqrt -fast-transcendentals -fp-model precise) + target_compile_options(${PROJECT_NAME} PRIVATE -no-prec-div -no-prec-sqrt -fast-transcendentals -fp-model precise) + if(${FESOM_PLATFORM_STRATEGY} STREQUAL levante.dkrz.de ) target_compile_options(${PROJECT_NAME} PRIVATE -march=core-avx2 -mtune=core-avx2) endif()