From 4537c4fdcdf82d48fb9569de6faec257dcba2d8b Mon Sep 17 00:00:00 2001 From: mahmoud Date: Wed, 23 Oct 2024 19:06:40 +0300 Subject: [PATCH] Parsec Headers and Hardware --- CMakeLists.txt | 4 +- examples/climate-emulator/ClimateEmulator.cpp | 106 +++------ inst/include/api/ExaGeoStat.hpp | 21 +- .../include/configurations/Configurations.hpp | 36 +++ inst/include/data-analyzer/DataAnalyzer.hpp | 61 +++++ .../data-transformer/DataTransformer.hpp | 52 +++++ inst/include/data-units/DescriptorData.hpp | 4 + inst/include/hardware/ExaGeoStatHardware.hpp | 18 ++ .../LinearAlgebraMethods.hpp | 220 ++++++++++-------- .../chameleon/ChameleonImplementation.hpp | 50 +++- .../hicma/tlr/HicmaImplementation.hpp | 48 +++- .../concrete/parsec/ParsecImplementation.hpp | 122 ++++++++++ inst/include/runtime/parsec/ParsecHeader.hpp | 16 ++ inst/include/utilities/EnumStringParser.hpp | 4 + src/CMakeLists.txt | 24 +- src/api/ExaGeoStat.cpp | 23 +- src/configurations/Configurations.cpp | 42 +++- src/data-analyzer/CMakeLists.txt | 17 ++ src/data-analyzer/DataAnalyzer.cpp | 27 +++ .../concrete/SyntheticGenerator.cpp | 3 + src/data-loader/DataLoader.cpp | 4 + src/data-transformer/CMakeLists.txt | 17 ++ src/data-transformer/DataTransformer.cpp | 32 +++ src/data-units/CMakeLists.txt | 21 +- src/data-units/DescriptorData.cpp | 11 +- src/hardware/ExaGeoStatHardware.cpp | 83 ++++++- src/linear-algebra-solvers/CMakeLists.txt | 13 +- .../LinearAlgebraFactory.cpp | 5 +- .../LinearAlgebraMethods.cpp | 31 --- .../concrete/CMakeLists.txt | 28 ++- .../chameleon/ChameleonImplementation.cpp | 37 ++- .../concrete/parsec/ParsecImplementation.cpp | 90 +++++++ .../concrete/tlr/HicmaImplementation.cpp | 63 ++++- src/prediction/Prediction.cpp | 5 +- tests/cpp-tests/CMakeLists.txt | 3 +- .../configurations/TestConfigurations.cpp | 45 ++++ 36 files changed, 1114 insertions(+), 272 deletions(-) create mode 100644 inst/include/data-analyzer/DataAnalyzer.hpp create mode 100644 inst/include/data-transformer/DataTransformer.hpp create mode 100644 inst/include/linear-algebra-solvers/concrete/parsec/ParsecImplementation.hpp create mode 100644 inst/include/runtime/parsec/ParsecHeader.hpp create mode 100644 src/data-analyzer/CMakeLists.txt create mode 100644 src/data-analyzer/DataAnalyzer.cpp create mode 100644 src/data-transformer/CMakeLists.txt create mode 100644 src/data-transformer/DataTransformer.cpp create mode 100644 src/linear-algebra-solvers/concrete/parsec/ParsecImplementation.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 17241215..accf04e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -195,9 +195,9 @@ 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) + target_compile_definitions(${PROJECT_NAME} PUBLIC DEFAULT_RUNTIME=1) elseif(RUNTIME_TYPE STREQUAL "PARSEC") - target_compile_definitions(${PROJECT_NAME} PRIVATE DEFAULT_RUNTIME=0) + target_compile_definitions(${PROJECT_NAME} PUBLIC DEFAULT_RUNTIME=0) endif() # Creates a new INTERFACE library target named ${PROJECT_NAME}_INTERFACE. diff --git a/examples/climate-emulator/ClimateEmulator.cpp b/examples/climate-emulator/ClimateEmulator.cpp index 1f27dafd..44f5424f 100644 --- a/examples/climate-emulator/ClimateEmulator.cpp +++ b/examples/climate-emulator/ClimateEmulator.cpp @@ -5,91 +5,39 @@ /** * @file ClimateEmulator.cpp - * @brief - * @details + * @brief example of climate emulator. * @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 ); +#include +#include +#include + +using namespace exageostat::configurations; +using namespace exageostat::api; + +int main(int argc, char **argv) { + + // Create a new configurations object. + Configurations configurations; + // Initialize the arguments with the provided command line arguments + configurations.InitializeArguments(argc, argv); + // Initialize the ExaGeoStat Hardware + auto hardware = ExaGeoStatHardware(configurations); + +// // Create a unique pointer to hold the data. +// std::unique_ptr> data; +// // Transform and prepare the data. +// ExaGeoStat::ExaGeoStatTransformData(configurations, data); +// // Load the data, either by reading from a file or generating synthetic data. +// ExaGeoStat::ExaGeoStatLoadData(configurations, data); +// // Perform data modeling. +// ExaGeoStat::ExaGeoStatDataModeling(configurations, data); +// // Analyze the data. +// ExaGeoStat::ExaGeoStatDataAnalyzer(configurations, data); return 0; } diff --git a/inst/include/api/ExaGeoStat.hpp b/inst/include/api/ExaGeoStat.hpp index 54c61c16..0430cac2 100644 --- a/inst/include/api/ExaGeoStat.hpp +++ b/inst/include/api/ExaGeoStat.hpp @@ -60,7 +60,7 @@ namespace exageostat::api { * @return double MLE results. * */ - static double ExaGeoStatMLETileAPI(const std::vector &aTheta, std::vector &aGrad, void *apInfo); + static double ModelingAPI(const std::vector &aTheta, std::vector &aGrad, void *apInfo); /** * @brief Predict missing measurements values. @@ -76,6 +76,25 @@ namespace exageostat::api { ExaGeoStatPrediction(configurations::Configurations &aConfigurations, std::unique_ptr> &aData, T *apMeasurementsMatrix = nullptr, dataunits::Locations *apTrainLocations = nullptr, dataunits::Locations *apTestLocations = nullptr); + /** + * @brief Transform data into the required format for ExaGeoStat operations. + * @param[in] aConfigurations Reference to Configurations object containing user input data. + * @param[in, out] aData Reference to an ExaGeoStatData object containing the descriptors and locations to be transformed. + * @return void + * + */ + static void + ExaGeoStatTransformData(configurations::Configurations &aConfigurations, std::unique_ptr> &aData); + + /** + * @brief Analyze the data to extract insights and patterns. + * @param[in] aConfigurations Reference to Configurations object containing user input data. + * @param[in, out] aData Reference to an ExaGeoStatData object that contains the data to be analyzed. + * @return void + * + */ + static void + ExaGeoStatDataAnalyzer(configurations::Configurations &aConfigurations, std::unique_ptr> &aData); }; diff --git a/inst/include/configurations/Configurations.hpp b/inst/include/configurations/Configurations.hpp index 5e523cc8..3821a34d 100644 --- a/inst/include/configurations/Configurations.hpp +++ b/inst/include/configurations/Configurations.hpp @@ -237,6 +237,42 @@ namespace exageostat::configurations { static void SetVerbosity(const common::Verbose &aVerbose); /** END OF THE COMMON ARGUMENTS BETWEEN ALL MODULES. **/ + + /** START OF THE HICMA-PARSEC SPECIFIC ARGUEMNTS. **/ + + CREATE_SETTER_FUNCTION(DenseBandDP, int, aDenseBandDP, "DenseBandDoublePrecision") + + CREATE_GETTER_FUNCTION(DenseBandDP, int, "DenseBandDoublePrecision") + + CREATE_SETTER_FUNCTION(ObjectsNumber, int, aObjectsNumber, "ObjectsNumber") + + CREATE_GETTER_FUNCTION(ObjectsNumber, int, "ObjectsNumber") + + CREATE_SETTER_FUNCTION(AdaptiveDecision, int, aAdaptiveDecision, "AdaptiveDecision") + + CREATE_GETTER_FUNCTION(AdaptiveDecision, int, "AdaptiveDecision") + + CREATE_SETTER_FUNCTION(DiagonalAddition, int, aDiagonalAddition, "DiagonalAddition") + + CREATE_GETTER_FUNCTION(DiagonalAddition, int, "DiagonalAddition") + + CREATE_SETTER_FUNCTION(TimeSlotPerFile, int, aTimeSlotPerFile, "TimeSlotPerFile") + + CREATE_GETTER_FUNCTION(TimeSlotPerFile, int, "TimeSlotPerFile") + + CREATE_SETTER_FUNCTION(FileNumber, int, aFileNumber, "FileNumber") + + CREATE_GETTER_FUNCTION(FileNumber, int, "FileNumber") + + CREATE_SETTER_FUNCTION(EnableInverse, bool , aEnableInverse, "EnableInverse") + + CREATE_GETTER_FUNCTION(EnableInverse, bool , "EnableInverse") + + CREATE_SETTER_FUNCTION(MPIIO, bool, aMPIIO, "MPIIO") + + CREATE_GETTER_FUNCTION(MPIIO, bool, "MPIIO") + + /** END OF THE HICMA-PARSEC SPECIFIC ARGUEMNTS. **/ /** START OF THE DATA GENERATION MODULES. **/ CREATE_SETTER_FUNCTION(Dimension, exageostat::common::Dimension, aDimension, "Dimension") diff --git a/inst/include/data-analyzer/DataAnalyzer.hpp b/inst/include/data-analyzer/DataAnalyzer.hpp new file mode 100644 index 00000000..72cadf02 --- /dev/null +++ b/inst/include/data-analyzer/DataAnalyzer.hpp @@ -0,0 +1,61 @@ + +// 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 DataAnalyzer.hpp + * @brief Contains the definition of the DataAnalyzer class. + * @version 1.1.0 + * @author Mahmoud ElKarargy + * @author Sameh Abdulah + * @date 2024-10-15 +**/ + +#ifndef EXAGEOSTATCPP_DATAANALYZER_HPP +#define EXAGEOSTATCPP_DATAANALYZER_HPP + +#include +#include + +namespace exageostat::analyzer{ + /** + * @brief Class represents the data analyzer for the Climate Emulator. + * @tparam T Data Type: float or double + */ + template + class DataAnalyzer { + + public: + /** + * @brief Default constructor. + */ + DataAnalyzer(); + + /** + * @brief Default destructor. + */ + ~DataAnalyzer(); + + /** + * @brief Analyzes the given matrix data. + * @param[in] aConfigurations Reference to Configurations object containing needed parameters. + * @param[in, out] aData Reference to an ExaGeoStatData object that contains matrix to be analyzed. + * @return void + * + */ + static void AnalyzeMatrix(configurations::Configurations &aConfigurations, std::unique_ptr> &aData); + + /** + * @brief Compares betweent two matrices by getting the difference. + * @param[in] aConfigurations Reference to Configurations object containing needed parameters. + * @param[in, out] aData Reference to an ExaGeoStatData object that contains matrix to be analyzed. + * @return the calculated MSE. + * + */ + static double CompareMatDifference(configurations::Configurations &aConfigurations, std::unique_ptr> &aData); + }; + +}//namespace exageostat + +#endif // EXAGEOSTATCPP_DATAANALYZER_HPP \ No newline at end of file diff --git a/inst/include/data-transformer/DataTransformer.hpp b/inst/include/data-transformer/DataTransformer.hpp new file mode 100644 index 00000000..a63e3c01 --- /dev/null +++ b/inst/include/data-transformer/DataTransformer.hpp @@ -0,0 +1,52 @@ + +// 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 DataTransformer.hpp + * @brief Contains the definition of the DataTransformer class. + * @version 1.1.0 + * @author Mahmoud ElKarargy + * @author Sameh Abdulah + * @date 2024-10-15 +**/ + +#ifndef EXAGEOSTATCPP_DATATRANSFORMER_HPP +#define EXAGEOSTATCPP_DATATRANSFORMER_HPP + +#include +#include + +namespace exageostat::transformer{ + + /** + * @brief Class represents the data transformer for the Climate Emulator. + * @tparam T Data Type: float or double + */ + template + class DataTransformer { + + /** + * @brief Performs the forward spherical harmonics transform (SHT). + * @param[in] aConfigurations Configurations object containing relevant settings. + * @param[in,out] aData Descriptor Data object to be populated with descriptors and data. + */ + static void ForwardSHT(configurations::Configurations &aConfigurations, std::unique_ptr> &aData); + + /** + * @brief Reshapes data during the forward phase of the simulation. + * @param[in] aConfigurations Configurations object containing relevant settings. + * @param[in,out] aData Descriptor Data object to be populated with descriptors and data. + */ + static void ForwardReshape(configurations::Configurations &aConfigurations, std::unique_ptr> &aData); + + /** + * @brief Performs the inverse spherical harmonics transform (SHT). + * @param[in] aConfigurations Configurations object containing relevant settings. + * @param[in,out] aData Descriptor Data object to be populated with descriptors and data. + */ + static void InverseSHT(configurations::Configurations &aConfigurations, std::unique_ptr> &aData); + }; +} +#endif // EXAGEOSTATCPP_DATATRANSFORMER_HPP diff --git a/inst/include/data-units/DescriptorData.hpp b/inst/include/data-units/DescriptorData.hpp index dc291b7e..f5775187 100644 --- a/inst/include/data-units/DescriptorData.hpp +++ b/inst/include/data-units/DescriptorData.hpp @@ -19,7 +19,9 @@ #include #include +#if DEFAULT_RUNTIME #include +#endif namespace exageostat::dataunits { @@ -29,9 +31,11 @@ namespace exageostat::dataunits { * */ union BaseDescriptor { +#if DEFAULT_RUNTIME CHAM_desc_t *chameleon_desc; #ifdef USE_HICMA HICMA_desc_t *hicma_desc; +#endif #endif }; diff --git a/inst/include/hardware/ExaGeoStatHardware.hpp b/inst/include/hardware/ExaGeoStatHardware.hpp index 6e872091..5d1ed2ea 100644 --- a/inst/include/hardware/ExaGeoStatHardware.hpp +++ b/inst/include/hardware/ExaGeoStatHardware.hpp @@ -16,6 +16,7 @@ #define EXAGEOSTATCPP_EXAGEOSTATHARDWARE_HPP #include +#include /** * @brief Class represents the hardware configuration for the ExaGeoStat solver. @@ -24,6 +25,14 @@ class ExaGeoStatHardware { public: + + /** + * @brief Constructor for ExaGeoStatHardware. + * @param[in] aConfigurations The set of arguments from the configurations. + * + */ + explicit ExaGeoStatHardware(exageostat::configurations::Configurations &aConfigurations); + /** * @brief Constructor for ExaGeoStatHardware. * @param[in] aComputation The computation mode for the solver. @@ -89,6 +98,13 @@ class ExaGeoStatHardware { */ [[nodiscard]] static void *GetHicmaContext(); + /** + * @brief Get the PaRSEC hardware context. + * @return Pointer to the hardware context. + * + */ + [[nodiscard]] static void *GetParsecContext(); + /** * @brief Get the hardware context. * @param[in] aComputation Used computation to decide whether to use Hicma or Chameleon context. @@ -136,6 +152,8 @@ class ExaGeoStatHardware { static void *mpChameleonContext; //// Used Pointer to the Hicma hardware context. static void *mpHicmaContext; + //// Used Pointer to the PaRSEC hardware context. + static void *mpParsecContext; //// Used P-Grid static int mPGrid; //// Used Q-Grid diff --git a/inst/include/linear-algebra-solvers/LinearAlgebraMethods.hpp b/inst/include/linear-algebra-solvers/LinearAlgebraMethods.hpp index 251d6319..2b35a6c9 100644 --- a/inst/include/linear-algebra-solvers/LinearAlgebraMethods.hpp +++ b/inst/include/linear-algebra-solvers/LinearAlgebraMethods.hpp @@ -49,6 +49,9 @@ namespace exageostat::linearAlgebra { */ virtual ~LinearAlgebraMethods() = default; + // TODO: Since the common linear algebra fn between HiCMA andChameleon won't work with PaRSEC, + // consider move them and make this file as an Interface for virtual fns +#if DEFAULT_RUNTIME /** * @brief Initializes the descriptors necessary for the linear algebra solver. * @details This method initializes the descriptors necessary for the linear algebra solver. @@ -127,84 +130,6 @@ namespace exageostat::linearAlgebra { dataunits::Locations *apLocation3, const int &aDistanceMetric, const kernels::Kernel &aKernel); - /** - * @brief Calculates the log likelihood value of a given value theta. - * @param[in,out] aData DescriptorData object to be populated with descriptors and data. - * @param[in] aConfigurations Configurations object containing relevant settings. - * @param[in] apTheta Optimization parameter used by NLOPT. - * @param[in] apMeasurementsMatrix measurements matrix to be stored in DescZ. - * @param[in] aKernel Reference to the kernel object to use. - * @return log likelihood value - * - */ - virtual T ExaGeoStatMLETile(std::unique_ptr> &aData, - configurations::Configurations &aConfigurations, const double *apTheta, - T *apMeasurementsMatrix, const kernels::Kernel &aKernel) = 0; - - - /** - * @brief Copies a matrix in the tile layout from source to destination - * @param[in] aUpperLower Specifies the part of the matrix A to be copied to B. - * @param[in] apA Source matrix A. - * @param[in,out] apB Destination matrix B. On exit, B = A in the locations specified by Upper Lower. - * @return void - * - */ - virtual void ExaGeoStatLapackCopyTile(const common::UpperLower &aUpperLower, void *apA, void *apB) = 0; - - /** - * @brief Wait for the completion of a sequence. - * @param[in] apSequence apSequence A pointer to either CHAMELEON or HiCMA sequence. - * @return void - * - */ - virtual void ExaGeoStatSequenceWait(void *apSequence) = 0; - - /** - * @brief Create Sequence. - * @param[out] apSequence A pointer to either CHAMELEON or HiCMA sequence. - * @return void - * - */ - virtual void - ExaGeoStatCreateSequence(void *apSequence) = 0; - - /** - * @brief Computes the Cholesky factorization of a symmetric positive definite or Symmetric positive definite matrix. - * @param[in] aUpperLower Whether upper or lower part of the matrix A. - * @param[in, out] apA Symmetric matrix A. - * @param[in] aBand Diagonal thickness parameter. - * @param[in] apCD Additional matrix CD. - * @param[in] apCrk Additional matrix Crk. - * @param[in] aMaxRank Maximum rank parameter. - * @param[in] aAcc Accuracy parameter. - * @return void - * - */ - virtual void - ExaGeoStatPotrfTile(const common::UpperLower &aUpperLower, void *apA, int aBand, void *apCD, void *apCrk, - const int &aMaxRank, const int &aAcc) = 0; - - /** - * @brief Solves one of the matrix equations op( A )*X = alpha*B, or X*op( A ) = alpha*B. - * @param[in] aSide Specifies whether op(A) appears on the left or on the right of X. - * @param[in] aUpperLower Specifies whether the matrix A is upper triangular or lower triangular. - * @param[in] aTrans Specifies the form of op( A ) to be used in the matrix multiplication. - * @param[in] aDiag Specifies whether or not A is unit triangular. - * @param[in] aAlpha Specifies the scalar alpha. When alpha is zero, A is not referenced and B need not be set before entry. - * @param[in] apA The triangular matrix A. - * @param[in] apCD Additional matrix CD. - * @param[in] apCrk Additional matrix Crk. - * @param[in, out] apZ The matrix B of dimension, on exit is overwritten by the solution matrix X. - * @param[in] aMaxRank Maximum rank parameter. - * @return void - * - */ - virtual void ExaGeoStatTrsmTile(const common::Side &aSide, const common::UpperLower &aUpperLower, - const common::Trans &aTrans, const common::Diag &aDiag, const T &aAlpha, - void *apA, void *apCD, void *apCrk, void *apZ, const int &aMaxRank) = 0; - - /** * @brief Solve a positive definite linear system of equations AX = B using tiled algorithms. * @param[in] aUpperLower Specifies whether the matrix A is upper triangular or lower triangular. @@ -285,22 +210,6 @@ namespace exageostat::linearAlgebra { */ void ExaGeoStatDesc2Lap(T *apA, const int &aLDA, void *apDescA, const common::UpperLower &aUpperLower); -#ifdef USE_HICMA - - /** - * @brief Copy Descriptor Matrix to another Descriptor matrix. - * @param[out] apSourceDesc Descriptor matrix to be copied - * @param[out] apDestinationDesc Descriptor matrix to be copied to. - * @param[in] aSize Size of matrix to be copied. - * @param[in] aDirection Specifies the type of Descriptors to be copied. - * @return void - * - */ - void CopyDescriptors(void *apSourceDesc, void *apDestinationDesc, const int &aSize, - const common::CopyDirection &aDirection); - -#endif - /** * @brief Sets the values of all or part of a two-dimensional Tile. * @param[in] aUpperLower Specifies Specifies whether the upper or lower triangular part of the covariance matrix is stored. @@ -399,6 +308,129 @@ namespace exageostat::linearAlgebra { * */ bool Recover(char *apPath, const int &aIterationCount, T *apTheta, T *apLogLik, const int &aNumParams); +#endif + + /** + * @brief Copy Descriptor Matrix to another Descriptor matrix. + * @param[out] apSourceDesc Descriptor matrix to be copied + * @param[out] apDestinationDesc Descriptor matrix to be copied to. + * @param[in] aSize Size of matrix to be copied. + * @param[in] aDirection Specifies the type of Descriptors to be copied. + * @return void + * + */ + virtual void CopyDescriptors(void *apSourceDesc, void *apDestinationDesc, const int &aSize, + const common::CopyDirection &aDirection) = 0; + + /** + * @brief The Gateway for the Modeling Operation + * @param[in,out] aData DescriptorData object to be populated with descriptors and data. + * @param[in] aConfigurations Configurations object containing relevant settings. + * @param[in] apTheta Optimization parameter used by NLOPT. + * @param[in] apMeasurementsMatrix measurements matrix to be stored in DescZ. + * @param[in] aKernel Reference to the kernel object to use. + * @return log likelihood value + * + */ + virtual T ModelingOperations(std::unique_ptr> &aData, + configurations::Configurations &aConfigurations, const double *apTheta, + T *apMeasurementsMatrix, const kernels::Kernel &aKernel) = 0; + + /** + * @brief Copies a matrix in the tile layout from source to destination + * @param[in] aUpperLower Specifies the part of the matrix A to be copied to B. + * @param[in] apA Source matrix A. + * @param[in,out] apB Destination matrix B. On exit, B = A in the locations specified by Upper Lower. + * @return void + * + */ + virtual void ExaGeoStatLapackCopyTile(const common::UpperLower &aUpperLower, void *apA, void *apB) = 0; + + /** + * @brief Wait for the completion of a sequence. + * @param[in] apSequence apSequence A pointer to either CHAMELEON or HiCMA sequence. + * @return void + * + */ + virtual void ExaGeoStatSequenceWait(void *apSequence) = 0; + + /** + * @brief Create Sequence. + * @param[out] apSequence A pointer to either CHAMELEON or HiCMA sequence. + * @return void + * + */ + virtual void + ExaGeoStatCreateSequence(void *apSequence) = 0; + + /** + * @brief Computes the Cholesky factorization of a symmetric positive definite or Symmetric positive definite matrix. + * @param[in] aUpperLower Whether upper or lower part of the matrix A. + * @param[in, out] apA Symmetric matrix A. + * @param[in] aBand Diagonal thickness parameter. + * @param[in] apCD Additional matrix CD. + * @param[in] apCrk Additional matrix Crk. + * @param[in] aMaxRank Maximum rank parameter. + * @param[in] aAcc Accuracy parameter. + * @return void + * + */ + virtual void + ExaGeoStatPotrfTile(const common::UpperLower &aUpperLower, void *apA, int aBand, void *apCD, void *apCrk, + const int &aMaxRank, const int &aAcc) = 0; + + /** + * @brief Solves one of the matrix equations op( A )*X = alpha*B, or X*op( A ) = alpha*B. + * @param[in] aSide Specifies whether op(A) appears on the left or on the right of X. + * @param[in] aUpperLower Specifies whether the matrix A is upper triangular or lower triangular. + * @param[in] aTrans Specifies the form of op( A ) to be used in the matrix multiplication. + * @param[in] aDiag Specifies whether or not A is unit triangular. + * @param[in] aAlpha Specifies the scalar alpha. When alpha is zero, A is not referenced and B need not be set before entry. + * @param[in] apA The triangular matrix A. + * @param[in] apCD Additional matrix CD. + * @param[in] apCrk Additional matrix Crk. + * @param[in, out] apZ The matrix B of dimension, on exit is overwritten by the solution matrix X. + * @param[in] aMaxRank Maximum rank parameter. + * @return void + * + */ + virtual void ExaGeoStatTrsmTile(const common::Side &aSide, const common::UpperLower &aUpperLower, + const common::Trans &aTrans, const common::Diag &aDiag, const T &aAlpha, + void *apA, void *apCD, void *apCrk, void *apZ, const int &aMaxRank) = 0; + + /** + * @brief Performs a SYRK (symmetric rank-k update) operation on the matrix. + * @param[in] aConfigurations Configurations object containing relevant settings. + * @param[in,out] aData Descriptor Data object to be populated with descriptors and data. + * + */ + virtual void + ExaGeoStatSYRK(configurations::Configurations &aConfigurations, std::unique_ptr> &aData) = 0; + + /** + * @brief Performs TLR Cholesky operation on the matrix. + * @param[in] aConfigurations Configurations object containing relevant settings. + * @param[in,out] aData Descriptor Data object to be populated with descriptors and data. + * + */ + virtual void ExaGeoStatTLRCholesky(configurations::Configurations &aConfigurations, std::unique_ptr> &aData) = 0; + + /** + * @brief Calculates norm. + * @param[in] aConfigurations Configurations object containing relevant settings. + * @param[in,out] aData Descriptor Data object to be populated with descriptors and data. + * + */ + virtual void ExaGeoStatNorm(configurations::Configurations &aConfigurations, std::unique_ptr> &aData) =0; + + /** + * @brief Calculates the Mean Squared Error (MSE). + * @param[in] aConfigurations Reference to Configurations object containing needed parameters. + * @param[out] aData Reference to an ExaGeoStatData object that contains matrix to be analyzed. + * @return the calculated MSE. + * + */ + virtual double CalculateMSE(configurations::Configurations &aConfigurations, std::unique_ptr> &aData) =0; }; /** diff --git a/inst/include/linear-algebra-solvers/concrete/chameleon/ChameleonImplementation.hpp b/inst/include/linear-algebra-solvers/concrete/chameleon/ChameleonImplementation.hpp index 6ecfb1fb..0b421af8 100644 --- a/inst/include/linear-algebra-solvers/concrete/chameleon/ChameleonImplementation.hpp +++ b/inst/include/linear-algebra-solvers/concrete/chameleon/ChameleonImplementation.hpp @@ -32,12 +32,12 @@ namespace exageostat::linearAlgebra { /** * @brief Calculates the log likelihood value of a given value theta. - * @copydoc LinearAlgebraMethods::ExaGeoStatMLETile() + * @copydoc LinearAlgebraMethods::ModelingOperations() * */ - T ExaGeoStatMLETile(std::unique_ptr> &aData, - configurations::Configurations &aConfigurations, const double *theta, - T *apMeasurementsMatrix, const kernels::Kernel &aKernel) override; + T ModelingOperations(std::unique_ptr > &aData, + configurations::Configurations &aConfigurations, const double *theta, + T *apMeasurementsMatrix, const kernels::Kernel &aKernel) override; /** * @brief Copies a matrix in the tile layout from source to destination @@ -55,6 +55,14 @@ namespace exageostat::linearAlgebra { const common::Trans &aTrans, const common::Diag &aDiag, const T &aAlpha, void *apA, void *apCD, void *apCrk, void *apZ, const int &aMaxRank) override; + /** + * @brief Copy Descriptor Matrix to another Descriptor matrix. + * @copydoc LinearAlgebraMethods::CopyDescriptors() + * + */ + void CopyDescriptors(void *apSourceDesc, void *apDestinationDesc, const int &aSize, + const common::CopyDirection &aDirection) override; + /** * @brief Wait for the completion of a sequence. * @copydoc LinearAlgebraMethods::ExaGeoStatSequenceWait() @@ -70,6 +78,40 @@ namespace exageostat::linearAlgebra { */ void ExaGeoStatCreateSequence(void *apSequence) override; + + /** + * @brief Performs a SYRK (symmetric rank-k update) operation on the matrix. + * @copydoc LinearAlgebraMethods::ExaGeoStatSYRK() + * + */ + void ExaGeoStatSYRK(configurations::Configurations &aConfigurations, + std::unique_ptr > &aData) override; + + /** + * @brief Performs TLR Cholesky operation on the matrix. + * @copydoc LinearAlgebraMethods::ExaGeoStatTLRCholesky() + * + */ + void ExaGeoStatTLRCholesky(configurations::Configurations &aConfigurations, + std::unique_ptr > &aData) override; + + /** + * @brief Calculates norm. + * @copydoc LinearAlgebraMethods::ExaGeoStatNorm() + * + */ + void ExaGeoStatNorm(configurations::Configurations &aConfigurations, + std::unique_ptr > &aData) override; + + /** + * @brief Calculates the Mean Squared Error (MSE). + * @copydoc LinearAlgebraMethods::CalculateMSE() + * + */ + double CalculateMSE(configurations::Configurations &aConfigurations, + std::unique_ptr > &aData) override; + + }; EXAGEOSTAT_INSTANTIATE_CLASS(ChameleonImplementation) diff --git a/inst/include/linear-algebra-solvers/concrete/hicma/tlr/HicmaImplementation.hpp b/inst/include/linear-algebra-solvers/concrete/hicma/tlr/HicmaImplementation.hpp index 4c488a3d..b7667205 100644 --- a/inst/include/linear-algebra-solvers/concrete/hicma/tlr/HicmaImplementation.hpp +++ b/inst/include/linear-algebra-solvers/concrete/hicma/tlr/HicmaImplementation.hpp @@ -50,11 +50,11 @@ namespace exageostat::linearAlgebra::tileLowRank { /** * @brief Calculates the log likelihood value of a given value theta. - * @copydoc LinearAlgebraMethods::ExaGeoStatMLETile() + * @copydoc LinearAlgebraMethods::ModelingOperations() */ - T ExaGeoStatMLETile(std::unique_ptr> &aData, - configurations::Configurations &aConfigurations, const double *theta, - T *apMeasurementsMatrix, const kernels::Kernel &aKernel) override; + T ModelingOperations(std::unique_ptr > &aData, + configurations::Configurations &aConfigurations, const double *theta, + T *apMeasurementsMatrix, const kernels::Kernel &aKernel) override; /** * @brief Copies a matrix in the tile layout from source to destination @@ -91,6 +91,46 @@ namespace exageostat::linearAlgebra::tileLowRank { const common::Trans &aTrans, const common::Diag &aDiag, const T &aAlpha, void *apA, void *apCD, void *apCrk, void *apZ, const int &aMaxRank) override; + /** + * @brief Copy Descriptor Matrix to another Descriptor matrix. + * @copydoc LinearAlgebraMethods::CopyDescriptors() + * + */ + void CopyDescriptors(void *apSourceDesc, void *apDestinationDesc, const int &aSize, + const common::CopyDirection &aDirection) override; + + /** + * @brief Performs a SYRK (symmetric rank-k update) operation on the matrix. + * @copydoc LinearAlgebraMethods::ExaGeoStatSYRK() + * + */ + void ExaGeoStatSYRK(configurations::Configurations &aConfigurations, + std::unique_ptr > &aData) override; + + /** + * @brief Performs TLR Cholesky operation on the matrix. + * @copydoc LinearAlgebraMethods::ExaGeoStatTLRCholesky() + * + */ + void ExaGeoStatTLRCholesky(configurations::Configurations &aConfigurations, + std::unique_ptr > &aData) override; + + /** + * @brief Calculates norm. + * @copydoc LinearAlgebraMethods::ExaGeoStatNorm() + * + */ + void ExaGeoStatNorm(configurations::Configurations &aConfigurations, + std::unique_ptr > &aData) override; + + /** + * @brief Calculates the Mean Squared Error (MSE). + * @copydoc LinearAlgebraMethods::CalculateMSE() + * + */ + double CalculateMSE(configurations::Configurations &aConfigurations, + std::unique_ptr > &aData) override; + }; /** diff --git a/inst/include/linear-algebra-solvers/concrete/parsec/ParsecImplementation.hpp b/inst/include/linear-algebra-solvers/concrete/parsec/ParsecImplementation.hpp new file mode 100644 index 00000000..6d7df8cd --- /dev/null +++ b/inst/include/linear-algebra-solvers/concrete/parsec/ParsecImplementation.hpp @@ -0,0 +1,122 @@ + +// 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 ParsecImplementation.hpp + * @brief This file contains the declaration of ParsecImplementation class. + * @details ParsecImplementation is a concrete implementation of the LinearAlgebraMethods class. + * @version 2.0.0 + * @author Mahmoud ElKarargy + * @author Sameh Abdulah + * @date 2024-10-15 +**/ + +#ifndef EXAGEOSTATCPP_PARSECIMPLEMENTATION_HPP +#define EXAGEOSTATCPP_PARSECIMPLEMENTATION_HPP + +#include + +namespace exageostat::linearAlgebra { + + /** + * @brief ParsecImplementation is a concrete implementation of LinearAlgebraMethods class. + * @tparam T Data Type: float or double + * + */ + template + class ParsecImplementation : public LinearAlgebraMethods { + + /** + * @brief Performs a SYRK (symmetric rank-k update) operation on the matrix. + * @copydoc LinearAlgebraMethods::ExaGeoStatSYRK() + * + */ + void ExaGeoStatSYRK(configurations::Configurations &aConfigurations, std::unique_ptr> &aData) override; + + /** + * @brief Performs TLR Cholesky operation on the matrix. + * @copydoc LinearAlgebraMethods::ExaGeoStatTLRCholesky() + * + */ + void ExaGeoStatTLRCholesky(configurations::Configurations &aConfigurations, std::unique_ptr> &aData) override; + + /** + * @brief Calculates norm. + * @copydoc LinearAlgebraMethods::ExaGeoStatNorm() + * + */ + void ExaGeoStatNorm(configurations::Configurations &aConfigurations, + std::unique_ptr> &aData) override; + + /** + * @brief Calculates the Mean Squared Error (MSE). + * @copydoc LinearAlgebraMethods::CalculateMSE() + * + */ + double CalculateMSE(configurations::Configurations &aConfigurations, + std::unique_ptr> &aData) override; + + /** + * @brief The Gateway for the Modeling Operation + * @copydoc LinearAlgebraMethods::ModelingOperations() + * + */ + virtual T ModelingOperations(std::unique_ptr> &aData, + configurations::Configurations &aConfigurations, const double *apTheta, + T *apMeasurementsMatrix, const kernels::Kernel &aKernel) = 0; + + /** + * @brief Copies a matrix in the tile layout from source to destination + * @copydoc LinearAlgebraMethods::ExaGeoStatLapackCopyTile() + * + */ + virtual void ExaGeoStatLapackCopyTile(const common::UpperLower &aUpperLower, void *apA, void *apB) = 0; + + /** + * @brief Wait for the completion of a sequence. + * @copydoc LinearAlgebraMethods::ExaGeoStatSequenceWait() + * + */ + virtual void ExaGeoStatSequenceWait(void *apSequence) = 0; + + /** + * @brief Create Sequence. + * @copydoc LinearAlgebraMethods::ExaGeoStatCreateSequence() + * + */ + virtual void + ExaGeoStatCreateSequence(void *apSequence) = 0; + + /** + * @brief Computes the Cholesky factorization of a symmetric positive definite or Symmetric positive definite matrix. + * @copydoc LinearAlgebraMethods::ExaGeoStatPotrfTile() + * + */ + virtual void + ExaGeoStatPotrfTile(const common::UpperLower &aUpperLower, void *apA, int aBand, void *apCD, void *apCrk, + const int &aMaxRank, const int &aAcc) = 0; + + /** + * @brief Solves one of the matrix equations op( A )*X = alpha*B, or X*op( A ) = alpha*B. + * @copydoc LinearAlgebraMethods::ExaGeoStatTrsmTile() + * + */ + virtual void ExaGeoStatTrsmTile(const common::Side &aSide, const common::UpperLower &aUpperLower, + const common::Trans &aTrans, const common::Diag &aDiag, const T &aAlpha, + void *apA, void *apCD, void *apCrk, void *apZ, const int &aMaxRank) = 0; + + /** + * @brief Copy Descriptor Matrix to another Descriptor matrix. + * @copydoc LinearAlgebraMethods::CopyDescriptors() + * + */ + virtual void CopyDescriptors(void *apSourceDesc, void *apDestinationDesc, const int &aSize, + const common::CopyDirection &aDirection) = 0; + + }; + EXAGEOSTAT_INSTANTIATE_CLASS(ParsecImplementation) +}//namespace exageostat + +#endif //EXAGEOSTATCPP_PARSECIMPLEMENTATION_HPP \ No newline at end of file diff --git a/inst/include/runtime/parsec/ParsecHeader.hpp b/inst/include/runtime/parsec/ParsecHeader.hpp new file mode 100644 index 00000000..37b367ce --- /dev/null +++ b/inst/include/runtime/parsec/ParsecHeader.hpp @@ -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 ParsecHeader.hpp + * @brief A header file to include hicma_parsec and undo str definition inside it. + * @details Due to an error occuers when using hicma_parsec.h which set a defination called str() it conflicts with the standart C++ str() fn + * @version 2.0.0 + * @author Mahmoud ElKarargy + * @date 2024-10-08 +**/ + +#include +#undef str diff --git a/inst/include/utilities/EnumStringParser.hpp b/inst/include/utilities/EnumStringParser.hpp index ee7201bb..46bf13d3 100644 --- a/inst/include/utilities/EnumStringParser.hpp +++ b/inst/include/utilities/EnumStringParser.hpp @@ -14,6 +14,10 @@ #ifndef EXAGEOSTATCPP_ENUMSTRINGPARSER_HPP #define EXAGEOSTATCPP_ENUMSTRINGPARSER_HPP +#ifdef min +#undef min +#endif + #include #include diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1ec74fb5..713d0b05 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,20 +15,20 @@ add_subdirectory(configurations) add_subdirectory(kernels) add_subdirectory(helpers) add_subdirectory(data-units) +add_subdirectory(runtime) +add_subdirectory(linear-algebra-solvers) +add_subdirectory(api) +add_subdirectory(results) +add_subdirectory(hardware) +add_subdirectory(data-generators) +add_subdirectory(data-loader) +add_subdirectory(prediction) # 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 (RUNTIME_TYPE STREQUAL "PARSEC") + add_subdirectory(data-analyzer) + add_subdirectory(data-transformer) +endif () if (USE_R) add_subdirectory(Rcpp-adapters) diff --git a/src/api/ExaGeoStat.cpp b/src/api/ExaGeoStat.cpp index e1f1b1d1..1e2a371e 100644 --- a/src/api/ExaGeoStat.cpp +++ b/src/api/ExaGeoStat.cpp @@ -66,7 +66,10 @@ T ExaGeoStat::ExaGeoStatDataModeling(Configurations &aConfigurations, std::un optimizing_function.set_ftol_abs(aConfigurations.GetTolerance()); // Set max iterations value. optimizing_function.set_maxeval(max_number_of_iterations); - optimizing_function.set_max_objective(ExaGeoStatMLETileAPI, (void *) modeling_data); + // TODO: ON API level it should be consistent regardless of the runtime being implemented +#if DEFAULT_RUNTIME + optimizing_function.set_max_objective(ModelingAPI, (void *) modeling_data); +#endif // Optimize mle using nlopt. optimizing_function.optimize(aConfigurations.GetStartingTheta(), opt_f); aConfigurations.SetEstimatedTheta(aConfigurations.GetStartingTheta()); @@ -89,8 +92,7 @@ T ExaGeoStat::ExaGeoStatDataModeling(Configurations &aConfigurations, std::un } template -double -ExaGeoStat::ExaGeoStatMLETileAPI(const std::vector &aTheta, std::vector &aGrad, void *apInfo) { +double ExaGeoStat::ModelingAPI(const std::vector &aTheta, std::vector &aGrad, void *apInfo) { auto config = ((mModelingData *) apInfo)->mpConfiguration; auto data = ((mModelingData *) apInfo)->mpData; @@ -100,7 +102,8 @@ ExaGeoStat::ExaGeoStatMLETileAPI(const std::vector &aTheta, std::vect // We do Date Modeling with any computation. auto linear_algebra_solver = linearAlgebra::LinearAlgebraFactory::CreateLinearAlgebraSolver( config->GetComputation()); - return linear_algebra_solver->ExaGeoStatMLETile(*data, *config, aTheta.data(), measurements, *kernel); + + return linear_algebra_solver->ModelingOperations(*data, *config, aTheta.data(), measurements, *kernel); } @@ -119,4 +122,14 @@ void ExaGeoStat::ExaGeoStatPrediction(Configurations &aConfigurations, std::u prediction::Prediction::PredictMissingData(aData, aConfigurations, apMeasurementsMatrix, *pKernel, apTrainLocations, apTestLocations); delete pKernel; -} \ No newline at end of file +} + +template +void ExaGeoStat::ExaGeoStatTransformData(Configurations &aConfigurations, std::unique_ptr> &aData){ + +} + +template +void ExaGeoStat::ExaGeoStatDataAnalyzer(Configurations &aConfigurations, std::unique_ptr> &aData){ + +} diff --git a/src/configurations/Configurations.cpp b/src/configurations/Configurations.cpp index e3b1557b..0e77e2c6 100644 --- a/src/configurations/Configurations.cpp +++ b/src/configurations/Configurations.cpp @@ -70,6 +70,17 @@ Configurations::Configurations() { SetAccuracy(0); SetIsNonGaussian(false); mIsThetaInit = false; +#if !DEFAULT_RUNTIME + // Set default values for Hicma-Parsec params + SetDenseBandDP(0); + SetObjectsNumber(0); + SetAdaptiveDecision(0); + SetDiagonalAddition(0); + SetTimeSlotPerFile(1); + SetFileNumber(1); + SetEnableInverse(false); + SetMPIIO(true); +#endif } void Configurations::InitializeArguments(const int &aArgC, char **apArgV, const bool &aEnableR) { @@ -122,7 +133,7 @@ void Configurations::InitializeArguments(const int &aArgC, char **apArgV, const } else if (argument_name == "--gpus" || argument_name == "--GPUsNumbers" || argument_name == "--gpu_number" || argument_name == "--ngpus") { SetGPUsNumbers(CheckNumericalValue(argument_value)); - } else if (argument_name == "--DTS" || argument_name == "--dts" || argument_name == "--Dts") { + } else if (argument_name == "--DTS" || argument_name == "--dts" || argument_name == "--Dts" || argument_name == "--NB") { SetDenseTileSize(CheckNumericalValue(argument_value)); } else if (argument_name == "--LTS" || argument_name == "--lts" || argument_name == "--Lts") { SetLowTileSize(CheckNumericalValue(argument_value)); @@ -154,6 +165,19 @@ void Configurations::InitializeArguments(const int &aArgC, char **apArgV, const ParseDistanceMetric(argument_value); } else if (argument_name == "--logpath" || argument_name == "--log_path" || argument_name == "--logPath") { SetLoggerPath(argument_value); + } else if(argument_name == "--band_dense" || argument_name == "--bandDense"){ + SetDenseBandDP(CheckNumericalValue(argument_value)); + } else if(argument_name == "--numobj" || argument_name == "--obj-num" || argument_name == "--objnum"){ + SetObjectsNumber(CheckNumericalValue(argument_value)); + } else if(argument_name == "--adaptive_decision"){ + SetAdaptiveDecision(CheckNumericalValue(argument_value)); + } else if(argument_name == "--add_diag" || argument_name == "--add-diag" || argument_name == "--add-diagonal" + || argument_name == "--add-diag-elements"){ + SetDiagonalAddition(CheckNumericalValue(argument_value)); + } else if(argument_name == "--file_time_slot" || argument_name == "--fileTimeSlot"){ + SetTimeSlotPerFile(CheckNumericalValue(argument_value)); + } else if(argument_name == "--numFiles" || argument_name == "--file-num"){ + SetFileNumber(CheckNumericalValue(argument_value)); } else { if (!(argument_name == "--ZmissNumber" || argument_name == "--Zmiss" || argument_name == "--ZMiss" || argument_name == "--predict" || argument_name == "--Predict" || @@ -183,6 +207,10 @@ void Configurations::InitializeArguments(const int &aArgC, char **apArgV, const SetApproximationMode(true); } else if (argument_name == "--log" || argument_name == "--Log") { SetLogger(true); + } else if(argument_name == "--enable-inverse" || argument_name == "--enable_inverse"){ + SetEnableInverse(true); + } else if(argument_name == "--mpiio"){ + SetMPIIO(true); } else { if (!(argument_name == "--mspe" || argument_name == "--MSPE" || argument_name == "--idw" || argument_name == "--IDW" || @@ -200,13 +228,17 @@ void Configurations::InitializeArguments(const int &aArgC, char **apArgV, const if (GetProblemSize() == 0 && GetIsSynthetic()) { throw domain_error("You need to set the problem size, before starting"); } + if (GetDenseTileSize() == 0) { throw domain_error("You need to set the Dense tile size, before starting"); } + +#if DEFAULT_RUNTIME // Throw Errors if any of these arguments aren't given by the user. if (GetKernelName().empty()) { throw domain_error("You need to set the Kernel, before starting"); } +#endif size_t found = GetKernelName().find("NonGaussian"); // Check if the substring was found @@ -423,6 +455,14 @@ void Configurations::PrintUsage() { LOGGER("--approximation_mode : Used to enable Approximation mode.") LOGGER("--log : Enable logging.") LOGGER("--acc : Used to set the accuracy when using tlr.") + LOGGER("--band_dense=value : Used to set the dense band double precision, Used with PaRSEC runtime only.") + LOGGER("--numobj=value : Used to set the number of objects (number of viruses within a population), Used with PaRSEC runtime only.") + LOGGER("--adaptive_decision=value : Used to set the adaptive decision of each tile's format using norm approach, if enabled, otherwise 0, Used with PaRSEC runtime only.") + LOGGER("--add_diag=value : Used to add this number to diagonal elements to make the matrix positive definite in electrodynamics problem, Used with PaRSEC runtime only.") + LOGGER("--file_time_slot=value : Used to set time slot per file, Used with PaRSEC runtime only.") + LOGGER("--numFiles=value : Used to set file number, Used with PaRSEC runtime only.") + LOGGER("--enable-inverse : Used to enable inverse spherical harmonics transform, Used with PaRSEC runtime only.") + LOGGER("--mpiio : Used to enable MPI IO, Used with PaRSEC runtime only.") LOGGER("\n\n") exit(0); diff --git a/src/data-analyzer/CMakeLists.txt b/src/data-analyzer/CMakeLists.txt new file mode 100644 index 00000000..c257f99f --- /dev/null +++ b/src/data-analyzer/CMakeLists.txt @@ -0,0 +1,17 @@ + +# 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 This file contains the CMake configuration for the data-analyzer directory. +# @version 2.0.0 +# @author Mahmoud ElKarargy +# @author Sameh Abdulah +# @date 2024-10-15 + +set(SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/DataAnalyzer.cpp + ${SOURCES} + PARENT_SCOPE +) \ No newline at end of file diff --git a/src/data-analyzer/DataAnalyzer.cpp b/src/data-analyzer/DataAnalyzer.cpp new file mode 100644 index 00000000..942c9df8 --- /dev/null +++ b/src/data-analyzer/DataAnalyzer.cpp @@ -0,0 +1,27 @@ + +// 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 DataAnalyzer.cpp + * @brief Contains the implementation of the DataAnalyzer class. + * @version 2.0.0 + * @author Mahmoud ElKarargy + * @author Sameh Abdulah + * @date 2024-02-04 +**/ + +#include + +using namespace exageostat::configurations; + +template +static void AnalyzeMatrix(Configurations &aConfigurations, std::unique_ptr> &aData){ + +} + +template +static double CompareMatDifference(Configurations &aConfigurations, std::unique_ptr> &aData){ + +} diff --git a/src/data-generators/concrete/SyntheticGenerator.cpp b/src/data-generators/concrete/SyntheticGenerator.cpp index 85cfa7ec..dea29b27 100644 --- a/src/data-generators/concrete/SyntheticGenerator.cpp +++ b/src/data-generators/concrete/SyntheticGenerator.cpp @@ -51,6 +51,8 @@ SyntheticGenerator::CreateData(Configurations &aConfigurations, *locations); data->SetLocations(*locations); + // TODO: May need to get refactored to avoid the if/else guards +#if DEFAULT_RUNTIME // Generate Descriptors phase auto linear_algebra_solver = linearAlgebra::LinearAlgebraFactory::CreateLinearAlgebraSolver(EXACT_DENSE); linear_algebra_solver->GenerateSyntheticData(aConfigurations, data, aKernel); @@ -81,6 +83,7 @@ SyntheticGenerator::CreateData(Configurations &aConfigurations, #endif VERBOSE("Done.") } +#endif Results::GetInstance()->SetGeneratedLocationsNumber(n); Results::GetInstance()->SetIsLogger(aConfigurations.GetLogger()); Results::GetInstance()->SetLoggerPath(aConfigurations.GetLoggerPath()); diff --git a/src/data-loader/DataLoader.cpp b/src/data-loader/DataLoader.cpp index fb7ca2fd..65874148 100644 --- a/src/data-loader/DataLoader.cpp +++ b/src/data-loader/DataLoader.cpp @@ -42,6 +42,9 @@ DataLoader::CreateData(configurations::Configurations &aConfigurations, exage //Initialize the descriptors. auto linear_algebra_solver = linearAlgebra::LinearAlgebraFactory::CreateLinearAlgebraSolver(EXACT_DENSE); + + // TODO: May need to get refactored to avoid the if/else guards +#if DEFAULT_RUNTIME linear_algebra_solver->InitiateDescriptors(aConfigurations, *data->GetDescriptorData(), p); linear_algebra_solver->ExaGeoStatLaSetTile(EXAGEOSTAT_UPPER_LOWER, 0, 0, data->GetDescriptorData()->GetDescriptor(CHAMELEON_DESCRIPTOR, @@ -58,6 +61,7 @@ DataLoader::CreateData(configurations::Configurations &aConfigurations, exage ((T *) data->GetDescriptorData()->GetDescriptor(CHAMELEON_DESCRIPTOR, DESCRIPTOR_Z).chameleon_desc->mat)[i] = measurements_vector[i]; } +#endif Results::GetInstance()->SetGeneratedLocationsNumber(aConfigurations.GetProblemSize() / p); Results::GetInstance()->SetIsLogger(aConfigurations.GetLogger()); diff --git a/src/data-transformer/CMakeLists.txt b/src/data-transformer/CMakeLists.txt new file mode 100644 index 00000000..273aeaf9 --- /dev/null +++ b/src/data-transformer/CMakeLists.txt @@ -0,0 +1,17 @@ + +# 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 CMake configuration file for data-transformer directory +# @version 2.0.0 +# @author Mahmoud ElKarargy +# @date 2024-10-15 + +# Add source files to the parent scope +set(SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/DataTransformer.cpp + ${SOURCES} + PARENT_SCOPE +) diff --git a/src/data-transformer/DataTransformer.cpp b/src/data-transformer/DataTransformer.cpp new file mode 100644 index 00000000..2145204e --- /dev/null +++ b/src/data-transformer/DataTransformer.cpp @@ -0,0 +1,32 @@ + +// 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 DataTransformer.cpp + * @brief Contains the implementation of the DataTransformer class. + * @version 2.0.0 + * @author Mahmoud ElKarargy + * @author Sameh Abdulah + * @date 2024-02-04 +**/ + +#include + +using namespace exageostat::configurations; + +template +static void ForwardSHT(Configurations &aConfigurations, std::unique_ptr> &aData){ + +} + +template +static void ForwardReshape(Configurations &aConfigurations, std::unique_ptr> &aData){ + +} + +template +static void InverseSHT(Configurations &aConfigurations, std::unique_ptr> &aData){ + +} diff --git a/src/data-units/CMakeLists.txt b/src/data-units/CMakeLists.txt index 70977f00..43a185ae 100644 --- a/src/data-units/CMakeLists.txt +++ b/src/data-units/CMakeLists.txt @@ -9,20 +9,17 @@ # @author Sameh Abdulah # @date 2023-02-27 -# Initialize SOURCES variable if not already initialized -set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/Locations.cpp ${SOURCES}) - 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) +# Initialize SOURCES variable if not already initialized +set(SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/Locations.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/DescriptorData.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/ExaGeoStatData.cpp + ${SOURCES} + PARENT_SCOPE + ) + diff --git a/src/data-units/DescriptorData.cpp b/src/data-units/DescriptorData.cpp index eff728d3..34efa842 100644 --- a/src/data-units/DescriptorData.cpp +++ b/src/data-units/DescriptorData.cpp @@ -21,6 +21,7 @@ using namespace exageostat::dataunits::descriptor; template DescriptorData::~DescriptorData() { +#if DEFAULT_RUNTIME ExaGeoStatDescriptor exaGeoStatDescriptor; // Destroy descriptors. const std::string &chameleon = "_CHAMELEON"; @@ -47,6 +48,7 @@ DescriptorData::~DescriptorData() { if (this->mpSequence) { CHAMELEON_Sequence_Destroy((RUNTIME_sequence_t *) this->mpSequence); } +#endif } template @@ -91,6 +93,8 @@ BaseDescriptor DescriptorData::GetDescriptor(const DescriptorType &aDescriptorType, const DescriptorName &aDescriptorName) { BaseDescriptor descriptor{}; +#if DEFAULT_RUNTIME + if (aDescriptorType == CHAMELEON_DESCRIPTOR) { if (this->mDictionary.find(GetDescriptorName(aDescriptorName) + "_CHAMELEON") == this->mDictionary.end()) { descriptor.chameleon_desc = nullptr; @@ -119,6 +123,7 @@ DescriptorData::GetDescriptor(const DescriptorType &aDescriptorType, const De throw std::runtime_error("To use HiCMA descriptor you need to enable USE_HICMA!"); #endif } +#endif return descriptor; } @@ -132,6 +137,8 @@ void DescriptorData::SetDescriptor(const DescriptorType &aDescriptorType, con void *descriptor; std::string type; ExaGeoStatDescriptor exaGeoStatDescriptor; +#if DEFAULT_RUNTIME + if (aDescriptorType == CHAMELEON_DESCRIPTOR) { descriptor = exaGeoStatDescriptor.CreateDescriptor((CHAM_desc_t *) descriptor, aDescriptorType, aIsOOC, apMatrix, aFloatPoint, aMB, aNB, aSize, aLM, aLN, aI, aJ, aM, @@ -153,12 +160,13 @@ void DescriptorData::SetDescriptor(const DescriptorType &aDescriptorType, con type = "_CHAM_HIC"; } this->mDictionary[GetDescriptorName(aDescriptorName) + type] = descriptor; - +#endif } template T * DescriptorData::GetDescriptorMatrix(const DescriptorType &aDescriptorType, const DescriptorName &aDescriptorName) { +#if DEFAULT_RUNTIME if (aDescriptorType == CHAMELEON_DESCRIPTOR) { return (T *) (this->GetDescriptor(CHAMELEON_DESCRIPTOR, aDescriptorName).chameleon_desc)->mat; } else { @@ -168,6 +176,7 @@ DescriptorData::GetDescriptorMatrix(const DescriptorType &aDescriptorType, co throw std::runtime_error("To use Hicma descriptor you need to enable USE_HICMA!"); #endif } +#endif } // Define a function that returns the name of a DescriptorName value as a string diff --git a/src/hardware/ExaGeoStatHardware.cpp b/src/hardware/ExaGeoStatHardware.cpp index 3e9f3c18..d17631aa 100644 --- a/src/hardware/ExaGeoStatHardware.cpp +++ b/src/hardware/ExaGeoStatHardware.cpp @@ -12,13 +12,19 @@ * @date 2024-02-04 **/ +#include + +#if DEFAULT_RUNTIME #ifdef USE_MPI #include #endif #include #include -#include +#else +#include +#endif + #include #include #include @@ -26,6 +32,68 @@ using namespace exageostat::common; using namespace exageostat::results; +using namespace std; + +ExaGeoStatHardware::ExaGeoStatHardware(exageostat::configurations::Configurations &aConfigurations){ + + // These variables are named according to HiCMA-X inputs + const int N = aConfigurations.GetProblemSize(); + const int t = aConfigurations.GetDenseTileSize(); + const int e = aConfigurations.GetAccuracy(); + const int a = aConfigurations.GetAdaptiveDecision(); + const int g = aConfigurations.GetGPUsNumbers(); + const int c = aConfigurations.GetCoresNumber(); + const int j = aConfigurations.GetDiagonalAddition(); + const int J = aConfigurations.GetTimeSlot(); + const int K = aConfigurations.GetObjectsNumber(); + const int I = aConfigurations.GetDenseBandDP(); + const int time_slot_per_file = aConfigurations.GetTimeSlotPerFile(); + const int num_file = aConfigurations.GetFileNumber(); + + int v = 0; + if (aConfigurations.GetVerbosity() == Verbose::DETAILED_MODE){ + v = 1; + } + + // Create a vector to store the arguments as strings + std::vector new_args = { + "-g", to_string(g), + "-NB", to_string(t), + "-K", to_string(t), + "-N", to_string(N), + "-v", to_string(v), + "-I", to_string(I), + "-a", to_string(a), + "-J", to_string(J), + "-c", to_string(c), + "-K", to_string(K), + "-j", to_string(j) + }; + + // Convert std::vector to char** for the new argv + int new_argc = new_args.size(); + char **new_argv = new char*[new_argc]; + + for (int i = 0; i < new_argc; ++i) { + new_argv[i] = new char[new_args[i].length() + 1]; + strcpy(new_argv[i], new_args[i].c_str()); + } + +#if !DEFAULT_RUNTIME + 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; + this->mpParsecContext = hicma_parsec_init( new_argc, new_argv, iparam, dparam, cparam, ¶ms, ¶ms_kernel, &data ); +#endif + + LOGGER("Climate Emulator Parameters") + LOGGER("L: " << t << "\tT: " << J << "\tNB: " << t << "\tgpus: " << g) + LOGGER("nodes: " << c << "\ttime_slot_per_file: " << time_slot_per_file << "\tnum_file: " << num_file << "\tfile_per_node: " << ((num_file%c)? num_file/c+1 : num_file/c)) +} ExaGeoStatHardware::ExaGeoStatHardware(const Computation &aComputation, const int &aCoreNumber, const int &aGpuNumber, const int &aP, const int &aQ) { @@ -45,6 +113,7 @@ void ExaGeoStatHardware::InitHardware(const Computation &aComputation, const int SetQGrid(aQ); int tag_width = 31, tag_sep = 40; +#if DEFAULT_RUNTIME // Init hardware using Chameleon if (!mpChameleonContext) { #ifdef USE_MPI @@ -80,12 +149,14 @@ void ExaGeoStatHardware::InitHardware(const Computation &aComputation, const int throw std::runtime_error("You need to enable HiCMA to use TLR computation!"); #endif } +#endif exageostat::helpers::CommunicatorMPI::GetInstance()->SetHardwareInitialization(); LOGGER("** Initialize ExaGeoStat hardware **") } void ExaGeoStatHardware::FinalizeHardware() { + #if DEFAULT_RUNTIME // finalize hardware using HiCMA #ifdef USE_HICMA if (mpHicmaContext) { @@ -104,6 +175,8 @@ void ExaGeoStatHardware::FinalizeHardware() { mpChameleonContext = nullptr; } +#endif + exageostat::helpers::CommunicatorMPI::GetInstance()->RemoveHardwareInitialization(); } @@ -127,6 +200,13 @@ void *ExaGeoStatHardware::GetChameleonContext() { return mpChameleonContext; } +void *ExaGeoStatHardware::GetParsecContext() { + if (!mpParsecContext) { + throw std::runtime_error("PaRSEC Hardware is not initialized!"); + } + return mpParsecContext; +} + void *ExaGeoStatHardware::GetContext(Computation aComputation) { if (aComputation == EXACT_DENSE || aComputation == DIAGONAL_APPROX) { return GetChameleonContext(); @@ -155,6 +235,7 @@ void ExaGeoStatHardware::SetQGrid(int aQ) { void *ExaGeoStatHardware::mpChameleonContext = nullptr; void *ExaGeoStatHardware::mpHicmaContext = nullptr; +void *ExaGeoStatHardware::mpParsecContext = nullptr; int ExaGeoStatHardware::mPGrid = 1; int ExaGeoStatHardware::mQGrid = 1; bool ExaGeoStatHardware::mIsMPIInit = false; diff --git a/src/linear-algebra-solvers/CMakeLists.txt b/src/linear-algebra-solvers/CMakeLists.txt index 8a9eba80..865936d7 100644 --- a/src/linear-algebra-solvers/CMakeLists.txt +++ b/src/linear-algebra-solvers/CMakeLists.txt @@ -16,7 +16,14 @@ add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/concrete) # Define the sources for the library set(SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/LinearAlgebraFactory.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/LinearAlgebraMethods.cpp ${SOURCES} - PARENT_SCOPE - ) \ No newline at end of file + ) + +if (RUNTIME_TYPE STREQUAL "STARPU") + set(SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/LinearAlgebraMethods.cpp + ${SOURCES} + ) +endif () + +set(SOURCES ${SOURCES} PARENT_SCOPE) diff --git a/src/linear-algebra-solvers/LinearAlgebraFactory.cpp b/src/linear-algebra-solvers/LinearAlgebraFactory.cpp index 0d72dbad..5a1fef26 100644 --- a/src/linear-algebra-solvers/LinearAlgebraFactory.cpp +++ b/src/linear-algebra-solvers/LinearAlgebraFactory.cpp @@ -15,13 +15,14 @@ #include +#if DEFAULT_RUNTIME #include #include #ifdef USE_HICMA - #include +#endif #endif @@ -31,6 +32,7 @@ using namespace exageostat::common; template std::unique_ptr> LinearAlgebraFactory::CreateLinearAlgebraSolver(Computation aComputation) { +#if DEFAULT_RUNTIME // Check the used Linear Algebra solver library, whether it's HiCMA or Chameleon. if (aComputation == EXACT_DENSE) { @@ -49,6 +51,7 @@ std::unique_ptr> LinearAlgebraFactory::CreateLinearAl return std::make_unique>(); } +#endif // Return nullptr if no computation is selected throw std::runtime_error("You need to enable whether HiCMA or Chameleon"); } diff --git a/src/linear-algebra-solvers/LinearAlgebraMethods.cpp b/src/linear-algebra-solvers/LinearAlgebraMethods.cpp index 146ccf9e..8a083d72 100644 --- a/src/linear-algebra-solvers/LinearAlgebraMethods.cpp +++ b/src/linear-algebra-solvers/LinearAlgebraMethods.cpp @@ -1340,37 +1340,6 @@ LinearAlgebraMethods::ExaGeoStatGetZObs(Configurations &aConfigurations, T *a this->ExaGeoStatDesc2Lap(apZ, aSize, z_desc, UpperLower::EXAGEOSTAT_UPPER_LOWER); } -#ifdef USE_HICMA - -template -void LinearAlgebraMethods::CopyDescriptors(void *apSourceDesc, void *apDestinationDesc, const int &aSize, - const common::CopyDirection &aDirection) { - auto *z = new T[aSize]; - int status; - if (aDirection == common::CHAMELEON_TO_HICMA) { - status = CHAMELEON_Desc2Lap((cham_uplo_t) EXAGEOSTAT_UPPER_LOWER, (CHAM_desc_t *) apSourceDesc, z, aSize); - if (status != CHAMELEON_SUCCESS) { - throw std::runtime_error("CHAMELEON_Desc2Lap Failed!"); - } - status = HICMA_Lapack_to_Tile(z, aSize, (HICMA_desc_t *) apDestinationDesc); - if (status != HICMA_SUCCESS) { - throw std::runtime_error("HICMA_Lapack_to_Tile Failed!"); - } - } else if (aDirection == common::HICMA_TO_CHAMELEON) { - status = HICMA_Tile_to_Lapack((HICMA_desc_t *) apSourceDesc, z, aSize); - if (status != HICMA_SUCCESS) { - throw std::runtime_error("HICMA_Tile_to_Lapack Failed!"); - } - status = CHAMELEON_Lap2Desc((cham_uplo_t) EXAGEOSTAT_UPPER_LOWER, z, aSize, (CHAM_desc_t *) apDestinationDesc); - if (status != CHAMELEON_SUCCESS) { - throw std::runtime_error("CHAMELEON_Lap2Desc Failed!"); - } - } - delete[] z; -} - -#endif - template void LinearAlgebraMethods::ExaGeoStatDesc2Lap(T *apA, const int &aLDA, void *apDescA, const UpperLower &aUpperLower) { diff --git a/src/linear-algebra-solvers/concrete/CMakeLists.txt b/src/linear-algebra-solvers/concrete/CMakeLists.txt index 74df59f8..f1989e2b 100644 --- a/src/linear-algebra-solvers/concrete/CMakeLists.txt +++ b/src/linear-algebra-solvers/concrete/CMakeLists.txt @@ -12,18 +12,24 @@ # @date 2023-03-20 # Include the concrete implementations of the LinearAlgebraMethods class based on the enabled libraries (HiCMA or Chameleon) -set(SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/chameleon/dense/ChameleonDense.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/chameleon/dst/ChameleonDST.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/chameleon/ChameleonImplementation.cpp - ${SOURCES} - ) +if (RUNTIME_TYPE STREQUAL "STARPU") + set(SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/chameleon/dense/ChameleonDense.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/chameleon/dst/ChameleonDST.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/chameleon/ChameleonImplementation.cpp + ${SOURCES} + ) -if (USE_HICMA) - list(APPEND SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/tlr/HicmaImplementation.cpp - ) + if (USE_HICMA) + list(APPEND SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/tlr/HicmaImplementation.cpp + ) + endif () +elseif (RUNTIME_TYPE STREQUAL "PARSEC") + set(SOURCES + ${CMAKE_CURRENT_SOURCE_DIR}/parsec/ParsecImplementation.cpp + ${SOURCES} + ) endif () - set(SOURCES ${SOURCES} PARENT_SCOPE) diff --git a/src/linear-algebra-solvers/concrete/chameleon/ChameleonImplementation.cpp b/src/linear-algebra-solvers/concrete/chameleon/ChameleonImplementation.cpp index 8ec6abe8..5c3dd8ef 100644 --- a/src/linear-algebra-solvers/concrete/chameleon/ChameleonImplementation.cpp +++ b/src/linear-algebra-solvers/concrete/chameleon/ChameleonImplementation.cpp @@ -33,9 +33,9 @@ using namespace exageostat::configurations; using namespace exageostat::linearAlgebra; template -T ChameleonImplementation::ExaGeoStatMLETile(std::unique_ptr> &aData, - configurations::Configurations &aConfigurations, const double *theta, - T *apMeasurementsMatrix, const kernels::Kernel &aKernel) { +T ChameleonImplementation::ModelingOperations(std::unique_ptr > &aData, + configurations::Configurations &aConfigurations, const double *theta, + T *apMeasurementsMatrix, const kernels::Kernel &aKernel) { if (!aData->GetDescriptorData()->GetIsDescriptorInitiated()) { this->InitiateDescriptors(aConfigurations, *aData->GetDescriptorData(), aKernel.GetVariablesNumber(), @@ -361,3 +361,34 @@ void ChameleonImplementation::ExaGeoStatCreateSequence(void *apSequence) { throw std::runtime_error("CHAMELEON_Sequence_Create Failed!"); } } + +template +void ChameleonImplementation::CopyDescriptors(void *apSourceDesc, void *apDestinationDesc, const int &aSize, + const common::CopyDirection &aDirection) { + +} + +template +void +ChameleonImplementation::ExaGeoStatSYRK(Configurations &aConfigurations, unique_ptr > &aData) { + +} + +template +void ChameleonImplementation::ExaGeoStatTLRCholesky(Configurations &aConfigurations, + unique_ptr > &aData) { + +} + +template +void +ChameleonImplementation::ExaGeoStatNorm(Configurations &aConfigurations, unique_ptr > &aData) { + +} + +template +double +ChameleonImplementation::CalculateMSE(Configurations &aConfigurations, unique_ptr > &aData) { + + return 0; +} \ No newline at end of file diff --git a/src/linear-algebra-solvers/concrete/parsec/ParsecImplementation.cpp b/src/linear-algebra-solvers/concrete/parsec/ParsecImplementation.cpp new file mode 100644 index 00000000..60a5f8fd --- /dev/null +++ b/src/linear-algebra-solvers/concrete/parsec/ParsecImplementation.cpp @@ -0,0 +1,90 @@ + +// 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 ParsecImplementation.cpp + * @brief This file contains the implementation of ParsecImplementation class. + * @details ParsecImplementation is a concrete implementation of the LinearAlgebraMethods class. + * @version 2.0.0 + * @author Mahmoud ElKarargy + * @author Sameh Abdulah + * @date 2024-10-15 +**/ + +#include + +using namespace exageostat::linearAlgebra; +using namespace exageostat::configurations; + +template +void ParsecImplementation::ExaGeoStatSYRK(Configurations &aConfigurations, std::unique_ptr> &aData){ + +} + +template +void ParsecImplementation::ExaGeoStatTLRCholesky(Configurations &aConfigurations, std::unique_ptr> &aData){ + +} + +template +void +ParsecImplementation::ExaGeoStatNorm(Configurations &aConfigurations, std::unique_ptr> &aData) { + +} + +template +double +ParsecImplementation::CalculateMSE(Configurations &aConfigurations, std::unique_ptr> &aData) { + + return 0; +} + +template +T ParsecImplementation::ModelingOperations(std::unique_ptr> &aData, + configurations::Configurations &aConfigurations, const double *apTheta, + T *apMeasurementsMatrix, const kernels::Kernel &aKernel) { + +} + +template +void ParsecImplementation::ExaGeoStatLapackCopyTile(const common::UpperLower &aUpperLower, void *apA, void *apB) { + +} + + +template +void ParsecImplementation::ExaGeoStatSequenceWait(void *apSequence) { + +} + + +template +void ParsecImplementation::ExaGeoStatCreateSequence(void *apSequence) { + +} + + +template +void +ParsecImplementation::ExaGeoStatPotrfTile(const common::UpperLower &aUpperLower, void *apA, int aBand, void *apCD, + void *apCrk, const int &aMaxRank, const int &aAcc) { + +} + + +template +void ParsecImplementation::ExaGeoStatTrsmTile(const common::Side &aSide, const common::UpperLower &aUpperLower, + const common::Trans &aTrans, const common::Diag &aDiag, + const T &aAlpha, void *apA, void *apCD, void *apCrk, void *apZ, + const int &aMaxRank) { + +} + + +template +void ParsecImplementation::CopyDescriptors(void *apSourceDesc, void *apDestinationDesc, const int &aSize, + const common::CopyDirection &aDirection) { + +} \ No newline at end of file diff --git a/src/linear-algebra-solvers/concrete/tlr/HicmaImplementation.cpp b/src/linear-algebra-solvers/concrete/tlr/HicmaImplementation.cpp index c297bb01..a466ea4e 100644 --- a/src/linear-algebra-solvers/concrete/tlr/HicmaImplementation.cpp +++ b/src/linear-algebra-solvers/concrete/tlr/HicmaImplementation.cpp @@ -31,14 +31,15 @@ using namespace exageostat::dataunits; using namespace exageostat::kernels; using namespace exageostat::helpers; using namespace exageostat::results; +using namespace exageostat::configurations; int store_only_diagonal_tiles = 1; int use_scratch = 1; int global_check = 0; //used to create dense matrix for accuracy check template -void HicmaImplementation::SetModelingDescriptors(std::unique_ptr> &aData, - configurations::Configurations &aConfigurations, const int &aP) { +void HicmaImplementation::SetModelingDescriptors(std::unique_ptr > &aData, + Configurations &aConfigurations, const int &aP) { int full_problem_size = aConfigurations.GetProblemSize() * aP; int lts = aConfigurations.GetLowTileSize(); @@ -114,9 +115,9 @@ void HicmaImplementation::SetModelingDescriptors(std::unique_ptr -T HicmaImplementation::ExaGeoStatMLETile(std::unique_ptr> &aData, - configurations::Configurations &aConfigurations, const double *theta, - T *apMeasurementsMatrix, const Kernel &aKernel) { +T HicmaImplementation::ModelingOperations(std::unique_ptr > &aData, + Configurations &aConfigurations, const double *theta, + T *apMeasurementsMatrix, const Kernel &aKernel) { if (!aData->GetDescriptorData()->GetIsDescriptorInitiated()) { this->InitiateDescriptors(aConfigurations, *aData->GetDescriptorData(), aKernel.GetVariablesNumber(), @@ -402,3 +403,55 @@ void HicmaImplementation::ExaGeoStatTrsmTile(const common::Side &aSide, const throw std::runtime_error("HICMA_dtrsmd_Tile Failed!"); } } + + +template +void HicmaImplementation::CopyDescriptors(void *apSourceDesc, void *apDestinationDesc, const int &aSize, + const common::CopyDirection &aDirection) { + + auto *z = new T[aSize]; + int status; + if (aDirection == common::CHAMELEON_TO_HICMA) { + status = CHAMELEON_Desc2Lap((cham_uplo_t) EXAGEOSTAT_UPPER_LOWER, (CHAM_desc_t *) apSourceDesc, z, aSize); + if (status != CHAMELEON_SUCCESS) { + throw std::runtime_error("CHAMELEON_Desc2Lap Failed!"); + } + status = HICMA_Lapack_to_Tile(z, aSize, (HICMA_desc_t *) apDestinationDesc); + if (status != HICMA_SUCCESS) { + throw std::runtime_error("HICMA_Lapack_to_Tile Failed!"); + } + } else if (aDirection == common::HICMA_TO_CHAMELEON) { + status = HICMA_Tile_to_Lapack((HICMA_desc_t *) apSourceDesc, z, aSize); + if (status != HICMA_SUCCESS) { + throw std::runtime_error("HICMA_Tile_to_Lapack Failed!"); + } + status = CHAMELEON_Lap2Desc((cham_uplo_t) EXAGEOSTAT_UPPER_LOWER, z, aSize, (CHAM_desc_t *) apDestinationDesc); + if (status != CHAMELEON_SUCCESS) { + throw std::runtime_error("CHAMELEON_Lap2Desc Failed!"); + } + } + delete[] z; +} + + +template +void HicmaImplementation::ExaGeoStatSYRK(Configurations &aConfigurations, unique_ptr > &aData) { + +} + +template +void +HicmaImplementation::ExaGeoStatTLRCholesky(Configurations &aConfigurations, unique_ptr > &aData) { + +} + +template +void HicmaImplementation::ExaGeoStatNorm(Configurations &aConfigurations, unique_ptr > &aData) { + +} + +template +double HicmaImplementation::CalculateMSE(Configurations &aConfigurations, unique_ptr > &aData) { + + return 0; +} \ No newline at end of file diff --git a/src/prediction/Prediction.cpp b/src/prediction/Prediction.cpp index c5b625b7..943fc8b1 100644 --- a/src/prediction/Prediction.cpp +++ b/src/prediction/Prediction.cpp @@ -32,6 +32,7 @@ void Prediction::PredictMissingData(unique_ptr> &aData, Con T *apMeasurementsMatrix, const kernels::Kernel &aKernel, Locations *apTrainLocations, Locations *apTestLocations) { +#if DEFAULT_RUNTIME int i, j; bool can_predict = true; int num_params = aKernel.GetParametersNumbers(); @@ -201,6 +202,7 @@ void Prediction::PredictMissingData(unique_ptr> &aData, Con delete[] z_actual; delete miss_locations; delete obs_locations; +#endif } template @@ -209,7 +211,7 @@ void Prediction::InitializePredictionArguments(Configurations &aConfiguration T *apZObs, T *apZActual, Locations &aMissLocation, Locations &aObsLocation, T *apMeasurementsMatrix, const int &aP, Locations *apTrainLocations, Locations *apTestLocations) { - +#if DEFAULT_RUNTIME int full_problem_size = aConfigurations.GetProblemSize() * aP; T *z = new T[full_problem_size]; @@ -231,4 +233,5 @@ void Prediction::InitializePredictionArguments(Configurations &aConfiguration memcpy(apZObs, apMeasurementsMatrix, aObsLocation.GetSize() * sizeof(T)); } delete[] z; +#endif } \ No newline at end of file diff --git a/tests/cpp-tests/CMakeLists.txt b/tests/cpp-tests/CMakeLists.txt index b1a4f2d8..fcbb425e 100644 --- a/tests/cpp-tests/CMakeLists.txt +++ b/tests/cpp-tests/CMakeLists.txt @@ -8,10 +8,11 @@ # @author Mahmoud ElKarargy # @date 2024-01-24 +add_subdirectory(configurations) + # 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) diff --git a/tests/cpp-tests/configurations/TestConfigurations.cpp b/tests/cpp-tests/configurations/TestConfigurations.cpp index 6ea294f6..cfe0afa8 100644 --- a/tests/cpp-tests/configurations/TestConfigurations.cpp +++ b/tests/cpp-tests/configurations/TestConfigurations.cpp @@ -94,6 +94,48 @@ void TEST_ARGUMENT_INITIALIZATION() { } + +void TEST_ARGUMENT_INITIALIZATION_PARSEC() { + + const int argc = 12; + char *argv[] = { + const_cast("program_name"), + const_cast("--N=16"), + const_cast("--dts=8"), + const_cast("--precision=double"), + const_cast("--band_dense=100"), + const_cast("--numobj=72"), + const_cast("--adaptive_decision=1"), + const_cast("--add_diag=10"), + const_cast("--file_time_slot=1"), + const_cast("--file-num=1"), + const_cast("--enable-inverse"), + const_cast("--mpiio") + }; + + Configurations configurations; + // Initialize configuration dictionary with only common arguments + configurations.InitializeArguments(argc, argv); + + REQUIRE(configurations.GetProblemSize() == 16); + REQUIRE(configurations.GetDenseTileSize() == 8); + REQUIRE(configurations.GetPrecision() == DOUBLE); + + // Check Hicma-Parsec parameters + REQUIRE(configurations.GetDenseBandDP() == 100); + REQUIRE(configurations.GetObjectsNumber() == 72); + REQUIRE(configurations.GetAdaptiveDecision() == 1); + REQUIRE(configurations.GetDiagonalAddition() == 10); + REQUIRE(configurations.GetTimeSlotPerFile() == 1); + REQUIRE(configurations.GetFileNumber() == 1); + REQUIRE(configurations.GetEnableInverse() == true); + REQUIRE(configurations.GetMPIIO() == true); + + // No data generation arguments initialized + REQUIRE(configurations.GetDataPath() == string("")); +} + + void TEST_SYNTHETIC_CONFIGURATIONS() { Configurations synthetic_data_configurations; @@ -186,4 +228,7 @@ TEST_CASE("Configurations Tests") { TEST_SYNTHETIC_CONFIGURATIONS(); TEST_COPY_CONSTRUCTOR(); TEST_ARGUMENT_INITIALIZATION(); +#if !DEFAULT_RUNTIME + TEST_ARGUMENT_INITIALIZATION_PARSEC(); +#endif }