Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create Csr constructor that takes Coo as the argument #100

Merged
merged 4 commits into from
Dec 6, 2023
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
6 changes: 3 additions & 3 deletions examples/r_KLU_GLU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ int main(int argc, char *argv[])
rhs_file.close();

//Now convert to CSR.
if (i < 1) {
matrix_handler->coo2csr(A_coo, A, "cpu");
if (i < 1) {
A->updateFromCoo(A_coo, ReSolve::memory::HOST);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::HOST);
vec_rhs->setDataUpdated(ReSolve::memory::HOST);
} else {
matrix_handler->coo2csr(A_coo, A, "cuda");
A->updateFromCoo(A_coo, ReSolve::memory::DEVICE);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::DEVICE);
}
std::cout<<"COO to CSR completed. Expanded NNZ: "<< A->getNnzExpanded()<<std::endl;
Expand Down
4 changes: 2 additions & 2 deletions examples/r_KLU_GLU_matrix_values_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ int main(int argc, char *argv[])

//Now convert to CSR.
if (i < 1) {
matrix_handler->coo2csr(A_coo, A, "cpu");
A->updateFromCoo(A_coo, ReSolve::memory::HOST);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::HOST);
vec_rhs->setDataUpdated(ReSolve::memory::HOST);
} else {
matrix_handler->coo2csr(A_coo, A, "cuda");
A->updateFromCoo(A_coo, ReSolve::memory::DEVICE);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::DEVICE);
}
std::cout<<"COO to CSR completed. Expanded NNZ: "<< A->getNnzExpanded()<<std::endl;
Expand Down
7 changes: 3 additions & 4 deletions examples/r_KLU_KLU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ int main(int argc, char *argv[])
vec_rhs = new vector_type(A->getNumRows());
vec_x = new vector_type(A->getNumRows());
vec_r = new vector_type(A->getNumRows());
}
else {
} else {
ReSolve::io::readAndUpdateMatrix(mat_file, A_coo);
ReSolve::io::readAndUpdateRhs(rhs_file, &rhs);
}
Expand All @@ -107,11 +106,11 @@ int main(int argc, char *argv[])

//Now convert to CSR.
if (i < 2) {
matrix_handler->coo2csr(A_coo, A, "cpu");
A->updateFromCoo(A_coo, ReSolve::memory::HOST);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::HOST);
vec_rhs->setDataUpdated(ReSolve::memory::HOST);
} else {
matrix_handler->coo2csr(A_coo, A, "cpu");
A->updateFromCoo(A_coo, ReSolve::memory::HOST);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::HOST);
}
std::cout<<"COO to CSR completed. Expanded NNZ: "<< A->getNnzExpanded()<<std::endl;
Expand Down
2 changes: 1 addition & 1 deletion examples/r_KLU_KLU_standalone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ int main(int argc, char *argv[])
rhs_file.close();

//Now convert to CSR.
matrix_handler->coo2csr(A_coo, A, "cpu");
A->updateFromCoo(A_coo, ReSolve::memory::HOST);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::HOST);
vec_rhs->setDataUpdated(ReSolve::memory::HOST);
std::cout << "COO to CSR completed. Expanded NNZ: " << A->getNnzExpanded() << std::endl;
Expand Down
4 changes: 2 additions & 2 deletions examples/r_KLU_rf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ int main(int argc, char *argv[] )

//Now convert to CSR.
if (i < 2) {
matrix_handler->coo2csr(A_coo, A, "cpu");
A->updateFromCoo(A_coo, ReSolve::memory::HOST);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::HOST);
vec_rhs->setDataUpdated(ReSolve::memory::HOST);
} else {
matrix_handler->coo2csr(A_coo, A, "cuda");
A->updateFromCoo(A_coo, ReSolve::memory::DEVICE);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::DEVICE);
}
std::cout<<"COO to CSR completed. Expanded NNZ: "<< A->getNnzExpanded()<<std::endl;
Expand Down
4 changes: 2 additions & 2 deletions examples/r_KLU_rf_FGMRES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ int main(int argc, char *argv[])

//Now convert to CSR.
if (i < 2) {
matrix_handler->coo2csr(A_coo, A, "cpu");
A->updateFromCoo(A_coo, ReSolve::memory::HOST);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::HOST);
vec_rhs->setDataUpdated(ReSolve::memory::HOST);
} else {
matrix_handler->coo2csr(A_coo,A, "cuda");
A->updateFromCoo(A_coo, ReSolve::memory::DEVICE);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::DEVICE);
}
std::cout<<"COO to CSR completed. Expanded NNZ: "<< A->getNnzExpanded()<<std::endl;
Expand Down
4 changes: 2 additions & 2 deletions examples/r_KLU_rf_FGMRES_reuse_factorization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ int main(int argc, char *argv[])

//Now convert to CSR.
if (i < 2) {
matrix_handler->coo2csr(A_coo,A, "cpu");
A->updateFromCoo(A_coo, ReSolve::memory::HOST);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::HOST);
vec_rhs->setDataUpdated(ReSolve::memory::HOST);
} else {
matrix_handler->coo2csr(A_coo, A, "cuda");
A->updateFromCoo(A_coo, ReSolve::memory::DEVICE);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::DEVICE);
}
std::cout<<"COO to CSR completed. Expanded NNZ: "<< A->getNnzExpanded()<<std::endl;
Expand Down
7 changes: 3 additions & 4 deletions examples/r_KLU_rocSolverRf_FGMRES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@ int main(int argc, char *argv[])
vec_x->allocate(ReSolve::memory::HOST);//for KLU
vec_x->allocate(ReSolve::memory::DEVICE);
vec_r = new vector_type(A->getNumRows());
}
else {
} else {
ReSolve::io::readAndUpdateMatrix(mat_file, A_coo);
ReSolve::io::readAndUpdateRhs(rhs_file, &rhs);
}
Expand All @@ -110,11 +109,11 @@ int main(int argc, char *argv[])

//Now convert to CSR.
if (i < 2) {
matrix_handler->coo2csr(A_coo, A, "cpu");
A->updateFromCoo(A_coo, ReSolve::memory::HOST);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::HOST);
vec_rhs->setDataUpdated(ReSolve::memory::HOST);
} else {
matrix_handler->coo2csr(A_coo,A, "hip");
A->updateFromCoo(A_coo, ReSolve::memory::DEVICE);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::DEVICE);
}
std::cout<<"COO to CSR completed. Expanded NNZ: "<< A->getNnzExpanded()<<std::endl;
Expand Down
7 changes: 3 additions & 4 deletions examples/r_KLU_rocsolverrf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,7 @@ int main(int argc, char *argv[] )
vec_rhs = new vector_type(A->getNumRows());
vec_x = new vector_type(A->getNumRows());
vec_r = new vector_type(A->getNumRows());
}
else {
} else {
ReSolve::io::readAndUpdateMatrix(mat_file, A_coo);
ReSolve::io::readAndUpdateRhs(rhs_file, &rhs);
}
Expand All @@ -106,11 +105,11 @@ int main(int argc, char *argv[] )

//Now convert to CSR.
if (i < 2) {
matrix_handler->coo2csr(A_coo, A, "cpu");
A->updateFromCoo(A_coo, ReSolve::memory::HOST);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::HOST);
vec_rhs->setDataUpdated(ReSolve::memory::HOST);
} else {
matrix_handler->coo2csr(A_coo, A, "hip");
A->updateFromCoo(A_coo, ReSolve::memory::DEVICE);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::DEVICE);
}
std::cout<<"COO to CSR completed. Expanded NNZ: "<< A->getNnzExpanded()<<std::endl;
Expand Down
7 changes: 3 additions & 4 deletions examples/r_KLU_rocsolverrf_redo_factorization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ int main(int argc, char *argv[] )
vec_rhs = new vector_type(A->getNumRows());
vec_x = new vector_type(A->getNumRows());
vec_r = new vector_type(A->getNumRows());
}
else {
} else {
ReSolve::io::readAndUpdateMatrix(mat_file, A_coo);
ReSolve::io::readAndUpdateRhs(rhs_file, &rhs);
}
Expand All @@ -109,11 +108,11 @@ int main(int argc, char *argv[] )

//Now convert to CSR.
if (i < 2) {
matrix_handler->coo2csr(A_coo, A, "cpu");
A->updateFromCoo(A_coo, ReSolve::memory::HOST);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::HOST);
vec_rhs->setDataUpdated(ReSolve::memory::HOST);
} else {
matrix_handler->coo2csr(A_coo, A, "hip");
A->updateFromCoo(A_coo, ReSolve::memory::DEVICE);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::DEVICE);
}
std::cout<<"COO to CSR completed. Expanded NNZ: "<< A->getNnzExpanded()<<std::endl;
Expand Down
7 changes: 2 additions & 5 deletions examples/r_SysSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,16 @@ int main(int argc, char *argv[])

//Now convert to CSR.
if (i < 2) {
matrix_handler->coo2csr(A_coo, A, "cpu");
A->updateFromCoo(A_coo, ReSolve::memory::HOST);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::HOST);
vec_rhs->setDataUpdated(ReSolve::memory::HOST);
} else {
matrix_handler->coo2csr(A_coo, A, "cpu");
A->updateFromCoo(A_coo, ReSolve::memory::HOST);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::HOST);
}
std::cout<<"COO to CSR completed. Expanded NNZ: "<< A->getNnzExpanded()<<std::endl;
//Now call direct solver
solver->setMatrix(A);
// if (i == 0) {
// solver->setupParameters(1, 0.1, false);
// }
int status;
if (i < 2){
// solver->setup(A);
Expand Down
4 changes: 2 additions & 2 deletions examples/r_SysSolverCuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ int main(int argc, char *argv[])

//Now convert to CSR.
if (i < 1) {
matrix_handler->coo2csr(A_coo, A, "cpu");
A->updateFromCoo(A_coo, ReSolve::memory::HOST);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::HOST);
vec_rhs->setDataUpdated(ReSolve::memory::HOST);
} else {
matrix_handler->coo2csr(A_coo, A, "cuda");
A->updateFromCoo(A_coo, ReSolve::memory::DEVICE);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::DEVICE);
}
std::cout<<"COO to CSR completed. Expanded NNZ: "<< A->getNnzExpanded()<<std::endl;
Expand Down
4 changes: 2 additions & 2 deletions examples/r_SysSolverHip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ int main(int argc, char *argv[] )

//Now convert to CSR.
if (i < 2) {
matrix_handler->coo2csr(A_coo, A, "cpu");
A->updateFromCoo(A_coo, ReSolve::memory::HOST);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::HOST);
vec_rhs->setDataUpdated(ReSolve::memory::HOST);
} else {
matrix_handler->coo2csr(A_coo, A, "hip");
A->updateFromCoo(A_coo, ReSolve::memory::DEVICE);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::DEVICE);
}
std::cout<<"COO to CSR completed. Expanded NNZ: "<< A->getNnzExpanded()<<std::endl;
Expand Down
4 changes: 2 additions & 2 deletions examples/r_SysSolverHipRefine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ int main(int argc, char *argv[])

//Now convert to CSR.
if (i < 2) {
matrix_handler->coo2csr(A_coo, A, "cpu");
A->updateFromCoo(A_coo, ReSolve::memory::HOST);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::HOST);
vec_rhs->setDataUpdated(ReSolve::memory::HOST);
} else {
matrix_handler->coo2csr(A_coo, A, "hip");
A->updateFromCoo(A_coo, ReSolve::memory::DEVICE);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::DEVICE);
}
std::cout<<"COO to CSR completed. Expanded NNZ: "<< A->getNnzExpanded()<<std::endl;
Expand Down
2 changes: 1 addition & 1 deletion examples/r_randGMRES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ int main(int argc, char *argv[])
mat_file.close();
rhs_file.close();

matrix_handler->coo2csr(A_coo,A, "hip");
A->updateFromCoo(A_coo, ReSolve::memory::DEVICE);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::DEVICE);
//Now call direct solver
real_type norm_b;
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 @@ -82,7 +82,7 @@ int main(int argc, char *argv[])
mat_file.close();
rhs_file.close();

matrix_handler->coo2csr(A_coo,A, "cuda");
A->updateFromCoo(A_coo, ReSolve::memory::DEVICE);
vec_rhs->update(rhs, ReSolve::memory::HOST, ReSolve::memory::DEVICE);
//Now call direct solver
real_type norm_b;
Expand Down
Loading
Loading