diff --git a/.gitlab-ci-env.sh b/.gitlab-ci-env.sh index 66128ab8eb3e9baa4441c4335bc7daa21787ad82..687df90dc59f1c561b2d45e826a197d3b83cfeab 100755 --- a/.gitlab-ci-env.sh +++ b/.gitlab-ci-env.sh @@ -8,6 +8,9 @@ # too noisy export STARPU_SILENT=1 +# initialize empty to get just what we need +export PKG_CONFIG_PATH="" + # if simgrid change the default starpu dir to use if [ "$1" == "simu" ]; then export STARPU_DIR=$STARPUSIMGRID_DIR diff --git a/CMakeLists.txt b/CMakeLists.txt index f6bf03d05860d84544e76aebd80ee9962d6534f3..0e5c7aede99053c338efdbe900eddcf155fee6dd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,7 @@ endif() set(CHAMELEON_VERSION_MAJOR 1) set(CHAMELEON_VERSION_MINOR 0) set(CHAMELEON_VERSION_MICRO 0) +set(CHAMELEON_VERSION "${CHAMELEON_VERSION_MAJOR}.${CHAMELEON_VERSION_MINOR}.${CHAMELEON_VERSION_MICRO}") set(CHAMELEON_CMAKE_DIR "" CACHE PATH "Directory of CHAMELEON CMake modules, can be external to the project") @@ -78,6 +79,9 @@ FortranCInterface_HEADER(${CMAKE_CURRENT_BINARY_DIR}/include/chameleon/mangling. # Parameters/Options # ###################### +# For fPIC when build static +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + # Set the RPATH config # -------------------- @@ -221,10 +225,6 @@ if(CHAMELEON_SCHED_STARPU) if (NOT CHAMELEON_ENABLE_PRUNING_STATS) message("-- ${BoldGreen}CHAMELEON_ENABLE_PRUNING_STATS is set to OFF, turn it ON to build pruning statistics${ColourReset}") endif() - if(CHAMELEON_ENABLE_PRUNING_STATS) - add_definitions(-DCHAMELEON_ENABLE_PRUNING_STATS) - endif(CHAMELEON_ENABLE_PRUNING_STATS) - cmake_dependent_option(CHAMELEON_SIMULATION_EXTENDED "Enable non GPU kernels to be simulated on GPU" OFF "CHAMELEON_SIMULATION" OFF) @@ -239,171 +239,71 @@ endif() # Build dependency HQR library # ################################ add_subdirectory(hqr) -include_directories(hqr/include) ############################################################################### # Look for dependencies # ######################### -set(CHAMELEON_DEP "") - -# Check for Thread library -# ------------------------ -set(CMAKE_THREAD_PREFER_PTHREAD TRUE) -find_package(Threads REQUIRED) -if( THREADS_FOUND AND CMAKE_THREAD_LIBS_INIT ) - libraries_absolute_path(CMAKE_THREAD_LIBS_INIT "") - list(APPEND EXTRA_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) -endif () - -# Add math library to the list of extra -# it normally exists on all common systems provided with a C compiler -if(UNIX OR WIN32) - find_library( - M_LIBRARY - NAMES m - ) - mark_as_advanced(M_LIBRARY) - if (M_LIBRARY) - list(APPEND EXTRA_LIBRARIES "${M_LIBRARY}") - else() - message(FATAL_ERROR "Could NOT find libm on your system." - " Are you sure to a have a C compiler installed?") - endif() -endif() -# Try to find librt (libposix4 - POSIX.1b Realtime Extensions library) -# on Unix systems except Apple ones because it does not exist on it -if(UNIX AND NOT APPLE) - find_library( - RT_LIBRARY - NAMES rt - ) - mark_as_advanced(RT_LIBRARY) - if (RT_LIBRARY) - list(APPEND EXTRA_LIBRARIES "${RT_LIBRARY}") - else() - message(FATAL_ERROR "Could NOT find librt on your system") - endif() -endif() +# Add math library (libm), searched with MORSE module FindM.cmake +# it normally exists on all common systems provided with a C compiler +find_package(M REQUIRED) -# If simulation we don't enter in kernel functions so that we don't need to -# link with concerned libraries +# If simulation we don't enter in kernel functions so that we don't need to link +# with concerned libraries if(NOT CHAMELEON_SIMULATION) + # CHAMELEON depends on CBLAS #--------------------------- find_package(CBLAS REQUIRED) - if(CBLAS_FOUND) - if (CBLAS_INCLUDE_DIRS_DEP) - include_directories(${CBLAS_INCLUDE_DIRS_DEP}) - endif() - if(CBLAS_CFLAGS_OTHER_DEP) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CBLAS_CFLAGS_OTHER_DEP}") - string(REPLACE ";" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - endif() - if(CBLAS_LDFLAGS_OTHER_DEP) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CBLAS_LDFLAGS_OTHER_DEP}") - string(REPLACE ";" " " CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") - endif() - if(CBLAS_LIBRARY_DIRS_DEP) - list(APPEND CMAKE_INSTALL_RPATH "${CBLAS_LIBRARY_DIRS_DEP}") - endif() - if (CBLAS_LIBRARIES_DEP) - list(INSERT CHAMELEON_DEP 0 ${CBLAS_LIBRARIES_DEP}) - endif() - else() - if(CHAMELEON_VERBOSE_FIND_PACKAGE) - if(CBLAS_STANDALONE OR NOT CBLAS_WORKS) - if (NOT CBLAS_cblas.h_DIRS) - Print_Find_Header_Status(cblas cblas.h) - endif () - if (NOT CBLAS_cblas_LIBRARY) - Print_Find_Library_Status(cblas libcblas) - endif () - endif() - else() - message(WARNING "CBLAS library has not been found and CHAMELEON_VERBOSE_FIND_PACKAGE is set to OFF." - " Try to activate CHAMELEON_VERBOSE_FIND_PACKAGE option (-DCHAMELEON_VERBOSE_FIND_PACKAGE=ON) to get some hints for the detection") - endif() - message(FATAL_ERROR "A CBLAS library is required but has not been found") - endif() # CHAMELEON depends on LAPACKE #----------------------------- find_package(LAPACKE REQUIRED) - if(LAPACKE_FOUND) - if (LAPACKE_INCLUDE_DIRS_DEP) - include_directories(${LAPACKE_INCLUDE_DIRS_DEP}) - endif() - if(LAPACKE_CFLAGS_OTHER_DEP) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${LAPACKE_CFLAGS_OTHER_DEP}") - string(REPLACE ";" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - endif() - if(LAPACKE_LDFLAGS_OTHER_DEP) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LAPACKE_LDFLAGS_OTHER_DEP}") - string(REPLACE ";" " " CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") - endif() - if(LAPACKE_LIBRARY_DIRS_DEP) - list(APPEND CMAKE_INSTALL_RPATH "${LAPACKE_LIBRARY_DIRS_DEP}") - endif() - if (LAPACKE_LIBRARIES_DEP) - list(INSERT CHAMELEON_DEP 0 ${LAPACKE_LIBRARIES_DEP}) - endif() - else() - if(CHAMELEON_VERBOSE_FIND_PACKAGE) - if (LAPACKE_STANDALONE OR NOT LAPACKE_WORKS) - if (NOT LAPACKE_lapacke.h_DIRS) - Print_Find_Header_Status(lapacke lapacke.h) - endif () - if (NOT LAPACKE_lapacke_LIBRARY) - Print_Find_Library_Status(lapacke liblapacke) - endif () - endif() - else() - message(WARNING "LAPACKE library has not been found and CHAMELEON_VERBOSE_FIND_PACKAGE is set to OFF." - " Try to activate CHAMELEON_VERBOSE_FIND_PACKAGE option (-DCHAMELEON_VERBOSE_FIND_PACKAGE=ON) to get some hints for the detection") - endif() - message(FATAL_ERROR "A LAPACKE library is required but has not been found") - endif() # CHAMELEON depends on CUDA/CUBLAS #---------------------------------- if (CHAMELEON_USE_CUDA) + # When our cmake_minimum version will be 3.17 we will be able to use this + # far better module: FindCUDAToolkit + # https://cmake.org/cmake/help/latest/module/FindCUDAToolkit.html#module:FindCUDAToolkit + find_package(CUDA REQUIRED) + if (CUDA_FOUND) message("-- ${Blue}Add definition CHAMELEON_USE_CUDA" " - Activate CUDA in Chameleon${ColourReset}") - libraries_absolute_path(CUDA_LIBRARIES "$ENV{CUDA_ROOT}/lib64") - set(EXTRA_LIBRARIES_CUDA) + # create imported target because not provided with old cmake + add_library(CUDA::CUDA INTERFACE IMPORTED) + add_library(CUDA::CUBLAS INTERFACE IMPORTED) if(CUDA_VERSION VERSION_LESS "3.0") set(CUDA_HOST_COMPILATION_CPP OFF) endif(CUDA_VERSION VERSION_LESS "3.0") set(CUDA_BUILD_EMULATION OFF) if (CUDA_INCLUDE_DIRS) - include_directories(${CUDA_INCLUDE_DIRS}) + set_target_properties(CUDA::CUDA PROPERTIES INTERFACE_INCLUDE_DIRECTORIES "${CUDA_INCLUDE_DIRS}") else() message(WARNING "CHAMELEON_USE_CUDA requires" "\n CUDA_INCLUDE_DIRS to be found. Be sure you have" "\n cuda headers with your distribution of CUDA.") endif() if (CUDA_LIBRARIES) - set(saved_include "${CMAKE_REQUIRED_INCLUDES}") - set(saved_libs "${CMAKE_REQUIRED_LIBRARIES}") - set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${CUDA_INCLUDE_DIRS}") - set(CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES};${CUDA_LIBRARIES}") + set_target_properties(CUDA::CUDA PROPERTIES INTERFACE_LINK_LIBRARIES "${CUDA_LIBRARIES}") + set(CMAKE_REQUIRED_INCLUDES "${CUDA_INCLUDE_DIRS}") + set(CMAKE_REQUIRED_LIBRARIES "${CUDA_LIBRARIES}") if(CUDA_VERSION VERSION_LESS "4.0") set(CUDA_HAVE_PEER_DEVICE_MEMORY_ACCESS 0) else() check_function_exists(cuDeviceCanAccessPeer CUDA_HAVE_PEER_DEVICE_MEMORY_ACCESS) endif() - set(CMAKE_REQUIRED_INCLUDES "${saved_include}") - set(CMAKE_REQUIRED_LIBRARIES "${saved_libs}") + unset(CMAKE_REQUIRED_INCLUDES) + unset(CMAKE_REQUIRED_LIBRARIES) # Add cublas if found if (CUDA_CUBLAS_LIBRARIES) + set_target_properties(CUDA::CUBLAS PROPERTIES INTERFACE_LINK_LIBRARIES "${CUDA_CUBLAS_LIBRARIES}") + target_link_libraries(CUDA::CUBLAS INTERFACE CUDA::CUDA) message("-- ${Blue}Add definition CHAMELEON_USE_CUBLAS" " - Use GPU kernels from cuBLAS${ColourReset}") - list(APPEND EXTRA_LIBRARIES_CUDA ${CUDA_CUBLAS_LIBRARIES}) - list(APPEND EXTRA_LIBRARIES_CUDA ${CUDA_LIBRARIES}) # need CUDA libs to link. else() message(FATAL_ERROR "CHAMELEON_USE_CUDA requires" "\n CUDA_CUBLAS_LIBRARIES to be found. Be sure you have" @@ -416,16 +316,6 @@ if(NOT CHAMELEON_SIMULATION) endif() endif (CUDA_FOUND) - list(APPEND EXTRA_LIBRARIES ${EXTRA_LIBRARIES_CUDA}) - foreach (_lib ${EXTRA_LIBRARIES_CUDA}) - if (EXISTS ${_lib}) - get_filename_component(libdir ${_lib} PATH) - if (EXISTS ${libdir}) - list(APPEND CMAKE_INSTALL_RPATH "${libdir}") - endif() - endif() - endforeach() - endif(CHAMELEON_USE_CUDA) # CHAMELEON depends on MPI @@ -443,30 +333,8 @@ if(NOT CHAMELEON_SIMULATION) if (MPI_C_FOUND) message("-- ${Blue}Add definition CHAMELEON_USE_MPI" " - Activate MPI in Chameleon${ColourReset}") - list(APPEND EXTRA_LIBRARIES ${MPI_C_LIBRARIES} ) - include_directories( ${MPI_C_INCLUDE_PATH} ) - # tests for intel mpi - #list(APPEND MPI_C_COMPILE_FLAGS "-mt_mpi") - #list(APPEND MPI_COMPILE_FLAGS "-mt_mpi") - if(MPI_C_COMPILE_FLAGS) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MPI_C_COMPILE_FLAGS}") - string(REPLACE ";" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - endif() - if(MPI_C_LINK_FLAGS) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MPI_C_LINK_FLAGS}") - string(REPLACE ";" " " CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") - endif() endif (MPI_C_FOUND) - foreach (_lib ${MPI_C_LIBRARIES}) - if (EXISTS ${_lib}) - get_filename_component(libdir ${_lib} PATH) - if (EXISTS ${libdir}) - list(APPEND CMAKE_INSTALL_RPATH "${libdir}") - endif() - endif() - endforeach() - endif (CHAMELEON_USE_MPI) else (NOT CHAMELEON_SIMULATION) @@ -510,10 +378,6 @@ else (NOT CHAMELEON_SIMULATION) # Simulation mode: we depend on SimGrid find_package(SIMGRID REQUIRED) - if (SIMGRID_INCLUDE_DIRS) - include_directories(${SIMGRID_INCLUDE_DIRS}) - endif() - # CHAMELEON depends on MPI #------------------------- if (CHAMELEON_USE_MPI) @@ -522,7 +386,7 @@ else (NOT CHAMELEON_SIMULATION) # -DMPI_C_COMPILER=path/to/mpicc -DMPI_Fortran_COMPILER=path/to/mpif90 # at cmake configure if(NOT MPI_C_COMPILER) - set(MPI_C_COMPILER "${SIMGRID_DIR_FOUND}/bin/smpicc") + set(MPI_C_COMPILER "${SIMGRID_PREFIX}/bin/smpicc") endif() if(NOT MPI_C_LIBRARIES) set(MPI_C_LIBRARIES "${SIMGRID_LIBRARIES}") @@ -532,7 +396,7 @@ else (NOT CHAMELEON_SIMULATION) list(APPEND MPI_C_INCLUDE_PATH "${SIMGRID_INCLUDE_DIRS}/smpi") endif() if(NOT MPI_CXX_COMPILER) - set(MPI_CXX_COMPILER "${SIMGRID_DIR_FOUND}/bin/smpicxx") + set(MPI_CXX_COMPILER "${SIMGRID_PREFIX}/bin/smpicxx") endif() if(NOT MPI_CXX_LIBRARIES) set(MPI_CXX_LIBRARIES "${SIMGRID_LIBRARIES}") @@ -542,7 +406,7 @@ else (NOT CHAMELEON_SIMULATION) list(APPEND MPI_CXX_INCLUDE_PATH "${SIMGRID_INCLUDE_DIRS}/smpi") endif() if(NOT MPI_Fortran_COMPILER) - set(MPI_Fortran_COMPILER "${SIMGRID_DIR_FOUND}/bin/smpif90") + set(MPI_Fortran_COMPILER "${SIMGRID_PREFIX}/bin/smpif90") endif() if(NOT MPI_Fortran_LIBRARIES) set(MPI_Fortran_LIBRARIES "${SIMGRID_LIBRARIES}") @@ -556,29 +420,10 @@ else (NOT CHAMELEON_SIMULATION) if (MPI_C_FOUND) message("-- ${Blue}Add definition CHAMELEON_USE_MPI" " - Activate MPI in Chameleon${ColourReset}") - list(APPEND EXTRA_LIBRARIES ${MPI_C_LIBRARIES} ) - include_directories( ${MPI_C_INCLUDE_PATH} ) - if(MPI_C_COMPILE_FLAGS) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${MPI_C_COMPILE_FLAGS}") - string(REPLACE ";" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - endif() - if(MPI_C_LINK_FLAGS) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MPI_C_LINK_FLAGS}") - string(REPLACE ";" " " CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") - endif() endif (MPI_C_FOUND) endif (CHAMELEON_USE_MPI) - foreach (_lib ${SIMGRID_LIBRARIES} ${MPI_C_LIBRARIES}) - if (EXISTS ${_lib}) - get_filename_component(libdir ${_lib} PATH) - if (EXISTS ${libdir}) - list(APPEND CMAKE_INSTALL_RPATH "${libdir}") - endif() - endif() - endforeach() - endif(NOT CHAMELEON_SIMULATION) # getopt @@ -594,71 +439,26 @@ cmake_dependent_option(CHAMELEON_USE_CUBLAS_V2 "Enable cublas API v2" ON "CHAMELEON_USE_CUDA;CHAMELEON_SCHED_STARPU" OFF) -list(REMOVE_DUPLICATES CMAKE_C_FLAGS) -string(REPLACE ";" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") -list(REMOVE_DUPLICATES CMAKE_EXE_LINKER_FLAGS) -string(REPLACE ";" " " CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") # Fix a problem on Mac OS X when building shared libraries if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(CMAKE_SHARED_LINKER_FLAGS "-undefined dynamic_lookup") endif() -# Save extra dependencies (all required links) -list(APPEND CHAMELEON_DEP ${EXTRA_LIBRARIES}) -# We remove duplicate dependencies ensuring that redundant libraries are placed last -list(REVERSE CHAMELEON_DEP) -list(REMOVE_DUPLICATES CHAMELEON_DEP) -list(REVERSE CHAMELEON_DEP) - -# we add chameleon's own library -set(CHAMELEON_LIBRARIES "chameleon") -if (NOT CHAMELEON_SIMULATION) - list(APPEND CHAMELEON_LIBRARIES coreblas) - if (CHAMELEON_USE_CUDA) - list(APPEND CHAMELEON_LIBRARIES cudablas) - endif() -endif() -if (CHAMELEON_SCHED_QUARK) - list(APPEND CHAMELEON_LIBRARIES chameleon_quark) -endif() -if (CHAMELEON_SCHED_PARSEC) - list(APPEND CHAMELEON_LIBRARIES chameleon_parsec) -endif() -if (CHAMELEON_SCHED_STARPU) - list(APPEND CHAMELEON_LIBRARIES chameleon_starpu) -endif() -if (CHAMELEON_SCHED_OPENMP) - list(APPEND CHAMELEON_LIBRARIES chameleon_openmp) -endif() -list(APPEND CHAMELEON_LIBRARIES hqr) -set(CHAMELEON_LIBRARIES_DEP ${CHAMELEON_LIBRARIES} ${CHAMELEON_DEP}) - # Check for the subdirectories # ---------------------------- set(CHAMELEON_SOURCES_TARGETS "" CACHE INTERNAL "List of targets of sources") -# include headers -# --------------- -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) -include_directories(${CMAKE_CURRENT_BINARY_DIR}/include) - if (NOT CHAMELEON_SIMULATION) ############################################################################### # Coreblas library (kernels for CPUs) # ####################################### - include_directories(${CMAKE_CURRENT_SOURCE_DIR}/coreblas/include) - include_directories(${CMAKE_CURRENT_BINARY_DIR}/coreblas/include) add_subdirectory(coreblas) ############################################################################### # Cudablas library (kernels for CUDAs) # ######################################## if(CHAMELEON_USE_CUDA) - include_directories(${CMAKE_CURRENT_SOURCE_DIR}/cudablas/include) - include_directories(${CMAKE_CURRENT_BINARY_DIR}/cudablas/include) add_subdirectory(cudablas) endif() @@ -684,8 +484,8 @@ include(CTest) # Necessary to compile C executables linked with ifort if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel") - message(STATUS "Add -nofor_main to the Fortran linker (Intel compiler)") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -nofor_main") + message(STATUS "Add -nofor_main to the Fortran linker (Intel compiler)") + set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -nofor_main") endif() # Testing executables @@ -708,10 +508,10 @@ add_custom_target(chameleon_all_sources ALL DEPENDS ${CHAMELEON_SOURCES_TARGETS} ################# if(CHAMELEON_ENABLE_DOC) - add_subdirectory(doc) - if (DOXYGEN_EXECUTABLE AND EMACS_COMPILER AND TEX_COMPILER) - add_custom_target(doc ALL DEPENDS doxygen-out doc-html-users_guide doc-pdf-users_guide) - endif() + add_subdirectory(doc) + if (DOXYGEN_EXECUTABLE AND EMACS_COMPILER AND TEX_COMPILER) + add_custom_target(doc ALL DEPENDS doxygen-out doc-html-users_guide doc-pdf-users_guide) + endif() endif() #------------------------------------------------------------------------------ @@ -721,13 +521,40 @@ endif() # link tests fail) only after tests. # ############################################################################### if( CHAMELEON_SCHED_STARPU ) - if ( STARPU_FOUND ) - if (CHAMELEON_SIMULATION) - list(APPEND CMAKE_REQUIRED_FLAGS "-include" "starpu_simgrid_wrap.h") - endif() + if ( STARPU_FOUND ) + if (CHAMELEON_SIMULATION) + list(APPEND CMAKE_REQUIRED_FLAGS "-include" "starpu_simgrid_wrap.h") endif() + endif() endif() +############################################################################### +# Export targets # +################## + +# see https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html +include(CMakePackageConfigHelpers) + +set(BIN_INSTALL_DIR "bin/" CACHE STRING "where to install executables relative to prefix" ) +set(INC_INSTALL_DIR "include/" CACHE STRING "where to install headers relative to prefix" ) +set(LIB_INSTALL_DIR "lib/" CACHE STRING "where to install libraries relative to prefix" ) + +configure_package_config_file(cmake_modules/CHAMELEONConfig.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/CHAMELEONConfig.cmake + INSTALL_DESTINATION ${LIB_INSTALL_DIR}/cmake/chameleon + PATH_VARS BIN_INSTALL_DIR INC_INSTALL_DIR LIB_INSTALL_DIR) +write_basic_package_version_file(CHAMELEONConfigVersion.cmake + VERSION ${CHAMELEON_VERSION} + COMPATIBILITY AnyNewerVersion) + +# Install config files +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/CHAMELEONConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/CHAMELEONConfigVersion.cmake + DESTINATION ${LIB_INSTALL_DIR}/cmake/chameleon) + +# need MORSE Find modules: necessary files must be distributed in the install path +set(morse_dependencies "M;CBLAS;LAPACKE;HWLOC;PARSEC;QUARK;STARPU") +morse_install_finds(morse_dependencies ${LIB_INSTALL_DIR}/cmake/chameleon/find) + ############################################################################### # Config files (pkg_config) # ############################# @@ -746,14 +573,14 @@ set(CPACK_PACKAGE_DESCRIPTION_FILE ${CMAKE_CURRENT_SOURCE_DIR}/README.org) set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Chameleon is a C library providing parallel algorithms to perform BLAS/LAPACK " " operations exploiting fully modern architectures.") set(CHAMELEON_VERSION_PATCH ${CHAMELEON_VERSION_MICRO}) -set(CPACK_PACKAGE_VERSION "${CHAMELEON_VERSION_MAJOR}.${CHAMELEON_VERSION_MINOR}.${CHAMELEON_VERSION_PATCH}") +set(CPACK_PACKAGE_VERSION "${CHAMELEON_VERSION}") set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") set(CPACK_PACKAGE_VENDOR "Inria") set(CPACK_PACKAGE_CONTACT "morse-devel@lists.gforge.inria.fr") set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.org) set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENCE.txt) -set(CPACK_SOURCE_IGNORE_FILES "/plasma-conversion/;/build*;.cproject;.settings;.dir-locals.el;.project;.pydevproject;/.git*") +set(CPACK_SOURCE_IGNORE_FILES "/build*;/.*") include(CPack) ############################################################################### @@ -762,10 +589,10 @@ include(CPack) include(PrintOpts) if (CMAKE_INSTALL_PREFIX STREQUAL "/usr/local" OR CMAKE_INSTALL_PREFIX STREQUAL "C:/Program Files") - message("-- ${Yellow}Your CMAKE_INSTALL_PREFIX is ${CMAKE_INSTALL_PREFIX} which is a default system path." - " You may want to change it: set the CMAKE_INSTALL_PREFIX variable to do so${ColourReset}") + message("-- ${Yellow}Your CMAKE_INSTALL_PREFIX is ${CMAKE_INSTALL_PREFIX} which is a default system path." + " You may want to change it: set the CMAKE_INSTALL_PREFIX variable to do so${ColourReset}") else() - message("-- ${Yellow}Your CMAKE_INSTALL_PREFIX is ${CMAKE_INSTALL_PREFIX}${ColourReset}") + message("-- ${Yellow}Your CMAKE_INSTALL_PREFIX is ${CMAKE_INSTALL_PREFIX}${ColourReset}") endif() ### diff --git a/cmake_modules/CHAMELEONConfig.cmake.in b/cmake_modules/CHAMELEONConfig.cmake.in new file mode 100644 index 0000000000000000000000000000000000000000..918855f920615ac6dd9312124fe5fb2d7d5f4a0a --- /dev/null +++ b/cmake_modules/CHAMELEONConfig.cmake.in @@ -0,0 +1,61 @@ +set(CHAMELEON_VERSION @CHAMELEON_VERSION@) + +# relocatable package +@PACKAGE_INIT@ + +set_and_check(CHAMELEON_BIN_DIR "@PACKAGE_BIN_INSTALL_DIR@") +set_and_check(CHAMELEON_INC_DIR "@PACKAGE_INC_INSTALL_DIR@") +set_and_check(CHAMELEON_LIB_DIR "@PACKAGE_LIB_INSTALL_DIR@") + +check_required_components(CHAMELEON) + +# need MORSE Find modules: necessary files must be distributed in the install path +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/find") + +# dependencies of CHAMELEON +include(CMakeFindDependencyMacro) +find_dependency(M) +if (NOT @CHAMELEON_SIMULATION@) + find_dependency(CBLAS REQUIRED) + find_dependency(LAPACKE REQUIRED) +endif() +if (@CHAMELEON_SCHED_OPENMP@) + find_dependency(OpenMP REQUIRED) +endif() +if (@CHAMELEON_SCHED_PARSEC@) + find_dependency(PARSEC REQUIRED) +endif() +if (@CHAMELEON_SCHED_QUARK@) + find_dependency(QUARK REQUIRED COMPONENTS HWLOC) +endif() +if (@CHAMELEON_SCHED_STARPU@) + find_package(STARPU @CHAMELEON_STARPU_VERSION@ REQUIRED) +endif() +if (@CHAMELEON_USE_MPI@) + find_dependency(MPI REQUIRED) +endif() +if (@CHAMELEON_USE_CUDA@ AND NOT @CHAMELEON_SIMULATION@) + find_dependency(CUDA REQUIRED) +endif() + +# add the targets file +include("${CMAKE_CURRENT_LIST_DIR}/../hqr/hqrTargets.cmake") +if (NOT @CHAMELEON_SIMULATION@) + include("${CMAKE_CURRENT_LIST_DIR}/coreblasTargets.cmake") +endif() +if (@CHAMELEON_USE_CUDA@ AND NOT @CHAMELEON_SIMULATION@) + include("${CMAKE_CURRENT_LIST_DIR}/cudablasTargets.cmake") +endif() +if (@CHAMELEON_SCHED_OPENMP@) + include("${CMAKE_CURRENT_LIST_DIR}/chameleon_openmpTargets.cmake") +endif() +if (@CHAMELEON_SCHED_PARSEC@) + include("${CMAKE_CURRENT_LIST_DIR}/chameleon_parsecTargets.cmake") +endif() +if (@CHAMELEON_SCHED_QUARK@) + include("${CMAKE_CURRENT_LIST_DIR}/chameleon_quarkTargets.cmake") +endif() +if (@CHAMELEON_SCHED_STARPU@) + include("${CMAKE_CURRENT_LIST_DIR}/chameleon_starpuTargets.cmake") +endif() +include("${CMAKE_CURRENT_LIST_DIR}/chameleonTargets.cmake") diff --git a/cmake_modules/GenPkgConfig.cmake b/cmake_modules/GenPkgConfig.cmake index af8c90b88a7c4b361ed934d35c487d290bc4f2e8..98e9e8b11a7b64eef0bbdd35e398ae67fe9836d1 100644 --- a/cmake_modules/GenPkgConfig.cmake +++ b/cmake_modules/GenPkgConfig.cmake @@ -110,9 +110,9 @@ MACRO(GENERATE_PKGCONFIG_FILE) if(CHAMELEON_SCHED_STARPU) list(APPEND CHAMELEON_PKGCONFIG_LIBS -lchameleon_starpu) if ( CHAMELEON_USE_MPI ) - list(APPEND CHAMELEON_PKGCONFIG_REQUIRED_PRIVATE starpumpi-${STARPU_VERSION}) + list(APPEND CHAMELEON_PKGCONFIG_REQUIRED_PRIVATE starpumpi-${CHAMELEON_STARPU_VERSION}) else() - list(APPEND CHAMELEON_PKGCONFIG_REQUIRED_PRIVATE starpu-${STARPU_VERSION}) + list(APPEND CHAMELEON_PKGCONFIG_REQUIRED_PRIVATE starpu-${CHAMELEON_STARPU_VERSION}) endif() elseif(CHAMELEON_SCHED_QUARK) list(APPEND CHAMELEON_PKGCONFIG_LIBS -lchameleon_quark) diff --git a/cmake_modules/PrintOpts.cmake b/cmake_modules/PrintOpts.cmake index 2a6a34e75213e163254c2c68d2e4c207e2573ee1..bdb7c58bded0926f5bcad9e0e7d1351c6c16f9a5 100644 --- a/cmake_modules/PrintOpts.cmake +++ b/cmake_modules/PrintOpts.cmake @@ -23,6 +23,31 @@ # ### +if (BLAS_LIBRARIES MATCHES "mkl_core") + set(BLAS_VENDOR_FOUND "Intel") +elseif(BLAS_LIBRARIES MATCHES "openblas") + set(BLAS_VENDOR_FOUND "OpenBLAS") +elseif(BLAS_LIBRARIES MATCHES "blis") + set(BLAS_VENDOR_FOUND "BLIS") +elseif(BLAS_LIBRARIES MATCHES "Accelerate") + set(BLAS_VENDOR_FOUND "Apple") +elseif(BLAS_LIBRARIES MATCHES "essl") + set(BLAS_VENDOR_FOUND "IBMESSL") +elseif(BLAS_LIBRARIES MATCHES "blas") + set(BLAS_VENDOR_FOUND "Generic") +endif() +if (LAPACK_LIBRARIES MATCHES "mkl_core") + set(LAPACK_VENDOR_FOUND "Intel") +elseif(LAPACK_LIBRARIES MATCHES "openblas") + set(LAPACK_VENDOR_FOUND "OpenBLAS") +elseif(LAPACK_LIBRARIES MATCHES "flame") + set(LAPACK_VENDOR_FOUND "FLAME") +elseif(LAPACK_LIBRARIES MATCHES "Accelerate") + set(LAPACK_VENDOR_FOUND "Apple") +elseif(LAPACK_LIBRARIES MATCHES "lapack") + set(LAPACK_VENDOR_FOUND "Generic") +endif() + set(dep_message "\nConfiguration of Chameleon:\n" " BUILDNAME ...........: ${BUILDNAME}\n" " SITE ................: ${SITE}\n" @@ -63,12 +88,8 @@ set(dep_message "${dep_message}" " documentation ........: ${CHAMELEON_ENABLE_DOC}\n" " example ..............: ${CHAMELEON_ENABLE_EXAMPLE}\n" " testing ..............: ${CHAMELEON_ENABLE_TESTING}\n" -"\n" -" CHAMELEON dependencies :\n") -foreach (_dep ${CHAMELEON_LIBRARIES_DEP}) - set(dep_message "${dep_message}" - " ${_dep}\n") -endforeach () +"\n") + set(dep_message "${dep_message}" "\n" " INSTALL_PREFIX ......: ${CMAKE_INSTALL_PREFIX}\n\n") diff --git a/compute/CMakeLists.txt b/compute/CMakeLists.txt index caea63ca9a8dd26b5b6f6cb3e3b68005cb52c9bb..e9656ea1ef67a80985a80e71aaf92f62a82aa18a 100644 --- a/compute/CMakeLists.txt +++ b/compute/CMakeLists.txt @@ -43,10 +43,6 @@ endif() mark_as_advanced(CHAMELEON_COPY_DIAG) -if (CHAMELEON_COPY_DIAG) - add_definitions(-DCHAMELEON_COPY_DIAG) -endif() - # Define the list of sources # -------------------------- set(CHAMELEON_CONTROL @@ -308,16 +304,8 @@ set(CHAMELEON_SOURCES_TARGETS "${CHAMELEON_SOURCES_TARGETS};chameleon_sources" C # Compile step # ------------ add_library(chameleon ${CHAMELEON_SRCS} ${CHAMELEON_SRCSF}) -if(CHAMELEON_SCHED_STARPU) - target_link_libraries(chameleon chameleon_starpu) -elseif(CHAMELEON_SCHED_PARSEC) - target_link_libraries(chameleon chameleon_parsec) -elseif(CHAMELEON_SCHED_QUARK) - target_link_libraries(chameleon chameleon_quark) -elseif(CHAMELEON_SCHED_OPENMP) - target_link_libraries(chameleon chameleon_openmp) -endif() -target_link_libraries(chameleon hqr) +set_target_properties(chameleon PROPERTIES VERSION ${CHAMELEON_VERSION}) +set_target_properties(chameleon PROPERTIES SOVERSION ${CHAMELEON_VERSION_MAJOR}) add_dependencies(chameleon chameleon_include @@ -325,7 +313,42 @@ add_dependencies(chameleon chameleon_sources ) -set_property(TARGET chameleon PROPERTY LINKER_LANGUAGE Fortran) +target_include_directories(chameleon PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> + $<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}/include> + $<BUILD_INTERFACE:${CHAMELEON_BINARY_DIR}/include> + $<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}/control> + $<BUILD_INTERFACE:${CHAMELEON_BINARY_DIR}/control> + $<INSTALL_INTERFACE:include>) + +if (CHAMELEON_SIMULATION) + target_include_directories(chameleon PUBLIC ${SIMGRID_INCLUDE_DIRS}) +endif() + +if(CHAMELEON_SCHED_STARPU) + target_link_libraries(chameleon PUBLIC chameleon_starpu) +elseif(CHAMELEON_SCHED_PARSEC) + target_link_libraries(chameleon PUBLIC chameleon_parsec) +elseif(CHAMELEON_SCHED_QUARK) + target_link_libraries(chameleon PUBLIC chameleon_quark) +elseif(CHAMELEON_SCHED_OPENMP) + target_link_libraries(chameleon PUBLIC chameleon_openmp) +endif() +if (NOT CHAMELEON_SIMULATION) + target_link_libraries(chameleon PUBLIC coreblas) +endif() +target_link_libraries(chameleon PUBLIC hqr) +if (CHAMELEON_USE_MPI) + target_link_libraries(chameleon PUBLIC MPI::MPI_C) +endif() +if (CHAMELEON_USE_CUDA) + if (NOT CHAMELEON_SIMULATION) + target_link_libraries(chameleon PUBLIC cudablas) + target_link_libraries(chameleon PUBLIC CUDA::CUBLAS) + endif() +endif() +target_link_libraries(chameleon PUBLIC MORSE::M) + set_property(TARGET chameleon PROPERTY Fortran_MODULE_DIRECTORY "${CMAKE_BINARY_DIR}/include") set_property(TARGET chameleon PROPERTY INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") @@ -334,6 +357,15 @@ set_property(TARGET chameleon PROPERTY INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX} install(TARGETS chameleon DESTINATION lib) +# export target +install(EXPORT chameleonTargets + NAMESPACE CHAMELEON:: + DESTINATION lib/cmake/chameleon + ) + +# install target file +install(TARGETS chameleon EXPORT chameleonTargets) + ### ### END CMakeLists.txt ### diff --git a/coreblas/compute/CMakeLists.txt b/coreblas/compute/CMakeLists.txt index f0d4976c2b52febd93b491e2890e48f62d0a94e2..ff5234f4e91cbe17e92256d94cb4c24c55517cb0 100644 --- a/coreblas/compute/CMakeLists.txt +++ b/coreblas/compute/CMakeLists.txt @@ -120,14 +120,20 @@ set(CHAMELEON_SOURCES_TARGETS "${CHAMELEON_SOURCES_TARGETS};coreblas_sources" CA # Compile step # ------------ add_library(coreblas ${COREBLAS_SRCS}) +set_target_properties(coreblas PROPERTIES VERSION ${CHAMELEON_VERSION}) +set_target_properties(coreblas PROPERTIES SOVERSION ${CHAMELEON_VERSION_MAJOR}) add_dependencies(coreblas coreblas_include coreblas_sources) -set_property(TARGET coreblas PROPERTY LINKER_LANGUAGE Fortran) +target_include_directories(coreblas PUBLIC + $<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}/coreblas/include> + $<BUILD_INTERFACE:${CHAMELEON_BINARY_DIR}/coreblas/include> + $<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}/include> + $<BUILD_INTERFACE:${CHAMELEON_BINARY_DIR}/include> + $<INSTALL_INTERFACE:include>) set_property(TARGET coreblas PROPERTY INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") -target_link_libraries(coreblas - ${LAPACKE_LIBRARIES_DEP} - ${CBLAS_LIBRARIES_DEP} - ) +target_link_libraries(coreblas PRIVATE MORSE::LAPACKE) +target_link_libraries(coreblas PRIVATE MORSE::CBLAS) +target_link_libraries(coreblas PUBLIC MORSE::M) # Installation # ------------ @@ -135,6 +141,15 @@ install(TARGETS coreblas ARCHIVE DESTINATION lib LIBRARY DESTINATION lib) +# export target coreblas +install(EXPORT coreblasTargets + NAMESPACE CHAMELEON:: + DESTINATION lib/cmake/chameleon + ) + +# install target file +install(TARGETS coreblas EXPORT coreblasTargets) + ### ### END CMakeLists.txt ### diff --git a/cudablas/compute/CMakeLists.txt b/cudablas/compute/CMakeLists.txt index 5d05dc015d8ffd843e13d74a68c07bdefe749107..f1626fbdaafe34eb434758f71fea9860d0dcc648 100644 --- a/cudablas/compute/CMakeLists.txt +++ b/cudablas/compute/CMakeLists.txt @@ -98,13 +98,19 @@ set(CHAMELEON_SOURCES_TARGETS "${CHAMELEON_SOURCES_TARGETS};cudablas_sources" CA # Compile step # ------------ add_library(cudablas ${CUDABLAS_SRCS}) +set_target_properties(cudablas PROPERTIES VERSION ${CHAMELEON_VERSION}) +set_target_properties(cudablas PROPERTIES SOVERSION ${CHAMELEON_VERSION_MAJOR}) add_dependencies(cudablas cudablas_include cudablas_sources) -set_property(TARGET cudablas PROPERTY LINKER_LANGUAGE Fortran) +target_include_directories(cudablas PUBLIC + $<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}/cudablas/include> + $<BUILD_INTERFACE:${CHAMELEON_BINARY_DIR}/cudablas/include> + $<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}/include> + $<BUILD_INTERFACE:${CHAMELEON_BINARY_DIR}/include> + $<INSTALL_INTERFACE:include>) set_property(TARGET cudablas PROPERTY INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") -target_link_libraries(cudablas - coreblas - ${EXTRA_LIBRARIES_CUDA}) +target_link_libraries(cudablas PRIVATE coreblas CUDA::CUBLAS) +target_link_libraries(cudablas PUBLIC MORSE::M) # installation # ------------ @@ -112,6 +118,15 @@ install(TARGETS cudablas ARCHIVE DESTINATION lib LIBRARY DESTINATION lib) +# export target coreblas +install(EXPORT cudablasTargets + NAMESPACE CHAMELEON:: + DESTINATION lib/cmake/chameleon + ) + +# install target file +install(TARGETS cudablas EXPORT cudablasTargets) + ### ### END CMakeLists.txt ### diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 785c71fe1f9076adbee330ff9d3ba6863880064a..1fb37ce40ccddf078c8b02f3f9c2f160a6341b1a 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -26,7 +26,7 @@ # ### -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.1) ############################################# # # diff --git a/doc/doxygen/CMakeLists.txt b/doc/doxygen/CMakeLists.txt index 989efb8a616cb9782788471acb01c290f32f2731..92a8b3d8ef945a9f6ea12cd08ae37e7003790154 100644 --- a/doc/doxygen/CMakeLists.txt +++ b/doc/doxygen/CMakeLists.txt @@ -26,7 +26,7 @@ # ### -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.1) # Looking for doxygen # ------------------- diff --git a/doc/orgmode/CMakeLists.txt b/doc/orgmode/CMakeLists.txt index 978d70d78182a02f0355947ae50c5ba9f9f94a0f..7df43993dc07f8a109e22120a42d91d22de03274 100644 --- a/doc/orgmode/CMakeLists.txt +++ b/doc/orgmode/CMakeLists.txt @@ -20,7 +20,7 @@ # ### -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.1) # Create file version.org # ----------------------- diff --git a/doc/orgmode/chapters/installing.org b/doc/orgmode/chapters/installing.org index f75d12e99bbbfb43d6a0292eec7e55112fd2f7c1..fbb5376e51f51b3c98b07ea905adef7829bdba6f 100644 --- a/doc/orgmode/chapters/installing.org +++ b/doc/orgmode/chapters/installing.org @@ -37,7 +37,8 @@ we encourage users to use [[sec:spack][Spack]]. - runtimes: [[http://runtime.bordeaux.inria.fr/StarPU/][StarPU]] or [[http://icl.utk.edu/parsec/][PaRSEC]] or [[http://icl.cs.utk.edu/quark/][QUARK]] or [[https://www.openmp.org/][OpenMP]] - kernels : CBLAS, LAPACKE (with TMG). These are C interfaces to Fortran kernels BLAS and LAPACK. There exist several providers - that can be used with Chameleon (Intel MKL, Netlib, OpenBlas) + that can be used with Chameleon (Intel MKL, Netlib, OpenBLAS, + BLIS/FLAME) Optional libraries: - cuda: [[https://developer.nvidia.com/cuda-downloads][cuda]], [[http://docs.nvidia.com/cuda/cublas/][cublas]] (comes with cuda) @@ -53,12 +54,14 @@ we encourage users to use [[sec:spack][Spack]]. # Update Debian packages list sudo apt-get update - # Install Netlib blas, lapack, tmglib, cblas and lapacke suite - sudo apt-get install -y liblapack-dev liblapacke-dev - # Alternatively to Netlib, OpenBLAS could be used (faster kernels) + # Install OpenBLAS sudo apt-get install -y libopenblas-dev liblapacke-dev # Install OpenMPI sudo apt-get install -y libopenmpi-dev + # Install StarPU + sudo apt-get install libstarpu-dev + + # Optionnaly to make some specific develoments, the following may be installed # Install hwloc (used by StarPU or QUARK, already a dependency of OpenMPI) sudo apt-get install -y libhwloc-dev # install EZTrace, usefull to export some nice execution traces @@ -69,12 +72,13 @@ we encourage users to use [[sec:spack][Spack]]. # Install cuda and cuBLAS: only if you have a GPU cuda compatible sudo apt-get install -y nvidia-cuda-toolkit nvidia-cuda-dev + # If you prefer a specific version of StarPU, install it yourself, e.g. # Install StarPU (with MPI and FxT enabled) mkdir -p $HOME/install cd $HOME/install - wget http://starpu.gforge.inria.fr/files/starpu-1.3.3/starpu-1.3.3.tar.gz - tar xvzf starpu-1.3.3.tar.gz - cd starpu-1.3.3/ + wget https://files.inria.fr/starpu/starpu-1.3.7/starpu-1.3.7.tar.gz + tar xvzf starpu-1.3.7.tar.gz + cd starpu-1.3.7/ ./configure --prefix=/usr/local --with-fxt=/usr/lib/x86_64-linux-gnu/ make -j5 sudo make install @@ -109,7 +113,8 @@ we encourage users to use [[sec:spack][Spack]]. library. The Debian packages /libopenblas-dev/ and /liblapacke-dev/ (version 1.0.0) do not provide the tmg interface. Please update your distribution or install the lapacke interface library in - another way, by yourself from source or with [[https://gitlab.inria.fr/solverstack/spack-repo][Spack]], ... + another way, by yourself from source or with [[https://gitlab.inria.fr/solverstack/spack-repo][Spack]], or with + [[https://gitlab.inria.fr/guix-hpc/guix-hpc-non-free][Guix-HPC]],... 2) sometimes parallel make with -j can fails due to undefined dependencies between some targets. Try to invoke the make command several times if so. @@ -531,7 +536,6 @@ we encourage users to use [[sec:spack][Spack]]. -DCHAMELEON_USE_CUDA=ON \ -DCHAMELEON_USE_MPI=ON \ -DBLA_VENDOR=Intel10_64lp \ - -DSTARPU_DIR=/home/jdoe/install/starpu-1.2/ \ -DCHAMELEON_ENABLE_TRACING=ON #+end_src @@ -557,27 +561,18 @@ we encourage users to use [[sec:spack][Spack]]. Fortran compilers if several exist in the environment **** Related to specific modules (find_package) to find external libraries - * *BLA_VENDOR=All|Eigen|Open|Generic|Intel10_64lp|Intel10_64lp_seq*: + * *BLA_VENDOR=All|OpenBLAS|Generic|Intel10_64lp|Intel10_64lp_seq|FLAME*: to use intel mkl for example, see the list of BLA_VENDOR in FindBLAS.cmake in cmake_modules/morse_cmake/modules/find - * *STARPU_DIR=path/to/root/starpu/install*, see [[sec:depdet][Dependencies - detection]] - * *STARPU_INCDIR=path/to/root/starpu/install/headers*, see - [[sec:depdet][Dependencies detection]] - * *STARPU_LIBDIR=path/to/root/starpu/install/libs*, see - [[sec:depdet][Dependencies detection]] - * List of packages that can be searched just like STARPU (with - _DIR, _INCDIR and _LIBDIR): - * *BLAS*, *CBLAS*, *EZTRACE*, *FXT*, *HWLOC*, *LAPACK*, *LAPACKE*, *QUARK*, - *SIMGRID*, *TMG* - - Libraries detected with an official cmake module (see module files - in CMAKE_ROOT/Modules/): CUDA - MPI - OpenMP - Threads. + + Libraries detected with an official cmake module (see module + files in CMAKE_ROOT/Modules/): BLAS - LAPACK - CUDA - MPI - + OpenMP - Threads. Libraries detected with our cmake modules (see module files in cmake_modules/morse_cmake/modules/find/ directory of Chameleon - sources): BLAS - CBLAS - EZTRACE - FXT - HWLOC - LAPACK - - LAPACKE - QUARK - SIMGRID - STARPU - TMG. + sources): CBLAS - EZTRACE - FXT - HWLOC - LAPACKE - PARSEC - + QUARK - SIMGRID - STARPU. **** Chameleon specific options * *CHAMELEON_SCHED=STARPU|PARSEC|QUARK|OPENMP* (default STARPU): to @@ -625,8 +620,8 @@ we encourage users to use [[sec:spack][Spack]]. #+begin_src export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:install/path/to/your/lib #+end_src - - INCLUDE should contain the list of paths where to find the - header files of libraries + - INCLUDE (or CPATH, or C_INCLUDE_PATH)should contain the list + of paths where to find the header files of libraries #+begin_src export INCLUDE=$INCLUDE:install/path/to/your/headers #+end_src @@ -637,19 +632,16 @@ we encourage users to use [[sec:spack][Spack]]. #+end_example where LIB stands for the name of the lib to look for, /e.g./ #+begin_src - cmake path/to/your/CMakeLists.txt -DSTARPU_DIR=path/to/starpudir \ + cmake path/to/your/CMakeLists.txt -DQUARK_DIR=path/to/starpudir \ -DCBLAS_DIR= ... #+end_src it is also possible to specify headers and library directories separately #+begin_src cmake path/to/your/CMakeLists.txt \ - -DSTARPU_INCDIR=path/to/libstarpu/include/starpu/1.1 \ - -DSTARPU_LIBDIR=path/to/libstarpu/lib + -DQUARK_INCDIR=path/to/quark/include \ + -DQUARK_LIBDIR=path/to/quark/lib #+end_src - - note: BLAS and LAPACK detection can be tedious so that we - provide a verbose mode you can set *-DBLAS_VERBOSE=ON* or - *-DLAPACK_VERBOSE=ON* to enable it 3) detection with custom environment variables: all variables like _DIR, _INCDIR, _LIBDIR can be set as environment variables instead of CMake options, there will be read @@ -658,23 +650,59 @@ we encourage users to use [[sec:spack][Spack]]. files of installed external libraries like hwloc, starpu, some blas/lapack, etc + Note that PaRSEC and StarPU are only detected with pkg-config + mechanism because it is always provided and this avoid errors. + ** Linking an external application with Chameleon libraries Compilation and link with Chameleon libraries have been tested with the GNU compiler suite ~gcc/gfortran~ and the Intel compiler suite ~icc/ifort~. -*** Flags required +*** For CMake projects + A CHAMELEONConfig.cmake file is provided at installation, stored + in <prefix>/lib/cmake/chameleon, so that users in cmake project + can use through the variable CHAMELEON_ROOT (set it as environment + or CMake variable). + + #+begin_src + sudo apt-get update + sudo apt-get install -y libopenblas-dev liblapacke-dev libstarpu-dev + git clone --recursive https://gitlab.inria.fr/solverstack/chameleon.git + cd chameleon && mkdir -p build && cd build + CHAMELEON_ROOT=$PWD/install + cmake .. -DCMAKE_INSTALL_PREFIX=$CHAMELEON_ROOT && make -j5 install + # chameleon is installed in $CHAMELEON_ROOT + + # if your work in a cmake project you can use the CHAMELEONConfig.cmake file + # installed under <prefix>/lib/cmake/chameleon/ by setting your + # CMAKE_PREFIX_PATH with the path of installation. In your cmake project, use + # find_package(CHAMELEON) and link your libraries and/or executables with the + # library target MORSE::CHAMELEON + cmake . -DCMAKE_PREFIX_PATH=$CHAMELEON_ROOT + #+end_src +*** For non CMake projects The compiler, linker flags that are necessary to build an application using Chameleon are given through the [[https://www.freedesktop.org/wiki/Software/pkg-config/][pkg-config]] mechanism. #+begin_src - export PKG_CONFIG_PATH=/home/jdoe/install/chameleon/lib/pkgconfig:$PKG_CONFIG_PATH + sudo apt-get update + sudo apt-get install -y libopenblas-dev liblapacke-dev libstarpu-dev + git clone --recursive https://gitlab.inria.fr/solverstack/chameleon.git + cd chameleon && mkdir -p build && cd build + CHAMELEON_ROOT=$PWD/install + cmake .. -DCMAKE_INSTALL_PREFIX=$CHAMELEON_ROOT && make -j5 install + # chameleon is installed in $CHAMELEON_ROOT + + export PKG_CONFIG_PATH=$CHAMELEON_ROOT/lib/pkgconfig:$PKG_CONFIG_PATH pkg-config --cflags chameleon pkg-config --libs chameleon pkg-config --libs --static chameleon + + # use it in your configure/make #+end_src The .pc files required are located in the sub-directory ~lib/pkgconfig~ of your Chameleon install directory. + *** Static linking in C Lets imagine you have a file ~main.c~ that you want to link with Chameleon static libraries. Lets consider diff --git a/example/lapack_to_chameleon/CMakeLists.txt b/example/lapack_to_chameleon/CMakeLists.txt index 9931b9d508e7087209ae08df92737ba246245a4c..c418e3bf177aea5f5448103172a7cf362cdc04a0 100644 --- a/example/lapack_to_chameleon/CMakeLists.txt +++ b/example/lapack_to_chameleon/CMakeLists.txt @@ -18,11 +18,29 @@ # @date 2020-03-03 # ### -include_directories(${CMAKE_CURRENT_BINARY_DIR}) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -# compilation for other sources step1 and > -set(LTM_SOURCES +# sources depending on CBLAS/LAPACKE +set(LAPACK_SOURCES + step0.c + ) +foreach(_src ${LAPACK_SOURCES}) + get_filename_component(_name_exe ${_src} NAME_WE) + add_executable(${_name_exe} ${_src}) + target_link_libraries(${_name_exe} PRIVATE + MORSE::LAPACKE + MORSE::CBLAS) + install(TARGETS ${_name_exe} + DESTINATION bin/chameleon/lapack_to_chameleon) + # for chameleon/include/chameleon/timer.h + target_include_directories(${_name_exe} PRIVATE + ${CHAMELEON_SOURCE_DIR}/include) + # for chameleon/coreblas/include/coreblas/cblas.h + target_include_directories(${_name_exe} PRIVATE + ${CHAMELEON_SOURCE_DIR}/coreblas/include) +endforeach() + +# sources depending on chameleon +set(CHAMELEON_SOURCES step1.c step2.c step3.c @@ -30,46 +48,26 @@ set(LTM_SOURCES step5.c step6.c step7.c - ) - -# Define what libraries we have to link with -# ------------------------------------------ -unset(libs_for_ltm) -list(APPEND libs_for_ltm chameleon) -# message(STATUS "libs_for_ltm: ${libs_for_ltm}") +) -# specific compilation for step0 because we potentially want to use -# multithreaded BLAS and LAPACK libraries for this step -unset(libs_for_step0) -if (BLAS_LIBRARIES_PAR) - # Intel MKL multithreaded - list(APPEND libs_for_step0 - ${BLAS_LIBRARIES_PAR} - ) -else() - # Any other blas/lapack suite - list(APPEND libs_for_step0 - ${LAPACKE_LIBRARIES_DEP} - ${CBLAS_LIBRARIES_DEP} - ) -endif() -# message(STATUS "libs_for_step0: ${libs_for_step0}") - -foreach(_ltm ${LTM_SOURCES}) - get_filename_component(_name_exe ${_ltm} NAME_WE) - add_executable(${_name_exe} ${_ltm}) - set_property(TARGET ${_name_exe} PROPERTY LINKER_LANGUAGE Fortran) - target_link_libraries(${_name_exe} ${libs_for_ltm}) +foreach(_src ${CHAMELEON_SOURCES}) + get_filename_component(_name_exe ${_src} NAME_WE) + add_executable(${_name_exe} ${_src}) + target_link_libraries(${_name_exe} PRIVATE + chameleon + coreblas + MORSE::LAPACKE) + # for chameleon/include/chameleon/timer.h + target_include_directories(${_name_exe} PRIVATE + ${CHAMELEON_SOURCE_DIR}/include) + # for chameleon/coreblas/include/coreblas/cblas.h + target_include_directories(${_name_exe} PRIVATE + ${CHAMELEON_SOURCE_DIR}/coreblas/include + ${CHAMELEON_BINARY_DIR}/coreblas/include) install(TARGETS ${_name_exe} DESTINATION bin/chameleon/lapack_to_chameleon) endforeach() -add_executable(step0 step0.c) -set_property(TARGET step0 PROPERTY LINKER_LANGUAGE Fortran) -target_link_libraries(step0 ${libs_for_step0}) -install(TARGETS step0 - DESTINATION bin/chameleon/lapack_to_chameleon) - #-------- Tests --------- include(CTestLists.cmake) diff --git a/example/lapack_to_chameleon/CTestLists.cmake b/example/lapack_to_chameleon/CTestLists.cmake index a32e3686f6d0c221ccbaa42245e469ecb41568bd..774e12e2c34fac67f48a66524da80d674542928e 100644 --- a/example/lapack_to_chameleon/CTestLists.cmake +++ b/example/lapack_to_chameleon/CTestLists.cmake @@ -2,7 +2,7 @@ # Check Example lapack_to_chameleon # -set(TESTLIST +set(TESTLIST step0 step1 step2 @@ -10,6 +10,7 @@ set(TESTLIST step4 step5 step6 + step7 ) foreach(test ${TESTLIST}) diff --git a/example/lapack_to_chameleon/step6.h b/example/lapack_to_chameleon/step6.h index d35e8e4e809f1399d2f8ab7e15ae46aae969c627..9bc104bffe9d231229947ff0d9869af560592dec 100644 --- a/example/lapack_to_chameleon/step6.h +++ b/example/lapack_to_chameleon/step6.h @@ -25,9 +25,9 @@ /* Specific includes for step 6 */ #include <coreblas/lapacke.h> #include <chameleon.h> -#if defined(CHAMELEON_USE_MPI) -#include <mpi.h> -#endif +// #if defined(CHAMELEON_USE_MPI) +// #include <mpi.h> +// #endif /* Integer parameters for step6 */ enum iparam_step6 { diff --git a/example/lapack_to_chameleon/step7.h b/example/lapack_to_chameleon/step7.h index dd97977bb12b4947f13b0c2079a4e03413a65f7c..ecb5c08358afd9485b6c3150a730dc37f0a51755 100644 --- a/example/lapack_to_chameleon/step7.h +++ b/example/lapack_to_chameleon/step7.h @@ -27,9 +27,9 @@ #include <coreblas/lapacke.h> #include <coreblas.h> #include <chameleon.h> -#if defined(CHAMELEON_USE_MPI) -#include <mpi.h> -#endif +// #if defined(CHAMELEON_USE_MPI) +// #include <mpi.h> +// #endif /* Integer parameters for step7 */ enum iparam_step7 { diff --git a/example/link_chameleon/CMakeLists.txt b/example/link_chameleon/CMakeLists.txt index 61ff4009a96d383548bdbce06022a7894c07afd5..ff8df44697cfe7bec8f1d4c21b852e9a33cbff6b 100644 --- a/example/link_chameleon/CMakeLists.txt +++ b/example/link_chameleon/CMakeLists.txt @@ -21,56 +21,16 @@ # @date 2020-03-03 # ### -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.1) project(LINK_CHAMELEON Fortran C CXX) -# Add extra cmake module path and initialize chameleon cmake modules -# -------------------------------------------------------------- -set( CHAMELEON_DISTRIB_DIR "" CACHE PATH "Directory of CHAMELEON distribution") -option( CHAMELEON_CHAMELEON_USE_QUARK "CHAMELEON to be linked with QUARK runtime" OFF) -option( CHAMELEON_CHAMELEON_USE_STARPU "CHAMELEON to be linked with StarPU runtime (default)" ON) +find_package(CHAMELEON) -# Both options cannot be ON at the same time: it is either QUARK or StarPU -if (CHAMELEON_CHAMELEON_USE_QUARK) - set(CHAMELEON_CHAMELEON_USE_STARPU OFF) -elseif (CHAMELEON_CHAMELEON_USE_STARPU) - set(CHAMELEON_CHAMELEON_USE_QUARK OFF) -endif() - -if (CHAMELEON_DISTRIB_DIR) - set( CHAMELEON_CMAKE_MODULE_DIR "${CHAMELEON_DISTRIB_DIR}/morse_cmake/modules" CACHE PATH - "Directory where to find CHAMELEON CMake modules (morse_cmake/modules)") - list(APPEND CMAKE_MODULE_PATH "${CHAMELEON_CMAKE_MODULE_DIR}") - list(APPEND CMAKE_MODULE_PATH "${CHAMELEON_CMAKE_MODULE_DIR}/find") - message(STATUS "CHAMELEON_CMAKE_MODULE_DIR : ${CHAMELEON_CMAKE_MODULE_DIR}/morse_cmake/modules") - include(ChamInit) - - # Detect CHAMELEON - if (CHAMELEON_CHAMELEON_USE_QUARK) - find_package(CHAMELEON COMPONENTS QUARK) - else() - find_package(CHAMELEON COMPONENTS STARPU MPI CUDA) - endif() - if (CHAMELEON_FOUND) - link_directories(${CHAMELEON_LIBRARY_DIRS_DEP}) - include_directories(${CHAMELEON_INCLUDE_DIRS_DEP}) - else() - message(FATAL_ERROR "Chameleon libraries not found in your environment." - "Please update your environment variables that help find it" - "(INCLUDE, LD_LIBRARY_PATH) or give its install directory setting CHAMELEON_DIR.") - endif() - - # link_chameleon exe - add_executable(link_chameleon_c link_chameleon.c) - target_link_libraries(link_chameleon_c ${CHAMELEON_LIBRARIES_DEP}) - add_executable(link_chameleon_f link_chameleon.f90) - target_link_libraries(link_chameleon_f ${CHAMELEON_LIBRARIES_DEP}) -else() - message(STATUS "CHAMELEON_DISTRIB_DIR is not set") - message(STATUS "Please indicate where is located your CHAMELEON distribution directory." - " This is necessary to find cmake_modules.") -endif() +add_executable(link_chameleon_c link_chameleon.c) +target_link_libraries(link_chameleon_c PRIVATE MORSE::CHAMELEON) +add_executable(link_chameleon_f link_chameleon.f90) +target_link_libraries(link_chameleon_f PRIVATE MORSE::CHAMELEON) ### ### END CMakeLists.txt ### diff --git a/example/link_chameleon/README.org b/example/link_chameleon/README.org index 13457c00a578ae684ac37ac08dbbd0cbd16bbc20..0ce8ba13b100e82865b393646444555fe67c2a78 100644 --- a/example/link_chameleon/README.org +++ b/example/link_chameleon/README.org @@ -3,18 +3,29 @@ #+OPTIONS: H:3 num:t \n:nil @:t ::t |:t _:nil ^:nil -:t f:t *:t <:t #+OPTIONS: TeX:t LaTeX:t skip:nil d:nil pri:nil tags:not-in-toc html-style:nil -Install Chameleon and its dependencies +Install Chameleon and its dependencies, please refer to this [[https://solverstack.gitlabpages.inria.fr/chameleon/#orga9a42d3][section]]. #+begin_src -# load an environment with dependencies available -# for example -spack install chameleon@master -spack load openblas -spack load hwloc -spack load starpu -spack load chameleon -# alternativaly use pkg-config and/or update your CPATH and LD_LIBRARY_PATH -# for example -export PKG_CONFIG_PATH=/where/is/installed/chameleon/lib/pkgconfig:$PKG_CONFIG_PATH +# example on a Debian/Ubuntu +sudo apt-get update +sudo apt-get install -y libopenblas-dev liblapacke-dev libstarpu-dev +git clone --recursive https://gitlab.inria.fr/solverstack/chameleon.git +cd chameleon && mkdir -p build && cd build +CHAMELEON_ROOT=$PWD/install +cmake .. -DCMAKE_INSTALL_PREFIX=$CHAMELEON_ROOT && make -j5 install +# chameleon is installed in $CHAMELEON_ROOT + +# if your work in a cmake project you can use the CHAMELEONConfig.cmake file +# installed under <prefix>/lib/cmake/chameleon/ by setting your +# CMAKE_PREFIX_PATH with the path of installation. In your cmake project, use +# find_package(CHAMELEON) and link your libraries and/or executables with the +# library target MORSE::CHAMELEON +cmake . -DCMAKE_PREFIX_PATH=$CHAMELEON_ROOT +# if your work outside of cmake you can use the pkg-config file provided +export PKG_CONFIG_PATH=$CHAMELEON_ROOT/lib/pkgconfig:$PKG_CONFIG_PATH +# then configure/build your program using pkg-config infos +# pkg-config --cflags [--static] chameleon +# pkg-config --libs [--static] chameleon +# ... #+end_src Example to link with chameleon in CMake project, see the @@ -22,13 +33,13 @@ Example to link with chameleon in CMake project, see the #+begin_src mkdir build cd build -cmake .. -DCHAMELEON_DISTRIB_DIR=$PWD/../../../cmake_modules -DCHAMELEON_CHAMELEON_USE_STARPU=ON +cmake .. -DCMAKE_PREFIX_PATH=$CHAMELEON_ROOT make VERBOSE=1 ./link_chameleon_c ./link_chameleon_f #+end_src -Example using directly the pkg-config file +Example using directly the pkg-config file and if chameleon is a static library (remove --static if dynamic) #+begin_src gcc `pkg-config --cflags chameleon` -o link_chameleon_c link_chameleon.c `pkg-config --libs --static chameleon` gfortran `pkg-config --cflags chameleon` -o link_chameleon_f link_chameleon.f90 `pkg-config --libs --static chameleon` diff --git a/include/chameleon/config.h.in b/include/chameleon/config.h.in index 0ad3b485bcef131531d70a27a5471ef49bf7f060..dea9a42007a68d915f633d48f417ca2b0b71c067 100644 --- a/include/chameleon/config.h.in +++ b/include/chameleon/config.h.in @@ -56,6 +56,12 @@ #cmakedefine CHAMELEON_HAVE_GETOPT_H #cmakedefine CHAMELEON_HAVE_GETOPT_LONG +/* chameleon compute */ +#cmakedefine CHAMELEON_COPY_DIAG + +/* chameleon runtime starpu */ +#cmakedefine CHAMELEON_ENABLE_PRUNING_STATS + #ifdef BEGIN_C_DECLS #undef BEGIN_C_DECLS #endif @@ -65,11 +71,13 @@ #endif #if defined(c_plusplus) || defined(__cplusplus) -# define BEGIN_C_DECLS extern "C" { -# define END_C_DECLS } +#define BEGIN_C_DECLS \ + extern "C" \ + { +#define END_C_DECLS } #else -# define BEGIN_C_DECLS /* empty */ -# define END_C_DECLS /* empty */ +#define BEGIN_C_DECLS /* empty */ +#define END_C_DECLS /* empty */ #endif -#endif /* CHAMELEON_CONFIG_H_HAS_BEEN_INCLUDED */ +#endif /* CHAMELEON_CONFIG_H_HAS_BEEN_INCLUDED */ diff --git a/lib/pkgconfig/chameleon.pc.in b/lib/pkgconfig/chameleon.pc.in index 80f9dabe1fb8fa8d513aff49c1cc54377b966f0d..50550a26c25617da1962bafee05020a518ad7fb9 100644 --- a/lib/pkgconfig/chameleon.pc.in +++ b/lib/pkgconfig/chameleon.pc.in @@ -5,7 +5,7 @@ includedir=${exec_prefix}/include Name: chameleon Description: Dense Linear Algebra for Scalable Multi-core Architectures and GPGPUs -Version: @CHAMELEON_VERSION_MAJOR@.@CHAMELEON_VERSION_MINOR@.@CHAMELEON_VERSION_MICRO@ +Version: @CHAMELEON_VERSION@ Cflags: @CHAMELEON_PKGCONFIG_DEFINITIONS@ -I${includedir} Libs: -L${libdir} @CHAMELEON_PKGCONFIG_LIBS@ Libs.private: @CHAMELEON_PKGCONFIG_LIBS_PRIVATE@ diff --git a/runtime/openmp/CMakeLists.txt b/runtime/openmp/CMakeLists.txt index 0dd9e7816f78957eeeefc3a1c9fac3b977d73369..6ad2c0cf7861a25720f89283520ffb44d2a39775 100644 --- a/runtime/openmp/CMakeLists.txt +++ b/runtime/openmp/CMakeLists.txt @@ -25,25 +25,19 @@ # @date 2020-03-03 # ### -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.1) find_package(OpenMP REQUIRED) if ( OPENMP_FOUND ) message("-- ${Blue}Add definition CHAMELEON_SCHED_OPENMP" " - Activate OpenMP in Chameleon${ColourReset}") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") - set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${OpenMP_Fortran_FLAGS}") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_C_FLAGS}") # TODO: check for compiler support for "_Pragma" else ( OPENMP_FOUND ) message(FATAL_ERROR "Something went wrong when finding OpenMP") return() endif ( OPENMP_FOUND ) -include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include ) -include_directories( ${CMAKE_CURRENT_BINARY_DIR}/include ) - # Define the list of headers # -------------------------- set(RUNTIME_HDRS @@ -110,22 +104,37 @@ set(CHAMELEON_SOURCES_TARGETS "${CHAMELEON_SOURCES_TARGETS};runtime_openmp_inclu # Add library # ----------- add_library(chameleon_openmp ${RUNTIME_SRCS}) -set_property(TARGET chameleon_openmp PROPERTY LINKER_LANGUAGE Fortran) +set_target_properties(chameleon_openmp PROPERTIES VERSION ${CHAMELEON_VERSION}) +set_target_properties(chameleon_openmp PROPERTIES SOVERSION ${CHAMELEON_VERSION_MAJOR}) set_property(TARGET chameleon_openmp PROPERTY INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") -target_link_libraries(chameleon_openmp - ${OPENMP_LIBRARIES_DEP}) -target_link_libraries(chameleon_openmp - coreblas) - add_dependencies(chameleon_openmp chameleon_include control_include + coreblas_include runtime_openmp_include openmp_sources ) -add_dependencies(chameleon_openmp coreblas_include) +target_include_directories(chameleon_openmp PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> + $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include> + $<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}> + $<BUILD_INTERFACE:${CHAMELEON_BINARY_DIR}> + $<INSTALL_INTERFACE:include>) +target_include_directories(chameleon_openmp PRIVATE + $<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}/include> + $<BUILD_INTERFACE:${CHAMELEON_BINARY_DIR}/include> + $<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}/coreblas/include> + $<BUILD_INTERFACE:${CHAMELEON_BINARY_DIR}/coreblas/include>) + +target_link_libraries(chameleon_openmp PRIVATE OpenMP::OpenMP_C) +target_link_libraries(chameleon_openmp PRIVATE coreblas) +target_link_libraries(chameleon_openmp PRIVATE MORSE::M) + +# necessary cause of include control/common.h which depends on hqr, mpi, cuda, ... +# TODO: remove this dependency as soon as headers are clean +target_link_libraries(chameleon_openmp PUBLIC hqr) # installation # ------------ @@ -133,6 +142,15 @@ install(TARGETS chameleon_openmp ARCHIVE DESTINATION lib LIBRARY DESTINATION lib) +# export target +install(EXPORT chameleon_openmpTargets + NAMESPACE CHAMELEON:: + DESTINATION lib/cmake/chameleon + ) + +# install target file +install(TARGETS chameleon_openmp EXPORT chameleon_openmpTargets) + ### ### END CMakeLists.txt ### diff --git a/runtime/parsec/CMakeLists.txt b/runtime/parsec/CMakeLists.txt index fd99b8d0a8544101f411825cf199f8696b3228a3..aae60b59c5050e9409868745ec9c90e56c3ce356 100644 --- a/runtime/parsec/CMakeLists.txt +++ b/runtime/parsec/CMakeLists.txt @@ -25,86 +25,14 @@ # @date 2020-03-03 # ### -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.1) -# create list of components in order to make a single call to find_package(starpu...) -set(PARSEC_COMPONENT_LIST "HWLOC") -if(CHAMELEON_USE_MPI) - list(APPEND PARSEC_COMPONENT_LIST "MPI") -endif() -if(CHAMELEON_USE_CUDA) - list(APPEND PARSEC_COMPONENT_LIST "CUDA") -endif() - -find_package( PARSEC REQUIRED - COMPONENTS ${PARSEC_COMPONENT_LIST} ) +find_package( PARSEC REQUIRED ) if(PARSEC_FOUND) message("-- ${Blue}Add definition CHAMELEON_SCHED_PARSEC" " - Activate PaRSEC in Chameleon${ColourReset}") - if (PARSEC_INCLUDE_DIRS_DEP) - include_directories(${PARSEC_INCLUDE_DIRS_DEP}) - endif() - if(PARSEC_CFLAGS_OTHER_DEP) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PARSEC_CFLAGS_OTHER_DEP}") - string(REPLACE ";" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - endif() - if(PARSEC_LDFLAGS_OTHER_DEP) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PARSEC_LDFLAGS_OTHER_DEP}") - string(REPLACE ";" " " CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") - endif() - if(PARSEC_LIBRARY_DIRS_DEP) - list(APPEND CMAKE_INSTALL_RPATH "${PARSEC_LIBRARY_DIRS_DEP}") - endif() - if (PARSEC_LIBRARIES_DEP) - list(INSERT CHAMELEON_DEP 0 ${PARSEC_LIBRARIES_DEP}) - endif() - string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") - # to test if symbols exist, e.g. - # set(CMAKE_REQUIRED_INCLUDES "${PARSEC_INCLUDE_DIRS_DEP}") - # set(CMAKE_REQUIRED_FLAGS "${PARSEC_CFLAGS_OTHER_DEP}") - # set(CMAKE_REQUIRED_LDFLAGS "${PARSEC_LDFLAGS_OTHER_DEP}") - # set(CMAKE_REQUIRED_LIBRARIES "${PARSEC_LIBRARIES_DEP}") - # check_function_exists(parsec_init HAVE_PARSEC_INIT) -else ( PARSEC_FOUND ) - if(CHAMELEON_VERBOSE_FIND_PACKAGE) - if(NOT HWLOC_FOUND OR NOT HWLOC_LIBRARIES) - if (NOT HWLOC_hwloc.h_DIRS) - Print_Find_Header_Status(hwloc hwloc.h) - endif () - if (NOT HWLOC_hwloc_LIBRARY) - Print_Find_Library_Status(hwloc libhwloc) - endif () - endif() - if( (NOT PARSEC_FOUND) OR (NOT PARSEC_LIBRARIES_DEP) ) - foreach(parsec_hdr ${PARSEC_hdrs_to_find}) - if (NOT PARSEC_${parsec_hdr}_INCLUDE_DIRS) - Print_Find_Header_Status(parsec ${parsec_hdr}) - endif () - endforeach() - if(PARSEC_VERSION_STRING) - foreach(parsec_lib ${PARSEC_libs_to_find}) - if (NOT PARSEC_${parsec_lib}_LIBRARY) - Print_Find_Library_Status(parsec ${parsec_lib}) - endif () - endforeach() - endif() - endif() - else(CHAMELEON_VERBOSE_FIND_PACKAGE) - message(WARNING "PaRSEC library has not been found and CHAMELEON_VERBOSE_FIND_PACKAGE is set to OFF." - " Try to activate CHAMELEON_VERBOSE_FIND_PACKAGE option (-DCHAMELEON_VERBOSE_FIND_PACKAGE=ON) to get some hints for the detection") - endif(CHAMELEON_VERBOSE_FIND_PACKAGE) - if(NOT HWLOC_FOUND OR NOT HWLOC_LIBRARIES) - message(FATAL_ERROR "hwloc library is required but has not been found") - endif() - if( (NOT PARSEC_FOUND) OR (NOT PARSEC_LIBRARIES_DEP) ) - message(FATAL_ERROR "PaRSEC library is required but has not been found") - endif() - return() -endif ( PARSEC_FOUND ) - -include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include ) -include_directories( ${CMAKE_CURRENT_BINARY_DIR}/include ) +endif(PARSEC_FOUND) # Generate headers for all possible precisions # -------------------------------------------- @@ -188,30 +116,48 @@ set(CHAMELEON_SOURCES_TARGETS "${CHAMELEON_SOURCES_TARGETS};runtime_parsec_inclu # Add library # ----------- add_library(chameleon_parsec ${RUNTIME_SRCS}) -set_property(TARGET chameleon_parsec PROPERTY LINKER_LANGUAGE Fortran) +set_target_properties(chameleon_parsec PROPERTIES VERSION ${CHAMELEON_VERSION}) +set_target_properties(chameleon_parsec PROPERTIES SOVERSION ${CHAMELEON_VERSION_MAJOR}) set_property(TARGET chameleon_parsec PROPERTY INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") -target_link_libraries(chameleon_parsec - ${PARSEC_LIBRARIES_DEP}) -if (NOT CHAMELEON_SIMULATION) - target_link_libraries(chameleon_parsec coreblas) - if(CHAMELEON_USE_CUDA) - target_link_libraries(chameleon_parsec cudablas) - endif(CHAMELEON_USE_CUDA) -endif(NOT CHAMELEON_SIMULATION) - add_dependencies(chameleon_parsec chameleon_include control_include + coreblas_include runtime_parsec_include parsec_sources ) +if (CHAMELEON_USE_CUDA) + add_dependencies(chameleon_parsec cudablas_include) +endif() -if (NOT CHAMELEON_SIMULATION) - add_dependencies(chameleon_parsec coreblas_include) - if (CHAMELEON_USE_CUDA) - add_dependencies(chameleon_parsec cudablas_include) - endif() +target_include_directories(chameleon_parsec PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> + $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include> + $<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}> + $<BUILD_INTERFACE:${CHAMELEON_BINARY_DIR}> + $<INSTALL_INTERFACE:include>) +target_include_directories(chameleon_parsec PRIVATE + $<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}/include> + $<BUILD_INTERFACE:${CHAMELEON_BINARY_DIR}/include> + $<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}/coreblas/include> + $<BUILD_INTERFACE:${CHAMELEON_BINARY_DIR}/coreblas/include>) + +target_link_libraries(chameleon_parsec PRIVATE MORSE::PARSEC) +target_link_libraries(chameleon_parsec PRIVATE coreblas) +if(CHAMELEON_USE_CUDA) + target_link_libraries(chameleon_parsec PRIVATE cudablas) +endif(CHAMELEON_USE_CUDA) +target_link_libraries(chameleon_parsec PRIVATE MORSE::M) + +# necessary cause of include control/common.h which depends on hqr, mpi, cuda, ... +# TODO: remove this dependency as soon as headers are clean +target_link_libraries(chameleon_parsec PUBLIC hqr) +if (CHAMELEON_USE_MPI) + target_link_libraries(chameleon_parsec PUBLIC MPI::MPI_C) +endif() +if (CHAMELEON_USE_CUDA) + target_link_libraries(chameleon_parsec PUBLIC CUDA::CUBLAS) endif() # installation @@ -220,6 +166,15 @@ install(TARGETS chameleon_parsec ARCHIVE DESTINATION lib LIBRARY DESTINATION lib) +# export target +install(EXPORT chameleon_parsecTargets + NAMESPACE CHAMELEON:: + DESTINATION lib/cmake/chameleon + ) + +# install target file +install(TARGETS chameleon_parsec EXPORT chameleon_parsecTargets) + ### ### END CMakeLists.txt ### diff --git a/runtime/quark/CMakeLists.txt b/runtime/quark/CMakeLists.txt index 099da938107b63d5c5576ca2c093b498ae056956..f62dba50fb16c2d25400c9ac0b2331334bc49a97 100644 --- a/runtime/quark/CMakeLists.txt +++ b/runtime/quark/CMakeLists.txt @@ -25,62 +25,16 @@ # @date 2020-03-03 # ### -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.1) -find_package( QUARK REQUIRED - COMPONENTS HWLOC ) +find_package( QUARK REQUIRED COMPONENTS HWLOC ) # Add definition and include_dir if found if(QUARK_FOUND) message("-- ${Blue}Add definition CHAMELEON_SCHED_QUARK" " - Activate QUARK in Chameleon${ColourReset}") - if (QUARK_INCLUDE_DIRS_DEP) - include_directories(${QUARK_INCLUDE_DIRS_DEP}) - endif() - if(QUARK_CFLAGS_OTHER_DEP) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${QUARK_CFLAGS_OTHER_DEP}") - string(REPLACE ";" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - endif() - if(QUARK_LDFLAGS_OTHER_DEP) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${QUARK_LDFLAGS_OTHER_DEP}") - string(REPLACE ";" " " CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") - endif() - if(QUARK_LIBRARY_DIRS_DEP) - list(APPEND CMAKE_INSTALL_RPATH "${QUARK_LIBRARY_DIRS_DEP}") - endif() - if (QUARK_LIBRARIES_DEP) - list(INSERT CHAMELEON_DEP 0 ${QUARK_LIBRARIES_DEP}) - endif() -else(QUARK_FOUND) - if(CHAMELEON_VERBOSE_FIND_PACKAGE) - if(NOT HWLOC_FOUND OR NOT HWLOC_LIBRARIES) - if (NOT HWLOC_hwloc.h_DIRS) - Print_Find_Header_Status(hwloc hwloc.h) - endif () - if (NOT HWLOC_hwloc_LIBRARY) - Print_Find_Library_Status(hwloc libhwloc) - endif () - endif() - if (NOT QUARK_quark.h_DIRS) - Print_Find_Header_Status(quark quark.h) - endif () - if (NOT QUARK_quark_LIBRARY) - Print_Find_Library_Status(quark libquark) - endif () - else() - message(WARNING "QUARK library has not been found and CHAMELEON_VERBOSE_FIND_PACKAGE is set to OFF." - " Try to activate CHAMELEON_VERBOSE_FIND_PACKAGE option (-DCHAMELEON_VERBOSE_FIND_PACKAGE=ON) to get some hints for the detection") - endif() - if(NOT HWLOC_FOUND OR NOT HWLOC_LIBRARIES) - message(FATAL_ERROR "hwloc library is required but has not been found") - endif() - message(FATAL_ERROR "QUARK library is required but has not been found") - return() endif(QUARK_FOUND) -include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include ) -include_directories( ${CMAKE_CURRENT_BINARY_DIR}/include ) - # # Generate headers for all possible precisions # # -------------------------------------------- # set(RUNTIME_HDRS_GENERATED "") @@ -164,29 +118,51 @@ set(CHAMELEON_SOURCES_TARGETS "${CHAMELEON_SOURCES_TARGETS};runtime_quark_includ # Add library # ----------- add_library(chameleon_quark ${RUNTIME_SRCS}) -set_property(TARGET chameleon_quark PROPERTY LINKER_LANGUAGE Fortran) +set_target_properties(chameleon_quark PROPERTIES VERSION ${CHAMELEON_VERSION}) set_property(TARGET chameleon_quark PROPERTY INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") -target_link_libraries(chameleon_quark coreblas ${QUARK_LIBRARIES_DEP}) -if(CHAMELEON_USE_CUDA) - target_link_libraries(chameleon_quark cudablas) -endif(CHAMELEON_USE_CUDA) - add_dependencies(chameleon_quark chameleon_include control_include + coreblas_include runtime_quark_include quark_sources ) -if (NOT CHAMELEON_SIMULATION) - add_dependencies(chameleon_quark coreblas_include) -endif() + +target_include_directories(chameleon_quark PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> + $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include> + $<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}> + $<BUILD_INTERFACE:${CHAMELEON_BINARY_DIR}> + $<INSTALL_INTERFACE:include>) +target_include_directories(chameleon_quark PRIVATE + $<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}/include> + $<BUILD_INTERFACE:${CHAMELEON_BINARY_DIR}/include> + $<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}/coreblas/include> + $<BUILD_INTERFACE:${CHAMELEON_BINARY_DIR}/coreblas/include>) + +target_link_libraries(chameleon_quark PUBLIC MORSE::QUARK) +target_link_libraries(chameleon_quark PUBLIC coreblas) +target_link_libraries(chameleon_quark PRIVATE MORSE::M) + +# necessary cause of include control/common.h which depends on hqr, mpi, cuda, ... +# TODO: remove this dependency as soon as headers are clean +target_link_libraries(chameleon_quark PUBLIC hqr) # installation # ------------ install(TARGETS chameleon_quark DESTINATION lib) + # export target +install(EXPORT chameleon_quarkTargets + NAMESPACE CHAMELEON:: + DESTINATION lib/cmake/chameleon + ) + +# install target file +install(TARGETS chameleon_quark EXPORT chameleon_quarkTargets) + ### ### END CMakeLists.txt ### diff --git a/runtime/starpu/CMakeLists.txt b/runtime/starpu/CMakeLists.txt index 1e5f726cdba477d7f70afa71938de246fabedafc..c6309cab10bce2c14d92cda00c43c9309cf0c65b 100644 --- a/runtime/starpu/CMakeLists.txt +++ b/runtime/starpu/CMakeLists.txt @@ -25,52 +25,18 @@ # @date 2020-03-03 # ### -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.1) -set(CHAMELEON_STARPU_VERSION "1.3" CACHE STRING "oldest STARPU version desired") +set(CHAMELEON_STARPU_VERSION "1.3" CACHE STRING "necessary STARPU API version") -# create list of components in order to make a single call to find_package(starpu...) -if(NOT CHAMELEON_SIMULATION) - set(STARPU_COMPONENT_LIST "HWLOC") - if(CHAMELEON_USE_CUDA) - list(APPEND STARPU_COMPONENT_LIST "CUDA") - endif() -else() - set(STARPU_COMPONENT_LIST "SIMGRID") -endif() -if(CHAMELEON_USE_MPI) - list(APPEND STARPU_COMPONENT_LIST "MPI") -endif() +find_package(STARPU ${CHAMELEON_STARPU_VERSION} REQUIRED) -find_package(STARPU ${CHAMELEON_STARPU_VERSION} REQUIRED - COMPONENTS ${STARPU_COMPONENT_LIST}) - -# Add definition and include_dir if found +# check available functions +# note: recall STARPU_VERSION provides the version if ( STARPU_FOUND ) message("-- ${Blue}Add definition CHAMELEON_SCHED_STARPU" " - Activate StarPU in Chameleon${ColourReset}") - if (STARPU_INCLUDE_DIRS_DEP) - include_directories(${STARPU_INCLUDE_DIRS_DEP}) - set(CMAKE_REQUIRED_INCLUDES "${STARPU_INCLUDE_DIRS_DEP}") - endif() - if(STARPU_CFLAGS_OTHER_DEP) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${STARPU_CFLAGS_OTHER_DEP}") - string(REPLACE ";" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") - set(CMAKE_REQUIRED_FLAGS "${STARPU_CFLAGS_OTHER_DEP}") - endif() - if(STARPU_LDFLAGS_OTHER_DEP) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${STARPU_LDFLAGS_OTHER_DEP}") - string(REPLACE ";" " " CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}") - set(CMAKE_REQUIRED_LDFLAGS "${STARPU_LDFLAGS_OTHER_DEP}") - endif() - if(STARPU_LIBRARY_DIRS_DEP) - list(APPEND CMAKE_INSTALL_RPATH "${STARPU_LIBRARY_DIRS_DEP}") - endif() - if (STARPU_LIBRARIES_DEP) - list(INSERT CHAMELEON_DEP 0 ${STARPU_LIBRARIES_DEP}) - set(CMAKE_REQUIRED_LIBRARIES "${STARPU_LIBRARIES_DEP}") - endif() - string(REPLACE ";" " " CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}") + get_target_property(CMAKE_REQUIRED_LIBRARIES MORSE::STARPU INTERFACE_LINK_LIBRARIES) check_function_exists(starpu_data_idle_prefetch_on_node HAVE_STARPU_IDLE_PREFETCH) if ( HAVE_STARPU_IDLE_PREFETCH ) message("-- ${Blue}Add definition HAVE_STARPU_IDLE_PREFETCH${ColourReset}") @@ -143,61 +109,9 @@ if ( STARPU_FOUND ) message("-- ${Blue}Add definition HAVE_STARPU_MPI_COMM_GET_ATTR${ColourReset}") endif() endif() -else ( STARPU_FOUND ) - if(CHAMELEON_VERBOSE_FIND_PACKAGE) - if(NOT HWLOC_FOUND OR NOT HWLOC_LIBRARIES) - if (NOT HWLOC_hwloc.h_DIRS) - Print_Find_Header_Status(hwloc hwloc.h) - endif () - if (NOT HWLOC_hwloc_LIBRARY) - Print_Find_Library_Status(hwloc libhwloc) - endif () - endif() - if(CHAMELEON_SIMULATION AND (NOT SIMGRID_FOUND OR NOT SIMGRID_LIBRARIES)) - if (NOT SIMGRID_simgrid.h_DIRS) - Print_Find_Header_Status(simgrid simgrid.h) - endif () - if (NOT SIMGRID_simgrid_LIBRARY) - Print_Find_Library_Status(simgrid libsimgrid) - endif () - endif() - if( (NOT STARPU_SHM_FOUND) OR (NOT STARPU_SHM_LIBRARIES) OR - ( STARPU_LOOK_FOR_MPI AND (NOT STARPU_MPI_FOUND OR NOT STARPU_MPI_LIBRARIES) ) - ) - foreach(starpu_hdr ${STARPU_hdrs_to_find}) - if (NOT STARPU_${starpu_hdr}_INCLUDE_DIRS) - Print_Find_Header_Status(starpu ${starpu_hdr}) - endif () - endforeach() - if(STARPU_VERSION_STRING) - foreach(starpu_lib ${STARPU_libs_to_find}) - if (NOT STARPU_${starpu_lib}_LIBRARY) - Print_Find_Library_Status(starpu ${starpu_lib}) - endif () - endforeach() - endif () - endif () - else(CHAMELEON_VERBOSE_FIND_PACKAGE) - message(WARNING "StarPU library has not been found and CHAMELEON_VERBOSE_FIND_PACKAGE is set to OFF." - " Try to activate CHAMELEON_VERBOSE_FIND_PACKAGE option (-DCHAMELEON_VERBOSE_FIND_PACKAGE=ON) to get some hints for the detection") - endif(CHAMELEON_VERBOSE_FIND_PACKAGE) - if(NOT HWLOC_FOUND OR NOT HWLOC_LIBRARIES) - message(FATAL_ERROR "hwloc library is required but has not been found") - endif() - if(CHAMELEON_SIMULATION AND (NOT SIMGRID_FOUND OR NOT SIMGRID_LIBRARIES)) - message(FATAL_ERROR "SimGrid library is required but has not been found") - endif() - if( (NOT STARPU_SHM_FOUND) OR (NOT STARPU_SHM_LIBRARIES) OR - ( STARPU_LOOK_FOR_MPI AND (NOT STARPU_MPI_FOUND OR NOT STARPU_MPI_LIBRARIES) ) - ) - message(FATAL_ERROR "StarPU library is required but has not been found") - endif() - return() + unset(CMAKE_REQUIRED_LIBRARIES) endif ( STARPU_FOUND ) -include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include ) -include_directories( ${CMAKE_CURRENT_BINARY_DIR}/include ) - configure_file("include/chameleon_starpu.h.in" "include/chameleon_starpu.h" @ONLY) @@ -298,20 +212,10 @@ set(CHAMELEON_SOURCES_TARGETS "${CHAMELEON_SOURCES_TARGETS};runtime_starpu_inclu # Add library # ----------- add_library(chameleon_starpu ${RUNTIME_SRCS}) -set_property(TARGET chameleon_starpu PROPERTY LINKER_LANGUAGE Fortran) +set_target_properties(chameleon_starpu PROPERTIES VERSION ${CHAMELEON_VERSION}) +set_target_properties(chameleon_starpu PROPERTIES SOVERSION ${CHAMELEON_VERSION_MAJOR}) set_property(TARGET chameleon_starpu PROPERTY INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") -target_link_libraries(chameleon_starpu - ${STARPU_LIBRARIES_DEP}) -if (NOT CHAMELEON_SIMULATION) - target_link_libraries(chameleon_starpu - coreblas) - if(CHAMELEON_USE_CUDA) - target_link_libraries(chameleon_starpu - cudablas) - endif(CHAMELEON_USE_CUDA) -endif(NOT CHAMELEON_SIMULATION) - add_dependencies(chameleon_starpu chameleon_include control_include @@ -325,12 +229,60 @@ if (NOT CHAMELEON_SIMULATION) endif() endif() +target_include_directories(chameleon_starpu PUBLIC + $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> + $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include> + $<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}> + $<BUILD_INTERFACE:${CHAMELEON_BINARY_DIR}> + $<INSTALL_INTERFACE:include>) +target_include_directories(chameleon_starpu PRIVATE + $<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}/include> + $<BUILD_INTERFACE:${CHAMELEON_BINARY_DIR}/include> + $<BUILD_INTERFACE:${CHAMELEON_SOURCE_DIR}/coreblas/include> + $<BUILD_INTERFACE:${CHAMELEON_BINARY_DIR}/coreblas/include>) + +if (CHAMELEON_SIMULATION) + # need PUBLIC here because simulation mode with starpu requires to replace the + # main function by a starpu main one + target_link_libraries(chameleon_starpu PUBLIC MORSE::STARPU) +else() + target_link_libraries(chameleon_starpu PRIVATE MORSE::STARPU) +endif() +if (NOT CHAMELEON_SIMULATION) + target_link_libraries(chameleon_starpu PRIVATE coreblas) + if(CHAMELEON_USE_CUDA) + target_link_libraries(chameleon_starpu PRIVATE cudablas) + endif(CHAMELEON_USE_CUDA) +endif(NOT CHAMELEON_SIMULATION) +target_link_libraries(chameleon_starpu PRIVATE MORSE::M) + +# necessary cause of include control/common.h which depends on hqr, mpi, cuda, ... +# TODO: remove this dependency as soon as headers are clean +target_link_libraries(chameleon_starpu PUBLIC hqr) +if (CHAMELEON_USE_MPI) + target_link_libraries(chameleon_starpu PUBLIC MPI::MPI_C) +endif() +if (NOT CHAMELEON_SIMULATION) + if (CHAMELEON_USE_CUDA) + target_link_libraries(chameleon_starpu PUBLIC CUDA::CUBLAS) + endif() +endif() + # installation # ------------ install(TARGETS chameleon_starpu ARCHIVE DESTINATION lib LIBRARY DESTINATION lib) +# export target +install(EXPORT chameleon_starpuTargets + NAMESPACE CHAMELEON:: + DESTINATION lib/cmake/chameleon + ) + +# install target file +install(TARGETS chameleon_starpu EXPORT chameleon_starpuTargets) + ### ### END CMakeLists.txt ### diff --git a/testing/CMakeLists.txt b/testing/CMakeLists.txt index df0573a94ebccdb71f57e7b24c607de3e60b5d21..10bdea1950fb6d4478df9e0c4a289e90fd7d3a1c 100644 --- a/testing/CMakeLists.txt +++ b/testing/CMakeLists.txt @@ -101,17 +101,6 @@ set(ZSRC testing_zplrnk.c ) -# Add include and link directories -# -------------------------------- -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -include_directories(${CMAKE_CURRENT_BINARY_DIR}) - -# Define what libraries we have to link with -# ------------------------------------------ -unset(libs_for_tests) -# testing executables depend on chameleon and cblas, lapacke, mpi (already chameleon's dependencies) -list(APPEND libs_for_tests chameleon) -# message(STATUS "libs testings: ${libs_for_tests}") # Create one testing per precision with all files # ----------------------------------------------- @@ -132,13 +121,32 @@ foreach(_precision ${CHAMELEON_PRECISION} ) control_include testing_include ) -if(NOT CHAMELEON_SIMULATION) - add_dependencies(${__target_name} - coreblas_include + if(NOT CHAMELEON_SIMULATION) + add_dependencies(${__target_name} + coreblas_include + ) + endif(NOT CHAMELEON_SIMULATION) + + target_include_directories(${__target_name} PRIVATE + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} ) -endif(NOT CHAMELEON_SIMULATION) - set_property(TARGET ${__target_name} PROPERTY LINKER_LANGUAGE Fortran) - target_link_libraries(${__target_name} ${libs_for_tests}) + # testing_zcheck.c includes additional chameleon headers + # coreblas/include/coreblas/cblas.h, coreblas/coreblas_z.h, control/common.h, ... + target_include_directories(${__target_name} PRIVATE + ${CHAMELEON_SOURCE_DIR} + ${CHAMELEON_BINARY_DIR} + ${CHAMELEON_SOURCE_DIR}/coreblas/include + ${CHAMELEON_BINARY_DIR}/coreblas/include + ) + + target_link_libraries(${__target_name} PRIVATE chameleon) + if(NOT CHAMELEON_SIMULATION) + target_link_libraries(${__target_name} PRIVATE + MORSE::LAPACKE + MORSE::CBLAS) + endif() + target_link_libraries(${__target_name} PRIVATE MORSE::M) install(TARGETS ${__target_name} DESTINATION bin/ )