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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

- Reworked templates to include example tests.

- Removed unnecessary full facotorization in the examples and made the input 1 based.

## Changes to Re::Solve in release 0.99.2

### Major Features
Expand Down
6 changes: 3 additions & 3 deletions examples/gluRefactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ int gluRefactor(int argc, char* argv[])
vector_type* vec_x = nullptr;

RESOLVE_RANGE_PUSH(__FUNCTION__);
for (int i = 0; i < num_systems; ++i)
for (int i = 1; i <= num_systems; ++i)
{
std::cout << "System " << i << ":\n";

Expand All @@ -189,7 +189,7 @@ int gluRefactor(int argc, char* argv[])
return -1;
}
bool is_expand_symmetric = true;
if (i == 0)
if (i == 1)
{
A = io::createCsrFromFile(mat_file, is_expand_symmetric);
vec_rhs = io::createVectorFromFile(rhs_file);
Expand All @@ -216,7 +216,7 @@ int gluRefactor(int argc, char* argv[])

int status = 0;

if (i < 1)
if (i < 2)
{
RESOLVE_RANGE_PUSH("KLU");
// Setup factorization solver
Expand Down
40 changes: 16 additions & 24 deletions examples/gpuRefactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ int gpuRefactor(int argc, char* argv[])
vector_type* vec_x = nullptr;

RESOLVE_RANGE_PUSH(__FUNCTION__);
for (int i = 0; i < num_systems; ++i)
for (int i = 1; i <= num_systems; ++i)
{
std::cout << "System " << i << ":\n";

Expand All @@ -211,7 +211,7 @@ int gpuRefactor(int argc, char* argv[])
return -1;
}
bool is_expand_symmetric = true;
if (i == 0)
if (i == 1)
{
A = io::createCsrFromFile(mat_file, is_expand_symmetric);
vec_rhs = io::createVectorFromFile(rhs_file);
Expand All @@ -238,7 +238,7 @@ int gpuRefactor(int argc, char* argv[])

int status = 0;

if (i == 0)
if (i == 1)
{
RESOLVE_RANGE_PUSH("KLU");
// Setup factorization solver
Expand All @@ -248,10 +248,6 @@ int gpuRefactor(int argc, char* argv[])
// Analysis (symbolic factorization)
status = KLU.analyze();
std::cout << "KLU analysis status: " << status << std::endl;
}

if (i < 2)
{
// Numeric factorization
status = KLU.factorize();
std::cout << "KLU factorization status: " << status << std::endl;
Expand All @@ -262,26 +258,22 @@ int gpuRefactor(int argc, char* argv[])

// Print summary of results
helper.printShortSummary(A, vec_rhs, vec_x);

if (i == 1)
// Extract factors and configure refactorization solver
matrix::Csr* L = (matrix::Csr*) KLU.getLFactor();
matrix::Csr* U = (matrix::Csr*) KLU.getUFactor();
if (L == nullptr || U == nullptr)
{
// Extract factors and configure refactorization solver
matrix::Csr* L = (matrix::Csr*) KLU.getLFactor();
matrix::Csr* U = (matrix::Csr*) KLU.getUFactor();
if (L == nullptr || U == nullptr)
{
std::cout << "Factor extraction from KLU failed!\n";
}
index_type* P = KLU.getPOrdering();
index_type* Q = KLU.getQOrdering();
std::cout << "Factor extraction from KLU failed!\n";
}
index_type* P = KLU.getPOrdering();
index_type* Q = KLU.getQOrdering();

Rf.setup(A, L, U, P, Q, vec_rhs);
Rf.setup(A, L, U, P, Q, vec_rhs);

// Setup iterative refinement solver
if (is_iterative_refinement)
{
FGMRES.setup(A);
}
// Setup iterative refinement solver
if (is_iterative_refinement)
{
FGMRES.setup(A);
}
RESOLVE_RANGE_POP("KLU");
}
Expand Down
9 changes: 3 additions & 6 deletions examples/kluRefactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ int main(int argc, char* argv[])
LinSolverDirectKLU* KLU = new LinSolverDirectKLU;
GramSchmidt GS(&vector_handler, GramSchmidt::CGS2);
LinSolverIterativeFGMRES FGMRES(&matrix_handler, &vector_handler, &GS);
for (int i = 0; i < num_systems; ++i)
for (int i = 1; i <= num_systems; ++i)
{
std::cout << "System " << i << ":\n";

Expand All @@ -153,7 +153,7 @@ int main(int argc, char* argv[])
return 1;
}
bool is_expand_symmetric = true;
if (i == 0)
if (i == 1)
{
A = ReSolve::io::createCsrFromFile(mat_file, is_expand_symmetric);

Expand All @@ -172,15 +172,12 @@ int main(int argc, char* argv[])
std::cout << "COO to CSR completed. Expanded NNZ: " << A->getNnz() << std::endl;
// Now call direct solver
int status;
if (i == 0)
if (i == 1)
{
vec_rhs->setDataUpdated(ReSolve::memory::HOST);
KLU->setup(A);
status = KLU->analyze();
std::cout << "KLU analysis status: " << status << std::endl;
}
if (i < 2)
{
status = KLU->factorize();
std::cout << "KLU factorization status: " << status << std::endl;
}
Expand Down
13 changes: 3 additions & 10 deletions examples/sysRefactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ int sysRefactor(int argc, char* argv[])
}

RESOLVE_RANGE_PUSH(__FUNCTION__);
for (int i = 0; i < num_systems; ++i)
for (int i = 1; i <= num_systems; ++i)
{
std::cout << "System " << i << ":\n";
RESOLVE_RANGE_PUSH("File input");
Expand All @@ -250,7 +250,7 @@ int sysRefactor(int argc, char* argv[])

// Refactorization is LU-based, so need to expand symmetric matrices
bool is_expand_symmetric = true;
if (i == 0)
if (i == 1)
{
A = ReSolve::io::createCsrFromFile(mat_file, is_expand_symmetric);
vec_rhs = ReSolve::io::createVectorFromFile(rhs_file);
Expand Down Expand Up @@ -281,7 +281,7 @@ int sysRefactor(int argc, char* argv[])
printSystemInfo(matrix_pathname_full, A);

// Now call direct solver
if (i == 0)
if (i == 1)
{
// Set matrix in solver after the initial matrix is loaded
status = solver.setMatrix(A);
Expand All @@ -298,13 +298,6 @@ int sysRefactor(int argc, char* argv[])
// Numeric factorization on the host
status = solver.factorize();
std::cout << "Numeric factorization on the host status: " << status << std::endl;
}
else if (i == 1)
{
// Numeric factorization on the host
status = solver.factorize();
std::cout << "Numeric factorization on the host status: " << status << std::endl;

// Set up refactorization solver
status = solver.refactorizationSetup();
std::cout << "Refactorization setup status: " << status << std::endl;
Expand Down