From 8be371c953cfce78bded751698702c779f01290d Mon Sep 17 00:00:00 2001 From: Florent Pruvost <florent.pruvost@inria.fr> Date: Wed, 13 May 2015 15:21:25 +0000 Subject: [PATCH] add a variable to get the number of CPUs --- cmake_modules/morse/MorseInit.cmake | 3 ++ cmake_modules/morse/Ressources.cmake | 56 ++++++++++++++++++++++++ cmake_modules/morse/find/FindBLAS.cmake | 2 +- cmake_modules/morse/find/FindCBLAS.cmake | 2 +- testing/CMakeLists.txt | 6 +-- 5 files changed, 64 insertions(+), 5 deletions(-) create mode 100644 cmake_modules/morse/Ressources.cmake diff --git a/cmake_modules/morse/MorseInit.cmake b/cmake_modules/morse/MorseInit.cmake index ccb528762..c4ed4fd33 100644 --- a/cmake_modules/morse/MorseInit.cmake +++ b/cmake_modules/morse/MorseInit.cmake @@ -43,6 +43,9 @@ include(PrintFindStatus) # Define some auxilary flags include(AuxilaryFlags) +# Define some variables to et info about ressources +include(Ressources) + # Add the path where we handle our FindFOO.cmake to seek for liraries list(APPEND CMAKE_MODULE_PATH ${MORSE_CMAKE_MODULE_PATH}/find) diff --git a/cmake_modules/morse/Ressources.cmake b/cmake_modules/morse/Ressources.cmake new file mode 100644 index 000000000..3a5cf6cdf --- /dev/null +++ b/cmake_modules/morse/Ressources.cmake @@ -0,0 +1,56 @@ +### +# +# @copyright (c) 2009-2014 The University of Tennessee and The University +# of Tennessee Research Foundation. +# All rights reserved. +# @copyright (c) 2012-2014 Inria. All rights reserved. +# @copyright (c) 2012-2014 Bordeaux INP, CNRS (LaBRI UMR 5800), Inria, Univ. Bordeaux. All rights reserved. +# +### +# +# @file Ressources.cmake +# +# @project MORSE +# MORSE is a software package provided by: +# Inria Bordeaux - Sud-Ouest, +# Univ. of Tennessee, +# King Abdullah Univesity of Science and Technology +# Univ. of California Berkeley, +# Univ. of Colorado Denver. +# +# @version 0.9.0 +# @author Florent Pruvost +# @date 13-05-2015 +# +# Define variables for hardware ressources: +# - NUMBER_OF_CPU. +# - TODO: NUMBER_OF_CUDA. +### + + +if(NOT DEFINED PROCESSOR_COUNT) + # Unknown: + set(NUMBER_OF_CPU 0) + + # Linux: + set(cpuinfo_file "/proc/cpuinfo") + if(EXISTS "${cpuinfo_file}") + file(STRINGS "${cpuinfo_file}" procs REGEX "^processor.: [0-9]+$") + list(LENGTH procs NUMBER_OF_CPU) + endif() + + # Mac: + if(APPLE) + find_program(cmd_sys_pro "system_profiler") + if(cmd_sys_pro) + execute_process(COMMAND ${cmd_sys_pro} OUTPUT_VARIABLE info) + string(REGEX REPLACE "^.*Total Number Of Cores: ([0-9]+).*$" "\\1" + NUMBER_OF_CPU "${info}") + endif() + endif() + + # Windows: + if(WIN32) + set(NUMBER_OF_CPU "$ENV{NUMBER_OF_PROCESSORS}") + endif() +endif() diff --git a/cmake_modules/morse/find/FindBLAS.cmake b/cmake_modules/morse/find/FindBLAS.cmake index 8fbf9f66b..d56ea3095 100644 --- a/cmake_modules/morse/find/FindBLAS.cmake +++ b/cmake_modules/morse/find/FindBLAS.cmake @@ -54,7 +54,7 @@ # - BLAS libraries can be detected from different ways # Here is the order of precedence: # 1) we look in cmake variable BLAS_LIBDIR or BLAS_DIR (we guess the libdirs) if defined -# 2) we look in environnement variable BLAS_LIBDIR or BLAS_DIR (we guess the libdirs) if defined +# 2) we look in environment variable BLAS_LIBDIR or BLAS_DIR (we guess the libdirs) if defined # 3) we look in common environnment variables depending on the system (INCLUDE, C_INCLUDE_PATH, CPATH - LIB, DYLD_LIBRARY_PATH, LD_LIBRARY_PATH) # 4) we look in common system paths depending on the system, see for example paths contained in the following cmake variables: # - CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES, CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES diff --git a/cmake_modules/morse/find/FindCBLAS.cmake b/cmake_modules/morse/find/FindCBLAS.cmake index eefd7b59d..73eb80271 100644 --- a/cmake_modules/morse/find/FindCBLAS.cmake +++ b/cmake_modules/morse/find/FindCBLAS.cmake @@ -55,7 +55,7 @@ # - CBLAS libraries can be detected from different ways # Here is the order of precedence: # 1) we look in cmake variable CBLAS_LIBDIR or CBLAS_DIR (we guess the libdirs) if defined -# 2) we look in environnement variable CBLAS_LIBDIR or CBLAS_DIR (we guess the libdirs) if defined +# 2) we look in environment variable CBLAS_LIBDIR or CBLAS_DIR (we guess the libdirs) if defined # 3) we look in common environnment variables depending on the system (INCLUDE, C_INCLUDE_PATH, CPATH - LIB, DYLD_LIBRARY_PATH, LD_LIBRARY_PATH) # 4) we look in common system paths depending on the system, see for example paths contained in the following cmake variables: # - CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES, CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt index 7af1c2fa3..bb3c5b717 100644 --- a/testing/CMakeLists.txt +++ b/testing/CMakeLists.txt @@ -150,17 +150,17 @@ if(NOT CHAMELEON_SIMULATION) link_directories(${LAPACK_LIBRARY_DIRS}) link_directories(${CBLAS_LIBRARY_DIRS}) link_directories(${BLAS_LIBRARY_DIRS}) - + else() list(APPEND libs_for_tests coreblas - simulapacke + simulapacke simucblas ${HWLOC_LIBRARIES} ${EXTRA_LIBRARIES} ) - + endif() link_directories(${HWLOC_LIBRARY_DIRS}) -- GitLab