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
21 changes: 1 addition & 20 deletions inst/include/Rcpp-adapters/FunctionsAdapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,25 +22,6 @@

namespace exageostat::adapters {

/**
* @brief Retrieves locations from ExaGeoStat data.
* @details Extracts and returns the locations stored in an ExaGeoStatData object,
* @param[in] apData Pointer to ExaGeoStatData object containing the spatial data.
* @return vector of locations coordinates.
*
*/
std::vector<std::vector<double>> R_GetLocations(ExaGeoStatData<double> *apData);

/**
* @brief Retrieves descriptive Z values from ExaGeoStat data based on type.
* @details Extracts and returns Z values from an ExaGeoStatData object, aiding in targeted spatial data analysis and visualization within ExaGeoStat.
* @param[in] apData Pointer to ExaGeoStatData object containing the spatial data.
* @param[in] aType String specifying the type of descriptor value to retrieve (e.g., "Chameleon", "HiCMA").
* @return Numeric vector of descriptive Z values.
*
*/
Rcpp::NumericVector R_GetDescZValues(ExaGeoStatData<double> *apData, const std::string &aType);

/**
* @brief Function to load ExaGeoStat data.
* @details This function loads data into an ExaGeoStatData object using the provided configuration and computational settings.
Expand All @@ -60,7 +41,7 @@ namespace exageostat::adapters {
* @return A pointer to an ExaGeoStatData object containing the loaded data.
*
*/
ExaGeoStatData<double> *
Rcpp::List
R_ExaGeoStatLoadData(const std::string &aKernelName, const std::vector<double> &aInitialTheta,
const std::string &aDistanceMatrix, const int &aProblemSize, const int &aSeed,
const int &aDenseTileSize, const int &aLowTileSize, const std::string &aDimension,
Expand Down
40 changes: 36 additions & 4 deletions inst/include/utilities/Logger.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,49 @@
#define DEFAULT_PRECISION 6

/**
* @def VERBOSE(msg)
* @brief Verbose macro for logging and debugging mode.
* @def VERBOSE_PRECISION
* @brief A fixed precision for the verbose mode.
*/
#define VERBOSE(msg) \
#define VERBOSE_PRECISION 12

/**
* @def VERBOSE_1(msg)
* @brief VERBOSE_1 macro for logging outputs in verbose mode, with double taps at the beginning, a fixed precision and a new line at the end.
*/
#define VERBOSE_1(msg) \
if(exageostat::configurations::Configurations::GetVerbosity() == exageostat::common::Verbose::DETAILED_MODE && \
!exageostat::helpers::CommunicatorMPI::GetInstance()->GetRank()) { \
std::ostringstream oss; \
oss << "\t\t " << std::fixed << std::setprecision(VERBOSE_PRECISION) << msg << std::endl; \
std::cout << oss.str(); \
}

/**
* @def VERBOSE_2(msg, A)
* @brief VERBOSE_2 macro for logging outputs in verbose mode, with double taps at the beginning, a fixed precision and without a new line at the end.
*/
#define VERBOSE_2(msg, A) \
if(exageostat::configurations::Configurations::GetVerbosity() == exageostat::common::Verbose::DETAILED_MODE && \
!exageostat::helpers::CommunicatorMPI::GetInstance()->GetRank()) { \
std::ostringstream oss; \
oss << "\t\t\t " << msg << std::endl; \
oss << "\t\t " << std::fixed << std::setprecision(VERBOSE_PRECISION) << msg ; \
std::cout << oss.str(); \
}

/**
* @def VERBOSE_CONTROL(x, A, B, FUNC, ...)
* @brief VERBOSE_CONTROL is The internal macro that simply strips the excess and ends up with the required macro
*/
#define VERBOSE_CONTROL(x, A, B, FUNC, ...) FUNC

/**
* @def VERBOSE(...)
* @brief VERBOSE macro that's called, Used to logging outputs in a verbose mode.
*/
#define VERBOSE(...) VERBOSE_CONTROL(,##__VA_ARGS__, \
VERBOSE_2(__VA_ARGS__), \
VERBOSE_1(__VA_ARGS__), \
)
/**
* @def LOGGER_1(msg)
* @brief LOGGER_1 macro for logging outputs with double taps and new line at the end.
Expand Down
1 change: 0 additions & 1 deletion man/get_Z_measurement_vector.Rd
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// TODO: dots
% 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).
Expand Down
6 changes: 3 additions & 3 deletions scripts/Benchmarking.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ for N in "${desired_N[@]}"; do
time_prediction=$(echo "$time_prediction" | tr -d '\n' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
time_modeling_iteration=$(echo "$command_output" | awk -F "#Average Time Modeling per Iteration: " '{print $2}' | awk -F "," '{print $1}')
time_modeling_iteration=$(echo "$time_modeling_iteration" | tr -d '\n' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
flops_generation=$(echo "$command_output" | awk -F "#Total Data Generation Gflop/s: " '{print $2}' | awk -F "," '{print $1}')
flops_generation=$(echo "$command_output" | awk -F "#Total Data Generation GFlop/s: " '{print $2}' | awk -F "," '{print $1}')
flops_generation=$(echo "$flops_generation" | tr -d '\n' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
flops_modeling=$(echo "$command_output" | awk -F "#Total MLE Gflop/s: " '{print $2}' | awk -F "," '{print $1}')
flops_modeling=$(echo "$command_output" | awk -F "#Total MLE GFlop/s: " '{print $2}' | awk -F "," '{print $1}')
flops_modeling=$(echo "$flops_modeling" | tr -d '\n' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
flops_modeling_iteration=$(echo "$command_output" | awk -F "#Average Flops per Iteration: " '{print $2}' | awk -F "," '{print $1}')
flops_modeling_iteration=$(echo "$flops_modeling_iteration" | tr -d '\n' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
flops_mspe=$(echo "$command_output" | awk -F "#MSPE Gflop/s: " '{print $2}' | awk -F "," '{print $1}')
flops_mspe=$(echo "$command_output" | awk -F "#MSPE GFlop/s: " '{print $2}' | awk -F "," '{print $1}')
flops_mspe=$(echo "$flops_mspe" | tr -d '\n' | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')

echo "$command_output"
Expand Down
108 changes: 53 additions & 55 deletions src/Rcpp-adapters/FunctionsAdapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,60 +25,7 @@ using namespace exageostat::configurations;

namespace exageostat::adapters {

vector<vector<double>> R_GetLocations(ExaGeoStatData<double> *apData) {

// Number of points per each dimension
int length = apData->GetLocations()->GetSize();
bool is3D = apData->GetLocations()->GetDimension() == Dimension3D;

double *locationXArray = apData->GetLocations()->GetLocationX();
double *locationYArray = apData->GetLocations()->GetLocationY();
double *locationZArray = nullptr;
if (is3D) {
locationZArray = apData->GetLocations()->GetLocationZ();
}

vector<vector<double>> locations_matrix;
for (int i = 0; i < length; ++i) {
vector<double> point;
point.push_back(locationXArray[i]);
point.push_back(locationYArray[i]);
if (is3D) {
point.push_back(locationZArray[i]);
}
locations_matrix.push_back(point);
}
return locations_matrix;
}

NumericVector R_GetDescZValues(ExaGeoStatData<double> *apData, const string &aType) {

DescriptorType descriptorType;
void *pDescriptor;

if (aType == "chameleon" || aType == "Chameleon") {
descriptorType = CHAMELEON_DESCRIPTOR;
} else if (aType == "hicma" || aType == "Hicma" || aType == "HICMA") {
#ifdef USE_HICMA
descriptorType = HICMA_DESCRIPTOR;
#else
throw runtime_error("Please enable HiCMA to use HiCMA descriptors.");
#endif
} else {
throw domain_error("Invalid type of descriptor, please use chameleon or hicma.");
}

// Obtain the pointer to the array of doubles
double *data = apData->GetDescriptorData()->GetDescriptorMatrix(descriptorType, DESCRIPTOR_Z);
int length = apData->GetLocations()->GetSize();
// Create an empty NumericVector of the appropriate length
NumericVector vec(length);
// Copy data from the double array to the NumericVector
copy(data, data + length, vec.begin());
return vec;
}

ExaGeoStatData<double> *
List
R_ExaGeoStatLoadData(const string &aKernelName, const vector<double> &aInitialTheta, const string &aDistanceMatrix,
const int &aProblemSize, const int &aSeed, const int &aDenseTileSize, const int &aLowTileSize,
const string &aDimension, const string &aLogPath, const string &aDataPath,
Expand Down Expand Up @@ -110,8 +57,59 @@ namespace exageostat::adapters {
unique_ptr<ExaGeoStatData<double>> data;
ExaGeoStat<double>::ExaGeoStatLoadData(configurations, data);

// Obtain the pointer to the array of doubles
double *descriptor_data = data->GetDescriptorData()->GetDescriptorMatrix(CHAMELEON_DESCRIPTOR, DESCRIPTOR_Z);
int length = data->GetLocations()->GetSize();
// Create an empty NumericVector of the appropriate length
NumericVector vec(length);
// Copy data from the double array to the NumericVector
copy(descriptor_data, descriptor_data + length, vec.begin());

// Number of points per each dimension
bool is3D = data->GetLocations()->GetDimension() == Dimension3D;

double *locationXArray = data->GetLocations()->GetLocationX();
double *locationYArray = data->GetLocations()->GetLocationY();
double *locationZArray = nullptr;
if (is3D) {
locationZArray = data->GetLocations()->GetLocationZ();
}

vector<vector<double>> locations_matrix;
for (int i = 0; i < length; ++i) {
vector<double> point;
point.push_back(locationXArray[i]);
point.push_back(locationYArray[i]);
if (is3D) {
point.push_back(locationZArray[i]);
}
locations_matrix.push_back(point);
}

// Create NumericVectors for location coordinates
NumericVector locationX(length);
NumericVector locationY(length);
NumericVector locationZ(length);

for (int i = 0; i < length; ++i) {
locationX[i] = locationXArray[i];
locationY[i] = locationYArray[i];
if (is3D) {
locationZ[i] = locationZArray[i];
}
}

// Create a list of vectors including z_values and locations
Rcpp::List result = Rcpp::List::create(
_["m"] = vec,
_["x"] = locationX,
_["y"] = locationY,
_["z"] = locationZ
);
// We can safely return the raw pointer, but we need to release it from data to avoid deletion.
return data.release();
data.release();

return result;
}

vector<double>
Expand Down
4 changes: 0 additions & 4 deletions src/Rcpp-adapters/RcppModules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,4 @@ RCPP_MODULE(ExaGeoStatCPP) {
List::create(_["kernel"], _["distance_matrix"] = "euclidean", _["estimated_theta"], _["dts"], _["lts"] = 0,
_["dimension"] = "2D", _["train_data"], _["test_data"], _["test_measurements"]));

function("get_locations", &exageostat::adapters::R_GetLocations, List::create(_["data"]));

function("get_Z_measurement_vector", &exageostat::adapters::R_GetDescZValues, List::create(_["data"], _["type"]));

}
12 changes: 12 additions & 0 deletions src/api/ExaGeoStat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ T ExaGeoStat<T>::ExaGeoStatDataModeling(Configurations &aConfigurations, std::un
optimizing_function.optimize(aConfigurations.GetStartingTheta(), opt_f);
aConfigurations.SetEstimatedTheta(aConfigurations.GetStartingTheta());

auto theta = aConfigurations.GetStartingTheta();

LOGGER("--> Final Theta Values (", true)
for (int i = 0; i < parameters_number; i++) {
LOGGER_PRECISION(theta[i])
if (i != parameters_number - 1) {
LOGGER_PRECISION(", ")
}
}
LOGGER_PRECISION(")")
LOGGER("")

delete pKernel;
delete modeling_data;
return optimizing_function.last_optimum_value();
Expand Down
4 changes: 3 additions & 1 deletion src/configurations/Configurations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ void Configurations::InitTheta(vector<double> &aTheta, const int &size) {

void Configurations::PrintSummary() {

#ifndef USING_R
Verbose temp = this->GetVerbosity();
mVerbosity = STANDARD_MODE;

Expand Down Expand Up @@ -674,9 +675,10 @@ void Configurations::PrintSummary() {
LOGGER("#Out Of Core (OOC) technology is enabled")
}
LOGGER("*************************************************")
mVerbosity = temp;
mFirstInit = true;
}
mVerbosity = temp;
#endif
}

int Configurations::CalculateZObsNumber() {
Expand Down
14 changes: 7 additions & 7 deletions src/linear-algebra-solvers/LinearAlgebraMethods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -813,16 +813,16 @@ void LinearAlgebraMethods<T>::ExaGeoStatMLETileMLOEMMOM(Configurations &aConfigu

int n_z_miss = aConfigurations.GetUnknownObservationsNb();
int num_par = aKernel.GetParametersNumbers();
LOGGER("\t\t- Truth Theta: ", true)
VERBOSE("\t\t- Truth Theta: ", true)
for (int num = 0; num < num_par; num++) {
LOGGER_PRECISION(apTruthTheta[num] << " ")
VERBOSE(apTruthTheta[num] << " ",true)
}
LOGGER("")
LOGGER("\t\t- Estimated Theta: ", true)
VERBOSE("")
VERBOSE("\t\t- Estimated Theta: ", true)
for (int num = 0; num < num_par; num++) {
LOGGER_PRECISION(apEstimatedTheta[num] << " ")
VERBOSE(apEstimatedTheta[num] << " ",true)
}
LOGGER("")
VERBOSE("")
int p;
double all_time, cholesky1, cholesky2, matrix_gen, vecs_gen, copy_vecs, trsm1, trsm2, trsm3, trsm4, gevv1, gevv2, gevv3, gevv4, gevv5;

Expand Down Expand Up @@ -1109,7 +1109,7 @@ void LinearAlgebraMethods<T>::ExaGeoStatMLETileMLOEMMOM(Configurations &aConfigu
*mloe /= n_z_miss;
*mmom /= n_z_miss;
STOP_TIMING(all_time);
LOGGER("\t\t- MLOE = " << *mloe << "\t\t- MMOM = " << *mmom)
VERBOSE("\t\t- MLOE = " << *mloe << "\t\t- MMOM = " << *mmom)
VERBOSE("\t---- MLOE MMOM Time: " << all_time << " seconds.")

Results::GetInstance()->SetMLOE(*mloe);
Expand Down
14 changes: 7 additions & 7 deletions src/prediction/Prediction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,16 @@ void Prediction<T>::PredictMissingData(unique_ptr<ExaGeoStatData<T>> &aData, Con
VERBOSE("\t\t- CI for nu: " << aConfigurations.GetEstimatedTheta()[2] - Q_NORM * sqrt(fisher_results[8]) << " "
<< aConfigurations.GetEstimatedTheta()[2] + Q_NORM * sqrt(fisher_results[8]))

LOGGER("\t\t- Fisher Matrix:")
VERBOSE("\t\t- Fisher Matrix:")
for (i = 0; i < num_params; i++) {
LOGGER("\t\t ", true)
VERBOSE("\t\t ", true)
for (j = 0; j < num_params; j++) {
LOGGER_PRECISION(fisher_results[i * num_params + j], 18)
VERBOSE(fisher_results[i * num_params + j],true)
if (j != num_params - 1) {
LOGGER_PRECISION(", ")
VERBOSE(", ",true)
}
}
LOGGER("")
VERBOSE("")
}
delete[] fisher_results;
}
Expand Down Expand Up @@ -159,7 +159,7 @@ void Prediction<T>::PredictMissingData(unique_ptr<ExaGeoStatData<T>> &aData, Con

// MSPE Prediction Function Call
if (aConfigurations.GetIsMSPE()) {
LOGGER("\t---- Using MSPE ----")
LOGGER("\t---- Using Prediction Function MSPE ----")
T *prediction_error_mspe;
if (aConfigurations.GetIsNonGaussian()) {
prediction_error_mspe = linear_algebra_solver->ExaGeoStatMLENonGaussianPredictTile(aData,
Expand Down Expand Up @@ -187,7 +187,7 @@ void Prediction<T>::PredictMissingData(unique_ptr<ExaGeoStatData<T>> &aData, Con
}
Results::GetInstance()->SetPredictedMissedValues(z_miss_vector);
if (z_actual) {
LOGGER("\t\t- MSPE: " << avg_pred_value[0])
LOGGER("\t\t- Prediction value: " << avg_pred_value[0])
}
delete[] prediction_error_mspe;
}
Expand Down
2 changes: 1 addition & 1 deletion src/prediction/PredictionAuxiliaryFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ void PredictionAuxiliaryFunctions<T>::PredictIDW(T *apZMiss, T *apZActual, T *ap
for (int index = 0; index < aZMissNumber; index++) {
VERBOSE(" (" << apZActual[index] << ", " << apZMiss[index] << ")")
}
LOGGER("\t\t- Prediction Error (IDW): " << apMSPE[0] << " - " << apMSPE[1] << " - " << apMSPE[2])
VERBOSE("\t\t- Prediction Error (IDW): " << apMSPE[0] << " - " << apMSPE[1] << " - " << apMSPE[2])
}
24 changes: 18 additions & 6 deletions tests/R-tests/TestDataGeneration.R
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,14 @@ hardware <- new(Hardware, computation, ncores, ngpus, p, q)
exageostat_data <- simulate_data(kernel=kernel, initial_theta=initial_theta, problem_size=problem_size, dts=dts, dimension=dimension, log_path=log_path)

# Print the data..
paste("** Locations X - Y - Z")
locations <- get_locations(data=exageostat_data)
paste(locations)
paste("Z Values")
paste(exageostat_data$m)
paste("Locations X")
paste(exageostat_data$x)
paste("Locations Y")
paste(exageostat_data$y)
paste("Locations Z")
paste(exageostat_data$z)

paste("---------------------------------------------------------------------------------------------")
paste("ExaGeoStat with Data Generation - Reading Data")
Expand All @@ -52,6 +57,13 @@ data_path <- "./synthetic_ds/SYN_16_1"

exageostat_data <- simulate_data(kernel=kernel, initial_theta=initial_theta, problem_size=problem_size, dts=dts, dimension=dimension, data_path=data_path)

paste("** Locations X - Y - Z - after reading")
locations <- get_locations(data=exageostat_data)
paste(locations)
paste("** after reading")
# Print the data..
paste("Z Values")
paste(exageostat_data$m)
paste("Locations X")
paste(exageostat_data$x)
paste("Locations Y")
paste(exageostat_data$y)
paste("Locations Z")
paste(exageostat_data$z)
Loading