diff --git a/CMakeLists.txt b/CMakeLists.txt index ae680a39..18ce5b92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -62,6 +62,8 @@ message(STATUS "CMAKE VERSION: ${CMAKE_VERSION}") enable_language(CXX) # Get the current path of the project. add_compile_definitions(PROJECT_SOURCE_DIR="${PROJECT_SOURCE_DIR}/") +# Set kernels path. +add_definitions(-DKERNELS_PATH="${PROJECT_SOURCE_DIR}/inst/include/kernels/concrete/") # ExaGeoStatCPP depends on CUDA # ------------------------------- diff --git a/examples/descriptors/ChameleonToHicmaConverter.cpp b/examples/descriptors/ChameleonToHicmaConverter.cpp index 1f60457c..2806ae75 100644 --- a/examples/descriptors/ChameleonToHicmaConverter.cpp +++ b/examples/descriptors/ChameleonToHicmaConverter.cpp @@ -65,12 +65,9 @@ int main(int argc, char **argv) { // Set Data Descriptor data->SetDescriptor(CHAMELEON_DESCRIPTOR, DESCRIPTOR_C, config_is_OOC, matrix.data(), EXAGEOSTAT_REAL_DOUBLE, - config_dts, - config_dts, - config_dts * config_dts, config_full_problem_size, config_full_problem_size, 0, 0, - config_full_problem_size, - config_full_problem_size, config_p_grid, config_q_grid); - + config_dts, config_dts, config_dts * config_dts, config_full_problem_size, + config_full_problem_size, 0, 0, config_full_problem_size, config_full_problem_size, + config_p_grid, config_q_grid); auto *CHAM_descriptorC = data->GetDescriptor(CHAMELEON_DESCRIPTOR, DESCRIPTOR_C).chameleon_desc; //Print Descriptor Attributes Before and After conversion @@ -98,9 +95,9 @@ int main(int argc, char **argv) { LOGGER_PRECISION_1(" " << cham_mat[i], 0) } - auto *HICMA_descriptorC = data->ConvertChameleonToHicma(CHAM_descriptorC); + auto *HICMA_descriptorC = data->ConvertChameleonToHicma(CHAM_descriptorC, DESCRIPTOR_C); - LOGGER("\n\t\t ** Hicma Descriptor, After Conversion:") + //Print Descriptor Attributes LOGGER(" Problem Size: " << HICMA_descriptorC->m) LOGGER(" Dense Tile Size: " << HICMA_descriptorC->mb) @@ -117,14 +114,13 @@ int main(int argc, char **argv) { LOGGER(" Size including Padding: " << HICMA_descriptorC->bsiz) // Print Data Matrix of Descriptor - LOGGER("** Data in Matrix of Hicma descriptor:") - auto *hicma_mat = (double *) HICMA_descriptorC->mat; + LOGGER("** Data in Matrix:") LOGGER_2("", 0) + auto *data_mat = (double *) HICMA_descriptorC->mat; for (int i = 0; i < config_problem_size; ++i) { - LOGGER_PRECISION_1(" " << hicma_mat[i], 0) + LOGGER_PRECISION_1(" " << data_mat[i], 0) } delete kernel; - delete HICMA_descriptorC; return 0; } diff --git a/inst/include/common/Definitions.hpp b/inst/include/common/Definitions.hpp index 3ca35b9c..400e26df 100644 --- a/inst/include/common/Definitions.hpp +++ b/inst/include/common/Definitions.hpp @@ -54,11 +54,6 @@ */ #define Q_NORM 1.959964 -/** - * Kernel Files Path Definition - */ -#define KERNELS_PATH PROJECT_SOURCE_DIR "/inst/include/kernels/concrete/" - /** * Logging Path Definition */ diff --git a/inst/include/data-units/DescriptorData.hpp b/inst/include/data-units/DescriptorData.hpp index e2207cdc..4c2b1d89 100644 --- a/inst/include/data-units/DescriptorData.hpp +++ b/inst/include/data-units/DescriptorData.hpp @@ -102,10 +102,12 @@ namespace exageostat::dataunits { /** * @brief Converts a CHAMELEON descriptor to a HICMA descriptor. * @param[in] apChameleonDesc Pointer to the CHAMELEON descriptor to be converted. + * @param[in] aDescriptorName The name of the descriptor. * @return Pointer to the converted HICMA descriptor. * */ - HICMA_desc_t *ConvertChameleonToHicma(CHAM_desc_t *apChameleonDesc); + HICMA_desc_t * + ConvertChameleonToHicma(CHAM_desc_t *apChameleonDesc, const common::DescriptorName &aDescriptorName); #endif @@ -128,6 +130,7 @@ namespace exageostat::dataunits { * @param[in] aP The number of rows in the complete matrix. * @param[in] aQ The number of columns in the complete matrix. * @param[in] aValidOOC Boolean refer to whether this descriptor can be created with OOC technology or not, default is true + * @param[in] aConverted Boolean indicates whether it's a converted descriptor from chameleon to hicma or not, default is false * @return void * @throws std::runtime_error if the corresponding library is not enabled (USE_HICMA). * @@ -136,7 +139,7 @@ namespace exageostat::dataunits { const bool &aIsOOC, void *apMatrix, const common::FloatPoint &aFloatPoint, const int &aMB, const int &aNB, const int &aSize, const int &aLM, const int &aLN, const int &aI, const int &aJ, const int &aM, const int &aN, const int &aP, const int &aQ, - const bool &aValidOOC = true); + const bool &aValidOOC = true, const bool &aConverted = false); /** * @brief Getter for the Descriptor matrix. diff --git a/inst/include/hardware/ExaGeoStatHardware.hpp b/inst/include/hardware/ExaGeoStatHardware.hpp index 5f76f51a..6e872091 100644 --- a/inst/include/hardware/ExaGeoStatHardware.hpp +++ b/inst/include/hardware/ExaGeoStatHardware.hpp @@ -117,6 +117,7 @@ class ExaGeoStatHardware { * @brief Sets the P dimension of the grid. * @details This function updates the P dimension setting of the grid. This dimension is critical in configuring the grid's layout for simulations or calculations. * @param[in] aP The new value for the P dimension. + * @return void * **/ static void SetPGrid(int aP); @@ -125,6 +126,7 @@ class ExaGeoStatHardware { * @brief Sets the Q dimension of the grid. * @details This function updates the Q dimension setting of the grid. This dimension is crucial in configuring the grid's layout for simulations or calculations. * @param[in] aQ The new value for the Q dimension. + * @return void * **/ static void SetQGrid(int aQ); diff --git a/src/data-units/DescriptorData.cpp b/src/data-units/DescriptorData.cpp index 019503e7..eff728d3 100644 --- a/src/data-units/DescriptorData.cpp +++ b/src/data-units/DescriptorData.cpp @@ -72,32 +72,16 @@ void *DescriptorData::GetRequest() { #ifdef USE_HICMA template -HICMA_desc_t *DescriptorData::ConvertChameleonToHicma(CHAM_desc_t *apChameleonDesc) { +HICMA_desc_t * +DescriptorData::ConvertChameleonToHicma(CHAM_desc_t *apChameleonDesc, const DescriptorName &aDescriptorName) { - // Create a new HICMA descriptor - auto *hicma_desc = new HICMA_desc_t; + this->SetDescriptor(HICMA_DESCRIPTOR, aDescriptorName, apChameleonDesc->ooc, apChameleonDesc->mat, + (FloatPoint) (apChameleonDesc->dtyp), apChameleonDesc->mb, apChameleonDesc->nb, + apChameleonDesc->bsiz, apChameleonDesc->lm, apChameleonDesc->ln, apChameleonDesc->i, + apChameleonDesc->j, apChameleonDesc->m, apChameleonDesc->n, apChameleonDesc->p, + apChameleonDesc->q, apChameleonDesc->ooc, true); - // Set function pointers in HICMA descriptor - hicma_desc->get_blkaddr = hicma_getaddr_ccrb; - hicma_desc->get_blkldd = hicma_getblkldd_ccrb; - hicma_desc->get_rankof = hicma_getrankof_2d; - - // Set sizes and offsets for memory copy - size_t hicma_desc_total_size = 184; - size_t chameleon_desc_total_size = 200; - // Size of the common members between Hicma_desc and Chameleon_desc - size_t common_total_size = 3 * sizeof(size_t) + 30 * sizeof(int); - // Skip the size of function pointers. - size_t hicma_offset = hicma_desc_total_size - (common_total_size + sizeof(void *)); - size_t chameleon_offset = chameleon_desc_total_size - (common_total_size + sizeof(void *)); - - // Copy common data from CHAMELEON descriptor to HICMA descriptor - memcpy(((char *) hicma_desc) + hicma_offset, ((char *) apChameleonDesc) + chameleon_offset, common_total_size); - // Set additional data in HICMA descriptor - hicma_desc->mat = apChameleonDesc->mat; - hicma_desc->schedopt = apChameleonDesc->schedopt; - - return hicma_desc; + return this->GetDescriptor(HICMA_DESCRIPTOR, aDescriptorName).hicma_desc; } #endif @@ -125,7 +109,8 @@ DescriptorData::GetDescriptor(const DescriptorType &aDescriptorType, const De } else if (this->mDictionary.find(GetDescriptorName(aDescriptorName) + "_CHAMELEON") != this->mDictionary.end()) { descriptor.hicma_desc = this->ConvertChameleonToHicma( - (CHAM_desc_t *) this->mDictionary[GetDescriptorName(aDescriptorName) + "_CHAMELEON"]); + (CHAM_desc_t *) this->mDictionary[GetDescriptorName(aDescriptorName) + "_CHAMELEON"], + aDescriptorName); this->mDictionary[GetDescriptorName(aDescriptorName) + "_CHAM_HIC"] = descriptor.hicma_desc; } else { descriptor.hicma_desc = nullptr; @@ -142,7 +127,7 @@ void DescriptorData::SetDescriptor(const DescriptorType &aDescriptorType, con const bool &aIsOOC, void *apMatrix, const FloatPoint &aFloatPoint, const int &aMB, const int &aNB, const int &aSize, const int &aLM, const int &aLN, const int &aI, const int &aJ, const int &aM, const int &aN, const int &aP, - const int &aQ, const bool &aValidOOC) { + const int &aQ, const bool &aValidOOC, const bool &aConverted) { void *descriptor; std::string type; @@ -164,7 +149,11 @@ void DescriptorData::SetDescriptor(const DescriptorType &aDescriptorType, con #endif } + if (aConverted) { + type = "_CHAM_HIC"; + } this->mDictionary[GetDescriptorName(aDescriptorName) + type] = descriptor; + } template diff --git a/tests/cpp-tests/data-units/TestDescriptorData.cpp b/tests/cpp-tests/data-units/TestDescriptorData.cpp index 2b8e97dc..5f87d1a0 100644 --- a/tests/cpp-tests/data-units/TestDescriptorData.cpp +++ b/tests/cpp-tests/data-units/TestDescriptorData.cpp @@ -32,14 +32,14 @@ void TEST_CHAM_TO_HICMA_CONV() { // Initialize linear algebra solver int p = 1; - auto hardware = ExaGeoStatHardware(EXACT_DENSE, 1, 0); + auto hardware = ExaGeoStatHardware(TILE_LOW_RANK, 1, 0); auto linearAlgebraSolver = LinearAlgebraFactory::CreateLinearAlgebraSolver(EXACT_DENSE); auto *data = new DescriptorData(); linearAlgebraSolver->InitiateDescriptors(synthetic_data_configurations, *data, p); // Create CHAM descriptor and convert it to HICMA descriptor auto *CHAM_descriptorC = data->GetDescriptor(CHAMELEON_DESCRIPTOR, DESCRIPTOR_C).chameleon_desc; - auto *HICMA_descriptor = data->ConvertChameleonToHicma(CHAM_descriptorC); + auto *HICMA_descriptor = data->ConvertChameleonToHicma(CHAM_descriptorC,DESCRIPTOR_C); // Verify common attributes are of same value REQUIRE(CHAM_descriptorC->m == HICMA_descriptor->m);