Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
# -------------------------------
Expand Down
20 changes: 8 additions & 12 deletions examples/descriptors/ChameleonToHicmaConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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;
}
5 changes: 0 additions & 5 deletions inst/include/common/Definitions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
7 changes: 5 additions & 2 deletions inst/include/data-units/DescriptorData.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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).
*
Expand All @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions inst/include/hardware/ExaGeoStatHardware.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
41 changes: 15 additions & 26 deletions src/data-units/DescriptorData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,32 +72,16 @@ void *DescriptorData<T>::GetRequest() {
#ifdef USE_HICMA

template<typename T>
HICMA_desc_t *DescriptorData<T>::ConvertChameleonToHicma(CHAM_desc_t *apChameleonDesc) {
HICMA_desc_t *
DescriptorData<T>::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
Expand Down Expand Up @@ -125,7 +109,8 @@ DescriptorData<T>::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;
Expand All @@ -142,7 +127,7 @@ void DescriptorData<T>::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;
Expand All @@ -164,7 +149,11 @@ void DescriptorData<T>::SetDescriptor(const DescriptorType &aDescriptorType, con
#endif
}

if (aConverted) {
type = "_CHAM_HIC";
}
this->mDictionary[GetDescriptorName(aDescriptorName) + type] = descriptor;

}

template<typename T>
Expand Down
4 changes: 2 additions & 2 deletions tests/cpp-tests/data-units/TestDescriptorData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>::CreateLinearAlgebraSolver(EXACT_DENSE);
auto *data = new DescriptorData<float>();
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);
Expand Down