From 1b629f479607e03d634a14dddb19f6cab9dfdd24 Mon Sep 17 00:00:00 2001 From: Mahmoud Elkarargy <113839437+mahmoudElkarargyBS@users.noreply.github.com> Date: Tue, 25 Feb 2025 14:49:35 +0200 Subject: [PATCH] V1.1.3 (#25) * add the pow_exp kernel and tested * all fixes * resolve threads plus some modifications * Fix cuda * fix for linking cuda * fix: hicma modifactions * try fixing Jenkines * Adding R structure * fix:add doxygen in Jenkines * add test file for pow-exp kernel * test with -fpic * some modifications for HiCMA * updates * try 2 gpu devices * back to starsh * a potential fix to doxygen * roll back * test Rcpp * Fix Jenkines * fix errors * Updated in design * updates * all release issue without src checks * adding MakeFile * Updated MPI * Documentation * fix examples tests * modeling takes pointers * example for read and write data * fix: typpo in Initialize * fix passing numbers of theta * fix: performance of gsl * fix: GPU support * fix:mspe * updated devel * R branch init * tests:add r tests * fix tests * bug: in tlr * fix:tlr * fix Jenkines * fix: Jenkines in Documentation * minior updates * huge refactoring * full R * potential for tlr issue * updates in heavy tests * a fix for gpu in gaussian kernels * smalling tlr size * update sizes of heavy_tests * smalling size for gpu * minior changes * Huge refactoring in docs * resolve threads * fix MPI * resolve thread * updated R documentation * documentation and hardware changes * finalized documentations * minior change in Hardware * Ft test mpi mk (#6) * solve multi thread issue in MPI * Fix MPI tests with chameleon * Fixed HiCMA with MPI * update license * minior cleanings (#7) * v1.1.0 (#4) (#8) * add the pow_exp kernel and tested * all fixes * resolve threads plus some modifications * Fix cuda * fix for linking cuda * fix: hicma modifactions * try fixing Jenkines * Adding R structure * fix:add doxygen in Jenkines * add test file for pow-exp kernel * test with -fpic * some modifications for HiCMA * updates * try 2 gpu devices * back to starsh * a potential fix to doxygen * roll back * test Rcpp * Fix Jenkines * fix errors * Updated in design * updates * all release issue without src checks * adding MakeFile * Updated MPI * Documentation * fix examples tests * modeling takes pointers * example for read and write data * fix: typpo in Initialize * fix passing numbers of theta * fix: performance of gsl * fix: GPU support * fix:mspe * updated devel * R branch init * tests:add r tests * fix tests * bug: in tlr * fix:tlr * fix Jenkines * fix: Jenkines in Documentation * minior updates * huge refactoring * full R * potential for tlr issue * updates in heavy tests * a fix for gpu in gaussian kernels * smalling tlr size * update sizes of heavy_tests * smalling size for gpu * minior changes * Huge refactoring in docs * resolve threads * fix MPI * resolve thread * updated R documentation * documentation and hardware changes * finalized documentations * minior change in Hardware * Ft test mpi mk (#6) * solve multi thread issue in MPI * Fix MPI tests with chameleon * Fixed HiCMA with MPI * update license * minior cleanings (#7) --------- Co-authored-by: Sameh M. Abdulah Co-authored-by: Mahmoud Karargy * Fix P & Q * updates in R (#9) * Fix error in R * Fix using of openblas (#16) * Update main (#19) * V1.1.1 (#15) * add the pow_exp kernel and tested * all fixes * resolve threads plus some modifications * Fix cuda * fix for linking cuda * fix: hicma modifactions * try fixing Jenkines * Adding R structure * fix:add doxygen in Jenkines * add test file for pow-exp kernel * test with -fpic * some modifications for HiCMA * updates * try 2 gpu devices * back to starsh * a potential fix to doxygen * roll back * test Rcpp * Fix Jenkines * fix errors * Updated in design * updates * all release issue without src checks * adding MakeFile * Updated MPI * Documentation * fix examples tests * modeling takes pointers * example for read and write data * fix: typpo in Initialize * fix passing numbers of theta * fix: performance of gsl * fix: GPU support * fix:mspe * updated devel * R branch init * tests:add r tests * fix tests * bug: in tlr * fix:tlr * fix Jenkines * fix: Jenkines in Documentation * minior updates * huge refactoring * full R * potential for tlr issue * updates in heavy tests * a fix for gpu in gaussian kernels * smalling tlr size * update sizes of heavy_tests * smalling size for gpu * minior changes * Huge refactoring in docs * resolve threads * fix MPI * resolve thread * updated R documentation * documentation and hardware changes * finalized documentations * minior change in Hardware * Ft test mpi mk (#6) * solve multi thread issue in MPI * Fix MPI tests with chameleon * Fixed HiCMA with MPI * update license * minior cleanings (#7) * v1.1.0 (#4) (#8) * add the pow_exp kernel and tested * all fixes * resolve threads plus some modifications * Fix cuda * fix for linking cuda * fix: hicma modifactions * try fixing Jenkines * Adding R structure * fix:add doxygen in Jenkines * add test file for pow-exp kernel * test with -fpic * some modifications for HiCMA * updates * try 2 gpu devices * back to starsh * a potential fix to doxygen * roll back * test Rcpp * Fix Jenkines * fix errors * Updated in design * updates * all release issue without src checks * adding MakeFile * Updated MPI * Documentation * fix examples tests * modeling takes pointers * example for read and write data * fix: typpo in Initialize * fix passing numbers of theta * fix: performance of gsl * fix: GPU support * fix:mspe * updated devel * R branch init * tests:add r tests * fix tests * bug: in tlr * fix:tlr * fix Jenkines * fix: Jenkines in Documentation * minior updates * huge refactoring * full R * potential for tlr issue * updates in heavy tests * a fix for gpu in gaussian kernels * smalling tlr size * update sizes of heavy_tests * smalling size for gpu * minior changes * Huge refactoring in docs * resolve threads * fix MPI * resolve thread * updated R documentation * documentation and hardware changes * finalized documentations * minior change in Hardware * Ft test mpi mk (#6) * solve multi thread issue in MPI * Fix MPI tests with chameleon * Fixed HiCMA with MPI * update license * minior cleanings (#7) --------- Co-authored-by: Sameh M. Abdulah Co-authored-by: Mahmoud Karargy * Fix P & Q * updates in R (#9) * Fix error in R * Fix using of openblas (#16) --------- Co-authored-by: Sameh M. Abdulah Co-authored-by: Mahmoud Karargy * V1.1.2 (#17) * Fixed cmake installation and add requirements in ReadME --------- Co-authored-by: Sameh M. Abdulah Co-authored-by: Mahmoud Karargy * Fix for zero values in locations (#20) * update devel (#21) * Fix tlr in R (#24) * V1.1.1 (#15) * add the pow_exp kernel and tested * all fixes * resolve threads plus some modifications * Fix cuda * fix for linking cuda * fix: hicma modifactions * try fixing Jenkines * Adding R structure * fix:add doxygen in Jenkines * add test file for pow-exp kernel * test with -fpic * some modifications for HiCMA * updates * try 2 gpu devices * back to starsh * a potential fix to doxygen * roll back * test Rcpp * Fix Jenkines * fix errors * Updated in design * updates * all release issue without src checks * adding MakeFile * Updated MPI * Documentation * fix examples tests * modeling takes pointers * example for read and write data * fix: typpo in Initialize * fix passing numbers of theta * fix: performance of gsl * fix: GPU support * fix:mspe * updated devel * R branch init * tests:add r tests * fix tests * bug: in tlr * fix:tlr * fix Jenkines * fix: Jenkines in Documentation * minior updates * huge refactoring * full R * potential for tlr issue * updates in heavy tests * a fix for gpu in gaussian kernels * smalling tlr size * update sizes of heavy_tests * smalling size for gpu * minior changes * Huge refactoring in docs * resolve threads * fix MPI * resolve thread * updated R documentation * documentation and hardware changes * finalized documentations * minior change in Hardware * Ft test mpi mk (#6) * solve multi thread issue in MPI * Fix MPI tests with chameleon * Fixed HiCMA with MPI * update license * minior cleanings (#7) * v1.1.0 (#4) (#8) * add the pow_exp kernel and tested * all fixes * resolve threads plus some modifications * Fix cuda * fix for linking cuda * fix: hicma modifactions * try fixing Jenkines * Adding R structure * fix:add doxygen in Jenkines * add test file for pow-exp kernel * test with -fpic * some modifications for HiCMA * updates * try 2 gpu devices * back to starsh * a potential fix to doxygen * roll back * test Rcpp * Fix Jenkines * fix errors * Updated in design * updates * all release issue without src checks * adding MakeFile * Updated MPI * Documentation * fix examples tests * modeling takes pointers * example for read and write data * fix: typpo in Initialize * fix passing numbers of theta * fix: performance of gsl * fix: GPU support * fix:mspe * updated devel * R branch init * tests:add r tests * fix tests * bug: in tlr * fix:tlr * fix Jenkines * fix: Jenkines in Documentation * minior updates * huge refactoring * full R * potential for tlr issue * updates in heavy tests * a fix for gpu in gaussian kernels * smalling tlr size * update sizes of heavy_tests * smalling size for gpu * minior changes * Huge refactoring in docs * resolve threads * fix MPI * resolve thread * updated R documentation * documentation and hardware changes * finalized documentations * minior change in Hardware * Ft test mpi mk (#6) * solve multi thread issue in MPI * Fix MPI tests with chameleon * Fixed HiCMA with MPI * update license * minior cleanings (#7) --------- Co-authored-by: Sameh M. Abdulah Co-authored-by: Mahmoud Karargy * Fix P & Q * updates in R (#9) * Fix error in R * Fix using of openblas (#16) --------- Co-authored-by: Sameh M. Abdulah Co-authored-by: Mahmoud Karargy * V1.1.2 (#17) * Fixed cmake installation and add requirements in ReadME * All fixes for hicma * Modify README.md (#22) * modify README.md * more edits to README.md * more minor edits * more minor edits to the R example * fix the R code * remove empty line --------- Co-authored-by: Sameh M. Abdulah Co-authored-by: Mahmoud Karargy Co-authored-by: Sameh Abdulah <23186151+SAbdulah@users.noreply.github.com> * Ft add accuracy tlr (#26) * V1.1.1 (#15) * add the pow_exp kernel and tested * all fixes * resolve threads plus some modifications * Fix cuda * fix for linking cuda * fix: hicma modifactions * try fixing Jenkines * Adding R structure * fix:add doxygen in Jenkines * add test file for pow-exp kernel * test with -fpic * some modifications for HiCMA * updates * try 2 gpu devices * back to starsh * a potential fix to doxygen * roll back * test Rcpp * Fix Jenkines * fix errors * Updated in design * updates * all release issue without src checks * adding MakeFile * Updated MPI * Documentation * fix examples tests * modeling takes pointers * example for read and write data * fix: typpo in Initialize * fix passing numbers of theta * fix: performance of gsl * fix: GPU support * fix:mspe * updated devel * R branch init * tests:add r tests * fix tests * bug: in tlr * fix:tlr * fix Jenkines * fix: Jenkines in Documentation * minior updates * huge refactoring * full R * potential for tlr issue * updates in heavy tests * a fix for gpu in gaussian kernels * smalling tlr size * update sizes of heavy_tests * smalling size for gpu * minior changes * Huge refactoring in docs * resolve threads * fix MPI * resolve thread * updated R documentation * documentation and hardware changes * finalized documentations * minior change in Hardware * Ft test mpi mk (#6) * solve multi thread issue in MPI * Fix MPI tests with chameleon * Fixed HiCMA with MPI * update license * minior cleanings (#7) * v1.1.0 (#4) (#8) * add the pow_exp kernel and tested * all fixes * resolve threads plus some modifications * Fix cuda * fix for linking cuda * fix: hicma modifactions * try fixing Jenkines * Adding R structure * fix:add doxygen in Jenkines * add test file for pow-exp kernel * test with -fpic * some modifications for HiCMA * updates * try 2 gpu devices * back to starsh * a potential fix to doxygen * roll back * test Rcpp * Fix Jenkines * fix errors * Updated in design * updates * all release issue without src checks * adding MakeFile * Updated MPI * Documentation * fix examples tests * modeling takes pointers * example for read and write data * fix: typpo in Initialize * fix passing numbers of theta * fix: performance of gsl * fix: GPU support * fix:mspe * updated devel * R branch init * tests:add r tests * fix tests * bug: in tlr * fix:tlr * fix Jenkines * fix: Jenkines in Documentation * minior updates * huge refactoring * full R * potential for tlr issue * updates in heavy tests * a fix for gpu in gaussian kernels * smalling tlr size * update sizes of heavy_tests * smalling size for gpu * minior changes * Huge refactoring in docs * resolve threads * fix MPI * resolve thread * updated R documentation * documentation and hardware changes * finalized documentations * minior change in Hardware * Ft test mpi mk (#6) * solve multi thread issue in MPI * Fix MPI tests with chameleon * Fixed HiCMA with MPI * update license * minior cleanings (#7) --------- Co-authored-by: Sameh M. Abdulah Co-authored-by: Mahmoud Karargy * Fix P & Q * updates in R (#9) * Fix error in R * Fix using of openblas (#16) --------- Co-authored-by: Sameh M. Abdulah Co-authored-by: Mahmoud Karargy * V1.1.2 (#17) * Fixed cmake installation and add requirements in ReadME * All fixes for hicma * Modify README.md (#22) * modify README.md * more edits to README.md * more minor edits * more minor edits to the R example * fix the R code * remove empty line * debuging prints * cleaner version --------- Co-authored-by: Sameh M. Abdulah Co-authored-by: Mahmoud Karargy Co-authored-by: Sameh Abdulah <23186151+SAbdulah@users.noreply.github.com> * change value of acc * update params values --------- Co-authored-by: Sameh M. Abdulah Co-authored-by: Mahmoud Karargy Co-authored-by: Sameh Abdulah <23186151+SAbdulah@users.noreply.github.com> --- README.md | 118 +++++++++++++++--- .../Rcpp-adapters/FunctionsAdapter.hpp | 3 +- man/model_data.Rd | 3 +- src/Rcpp-adapters/FunctionsAdapter.cpp | 8 +- src/Rcpp-adapters/RcppModules.cpp | 2 +- src/api/ExaGeoStat.cpp | 11 ++ src/configurations/Configurations.cpp | 4 +- src/data-units/Locations.cpp | 6 +- .../concrete/tlr/HicmaImplementation.cpp | 1 + tests/R-tests/TestExaGeoStatAPI.R | 17 ++- 10 files changed, 147 insertions(+), 26 deletions(-) diff --git a/README.md b/README.md index 9dc8f43f..a7a7d6d7 100644 --- a/README.md +++ b/README.md @@ -66,7 +66,7 @@ To build and run this software, you will need: 6. [R](https://cran.r-project.org/bin/windows/base/) (only if you plan on using the R functionality) ### C++ source code installation -To install the `ExaGeoStat` project locally, run the following commands in your terminal: +To install the `ExaGeoStatCPP` project locally (C++ version), run the following commands in your terminal: 1. Clone the project from the remote gitHub repository into your local machine using the following command ```bash @@ -78,14 +78,14 @@ To install the `ExaGeoStat` project locally, run the following commands in your cd ExaGeoStatCPP ``` -3. Run `configure` script with the flag `-h` for help, to know the supported options and their corresponding flags. +3. Run `configure` script (use the `-h` flag for help, to know the supported options and their corresponding flags). This step is **not required** when using R. ```bash - ./configure -h + ./configure -e ``` -4. Run `clean_build.sh` script with the flag `-h` for help, to know the needed arguments to run with your specific options. +4. Run `clean_build.sh` (use the `-h` flag for help, to know the needed arguments to run with your specific options). This step is **not required** when using R. ```bash - ./clean_build.sh -h + ./clean_build.sh ``` 5. Export the installation paths of the dependencies to your `.bashrc` file, e.g. @@ -99,11 +99,11 @@ ExaGeoStatCPP. ### R package installation 1. Open the R prompt window by simply running `R` command in the terminal, inside the prompt, we will install needed packages by running the following commands: ```R - install.packages(Rcpp) - install.packages("assert") + install.packages("Rcpp") + install.packages("assertthat") ``` -2. close the R prompt and return to the terminal. Run the following command, make sure your current path is the ExaGeoStat project directory +2. close the R prompt and return to the terminal. Run the following command, make sure your current path is the ExaGeoStatCPP project directory ```commandline R CMD INSTALL . --configure-args="-r" @@ -111,6 +111,44 @@ ExaGeoStatCPP. > For more detailed information on installing ExaGeoStat with different configurations and enabling technologies such as CUDA, MPI, R, etc., please refer to the [User Manual](USER_MANUAL.md) +## Common Installation Errors and Solutions + +### 1. Missing CMake +The installation requires **CMake** version 3.2 or higher. Ensure it is installed on your system before proceeding with the installation of **ExaGeoStatCPP**. + +To install CMake, use: +```sh +sudo apt install cmake +``` + +### 2. Missing Libtool +If you encounter the following error during installation: +``` +./autogen.sh: line 17: libtool: command not found +./autogen.sh: line 20: glibtool: command not found +``` +This indicates that **Libtool** is missing. You can install it using: +```sh +sudo apt install libtool libtool-bin +``` + +Alternatively, you can install **Libtool** locally: +```sh +wget http://ftpmirror.gnu.org/libtool/libtool-2.4.7.tar.gz +tar -xvzf libtool-2.4.7.tar.gz +cd libtool-2.4.7 +./configure --prefix=$HOME/local +make +make install +``` +Then, update your environment variables: +```sh +export PATH=$HOME/local/bin:$PATH +export LD_LIBRARY_PATH=$HOME/local/lib:$LD_LIBRARY_PATH +export PKG_CONFIG_PATH=$HOME/local/lib/pkgconfig:$PKG_CONFIG_PATH +``` +After this, restart your terminal or run `source ~/.bashrc` to apply the changes. + ## Usage #### C++ Example @@ -135,14 +173,66 @@ int main(int argc, char **argv) { return 0; } ``` -### R Example: -```R +## R Example +Here is an example demonstrating how to use **ExaGeoStatCPP** in R: + +```r +# Load the ExaGeoStatCPP library +library(ExaGeoStatCPP) + +# Set parameters for the simulation +ncores <- 30 +ngpus <- 0 +problem_size <- 1600 +dts <- 320 +lts <- 0 +computation <- "exact" +dimension <- "2D" +kernel <- "univariate_matern_stationary" +initial_theta <- c(1,0.1,0.5) +lower_bound <- c(0.1,0.1,0.1) +upper_bound <- c(5,5,5) +p <- 1 +q <- 1 +opt_itrs <- 100 + +# Initialize hardware configuration 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) -estimated_theta <- model_data(data=exageostat_data, kernel=kernel, dts=dts, dimension=dimension,lb=lower_bound, ub=upper_bound, mle_itr=10) -predict_data(train_data=list(x, y, z_measurement), test_data=list(test_x, test_y), kernel=kernel, dts=dts, estimated_theta=estimated_theta) + +# Simulate spatial data based on the specified kernel and parameters +exageostat_data <- simulate_data( + kernel = kernel, + initial_theta = initial_theta, + problem_size = problem_size, + dts = dts, + dimension = dimension +) + +# Estimate model parameters using MLE +estimated_theta <- model_data( + matrix=exageostat_data$m, + x=exageostat_data$x, + y=exageostat_data$y, + kernel=kernel, dts=dts, + dimension=dimension, + lb=lower_bound, + ub=upper_bound, + mle_itr=opt_itrs) + +# Perform spatial prediction using the estimated parameters +test_x <- c(0.2, 0.330) +test_y <- c(0.104, 0.14) +predict_data( + train_data=list(x=exageostat_data$x, y=exageostat_data$y, exageostat_data$m), + test_data=list(test_x, test_y), + kernel=kernel, + dts=dts, + estimated_theta=estimated_theta) + ``` +This example walks through initializing hardware, simulating spatial data, estimating model parameters, and making predictions using **ExaGeoStatCPP** in R. + > Please take a look at the end-to-end examples as a reference for using all the operations. ## Contributing @@ -196,4 +286,4 @@ Find detailed information on how to contribute to ExaGeoStatCPP [here](CONTRIBUT [BSD 3-Clause](LICENSE) ## Handout -![ExaGeoStatCPP-handout.png](docs/ExaGeoStatCPP-handout.png) \ No newline at end of file +![ExaGeoStatCPP-handout.png](docs/ExaGeoStatCPP-handout.png) diff --git a/inst/include/Rcpp-adapters/FunctionsAdapter.hpp b/inst/include/Rcpp-adapters/FunctionsAdapter.hpp index 336b037f..7d65974f 100644 --- a/inst/include/Rcpp-adapters/FunctionsAdapter.hpp +++ b/inst/include/Rcpp-adapters/FunctionsAdapter.hpp @@ -65,6 +65,7 @@ namespace exageostat::adapters { * @param[in] aDimension Dimensionality of the problem ("2D" or "3D"). * @param[in] aBand Bandwidth for band matrices, applicable in certain computational kernels. * @param[in] aMaxRank Maximum rank for low-rank approximations. + * @param[in] aAccuracy Accuracy value for low-rank approximations, The final value is computed as 10^(-1.0 * aAccuracy) * @param[in] apData Pointer to ExaGeoStatData object to be modeled. * @param[in] aMeasurementsVector Optional vector of measurements to enhance modeling, can be nullable. * @param[in] aLocationsX Optional vector of X coordinates for locations, can be nullable. @@ -79,7 +80,7 @@ namespace exageostat::adapters { const std::vector &aUpperBound, const int &aTolerance, const int &aMleIterations, const int &aDenseTileSize, const int &aLowTileSize, const std::string &aDimension, const int &aBand, - const int &aMaxRank, SEXP apData, + const int &aMaxRank, const int &aAccuracy, SEXP apData, Rcpp::Nullable aMeasurementsVector = R_NilValue, Rcpp::Nullable aLocationsX = R_NilValue, Rcpp::Nullable aLocationsY = R_NilValue, diff --git a/man/model_data.Rd b/man/model_data.Rd index b49a3665..32e63a49 100644 --- a/man/model_data.Rd +++ b/man/model_data.Rd @@ -15,7 +15,7 @@ \usage{ model_data(computation = "exact", kernel, distance_matrix = "euclidean", lb, -ub, tol = 4, mle_itr, dts, lts = 0, dimension = "2D", band = 0, max_rank = 500, +ub, tol = 4, mle_itr, dts, lts = 0, dimension = "2D", band = 0, max_rank = 500, acc = 0, data = NULL, matrix = NULL, x = NULL, y = NULL, z = NULL) } @@ -54,6 +54,7 @@ data = NULL, matrix = NULL, x = NULL, y = NULL, z = NULL) \item{dimension}{A string specifies the data dimension, either "2D" or "3D". Default is "2D".} \item{band}{A numeric value Bandwidth for band matrices, applicable in certain computational kernels, Default is 0.} \item{max_rank}{A numeric value specifies the Maximum rank for low-rank approximations, Default is 500.} +\item{acc}{A numeric value specifies the accuracy for low-rank approximations, The final value is computed as 10^(-1.0 * acc). Default is 0.} \item{data}{A list of data vectors. Default is `R_NilValue`.} \item{matrix}{A matrix object. Default is `R_NilValue`.} \item{x}{A numeric vector. Default is `R_NilValue`.} diff --git a/src/Rcpp-adapters/FunctionsAdapter.cpp b/src/Rcpp-adapters/FunctionsAdapter.cpp index 99560eca..7e54aee8 100644 --- a/src/Rcpp-adapters/FunctionsAdapter.cpp +++ b/src/Rcpp-adapters/FunctionsAdapter.cpp @@ -116,9 +116,10 @@ namespace exageostat::adapters { R_ExaGeoStatModelData(const string &aComputation, const string &aKernelName, const string &aDistanceMatrix, const vector &aLowerBound, const vector &aUpperBound, const int &aTolerance, const int &aMleIterations, const int &aDenseTileSize, const int &aLowTileSize, - const string &aDimension, const int &aBand, const int &aMaxRank, SEXP apData, - Nullable aMeasurementsVector, Nullable aLocationsX, - Nullable aLocationsY, Nullable aLocationsZ) { + const string &aDimension, const int &aBand, const int &aMaxRank, const int &aAccuracy, + SEXP apData, Nullable aMeasurementsVector, + Nullable aLocationsX, Nullable aLocationsY, + Nullable aLocationsZ) { Configurations configurations; bool is_initialized = ((SEXP) apData == R_NilValue); @@ -144,6 +145,7 @@ namespace exageostat::adapters { configurations.SetTolerance(aTolerance); configurations.SetBand(aBand); configurations.SetMaxRank(aMaxRank); + configurations.SetAccuracy(aAccuracy); ExaGeoStat::ExaGeoStatDataModeling(configurations, data, pMeasurementsVectorPtr); // Take back ownership, to avoid deleting apData when the unique_ptr goes out of scope. diff --git a/src/Rcpp-adapters/RcppModules.cpp b/src/Rcpp-adapters/RcppModules.cpp index 17c9036d..55eb19ff 100644 --- a/src/Rcpp-adapters/RcppModules.cpp +++ b/src/Rcpp-adapters/RcppModules.cpp @@ -47,7 +47,7 @@ RCPP_MODULE(ExaGeoStatCPP) { function("model_data", &exageostat::adapters::R_ExaGeoStatModelData, List::create(_["computation"] = "exact", _["kernel"], _["distance_matrix"] = "euclidean", _["lb"], _["ub"], _["tol"] = 4, _["mle_itr"], _["dts"], _["lts"] = 0, _["dimension"] = "2D", _["band"] = 0, - _["max_rank"] = 500, _["data"] = R_NilValue, _["matrix"] = R_NilValue, _["x"] = R_NilValue, + _["max_rank"] = 500, _["acc"] = 0, _["data"] = R_NilValue, _["matrix"] = R_NilValue, _["x"] = R_NilValue, _["y"] = R_NilValue, _["z"] = R_NilValue)); function("predict_data", &exageostat::adapters::R_ExaGeoStatPredictData, diff --git a/src/api/ExaGeoStat.cpp b/src/api/ExaGeoStat.cpp index e1f1b1d1..7abc2b46 100644 --- a/src/api/ExaGeoStat.cpp +++ b/src/api/ExaGeoStat.cpp @@ -27,6 +27,8 @@ using namespace exageostat::configurations; template void ExaGeoStat::ExaGeoStatLoadData(Configurations &aConfigurations, std::unique_ptr> &aData) { + int seed = 0; + std::srand(seed); aConfigurations.PrintSummary(); LOGGER("** ExaGeoStat data generation/loading **") // Register and create a kernel object @@ -67,6 +69,15 @@ T ExaGeoStat::ExaGeoStatDataModeling(Configurations &aConfigurations, std::un // Set max iterations value. optimizing_function.set_maxeval(max_number_of_iterations); optimizing_function.set_max_objective(ExaGeoStatMLETileAPI, (void *) modeling_data); + + if (aConfigurations.GetComputation() == common::EXACT_DENSE) { + LOGGER("\t--> Modeling Using Dense Tile - Chameleon") + } else if (aConfigurations.GetComputation() == common::DIAGONAL_APPROX){ + LOGGER("\t--> Modeling Using Diagonal Super Tile - Chameleon") + } + else { + LOGGER("\t--> Modeling Using Tile Low Rank - HiCMA") + } // Optimize mle using nlopt. optimizing_function.optimize(aConfigurations.GetStartingTheta(), opt_f); aConfigurations.SetEstimatedTheta(aConfigurations.GetStartingTheta()); diff --git a/src/configurations/Configurations.cpp b/src/configurations/Configurations.cpp index be6d63ca..48493e13 100644 --- a/src/configurations/Configurations.cpp +++ b/src/configurations/Configurations.cpp @@ -454,12 +454,12 @@ Computation Configurations::CheckComputationValue(const std::string &aValue) { if (aValue != "exact" and aValue != "Exact" and aValue != "Dense" and aValue != "dense" and aValue != "diag_approx" and aValue != "diagonal_approx" and aValue != "lr_approx" and aValue != "tlr" and - aValue != "TLR") { + aValue != "TLR" and aValue != "dst") { throw range_error("Invalid value for Computation. Please use Exact, diagonal_approx or TLR."); } if (aValue == "exact" or aValue == "Exact" or aValue == "Dense" or aValue == "dense") { return EXACT_DENSE; - } else if (aValue == "diag_approx" or aValue == "diagonal_approx") { + } else if (aValue == "diag_approx" or aValue == "diagonal_approx" or aValue == "dst") { return DIAGONAL_APPROX; } return TILE_LOW_RANK; diff --git a/src/data-units/Locations.cpp b/src/data-units/Locations.cpp index abe0572c..701730e9 100644 --- a/src/data-units/Locations.cpp +++ b/src/data-units/Locations.cpp @@ -22,7 +22,7 @@ using namespace exageostat::common; template void Locations::SetLocationX(T &aLocationX, const int &aSize) { - if (aLocationX && aSize == this->mSize) { + if (&aLocationX != nullptr && aSize == this->mSize) { memcpy(this->mpLocationX, &aLocationX, this->mSize * sizeof(T)); } else { throw std::runtime_error("Invalid value for setting Locations X"); @@ -41,7 +41,7 @@ T *Locations::GetLocationX() { template void Locations::SetLocationY(T &aLocationY, const int &aSize) { - if (aLocationY && aSize == this->mSize) { + if (&aLocationY != nullptr && aSize == this->mSize) { memcpy(this->mpLocationY, &aLocationY, this->mSize * sizeof(T)); } else { throw std::runtime_error("Invalid value for setting Locations Y"); @@ -59,7 +59,7 @@ T *Locations::GetLocationY() { template void Locations::SetLocationZ(T &aLocationZ, const int &aSize) { - if (aLocationZ && aSize == this->mSize) { + if (&aLocationZ != nullptr && aSize == this->mSize) { memcpy(this->mpLocationZ, &aLocationZ, this->mSize * sizeof(T)); } else { throw std::runtime_error("Invalid value for setting Locations Z"); diff --git a/src/linear-algebra-solvers/concrete/tlr/HicmaImplementation.cpp b/src/linear-algebra-solvers/concrete/tlr/HicmaImplementation.cpp index c297bb01..da7e378e 100644 --- a/src/linear-algebra-solvers/concrete/tlr/HicmaImplementation.cpp +++ b/src/linear-algebra-solvers/concrete/tlr/HicmaImplementation.cpp @@ -232,6 +232,7 @@ T HicmaImplementation::ExaGeoStatMLETile(std::unique_ptr> & //Calculate Cholesky Factorization (C=LL-1) VERBOSE("LR: Cholesky factorization of Sigma...") START_TIMING(time_facto); + this->ExaGeoStatPotrfTile(EXAGEOSTAT_LOWER, HICMA_descCUV, 0, HICMA_descCD, HICMA_descCrk, max_rank, pow(10, -1.0 * acc)); diff --git a/tests/R-tests/TestExaGeoStatAPI.R b/tests/R-tests/TestExaGeoStatAPI.R index 9d1328fe..fdb5c7be 100644 --- a/tests/R-tests/TestExaGeoStatAPI.R +++ b/tests/R-tests/TestExaGeoStatAPI.R @@ -18,7 +18,6 @@ ncores <- 1 ngpus <- 0 problem_size <- 16 dts <- 8 -lts <- 0 computation <- "exact" dimension = "2D" kernel <- "univariate_matern_stationary" @@ -75,3 +74,19 @@ test_x <- c(0.2, 0.330) test_y <- c(0.104, 0.14) predict_data(train_data=list(locations_x, locations_y, z_value), test_data=list(test_x, test_y), kernel=kernel, dts=dts, estimated_theta=estimated_theta) + +paste("---------------------------------------------------------------") +paste("ExaGeoStat with all Modules - tile low rank") + +problem_size <- 1600 +computation <- "tlr" +lts <- 400 +dts <- 400 +max_rank <- 200 +# The final value is computed as 10^(-1.0 * aAccuracy) +acc <- 5 + +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) +estimated_theta <- model_data(matrix=exageostat_data$m, x=exageostat_data$x, y=exageostat_data$y, kernel=kernel, dts=dts, lts = lts, dimension=dimension,lb=lower_bound, ub=upper_bound, mle_itr=10, computation=computation, max_rank=max_rank, acc=acc) +