Skip to content

Commit

Permalink
SystemSolver Interface updates (#120)
Browse files Browse the repository at this point in the history
* Refactor residual norm getter in SystemSolver.

* Implement and test NSR computation in SystemSolver.

* Have iterative refinement inside the solve call.

* System solver example that works with CUDA and HIP.

* Fix cmake presets for Deception.

* Fix SystemSolver running GLU test.

* Use memspace as parameter consistently in FGMRES classes. (#125)

* Fix bug when data/values ownership is incorrectly assigned. (#124)

* Fix broken CPU build, add logger to Csc and Coo classes.

* Have fgmres and gs set memory space at runtime based on vector handler.

* Randomized solver called through SystemSolver class (#128)

* Support for iterative methods in SystemSolver.

* Working example of a randomized solver.

* Use more consistent naming scheme for functionality tests.

* Fix issue with building SystemSolver on CPU.
  • Loading branch information
pelesh authored Dec 20, 2023
1 parent f34b05a commit 3c3deb0
Show file tree
Hide file tree
Showing 43 changed files with 2,006 additions and 1,287 deletions.
27 changes: 15 additions & 12 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"generator": "Unix Makefiles",
"cacheVariables": {
"RESOLVE_USE_CUDA": "ON",
"CMAKE_CUDA_ARCHITECTURES": "60"
"CMAKE_CUDA_ARCHITECTURES": "60"
}
},
{
Expand All @@ -37,18 +37,18 @@
"installDir": "${sourceDir}/install",
"generator": "Unix Makefiles"
},
{
{
"name": "ascent",
"inherits": "cuda",
"displayName": "Ascent Build",
"description": "Custom changes specific for Ascent",
"cacheVariables": {
"CMAKE_C_COMPILER": "$env{OLCF_GCC_ROOT}/bin/gcc",
"CMAKE_CXX_COMPILER": "$env{OLCF_GCC_ROOT}/bin/g++",
"CMAKE_CUDA_ARCHITECTURES": "70"
}
"CMAKE_CUDA_ARCHITECTURES": "70"
}
},
{
{
"name": "ascent-clang",
"inherits": "cuda",
"displayName": "Ascent Build with Clang",
Expand All @@ -60,14 +60,17 @@
"CMAKE_CUDA_HOST_COMPILER": "$env{OLCF_LLVM_ROOT}/bin/clang++",
"CMAKE_CUDA_FLAGS": "-allow-unsupported-compiler",
"RESOLVE_USE_ASAN": "OFF",
"CMAKE_CUDA_ARCHITECTURES": "70"
"CMAKE_CUDA_ARCHITECTURES": "70"
}
},
{
"name": "deception",
"inherits": "cuda",
"displayName": "Deception Build",
"description": "Custom changes specific for Deception"
"description": "Custom changes specific for Deception",
"cacheVariables": {
"CMAKE_CUDA_ARCHITECTURES": "60;70;75;80"
}
},
{
"name": "incline",
Expand All @@ -86,15 +89,15 @@
},
{
"name": "crusher",
"inherits": "rocm",
"inherits": "rocm",
"displayName": "Crusher Build",
"description": "Custom changes specific for Crusher",
"cacheVariables": {
"cacheVariables": {
"CMAKE_HIP_ARCHITECTURES": "gfx90a",
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_C_COMPILER": "/opt/rocm-5.6.0/llvm/bin/clang",
"CMAKE_C_COMPILER": "/opt/rocm-5.6.0/llvm/bin/clang",
"CMAKE_CXX_COMPILER": "/opt/rocm-5.6.0/llvm/bin/clang++"
}
}
}
}
]
}
2 changes: 1 addition & 1 deletion examples/r_KLU_rocSolverRf_FGMRES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int main(int argc, char *argv[])
ReSolve::GramSchmidt* GS = new ReSolve::GramSchmidt(vector_handler, ReSolve::GramSchmidt::cgs2);
ReSolve::LinSolverDirectKLU* KLU = new ReSolve::LinSolverDirectKLU;
ReSolve::LinSolverDirectRocSolverRf* Rf = new ReSolve::LinSolverDirectRocSolverRf(workspace_HIP);
ReSolve::LinSolverIterativeFGMRES* FGMRES = new ReSolve::LinSolverIterativeFGMRES(matrix_handler, vector_handler, GS, "hip");
ReSolve::LinSolverIterativeFGMRES* FGMRES = new ReSolve::LinSolverIterativeFGMRES(matrix_handler, vector_handler, GS);

for (int i = 0; i < numSystems; ++i)
{
Expand Down
25 changes: 16 additions & 9 deletions examples/r_SysSolverHipRefine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,15 @@ int main(int argc, char *argv[])
ReSolve::LinAlgWorkspaceHIP* workspace_HIP = new ReSolve::LinAlgWorkspaceHIP();
workspace_HIP->initializeHandles();
ReSolve::MatrixHandler* matrix_handler = new ReSolve::MatrixHandler(workspace_HIP);

real_type* rhs = nullptr;
real_type* x = nullptr;

vector_type* vec_rhs = nullptr;
vector_type* vec_x = nullptr;

ReSolve::SystemSolver* solver = new ReSolve::SystemSolver(workspace_HIP, "fgmres");
ReSolve::SystemSolver* solver = new ReSolve::SystemSolver(workspace_HIP);
solver->setRefinementMethod("fgmres", "cgs2");

for (int i = 0; i < numSystems; ++i)
{
Expand Down Expand Up @@ -126,8 +128,9 @@ int main(int argc, char *argv[])

status = solver->solve(vec_rhs, vec_x);
std::cout << "KLU solve status: " << status << std::endl;
std::cout << "\t 2-Norm of the residual: "
<< std::scientific << std::setprecision(16)

std::cout << "\t 2-Norm of the residual : "
<< std::scientific << std::setprecision(16)
<< solver->getResidualNorm(vec_rhs, vec_x) << "\n";
if (i == 1) {
solver->refactorizationSetup();
Expand All @@ -139,21 +142,25 @@ int main(int argc, char *argv[])
std::cout << "ROCSOLVER RF refactorization status: " << status << std::endl;
status = solver->solve(vec_rhs, vec_x);
std::cout << "ROCSOLVER RF solve status: " << status << std::endl;

real_type rnrm = solver->getResidualNorm(vec_rhs, vec_x);
std::cout << "\t 2-Norm of the residual (before IR): "
<< std::scientific << std::setprecision(16)
<< rnrm << "\n";
std::cout << std::scientific << std::setprecision(16)
<< "\t 2-Norm of the residual (after IR): "
<< rnrm
<< "\t 2-Norm of scaled residuals (after IR): "
<< solver->getNormOfScaledResiduals(vec_rhs, vec_x)
<< "\n";

vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::DEVICE);
real_type norm_b = solver->getVectorNorm(vec_rhs);
if (!std::isnan(rnrm) && !std::isinf(rnrm)) {
status = solver->refine(vec_rhs, vec_x);
std::cout << "FGMRES solve status: " << status << std::endl;

std::cout << "FGMRES: init nrm: "
<< std::scientific << std::setprecision(16)
<< rnrm
<< solver->getIterativeSolver().getInitResidualNorm()/norm_b
<< " final nrm: "
<< solver->getResidualNorm(vec_rhs, vec_x)
<< solver->getIterativeSolver().getFinalResidualNorm()/norm_b
<< " iter: " << solver->getIterativeSolver().getNumIter()
<< "\n";
}
Expand Down
2 changes: 1 addition & 1 deletion examples/r_randGMRES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int main(int argc, char *argv[])
ReSolve::GramSchmidt* GS = new ReSolve::GramSchmidt(vector_handler, ReSolve::GramSchmidt::cgs2);

ReSolve::LinSolverDirectRocSparseILU0* Rf = new ReSolve::LinSolverDirectRocSparseILU0(workspace_HIP);
ReSolve::LinSolverIterativeRandFGMRES* FGMRES = new ReSolve::LinSolverIterativeRandFGMRES(matrix_handler, vector_handler,ReSolve::LinSolverIterativeRandFGMRES::cs, GS, "hip");
ReSolve::LinSolverIterativeRandFGMRES* FGMRES = new ReSolve::LinSolverIterativeRandFGMRES(matrix_handler, vector_handler,ReSolve::LinSolverIterativeRandFGMRES::cs, GS);

std::cout << std::endl << std::endl << std::endl;
std::cout << "========================================================================================================================"<<std::endl;
Expand Down
2 changes: 1 addition & 1 deletion examples/r_randGMRES_CUDA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int main(int argc, char *argv[])
ReSolve::GramSchmidt* GS = new ReSolve::GramSchmidt(vector_handler, ReSolve::GramSchmidt::cgs2);

ReSolve::LinSolverDirectCuSparseILU0* Rf = new ReSolve::LinSolverDirectCuSparseILU0(workspace_CUDA);
ReSolve::LinSolverIterativeRandFGMRES* FGMRES = new ReSolve::LinSolverIterativeRandFGMRES(matrix_handler, vector_handler, ReSolve::LinSolverIterativeRandFGMRES::fwht, GS, "cuda");
ReSolve::LinSolverIterativeRandFGMRES* FGMRES = new ReSolve::LinSolverIterativeRandFGMRES(matrix_handler, vector_handler, ReSolve::LinSolverIterativeRandFGMRES::fwht, GS);

std::cout << std::endl << std::endl << std::endl;
std::cout << "========================================================================================================================"<<std::endl;
Expand Down
Loading

0 comments on commit 3c3deb0

Please sign in to comment.