Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 6e4798d8 authored by FELŠÖCI Marek's avatar FELŠÖCI Marek
Browse files

Update build configuration

- simplify CMakeLists and rename executable to minisolver
- simplify and move config.h.in
- add batch test file for CTests
- remove CMake scripts, we don't use them anymore
parent 42ceb56d
No related branches found
No related tags found
No related merge requests found
# HLIBPRO
if("$ENV{HLIBPRO_ROOT}" AND (NOT HLIBPRO_ROOT))
set(HLIBPRO_ROOT $ENV{HLIBPRO_ROOT})
endif()
set(HLIBPRO_ROOT "${HLIBPRO_ROOT}" CACHE PATH "HLIBPRO prefix")
find_path(HLIBPRO_INCLUDE_DIRS NAMES hlib-c.h PATHS "${HLIBPRO_ROOT}" PATH_SUFFIXES include)
find_library(HLIBPRO_LIBRARIES NAMES hpro HINTS "${HLIBPRO_ROOT}" PATH_SUFFIXES lib)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(HLIBPRO HLIBPRO_INCLUDE_DIRS HLIBPRO_LIBRARIES)
if(HLIBPRO_FOUND)
# BOOST
find_package(Boost COMPONENTS filesystem iostreams system program_options REQUIRED)
list(APPEND HLIBPRO_LIBRARIES ${Boost_LIBRARIES} )
# HDF5
find_package(HDF5 COMPONENTS CXX)
if (HDF5_FOUND)
list(APPEND HLIBPRO_LIBRARIES ${HDF5_LIBRARIES} )
endif()
# TBB
find_library(TBB_LIBRARIES NAMES tbb HINTS "${HLIBPRO_ROOT}/aux" PATH_SUFFIXES lib)
if (TBB_LIBRARIES)
list(APPEND HLIBPRO_LIBRARIES ${TBB_LIBRARIES} )
endif()
# GSL
find_package(GSL REQUIRED)
if (GSL_FOUND)
list(APPEND HLIBPRO_LIBRARIES ${GSL_LIBRARIES} )
endif()
# FFTW3
find_library(FFTW_LIBRARIES NAMES fftw3 HINTS "${HLIBPRO_ROOT}/aux" PATH_SUFFIXES lib)
if (FFTW_LIBRARIES)
list(APPEND HLIBPRO_LIBRARIES ${FFTW_LIBRARIES} )
endif()
# METIS
find_library(METIS_LIBRARIES NAMES metis HINTS "${HLIBPRO_ROOT}/aux" PATH_SUFFIXES lib)
if (METIS_LIBRARIES)
list(APPEND HLIBPRO_LIBRARIES ${METIS_LIBRARIES} )
endif()
endif(HLIBPRO_FOUND)
# - Find MKL installation.
# Try to find MKL. The following values are defined
# MKL_FOUND - True if MKL has been found in MKL
# MKL_BLAS_FOUND - True if blas has been found in MKL (should be always ok)
# MKL_CBLAS_FOUND - True if cblas has been found in MKL (OK for >=10.2)
# MKL_LAPACKE_FOUND - True if lapacke has been found in MKL (OK for >=10.3)
# MKL_BLACS_FOUND - True if blacs has been found in libraries listed in ${MKL_LIBRARIES}
# MKL_SCALAPACK_FOUND - True if scalapack has been found in libraries listed in ${MKL_LIBRARIES}
# MKL_DEFINITIONS - list of compilation definition -DFOO
# + many HAVE_XXX...
#See http://software.intel.com/sites/products/mkl/MKL_Link_Line_Advisor.html
#TODO add scalapack, sequential, ilp64, ...
# Allow to skip MKL detection even if MKLROOT is set in the environment.
option(MKL_DETECT "Try to detect and use MKL." ON)
if(MKL_DETECT)
find_path(MKL_INCLUDE_DIRS NAMES mkl.h HINTS
$ENV{MKLROOT}/include
${MKLROOT}/include)
option(MKL_STATIC "Link with MKL statically." OFF)
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set(MKL_ARCH "intel64")
set(MKL_IL "lp64")
else( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set(MKL_ARCH "ia32")
set(MKL_IL "c")
endif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
find_library(MKL_RT_LIBRARY NAMES mkl_rt HINTS
$ENV{MKLROOT}/lib
${MKLROOT}/lib
PATH_SUFFIXES ${MKL_ARCH})
get_filename_component(MKL_LIBRARY_DIR ${MKL_RT_LIBRARY} PATH)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-mkl=parallel" MKL_PARALLEL_COMPILER_FLAG)
if(MINGW)
set(MKL_LINKER_FLAGS ${MKL_RT_LIBRARY})
elseif(WIN32)
if(MKL_STATIC)
set(MKL_LINKER_FLAGS "mkl_intel_${MKL_IL}.lib mkl_core.lib mkl_intel_thread.lib")
set(MKL_COMPILE_FLAGS "")
else()
set(MKL_LINKER_FLAGS "mkl_intel_${MKL_IL}_dll.lib mkl_core_dll.lib mkl_intel_thread_dll.lib")
set(MKL_COMPILE_FLAGS "/Qmkl:parallel")
endif()
else()
if(MKL_STATIC)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(MKL_LINKER_FLAGS "-Wl,--start-group ${MKL_LIBRARY_DIR}/libmkl_intel_${MKL_IL}.a ${MKL_LIBRARY_DIR}/libmkl_core.a ${MKL_LIBRARY_DIR}/libmkl_gnu_thread.a -Wl,--end-group -ldl -lm")
set(MKL_COMPILE_FLAGS "")
else()
set(MKL_LINKER_FLAGS "-Wl,--start-group ${MKL_LIBRARY_DIR}/libmkl_intel_${MKL_IL}.a ${MKL_LIBRARY_DIR}/libmkl_core.a ${MKL_LIBRARY_DIR}/libmkl_intel_thread.a -Wl,--end-group")
set(MKL_COMPILE_FLAGS "")
endif()
else()
if(MKL_PARALLEL_COMPILER_FLAG)
set(MKL_LINKER_FLAGS "-mkl=parallel")
set(MKL_COMPILE_FLAGS "-mkl=parallel")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
find_library(_lib1 mkl_intel_${MKL_IL} PATHS ${MKL_LIBRARY_DIR})
find_library(_lib2 mkl_core PATHS ${MKL_LIBRARY_DIR})
find_library(_lib3 mkl_gnu_thread PATHS ${MKL_LIBRARY_DIR})
set(MKL_LINKER_FLAGS ${_lib1} ${_lib2} ${_lib3} m)
set(MKL_COMPILE_FLAGS "")
endif()
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(MKL DEFAULT_MSG MKL_INCLUDE_DIRS)
set(MKL_CBLAS_FOUND FALSE)
set(MKL_BLAS_FOUND FALSE)
endif(MKL_DETECT)
if (MKL_FOUND)
include(CMakePushCheckState)
cmake_push_check_state()
set(CMAKE_REQUIRED_FLAGS ${MKL_COMPILE_FLAGS})
set(CMAKE_REQUIRED_INCLUDES ${MKL_INCLUDE_DIRS})
# We want MKL link flags to be added at the end of the command line
# else static compilation will fail, so we use CMAKE_REQUIRED_LIBRARIES
# instead of CMAKE_REQUIRED_FLAGS
list(APPEND CMAKE_REQUIRED_LIBRARIES ${MKL_LINKER_FLAGS})
include(CheckIncludeFile)
check_include_file("mkl_cblas.h" HAVE_MKL_CBLAS_H)
check_include_file("mkl.h" HAVE_MKL_H)
include(CheckFunctionExists)
check_function_exists("dgemm" HAVE_DGEMM)
check_function_exists("cblas_dgemm" HAVE_CBLAS_DGEMM)
check_function_exists("zgemm3m" HAVE_ZGEMM3M)
check_function_exists("mkl_set_num_threads" HAVE_MKL_SET_NUM_THREADS)
check_function_exists("mkl_get_max_threads" HAVE_MKL_GET_MAX_THREADS)
check_function_exists("mkl_simatcopy" HAVE_MKL_IMATCOPY)
if (HAVE_MKL_CBLAS_H AND HAVE_CBLAS_DGEMM)
set(MKL_CBLAS_FOUND TRUE)
endif()
if (HAVE_DGEMM)
set(MKL_BLAS_FOUND TRUE)
endif()
set(MKL_DEFINITIONS)
foreach(arg_ HAVE_MKL_H HAVE_MKL_CBLAS_H)
if(${${arg_}})
list(APPEND MKL_DEFINITIONS ${arg_})
endif()
endforeach(arg_ ${ARGN})
endif (MKL_FOUND)
# Set label_VERSION to the git version
function(git_version label default_version)
option(${label}_GIT_VERSION "Get the version string from git describe" ON)
if(${label}_GIT_VERSION)
find_package(Git)
if(GIT_FOUND)
execute_process(COMMAND "${GIT_EXECUTABLE}"
describe --dirty=-dirty --always --tags
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE _GIT_DESCRIBE ERROR_QUIET)
if(_GIT_DESCRIBE)
string(STRIP ${_GIT_DESCRIBE} ${label}_VERSION)
# Remove nonnumeric prefix, if any
STRING(REGEX REPLACE "^[^0-9]+" "" ${label}_STRIPPED_VERSION ${${label}_VERSION})
set(${label}_VERSION ${${label}_STRIPPED_VERSION} PARENT_SCOPE)
endif()
endif()
endif()
if(NOT ${label}_VERSION)
set(${label}_VERSION ${default_version} PARENT_SCOPE)
endif()
message(STATUS "Version string is ${${label}_VERSION}")
endfunction()
# To be included before find_package(MPI) so that
# Intel MPI is propery detected from I_MPI_ROOT
if(WIN32)
option(USE_INTEL_MPI "Use Intel MPI if available" ON)
else()
option(USE_INTEL_MPI "Use Intel MPI if available" OFF)
endif()
if(USE_INTEL_MPI)
# mpicc option for using multithread MPI library
# This is not needed for hmat for now
#set(ENV{I_MPI_LINK} "opt_mt")
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set(MPI_ARCH "intel64")
else( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set(MPI_ARCH "ia32")
endif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
find_program(MPI_C_COMPILER NAMES mpiicc mpiicc.bat
HINTS $ENV{I_MPI_ROOT}/${MPI_ARCH} $ENV{I_MPI_ROOT}/${MPI_ARCH}/bin
${I_MPI_ROOT}/${MPI_ARCH} ${I_MPI_ROOT}/${MPI_ARCH}/bin
)
set(MPI_CXX_COMPILER ${MPI_C_COMPILER})
if(WIN32)
find_path(MPI_INCLUDE_PATH NAMES mpi.h
HINTS $ENV{I_MPI_ROOT}/${MPI_ARCH}/include ${I_MPI_ROOT}/${MPI_ARCH}/include
NO_DEFAULT_PATH)
set(MPI_LIB_SUFFIX "" CACHE STRING "Set to d to link against Debug libraries")
find_library(MPI_C_LIBRARIES NAMES impi${MPI_LIB_SUFFIX}.lib
HINTS $ENV{I_MPI_ROOT}/${MPI_ARCH}/lib ${I_MPI_ROOT}/${MPI_ARCH}/lib)
set(MPI_CXX_LIBRARIES ${MPI_C_LIBRARIES})
else()
# Let FindMPI do the job
endif()
endif()
# Main CMakeLists.txt cmake file for hmat-comparison test project
#
cmake_minimum_required(VERSION 2.8.12)
# Set CMAKE_BUILD_TYPE to Release by default.
# Must be done before calling project()
# Consider 'Release' build type by default.
if(CMAKE_BUILD_TYPE MATCHES "^CMAKE_BUILD_TYPE$")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: None(CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel." FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "" Release Debug RelWithDebInfo MinSizeRel)
set(
CMAKE_BUILD_TYPE "Release" CACHE STRING
"One of: None(CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel."
FORCE
)
set_property(
CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ""
Release Debug RelWithDebInfo MinSizeRel
)
endif()
project(test_fembem C CXX)
string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPER)
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMake")
# Declare the minisolver project.
project(minisolver C CXX)
# Set up include directories.
include_directories(${PROJECT_BINARY_DIR};${PROJECT_SOURCE_DIR}/include)
# Add selected definitions.
add_definitions(-DHAVE_CONFIG_H)
add_definitions(-D_GNU_SOURCE)
#On windows to supress some very verbose compiler warnings
if (MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
endif (MSVC)
# ============================
# Version & Subversion | Git
# ============================
include(GitVersion)
git_version(TEST_FEMBEM 0.1)
message(STATUS "Current revision is ${TEST_FEMBEM_VERSION}")
# ============================
# Installation paths
# ============================
# Offer the user the choice of overriding the installation directories
set(INSTALL_BIN_DIR bin CACHE PATH "Installation directory for executables")
# Make relative paths absolute (needed later on)
if(NOT IS_ABSOLUTE "${INSTALL_BIN_DIR}")
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/${INSTALL_BIN_DIR}")
endif()
# ========================
# C
# ========================
# Set project's version number.
set(minisolver_VERSION 0.1)
# Define installation path for executables.
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin")
# Verify the availability of selected C headers.
include(CheckIncludeFile)
CHECK_INCLUDE_FILE("sys/time.h" HAVE_SYS_TIME_H)
CHECK_INCLUDE_FILE("time.h" HAVE_TIME_H)
CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H)
CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H)
CHECK_INCLUDE_FILE("sys/resource.h" HAVE_SYS_RESOURCE_H)
CHECK_INCLUDE_FILE("mach/mach_time.h" HAVE_MACH_MACH_TIME_H)
# ========================
# SYSTEM & EXTERNAL LIBS
# ========================
include(CheckLibraryExists)
CHECK_LIBRARY_EXISTS("m" sqrt "" HAVE_LIBM)
if(HAVE_LIBM)
set(EXTRA_LIBS m;${EXTRA_LIBS})
set(CMAKE_REQUIRED_LIBRARIES m;${CMAKE_REQUIRED_LIBRARIES})
endif()
CHECK_LIBRARY_EXISTS("rt" clock_gettime "" HAVE_LIBRT)
if(HAVE_LIBRT)
set(CMAKE_REQUIRED_LIBRARIES rt;${CMAKE_REQUIRED_LIBRARIES})
set(RT_LIBRARY rt)
endif()
# ========================
# HMAT-OSS
# ========================
if (NOT TARGET HMAT::hmat)
# Find required dependencies:
# - math library (-lm),
find_library(HAVE_LIBM m REQUIRED)
# - HMAT-OSS,
if(NOT TARGET HMAT::hmat)
find_package(HMAT REQUIRED)
if(HMAT_FOUND)
message(STATUS "HMAT: Found")
set(HAVE_HMAT TRUE)
endif(HMAT_FOUND)
else()
set(HAVE_HMAT TRUE)
endif()
# ========================
# Lib M
# ========================
find_library(M_LIBRARIES m)
# - POSIX threads (-lpthread).
find_package(Threads REQUIRED)
# ========================
# Warning flags
# ========================
# Find optional dependencies:
# - real-time library (-lrt)
find_library(HAVE_LIBRT rt)
# Configure compilation flags.
include(CheckCCompilerFlag)
check_c_compiler_flag("-Werror -Wall -Wno-unused-result -Wno-sign-compare" HAVE_GCC_WARNING_FLAGS)
check_c_compiler_flag(
"-Werror -Wall -Wno-unused-result -Wno-sign-compare" HAVE_GCC_WARNING_FLAGS
)
if(HAVE_GCC_WARNING_FLAGS)
SET(CMAKE_C_FLAGS "-Werror -Wall -Wno-unused-result -Wno-sign-compare ${CMAKE_C_FLAGS}")
SET(
CMAKE_C_FLAGS
"-Werror -Wall -Wno-unused-result -Wno-sign-compare ${CMAKE_C_FLAGS}"
)
endif()
# ========================
# Configuration file
# ========================
configure_file("${PROJECT_SOURCE_DIR}/CMake/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h" )
# ============================
# Generation of executables
# ============================
file(GLOB_RECURSE TEST_SOURCES RELATIVE ${PROJECT_SOURCE_DIR} src/*.c include/*.h)
add_executable(test_FEMBEM ${TEST_SOURCES})
# Configure an input configuration file.
configure_file(
"${PROJECT_SOURCE_DIR}/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h"
)
# Configure executables:
# - recursively discover source and include files,
file(
GLOB_RECURSE minisolver_SOURCES RELATIVE ${PROJECT_SOURCE_DIR}
src/*.c include/*.h
)
# - use them to define the project's executable.
add_executable(minisolver ${minisolver_SOURCES})
# Link with external libraries (package's dependencies).
if(HAVE_HMAT)
target_link_libraries( test_FEMBEM PUBLIC HMAT::hmat )
target_link_libraries(minisolver PUBLIC HMAT::hmat)
endif()
if ( M_LIBRARIES )
target_link_libraries(test_FEMBEM PUBLIC ${M_LIBRARIES} )
if(HAVE_LIBM)
target_link_libraries(minisolver PUBLIC ${HAVE_LIBM})
endif()
if(CMAKE_THREAD_LIBS_INIT)
target_link_libraries(test_FEMBEM PUBLIC ${CMAKE_THREAD_LIBS_INIT})
if(HAVE_LIBRT)
target_link_libraries(minisolver PUBLIC ${HAVE_LIBRT})
endif()
# ========================
# INSTALL
# ========================
install(TARGETS test_FEMBEM RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT Runtime)
if(CMAKE_THREAD_LIBS_INIT)
target_link_libraries(minisolver PUBLIC ${CMAKE_THREAD_LIBS_INIT})
endif()
# To install, for example, MSVC runtime libraries:
include (InstallRequiredSystemLibraries)
# Configure the installation target.
install(
TARGETS minisolver RUNTIME DESTINATION "${INSTALL_BIN_DIR}" COMPONENT Runtime
)
# ========================
# CTEST
# ========================
# Configure the tests target.
enable_testing()
if(HMAT_FOUND)
add_test(NAME BEMsolveH_Z COMMAND test_FEMBEM -nbpts 800 -z --hmat -solvehmat )
add_test(NAME BEMgemvH_D COMMAND test_FEMBEM -nbpts 1000 -d --hmat -gemvhmat )
add_test(NAME BEMinverseH_S COMMAND test_FEMBEM -nbpts 600 -s --hmat -inversehmat --nosym)
add_test(NAME FEMsolveH_C COMMAND test_FEMBEM --fem -nbpts 2500 -c --hmat -solvehmat )
add_test(NAME FEMgemvH_S COMMAND test_FEMBEM --fem -nbpts 4000 -s --hmat -gemvhmat )
add_test(NAME FEMinverseH_Z COMMAND test_FEMBEM --fem -nbpts 1000 -z --hmat -inversehmat --nosym)
endif(HMAT_FOUND)
# ========================
# FINAL LOG
# ========================
add_test(NAME minisolver_single COMMAND minisolver --size 1600)
add_test(NAME minisolver_batch COMMAND minisolver --batch-input ../tests.csv)
# Show final configuration report.
include(FeatureSummary)
feature_summary(WHAT ALL)
/** MPF Configuration header file prototype for CMake
* M. Pallud
* 02/05/2011
*
* Mimic autotools configure header file
*/
/* ======================================
* VERSION & PACKAGE NAMES
* ====================================== */
/* PACKAGE INFORMATION */
/* Name of package */
#define PACKAGE "@PROJECT_NAME@"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "https://imacs.polytechnique.fr/bugzilla/enter_bug.cgi"
/* Define to the full name of this package. */
#define PACKAGE_NAME "@PROJECT_NAME@"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "@PROJECT_NAME@ ${@PROJECT_NAME_UPPER@_VERSION}"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "@PROJECT_NAME@"
#define PACKAGE_STRING "@PROJECT_NAME@ ${@PROJECT_NAME@_VERSION}"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
#define PACKAGE_URL "https://gitlab.inria.fr/tutorial-guix-hpc-workshop/software/minisolver"
/* Define to the version of this package. */
#define PACKAGE_VERSION "${@PROJECT_NAME_UPPER@_VERSION}"
/* Version number of package */
#define VERSION "${@PROJECT_NAME_UPPER@_VERSION}"
#define PACKAGE_VERSION "${@PROJECT_NAME@_VERSION}"
#define __COMMITID__ "${@PROJECT_NAME_UPPER@_COMMITID_VERSION}"
/* ======================================
* SYSTEM LIBRARIES
* ====================================== */
/* SYSTEM LIBRARIES */
/* Define to 1 if you have the `m' library (-lm). */
#cmakedefine HAVE_LIBM
......@@ -62,11 +40,3 @@
/* Define to 1 if you have the <sys/resource.h> header file. */
#cmakedefine HAVE_SYS_RESOURCE_H
/* ======================================
* OTHER LIBRARIES
* ====================================== */
#cmakedefine HAVE_HMAT
#cmakedefine HAVE_CHAMELEON
#cmakedefine HAVE_HLIBPRO
1000,high
2000,low
3000,medium
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment