diff --git a/CMakeLists.txt b/CMakeLists.txt index 18ce5b92..17241215 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,8 +18,8 @@ cmake_minimum_required(VERSION 3.20 FATAL_ERROR) cmake_policy(SET CMP0048 NEW) # Set project options -option(USE_CUDA "Use Cuda, if available" false) -option(USE_MPI "Use MPI, if available" false) +option(USE_CUDA "Use CUDA, if available" OFF) +option(USE_MPI "Use MPI, if available" OFF) option(BUILD_TESTS "Option to enable building tests" OFF) option(BUILD_HEAVY_TESTS "Option to enable building heavy tests, This may take a lot of time" OFF) option(BUILD_EXAMPLES "Option to enable building examples" ON) @@ -27,15 +27,27 @@ option(BUILD_DOCS "Build documentation in docs directory" ON) option(USE_R "Enable the use of R and Rcpp in the project" OFF) option(CREATE_PACKAGE "Enable a packaging system for distribution" OFF) +# Declare the RUNTIME_TYPE variable with a default value +set(RUNTIME_TYPE "starpu" CACHE STRING "Specify the runtime type (e.g., starpu or parsec)") # Cmake Module Paths set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake;${CMAKE_MODULE_PATH}") - if (${BUILD_SHARED_LIBS}) set(BLA_STATIC OFF) else () set(BLA_STATIC ON) endif () +# Project Name and Version +project(ExaGeoStatCPP VERSION 2.0.0 DESCRIPTION "ExaGeoStatCPP is a parallel high performance unified framework for geostatistics on manycore systems.") +set(CMAKE_CXX_EXTENSIONS OFF) +string(TOUPPER ${RUNTIME_TYPE} RUNTIME_TYPE) + +if(RUNTIME_TYPE STREQUAL "PARSEC") + message(STATUS "MPI is required to be enabled in order to use PaRSEC") + set(USE_MPI ON) + set(USE_HICMA OFF) +endif() + # Select toolchain based on whether CUDA is enabled or not if (USE_CUDA) message("") @@ -53,9 +65,6 @@ else () include(toolchains/GccToolchain) endif () -# Project Name and Version -project(ExaGeoStatCPP VERSION 1.0.0 DESCRIPTION "ExaGeoStatCPP is a parallel high performance unified framework for geostatistics on manycore systems.") - # Show the current version of CMake. message(STATUS "CMAKE VERSION: ${CMAKE_VERSION}") # Enable C++ language @@ -110,30 +119,43 @@ include(ImportHwloc) list(APPEND STARPU_COMPONENT_LIST "HWLOC") string(REPLACE ";" " " STARPU_COMPONENT_STRING "${STARPU_COMPONENT_LIST}") -# ExaGeoStatCPP depends on StarPU runtime +# ExaGeoStatCPP depends on NLOPT # ------------------------------- -include(ImportStarPu) +include(ImportNLOPT) # ExaGeoStatCPP depends on GSL # ------------------------------- include(ImportGSL) -# ExaGeoStatCPP depends on NLOPT -# ------------------------------- -include(ImportNLOPT) - -# ExaGeoStatCPP depends on HiCMA -# ------------------------------- -if (USE_HICMA) - add_definitions(-DUSE_HICMA=TRUE) - include(ImportHCore) +message("---------------------------------------- ${RUNTIME_TYPE}") +if(RUNTIME_TYPE STREQUAL "STARPU") + message(STATUS "Using StarPU as the runtime") + # ExaGeoStatCPP depends on StarPU runtime + # ------------------------------- + include(ImportStarPu) + # ExaGeoStatCPP depends on HiCMA + # ------------------------------- + if (USE_HICMA) + add_definitions(-DUSE_HICMA=TRUE) + include(ImportHCore) + include(ImportStarsH) + include(ImportHiCMA) + endif () + # ExaGeoStatCPP depends on Chameleon + # ------------------------------- + include(ImportChameleon) + +elseif(RUNTIME_TYPE STREQUAL "PARSEC") + message(STATUS "Using PaRSEC as the runtime") + # ExaGeoStatCPP depends on StarPU runtime + # ------------------------------- include(ImportStarsH) - include(ImportHiCMA) -endif () + include(ImportHCore) + include(ImportHiCMAX) +else() + message(FATAL_ERROR "Unknown RUNTIME_TYPE: ${RUNTIME_TYPE}. Supported values are 'STARPU' or 'PARSEC'.") +endif() -# ExaGeoStatCPP depends on Chameleon -# ------------------------------- -include(ImportChameleon) # ExaGeoStatCPP depends on LAPACK/BLASPP # ------------------------------- @@ -168,10 +190,16 @@ if (USE_R) endif () endif () - # Add src Directory to expose added libraries add_subdirectory(src) +# Define USE_STARPU or USE_RUNTIME based on the selected runtime +if(RUNTIME_TYPE STREQUAL "STARPU") + target_compile_definitions(${PROJECT_NAME} PRIVATE DEFAULT_RUNTIME=1) +elseif(RUNTIME_TYPE STREQUAL "PARSEC") + target_compile_definitions(${PROJECT_NAME} PRIVATE DEFAULT_RUNTIME=0) +endif() + # Creates a new INTERFACE library target named ${PROJECT_NAME}_INTERFACE. # The INTERFACE keyword specifies that this library will not be built, but instead will only be used for its properties. add_library(${PROJECT_NAME}_INTERFACE INTERFACE) @@ -213,15 +241,21 @@ endif () message(" \n \t ** Configurations of ExaGeoStatCPP and installation of dependence is done successfully ** ") message("\t - Export the following line to avoid re-install dependencies each time. -") message("\t ----------------------------------------------------------------------------------------------------------------------------------- ") -message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/CHAMELEON/lib/pkgconfig:$PKG_CONFIG_PATH") -message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/STARPU/lib/pkgconfig:$PKG_CONFIG_PATH") message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/HWLOC/lib/pkgconfig:$PKG_CONFIG_PATH") -message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/GSL/lib/pkgconfig:$PKG_CONFIG_PATH") message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/NLOPT/lib/pkgconfig:${CMAKE_INSTALL_PREFIX}/NLOPT/lib64/pkgconfig:$PKG_CONFIG_PATH") -if(USE_HICMA) +message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/GSL/lib/pkgconfig:$PKG_CONFIG_PATH") +if(RUNTIME_TYPE STREQUAL "STARPU") + message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/STARPU/lib/pkgconfig:$PKG_CONFIG_PATH") + message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/CHAMELEON/lib/pkgconfig:$PKG_CONFIG_PATH") + if(USE_HICMA) + message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/STARSH/lib/pkgconfig:$PKG_CONFIG_PATH") + message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/HCORE/lib/pkgconfig:$PKG_CONFIG_PATH") + message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/HICMA/lib/pkgconfig:$PKG_CONFIG_PATH") + endif() +elseif(RUNTIME_TYPE STREQUAL "PARSEC") message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/STARSH/lib/pkgconfig:$PKG_CONFIG_PATH") message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/HCORE/lib/pkgconfig:$PKG_CONFIG_PATH") - message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/HICMA/lib/pkgconfig:$PKG_CONFIG_PATH") + message("\t export PKG_CONFIG_PATH=${CMAKE_INSTALL_PREFIX}/HICMA-X/lib/pkgconfig:${CMAKE_INSTALL_PREFIX}/HICMA-X/lib64:$PKG_CONFIG_PATH") endif() message("\t ----------------------------------------------------------------------------------------------------------------------------------- \n") diff --git a/README.md b/README.md index 6f6e83f1..3f699598 100644 --- a/README.md +++ b/README.md @@ -60,12 +60,12 @@ statisticians with modest computational resources. ### C++ source code installation To install the `ExaGeoStat` project locally, run the following commands in your terminal: -1. Clone the project from the remote gitHub repository into your local machine using the following command +1. Clone the project repository to your local machine: ```bash git clone https://github.com/ecrc/ExaGeoStatCPP.git ``` -2. Change your current directory by getting into the `ExaGeoStatCPP` project directory +2. Navigate to the cloned directory: ```bash cd ExaGeoStatCPP ``` @@ -84,6 +84,7 @@ To install the `ExaGeoStat` project locally, run the following commands in your ```bash export PKG_CONFIG_PATH=$PWD/installdir/_deps/DEPENDENCY_NAME/lib/pkgconfig:$PKG_CONFIG_PATH ``` + or copy/paste the output pkg-config paths from the configure step Now, you can use the pkg-config executable to collect compiler and linker flags for ExaGeoStatCPP. diff --git a/USER_MANUAL.md b/USER_MANUAL.md index 6b95b532..7f7bfcfb 100644 --- a/USER_MANUAL.md +++ b/USER_MANUAL.md @@ -80,6 +80,7 @@ * To enable packaging system for distribution, add `-p` disabled by default. * To enable showing code warnings, add `-w` disabled by default. * To manually set mkl as blas vendor, add `--use-mkl`. MKL is required as blas vendor and it's automatically detected but in some environments it need to be manually set. +* To enable PaRSEC as a runtime system, add `--use=parsec`, StarPU by default. ## Building diff --git a/cmake/FindHICMA-X.cmake b/cmake/FindHICMA-X.cmake new file mode 100644 index 00000000..a0d3ff3c --- /dev/null +++ b/cmake/FindHICMA-X.cmake @@ -0,0 +1,108 @@ + +# Copyright (c) 2017-2024 King Abdullah University of Science and Technology, +# All rights reserved. +# ExaGeoStat is a software package, provided by King Abdullah University of Science and Technology (KAUST). + +# @file FindHICMA-X.cmake +# @brief This is a CMakeLists file for finding HiCMA-X and link and include it's headers +# @version 2.0.0 +# @author Mahmoud ElKarargy +# @date 2024-09-28 + +# Include pkg-config +find_package(PkgConfig QUIET) + +# Try to find dplasma and parsec via pkg-config +if(PKG_CONFIG_FOUND) + pkg_check_modules(DPLASMA_PKG dplasma) + pkg_check_modules(PARSEC_PKG parsec) + if(DPLASMA_PKG_FOUND AND PARSEC_PKG_FOUND) + # Try to find the HICMA-X or hicma-x path in the library directories + string(FIND "${PARSEC_PKG_LIBRARY_DIRS}" "HICMA-X" HICMA_X_START) + if(HICMA_X_START EQUAL -1) + string(FIND "${PARSEC_PKG_LIBRARY_DIRS}" "hicma-x" HICMA_X_START) + endif() + if(HICMA_X_START GREATER -1) + # Extract the full path to HICMA-X or hicma-x and set the include directory + string(REGEX MATCH "([^;]*(HICMA-X|hicma-x)[^;]*/lib)" HICMA_X_LIB_PATH "${PARSEC_PKG_LIBRARY_DIRS}") + get_filename_component(HICMA_X_ROOT "${HICMA_X_LIB_PATH}" DIRECTORY) # Go one level up + set(HICMA-X_INCLUDE_DIRS "${HICMA_X_ROOT}/include") # Set the include path + endif() + # TODO: This is not generalized for the case of hicma installed manually + set(HICMA_X_SRC_DIR ${HICMA_X_ROOT}/hicma-x-src) + set(HICMA-X_FOUND TRUE) + set(HICMA-X_LIBRARIES ${DPLASMA_PKG_LIBRARIES} ${PARSEC_PKG_LIBRARIES}) + set(HICMA-X_LIBRARY_DIRS "${HICMA_X_LIB_PATH}") + # Add a search for lib64 directories and set HICMA-X_LIBRARY_DIRS_DEP + set(HICMA-X_LIBRARY_DIRS_DEP "${HICMA_X_LIB_PATH}64") + + find_library(HICMA_PARSEC_LIB hicma_parsec PATHS ${HICMA-X_LIBRARY_DIRS_DEP}) + + if(HICMA_PARSEC_LIB) + list(APPEND HICMA-X_LIBRARIES ${HICMA_PARSEC_LIB}) + else() + message(FATAL_ERROR "libhicma_parsec.so not found") + endif() + + endif() +endif() + +# Fallback: Manual search if pkg-config fails or HICMA-X path isn't set +if(NOT HICMA-X_FOUND) + # Improved search to handle multiple possible paths and fallback for include directories + find_path(HICMA-X_INCLUDE_DIR + NAMES hicma.h + PATHS + ${CMAKE_CURRENT_LIST_DIR}/../hicma-x/include + /usr/local/include/hicma-x + /usr/local/include + /usr/include/hicma-x + /usr/include + DOC "Path to HICMA-X include directory" + ) + + # Search for the main HICMA-X library + find_library(HICMA-X_LIBRARY + NAMES hicma-x + PATHS + ${CMAKE_CURRENT_LIST_DIR}/../hicma-x/lib + /usr/local/lib + /usr/lib + DOC "Path to HICMA-X library" + ) + + # Search for the hicma_parsec library in the lib64 directory if it's not found in the standard lib + find_library(HICMA_PARSEC_LIB + NAMES hicma_parsec + PATHS + ${CMAKE_CURRENT_LIST_DIR}/../hicma-x/lib64 + /usr/local/lib64 + /usr/lib64 + DOC "Path to HICMA-Parsec library" + ) + + # Check if both the include directory and libraries were found + if(HICMA-X_INCLUDE_DIR AND HICMA-X_LIBRARY AND HICMA_PARSEC_LIB) + set(HICMA-X_FOUND TRUE) + # Combine the found libraries + set(HICMA-X_LIBRARIES ${HICMA-X_LIBRARY} ${HICMA_PARSEC_LIB}) + # Set the include directory + set(HICMA-X_INCLUDE_DIRS "${HICMA-X_INCLUDE_DIR}") + # Include both lib and lib64 directories + # TODO: This paths are not generalized, if the install is not with the same dir. + set(HICMA-X_LIBRARY_DIRS "${HICMA-X_LIBRARY}/lib") + set(HICMA-X_LIBRARY_DIRS_DEP "${HICMA-X_LIBRARY}/lib64") + else() + set(HICMA-X_FOUND FALSE) + endif() +endif() + +# Mark the variables as advanced to keep the CMake GUI clean +mark_as_advanced(HICMA-X_INCLUDE_DIR HICMA-X_LIBRARY HICMA_PARSEC_LIB) + +# Provide feedback on whether the library was found +if(HICMA-X_FOUND) + message(STATUS "Found HICMA-X") +else() + message("Could not find HICMA-X or its dependencies (dplasma, parsec)") +endif() diff --git a/cmake/FindHWLOC.cmake b/cmake/FindHwloc.cmake similarity index 96% rename from cmake/FindHWLOC.cmake rename to cmake/FindHwloc.cmake index 2613be08..5b333b4b 100644 --- a/cmake/FindHWLOC.cmake +++ b/cmake/FindHwloc.cmake @@ -13,6 +13,7 @@ # Hwloc_FOUND - True if hwloc was found # Hwloc_INCLUDE_DIRS - include directories for hwloc # Hwloc_LIBRARIES - link against these libraries to use hwloc +# Hwloc_LIBRARY_DIRS - directories where hwloc libraries are found # Hwloc_VERSION - version # Hwloc_CFLAGS - include directories as compiler flags # Hwloc_LDLFAGS - link paths and libs as compiler flags @@ -171,6 +172,9 @@ else() list(GET Hwloc_VERSION_PARSED 1 Hwloc_VERSION_MINOR) set(Hwloc_VERSION_MINOR "${Hwloc_VERSION_MINOR}" CACHE STRING "Minor version of Hwloc") + # Capture the library directories + set(Hwloc_LIBRARY_DIRS ${Hwloc_LIBRARY_DIRS} CACHE STRING "Directories where hwloc libraries are found") + include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Hwloc DEFAULT_MSG Hwloc_LIBRARIES) @@ -184,5 +188,4 @@ else() endif() endif() - -endif() +endif() \ No newline at end of file diff --git a/cmake/ImportHiCMAX.cmake b/cmake/ImportHiCMAX.cmake new file mode 100644 index 00000000..06493016 --- /dev/null +++ b/cmake/ImportHiCMAX.cmake @@ -0,0 +1,40 @@ +# Copyright (c) 2017-2024 King Abdullah University of Science and Technology, +# All rights reserved. +# ExaGeoStat is a software package, provided by King Abdullah University of Science and Technology (KAUST). + +# @file ImportHiCMAX.cmake +# @brief Find and include HiCMA-X library as a dependency. +# @version 2.0.0 +# @author Mahmoud ElKarargy +# @author Sameh Abdulah +# @date 2024-09-21 + +# Configuration settings for integrating the HICMA-X library into the project +# 'name' sets the identifier for the HICMA-X library within this script to "HICMA-X". +set(name "HICMA-X") +# Set the version tag for HiCMA-X. +set(tag "FIX-package-installation-MK") +# Flags to configure the build for HiCMA-X, including precision settings for DPLASMA +# and disabling GPU support for both CUDA and HIP. +set(flags '-DDPLASMA_PRECISIONS="s;d"' \-DPARSEC_WITH_DEVEL_HEADERS=ON \-DCMAKE_Fortran_FLAGS="-Wno-main" \-DPARSEC_GPU_WITH_HIP=OFF \-DPARSEC_GPU_WITH_CUDA=OFF \-DPARSEC_HAVE_CUDA=OFF \-DPARSEC_DIST_SHORT_LIMIT=0 \-DPARSEC_DIST_COLLECTIVES=ON \-DPARSEC_HAVE_DEV_CUDA_SUPPORT=OFF \-DDPLASMA_HAVE_CUDA=OFF) +# Indicates that HiCMA-X uses CMake for its build system. +set(is_cmake ON) +# Indicates that HiCMA-X is hosted on a Git repository. +set(is_git ON) +# Indicates that autogen scripts are not required for HiCMA-X. +set(auto_gen OFF) +# Set the URL of the HiCMA-X GitHub repository. +set(url "https://github.com/SAbdulah/hicma-x-dev.git") +# Include the macro to import HiCMA-X as a dependency. +include(macros/ImportDependency) + +# Use the ImportDependency macro to handle fetching, detecting, and setting up HiCMA-X. +ImportDependency(${name} ${tag} "" ${url} "${flags}" "" ${is_cmake} ${is_git} ${auto_gen}) + +# Include necessary directories for HiCMA-X and its dependencies. +include_directories(${HICMA_X_SRC_DIR}) +include_directories(${HICMA_X_SRC_DIR}/dplasma/src) +include_directories(${HICMA_X_SRC_DIR}/hicma_parsec) +include_directories(${HICMA_X_SRC_DIR}/bin/dplasma/src) +# Display a status message indicating that HiCMA-X has been successfully included. +message(STATUS "HiCMA-X done") diff --git a/cmake/ImportHwloc.cmake b/cmake/ImportHwloc.cmake index 5f632725..9607943f 100644 --- a/cmake/ImportHwloc.cmake +++ b/cmake/ImportHwloc.cmake @@ -12,7 +12,7 @@ # Configuration settings for integrating the HWLOC library # 'name' sets the identifier for the HWLOC library within this script to "HWLOC". -set(name "HWLOC") +set(name "Hwloc") # 'tag' specifies "hwloc-2.10.0" as the version tag, identifying a specific release of HWLOC to be used. set(tag "hwloc-2.10.0") # 'version' defines "2.10.0" as the version of HWLOC, ensuring it meets project compatibility requirements. diff --git a/cmake/ImportStarsH.cmake b/cmake/ImportStarsH.cmake index 0fd9cde5..10ec8347 100644 --- a/cmake/ImportStarsH.cmake +++ b/cmake/ImportStarsH.cmake @@ -5,18 +5,31 @@ # @file CMakeLists.txt # @brief Find and include STARSH library as a dependency. -# @version 1.1.0 +# @version 2.0.0 # @author Mahmoud ElKarargy # @author Sameh Abdulah -# @date 2023-03-13 +# @date 2024-09-28 # Configuration parameters for integrating the STARSH library # 'name' is set to "STARSH" to identify the STARSH library within this script. set(name "STARSH") -# 'tag' specifies "v0.3.1" as the version tag for STARSH, denoting the exact release to be used. -set(tag "v0.3.1") -# 'version' sets "0.3.1" as the version of the STARSH library, ensuring it aligns with project requirements. -set(version "0.3.1") + +# Check the value of RUNTIME_TYPE and configure STARSH accordingly +if(RUNTIME_TYPE STREQUAL "STARPU") + # Default values for STARPU runtime + set(STARSH_TAG "v0.3.1") + set(STARSH_VERSION "0.3.1") + set(STARSH_URL "https://github.com/ecrc/stars-h.git") + message(STATUS "RUNTIME_TYPE is STARPU. Using default STARSH configuration.") + +elseif(RUNTIME_TYPE STREQUAL "PARSEC") + # Custom values for PARSEC runtime + set(STARSH_TAG "sabdulah/non-gaussian-kernel") + set(STARSH_VERSION "0") + set(STARSH_URL "https://github.com/SAbdulah/stars-h.git") + message(STATUS "RUNTIME_TYPE is PARSEC. Using custom STARSH configuration for PARSEC.") +endif() + # 'flag' is used for additional build configuration options, specifically disabling StarPU and optionally enabling MPI. set(flag \-DSTARPU=OFF \-DMPI=${USE_MPI}) # 'is_cmake' indicates that STARSH uses CMake as its build system, set to ON. @@ -25,13 +38,10 @@ set(is_cmake ON) set(is_git ON) # 'auto_gen' signals whether autogen scripts are needed for the build process; it is set to OFF for STARSH. set(auto_gen OFF) -# 'url' provides the GitHub repository URL for STARSH, specifying the source code's location. -set(url "https://github.com/ecrc/stars-h.git") - # The 'ImportDependency' macro, located in the 'macros' directory, is included to manage the import and setup of the STARSH library. include(macros/ImportDependency) # The 'ImportDependency' macro is called with the configuration parameters set above to manage the detection, fetching, and setup of STARSH. -ImportDependency(${name} ${tag} ${version} ${url} "${flag}" "" ${is_cmake} ${is_git} ${auto_gen}) +ImportDependency(${name} ${STARSH_TAG} ${STARSH_VERSION} ${STARSH_URL} "${flag}" "" ${is_cmake} ${is_git} ${auto_gen}) # A message is output to indicate the successful integration of the STARSH library into the project. message(STATUS "${name} done") diff --git a/cmake/macros/BuildDependency.cmake b/cmake/macros/BuildDependency.cmake index 50f5c125..a16e45c2 100644 --- a/cmake/macros/BuildDependency.cmake +++ b/cmake/macros/BuildDependency.cmake @@ -85,6 +85,11 @@ macro(BuildDependency raw_name url tag flags is_using_cmake is_using_git auto_ge # Include the ProcessorCount module to determine the number of CPUs for parallel build and install commands. include(ProcessorCount) ProcessorCount(N) + # Subtract 5 from N, ensuring it doesn't go below 0 + math(EXPR N "${N} - 5") + if (N LESS 0) + set(N 1) + endif() # Build the project using make, with parallel jobs based on processor count. This applies to both CMake and non-CMake projects. if (${is_using_cmake}) execute_process(COMMAND make -j ${N} diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 450c6d91..1cf40017 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -5,14 +5,19 @@ # @file CMakeLists.txt # @brief Includes subdirectories for different modules of the ExaGeoStat software package. -# @version 1.1.0 +# @version 2.0.0 # @author Mahmoud ElKarargy -# @date 2024-02-24 +# @date 2024-09-28 # Include subdirectories for end-to-end module, configurations module and data-generators module. -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/configurations) -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/data-generators) -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/data-loader) -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/descriptors) -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/end-to-end) -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/hardware) +# Check the value of RUNTIME_TYPE +if (RUNTIME_TYPE STREQUAL "STARPU") + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/hardware) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/configurations) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/data-loader) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/end-to-end) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/data-generators) + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/descriptors) +elseif (RUNTIME_TYPE STREQUAL "PARSEC") + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/climate-emulator) +endif () diff --git a/examples/climate-emulator/CMakeLists.txt b/examples/climate-emulator/CMakeLists.txt new file mode 100644 index 00000000..01ee6898 --- /dev/null +++ b/examples/climate-emulator/CMakeLists.txt @@ -0,0 +1,16 @@ + +# Copyright (c) 2017-2024 King Abdullah University of Science and Technology, +# All rights reserved. +# ExaGeoStat is a software package, provided by King Abdullah University of Science and Technology (KAUST). + +# @file CMakeLists.txt +# @brief Defines an executables and links them with the ExaGeoStat library and other libraries. +# @version 2.0.0 +# @author Mahmoud ElKarargy +# @date 2024-09-23 + +# Define the target executable +add_executable(Example_Climate_Emulator ${CMAKE_CURRENT_SOURCE_DIR}/ClimateEmulator.cpp) + +# Link the target executable with the project and any additional libraries +target_link_libraries(Example_Climate_Emulator PUBLIC ${PROJECT_NAME}_INTERFACE) diff --git a/examples/climate-emulator/ClimateEmulator.cpp b/examples/climate-emulator/ClimateEmulator.cpp new file mode 100644 index 00000000..1f27dafd --- /dev/null +++ b/examples/climate-emulator/ClimateEmulator.cpp @@ -0,0 +1,95 @@ + +// Copyright (c) 2017-2024 King Abdullah University of Science and Technology, +// All rights reserved. +// ExaGeoStat is a software package, provided by King Abdullah University of Science and Technology (KAUST). + +/** + * @file ClimateEmulator.cpp + * @brief + * @details + * @version 2.0.0 + * @author Mahmoud ElKarargy + * @author Sameh Abdulah + * @date 2024-09-23 +**/ + +#include + +int main(int argc, char ** argv) +{ + int iparam[IPARAM_SIZEOF] = {0}; + double dparam[DPARAM_SIZEOF]; + char *cparam[CPARAM_SIZEOF]; + hicma_parsec_params_t params; + starsh_params_t params_kernel; + hicma_parsec_data_t data; + hicma_parsec_matrix_analysis_t analysis; + + /* Init */ + parsec_context_t* parsec = hicma_parsec_init( argc, argv, iparam, dparam, cparam, ¶ms, ¶ms_kernel, &data ); + + SYNC_TIME_START(); + //gb24_init_serial(&gb); + SYNC_TIME_PRINT(params.rank, ("gb24_init\n")); + + // Forward SHT + SYNC_TIME_START(); + + // Forward SHT reshape + SYNC_TIME_START(); + SYNC_TIME_PRINT(params.rank, ("geqsht_forward_reshape\n")); + + // Make sure it's dense and only off_band maters + if(params.band_size_dist != 0) { + if( 0 == params.rank ) { + fprintf(stderr, RED "Fatal error: band_size_dist= %d needs to be 0\n" RESET, params.band_size_dist); + } + params.band_size_dist = 0; + //return 1; + } + + if(params.band_size_dense < ceil((double)params.N/params.NB)) { + if( 0 == params.rank ) { + fprintf(stderr, RED "Fatal error: the matrix needs to be all DENSE\n" RESET); + } + return 1; + } + + /* Generate matrix */ + SYNC_TIME_START(); + SYNC_TIME_PRINT(params.rank, ("Matrix genneration Matrix norm: norm_global= %le\n", params.norm_global)); + + // SYRK + SYNC_TIME_START(); + dplasma_dsyrk(parsec, dplasmaLower, dplasmaNoTrans, + 1.0, (parsec_tiled_matrix_t *)&data.dcA, + 0.0, (parsec_tiled_matrix_t *)&data.dcA); + SYNC_TIME_PRINT(params.rank, ("SYRK\n")); + + // Calculate norm + SYNC_TIME_START(); + SYNC_TIME_PRINT(params.rank, ("Matrix norm: norm_global= %le\n", params.norm_global)); + + /* Analyze matrix before Cholesky */ + hicma_parsec_matrix_pre_analysis( parsec, &data, ¶ms, ¶ms_kernel, &analysis ); + + /* HiCMA Cholesky */ + for( int i= 0; i < params.nruns; i++ ) { + hicma_parsec_potrf( parsec, &data, ¶ms, &analysis ); + } + + if( 0 == params.rank && params.info != 0 && 1 == params.nruns ) { + fprintf(stderr, "-- Factorization is suspicious (info = %d) ! \n", params.info); + //exit(params.info); + } + + /* Analyze matrix after Cholesky */ + hicma_parsec_matrix_post_analysis( parsec, &data, ¶ms, ¶ms_kernel, &analysis ); + + SYNC_TIME_PRINT(params.rank, ("mse\n")); + + /* Finalize */ + hicma_parsec_fini( parsec, argc, argv, iparam, dparam, cparam, ¶ms, ¶ms_kernel, &data, &analysis ); + + return 0; +} diff --git a/inst/include/data-units/DescriptorData.hpp b/inst/include/data-units/DescriptorData.hpp index 4c2b1d89..dc291b7e 100644 --- a/inst/include/data-units/DescriptorData.hpp +++ b/inst/include/data-units/DescriptorData.hpp @@ -19,6 +19,7 @@ #include #include +#include namespace exageostat::dataunits { diff --git a/inst/include/data-units/descriptor/ExaGeoStatDescriptor.hpp b/inst/include/data-units/descriptor/ExaGeoStatDescriptor.hpp index fbf1eb3d..d8a734fa 100644 --- a/inst/include/data-units/descriptor/ExaGeoStatDescriptor.hpp +++ b/inst/include/data-units/descriptor/ExaGeoStatDescriptor.hpp @@ -15,7 +15,9 @@ #ifndef EXAGEOSTATCPP_EXAGEOSTATDESCRIPTOR_HPP #define EXAGEOSTATCPP_EXAGEOSTATDESCRIPTOR_HPP +#if DEFAULT_RUNTIME #include +#endif #include #include diff --git a/inst/include/kernels/Kernel.hpp b/inst/include/kernels/Kernel.hpp index 3d018d5c..2460c0f3 100644 --- a/inst/include/kernels/Kernel.hpp +++ b/inst/include/kernels/Kernel.hpp @@ -20,7 +20,9 @@ #include +#if DEFAULT_RUNTIME #include +#endif extern "C" { #include diff --git a/inst/include/linear-algebra-solvers/concrete/chameleon/ChameleonImplementation.hpp b/inst/include/linear-algebra-solvers/concrete/chameleon/ChameleonImplementation.hpp index 8653bfc5..6ecfb1fb 100644 --- a/inst/include/linear-algebra-solvers/concrete/chameleon/ChameleonImplementation.hpp +++ b/inst/include/linear-algebra-solvers/concrete/chameleon/ChameleonImplementation.hpp @@ -17,6 +17,7 @@ #define EXAGEOSTATCPP_CHAMELEONIMPLEMENTATION_HPP #include +#include namespace exageostat::linearAlgebra { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index beb9378f..1ec74fb5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -11,18 +11,24 @@ # @date 2024-02-04 # Add subdirectories for configurations, data-generators, data-units, and linear-algebra-solvers. -add_subdirectory(api) add_subdirectory(configurations) -add_subdirectory(data-generators) -add_subdirectory(data-loader) -add_subdirectory(data-units) -add_subdirectory(hardware) -add_subdirectory(helpers) add_subdirectory(kernels) -add_subdirectory(linear-algebra-solvers) -add_subdirectory(prediction) -add_subdirectory(results) -add_subdirectory(runtime) +add_subdirectory(helpers) +add_subdirectory(data-units) + +# Check the value of RUNTIME_TYPE and configure chameleon/starpu accordingly +if(RUNTIME_TYPE STREQUAL "STARPU") + add_subdirectory(api) + add_subdirectory(data-generators) + add_subdirectory(data-loader) + add_subdirectory(hardware) + add_subdirectory(linear-algebra-solvers) + add_subdirectory(prediction) + add_subdirectory(results) + add_subdirectory(runtime) + +elseif(RUNTIME_TYPE STREQUAL "PARSEC") +endif() if (USE_R) add_subdirectory(Rcpp-adapters) diff --git a/src/configurations/Configurations.cpp b/src/configurations/Configurations.cpp index 8da6a38f..e3b1557b 100644 --- a/src/configurations/Configurations.cpp +++ b/src/configurations/Configurations.cpp @@ -12,9 +12,11 @@ * @date 2024-02-04 **/ +#include + #include -#include #include +#include using namespace std; diff --git a/src/data-units/CMakeLists.txt b/src/data-units/CMakeLists.txt index 85e48392..70977f00 100644 --- a/src/data-units/CMakeLists.txt +++ b/src/data-units/CMakeLists.txt @@ -9,13 +9,20 @@ # @author Sameh Abdulah # @date 2023-02-27 -# Include the concrete implementations of the ExaGeoStat Descriptor class -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/descriptor) +# Initialize SOURCES variable if not already initialized +set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Locations.cpp ${SOURCES}) -set(SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/Locations.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/DescriptorData.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/ExaGeoStatData.cpp - ${SOURCES} - PARENT_SCOPE - ) \ No newline at end of file +if (RUNTIME_TYPE STREQUAL "STARPU") + + # Include the concrete implementations of the ExaGeoStat Descriptor class + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/descriptor) + # Append the necessary source files for the STARPU runtime + list(APPEND SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/DescriptorData.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ExaGeoStatData.cpp + + ) +endif() + +# Set the SOURCES variable to the parent scope +set(SOURCES ${SOURCES} PARENT_SCOPE) diff --git a/src/data-units/descriptor/CMakeLists.txt b/src/data-units/descriptor/CMakeLists.txt index 352aec33..608bbf07 100644 --- a/src/data-units/descriptor/CMakeLists.txt +++ b/src/data-units/descriptor/CMakeLists.txt @@ -10,7 +10,9 @@ # @date 2023-08-15 # Include the concrete implementations of the ExaGeoStat Descriptor class -add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/concrete) +if (RUNTIME_TYPE STREQUAL "STARPU") + add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/concrete) +endif () set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/ExaGeoStatDescriptor.cpp diff --git a/src/helpers/CommunicatorMPI.cpp b/src/helpers/CommunicatorMPI.cpp index 0abc6d1c..b4227e26 100644 --- a/src/helpers/CommunicatorMPI.cpp +++ b/src/helpers/CommunicatorMPI.cpp @@ -12,8 +12,9 @@ **/ #include +#if DEFAULT_RUNTIME #include - +#endif using namespace exageostat::helpers; CommunicatorMPI *CommunicatorMPI::GetInstance() { @@ -27,12 +28,14 @@ int CommunicatorMPI::GetRank() const { #ifdef USE_MPI if (!mIsHardwareInitialized) { return 0; - } else { + } + #if DEFAULT_RUNTIME + else { return CHAMELEON_Comm_rank(); } -#else - return 0; + #endif #endif + return 0; } void CommunicatorMPI::SetHardwareInitialization() { diff --git a/src/linear-algebra-solvers/LinearAlgebraMethods.cpp b/src/linear-algebra-solvers/LinearAlgebraMethods.cpp index 31931325..146ccf9e 100644 --- a/src/linear-algebra-solvers/LinearAlgebraMethods.cpp +++ b/src/linear-algebra-solvers/LinearAlgebraMethods.cpp @@ -22,6 +22,7 @@ #include #include +#include using namespace std; diff --git a/src/linear-algebra-solvers/concrete/chameleon/dense/ChameleonDense.cpp b/src/linear-algebra-solvers/concrete/chameleon/dense/ChameleonDense.cpp index f08c8c3b..f5f843a7 100644 --- a/src/linear-algebra-solvers/concrete/chameleon/dense/ChameleonDense.cpp +++ b/src/linear-algebra-solvers/concrete/chameleon/dense/ChameleonDense.cpp @@ -15,6 +15,7 @@ #include #include +#include using namespace std; diff --git a/src/runtime/CMakeLists.txt b/src/runtime/CMakeLists.txt index 74d34df3..e4d999e5 100644 --- a/src/runtime/CMakeLists.txt +++ b/src/runtime/CMakeLists.txt @@ -10,7 +10,7 @@ # @date 2024-03-10 # Include runtime directory,based on runtime flag. -if ("${RUNTIME_TYPE}" STREQUAL "parsec") +if ("${RUNTIME_TYPE}" STREQUAL "PARSEC") add_subdirectory(parsec) else () #by default use StarPu runtime. diff --git a/src/runtime/parsec/ParsecFunctions.cpp b/src/runtime/parsec/ParsecFunctions.cpp index 65b0073d..02e46b93 100644 --- a/src/runtime/parsec/ParsecFunctions.cpp +++ b/src/runtime/parsec/ParsecFunctions.cpp @@ -20,68 +20,92 @@ using namespace exageostat::dataunits; //TODO: implement parsec functions template -void RuntimeFunctions::CovarianceMatrix(DescriptorData &aDescriptorData, void *apDescriptor, - const int &aTriangularPart, Locations *apLocation1, - Locations *apLocation2, Locations *apLocation3, - T *apLocalTheta, const int &aDistanceMetric, - const kernels::Kernel *apKernel, void *apContext) {} +void RuntimeFunctions::CovarianceMatrix(dataunits::DescriptorData &aDescriptorData, void *apDescriptor, + const int &aTriangularPart, + dataunits::Locations *apLocation1, dataunits::Locations *apLocation2, + dataunits::Locations *apLocation3, T *apLocalTheta, + const int &aDistanceMetric, + const kernels::Kernel *apKernel) { +} + template -void RuntimeFunctions::ExaGeoStatMLETileAsyncMLOEMMOM(void *apDescExpr1, void *apDescExpr2, void *apDescExpr3, +void RuntimeFunctions::ExaGeoStatMLETileAsyncMLOEMMOM(void *apDescExpr2, void *apDescExpr3, void *apDescExpr4, void *apDescMLOE, void *apDescMMOM, void *apSequence, - void *apRequest, void *apContext) {} + void *apRequest) { + +} template void RuntimeFunctions::ExaGeoStatMLEMSPETileAsync(void *apDescZPredict, void *apDescZMiss, void *apDescError, - void *apSequence, void *apRequest, void *apContext) {} + void *apSequence, + void *apRequest) { + +} template -void RuntimeFunctions::CopyDescriptorZ(DescriptorData &aDescriptorData, void *apDescriptor, T *apDoubleVector, - void *apContext) {} +void RuntimeFunctions::CopyDescriptorZ(dataunits::DescriptorData &aDescriptorData, void *apDescriptor, + T *apDoubleVector) { + +} template -void -RuntimeFunctions::ExaGeoStatGaussianToNonTileAsync(DescriptorData &aDescriptorData, void *apDesc, T *apTheta, - void *apContext) {} +void RuntimeFunctions::ExaGeoStatGaussianToNonTileAsync(dataunits::DescriptorData &aDescriptorData, void *apDesc, + T *apTheta) { + +} template void -RuntimeFunctions::ExaGeoStatMeasureDetTileAsync(const Computation &aComputation, void *apDescA, void *apSequence, - void *apRequest, void *apDescDet, void *apContext) {} +RuntimeFunctions::ExaGeoStatMeasureDetTileAsync(const common::Computation &aComputation, void *apDescA, + void *apSequence, void *apRequest, + void *apDescDet) { +} template void RuntimeFunctions::ExaGeoStaStrideVectorTileAsync(void *apDescA, void *apDescB, void *apDescC, void *apSequence, void *apRequest, void *apContext) {} template -void RuntimeFunctions::ExaGeoStaStrideVectorTileAsync(void *apDescA, void *apDescB, void *apDescC, void *apDescD, - void *apSequence, void *apRequest, void *apContext) {} +void RuntimeFunctions::ExaGeoStaStrideVectorTileAsync(void *apDescA, void *apDescB, void *apDescC, void *apSequence, + void *apRequest) { +} template -void -RuntimeFunctions::ExaGeoStatMLETraceTileAsync(void *apDescA, void *apSequence, void *apRequest, void *apDescNum, - void *apDescTrace, void *apContext) {} +void RuntimeFunctions::ExaGeoStatMLETraceTileAsync(void *apDescA, void *apSequence, void *apRequest, void *apDescNum, + void *apDescTrace) { + +} template void -RuntimeFunctions::ExaGeoStatDoubleDotProduct(void *apDescA, void *apDescProduct, void *apSequence, - void *apRequest, - void *apContext) {} +RuntimeFunctions::ExaGeoStatDoubleDotProduct(void *apDescA, void *apDescProduct, void *apSequence, void *apRequest) { + + +} template -void -RuntimeFunctions::ExaGeoStatMLEMSPEBivariateTileAsync(void *apDescZPre, void *apDescZMiss, void *apDescsError1, - void *apDescsError2, void *apDescsError, void *apSequence, - void *apRequest, void *apContext) {} +void RuntimeFunctions::ExaGeoStatMLEMSPEBivariateTileAsync(void *apDescZPre, void *apDescZMiss, void *apDescError1, + void *apDescError2, + void *apDescError, void *apSequence, void *apRequest) { + +} template -void RuntimeFunctions::ExaGeoStatNonGaussianLogLikeTileAsync(const Computation &aComputation, void *apDescZ, - void *apDescSum, const T *apTheta, void *apSequence, - void *apRequest, void *apContext) {} +void RuntimeFunctions::ExaGeoStatNonGaussianLogLikeTileAsync(const common::Computation &aComputation, void *apDescZ, + void *apDescSum, + const T *apTheta, void *apSequence, void *apRequest) { + + + +} template void -RuntimeFunctions::ExaGeoStatNonGaussianTransformTileAsync(const Computation &aComputation, void *apDescZ, +RuntimeFunctions::ExaGeoStatNonGaussianTransformTileAsync(const common::Computation &aComputation, void *apDescZ, const T *apTheta, - void *apSequence, void *apRequest, void *apContext) {} + void *apSequence, void *apRequest) { + + +} diff --git a/tests/cpp-tests/CMakeLists.txt b/tests/cpp-tests/CMakeLists.txt index 75c33860..b1a4f2d8 100644 --- a/tests/cpp-tests/CMakeLists.txt +++ b/tests/cpp-tests/CMakeLists.txt @@ -8,19 +8,23 @@ # @author Mahmoud ElKarargy # @date 2024-01-24 -add_subdirectory(api) -add_subdirectory(configurations) -add_subdirectory(data-generators) -add_subdirectory(hardware) -add_subdirectory(helpers) -add_subdirectory(kernels) -add_subdirectory(linear-algebra-solvers) -add_subdirectory(prediction) -add_subdirectory(results) +# Check the value of RUNTIME_TYPE +if(RUNTIME_TYPE STREQUAL "STARPU") + add_subdirectory(api) + add_subdirectory(configurations) + add_subdirectory(data-generators) + add_subdirectory(hardware) + add_subdirectory(helpers) + add_subdirectory(kernels) + add_subdirectory(linear-algebra-solvers) + add_subdirectory(prediction) + add_subdirectory(results) + if (USE_HICMA) + add_subdirectory(data-units) + endif () +elseif(RUNTIME_TYPE STREQUAL "PARSEC") -if (USE_HICMA) - add_subdirectory(data-units) -endif () +endif() if (USE_R) add_subdirectory(Rcpp-adapters)