Skip to content
Merged
Show file tree
Hide file tree
Changes from 64 commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
7990197
Create Matrix class, a parent class for matrices including Sparse
andrewxu319 May 15, 2026
37c8ccf
Added CPU implementation for Schur Complement Conjugate Gradient and …
andrewxu319 May 15, 2026
08d691c
Fixed bug in MatrixHandlerTests.hpp that caused leftScale and rightSc…
andrewxu319 May 15, 2026
7868e59
Add to CHANGELOG.md. Removed some unnecessary comments.
andrewxu319 May 15, 2026
8d3a3d8
Bug fixes (missing <cmath>, type mismatch of variable "i").
andrewxu319 May 15, 2026
1bf3553
Revert "Create Matrix class, a parent class for matrices including Sp…
andrewxu319 May 15, 2026
d025508
Apply pre-commmit fixes
andrewxu319 May 15, 2026
276571c
Update tests/unit/hykkt/HykktSCCGTests.hpp
shakedregev May 15, 2026
b2d0d13
Apply pre-commmit fixes
shakedregev May 15, 2026
2bc2d4a
Formatting fixes.
andrewxu319 May 15, 2026
2d090b6
Apply pre-commmit fixes
andrewxu319 May 15, 2026
78b532e
Removed "Matrix.hpp" from resolve/matrix/CMakeLists.txt
andrewxu319 May 15, 2026
a2af9f3
Apply pre-commmit fixes
andrewxu319 May 15, 2026
b3eed10
Apply suggestion from @shakedregev
shakedregev May 15, 2026
df856c0
fixed not building test, test still fails on HIP
shakedregev May 15, 2026
37d6f1f
Fix SCCG vector initialization values. The outputs now match the old …
andrewxu319 Jun 4, 2026
55d9318
Put SCCG's internal vectors on the heap via malloc. Not strictly need…
andrewxu319 Jun 4, 2026
9e9bdd6
Create SCCG unit tests (one set of inputs). NOTE: this code currently…
andrewxu319 Jun 4, 2026
c64cb2d
Make SCCG test path CPU, CUDA, and HIP capable (#422)
tamar-dewilde May 29, 2026
e6eba9d
Address SCCG GPU review comments
tamar-dewilde Jun 2, 2026
5fffaee
Add comments to edited sections of removeDuplicates.
andrewxu319 Jun 2, 2026
3974c6c
Standardize matrix/vector handler object use and naming.
andrewxu319 Jun 4, 2026
c25cd6f
Apply pre-commmit fixes
andrewxu319 Jun 4, 2026
85cfd95
Make matrix and vector handlers passed to SCCG instead of owned by it
andrewxu319 Jun 4, 2026
1d75e64
Pass handlers by pointer. This is more consistent with the rest of th…
andrewxu319 Jun 4, 2026
b7c09b0
Formatting fixes as suggested in PR.
andrewxu319 Jun 4, 2026
2d44fb0
Apply pre-commmit fixes
andrewxu319 Jun 4, 2026
c98b838
Reordered variable declaration in SCCG to avoid [-Wreorder] warning
andrewxu319 Jun 4, 2026
9c16eff
SCCG test no longer needs a random number generator
andrewxu319 Jun 4, 2026
84d3063
Apply pre-commmit fixes
andrewxu319 Jun 4, 2026
31fd1aa
Apply suggestion from @shakedregev
shakedregev Jun 4, 2026
6a1eeef
Add HyKKT Solver Class (#432)
andrewxu319 Jun 4, 2026
9b98150
Merge branch 'develop' into andrew/sccg-and-matrix-class
andrewxu319 Jun 4, 2026
e974d33
Merge branch 'develop' into andrew/sccg-and-matrix-class
shakedregev Jun 5, 2026
9f909a6
Remove unused variables in SCCG and HyKKTSolver
andrewxu319 Jun 5, 2026
3d9c63f
Print the current stage in the solver to locate the error
andrewxu319 Jun 5, 2026
06ee291
Print the current file set being tested.
andrewxu319 Jun 7, 2026
6566ab3
Remove lazy allocation in copyFromExternal in Vector and Matrix class…
andrewxu319 Jun 7, 2026
ef26009
Remove the version of Sparse::copyFromExternal() that changes nnz. It…
andrewxu319 Jun 7, 2026
a4787b8
Merge remote-tracking branch 'origin/develop' into andrew/strict-mem-…
andrewxu319 Jun 8, 2026
0560e77
Remove auto syncing from Vector::getData() and remove "const real_typ…
andrewxu319 Jun 8, 2026
7cc4fa0
Add Vector::isUpdated() to enable conditional syncData.
andrewxu319 Jun 8, 2026
7080965
Add test outputs to .gitignore
andrewxu319 Jun 8, 2026
941a6ce
Remove automatic allocation from Vector::setToZero() and Vector::setT…
andrewxu319 Jun 8, 2026
6b34f39
Remove HyKKTSolver::readMatrixFiles(). It really is not necessary, an…
andrewxu319 Jun 8, 2026
0460479
Prohibit repeated allocations for vectors and matrices.
andrewxu319 Jun 8, 2026
1d0c07d
Remove automatic allocation from csc2csr()
andrewxu319 Jun 8, 2026
4545066
Add/fix allocation calls. Make sure all tests pass after the previous…
andrewxu319 Jun 8, 2026
2f5709e
Add Vector::isAllocated(). This avoids checking whether a vector is a…
andrewxu319 Jun 8, 2026
0e8a6ea
Add default returns to isUpdated() and isAllocated() in Vector
andrewxu319 Jun 8, 2026
d8689c6
Reinstate const pointer versions of getData() and removed data-out-of…
andrewxu319 Jun 8, 2026
a4834c4
Add allocateAll() for vectors and matrices to replace conditional all…
andrewxu319 Jun 8, 2026
5c93316
In VectorHandlerCuda, change the return status of cusolverSpDnrminf()…
andrewxu319 Jun 9, 2026
c78ee58
Make setTransposeBufferWorkspace() not allow repeatedly setting the t…
andrewxu319 Jun 9, 2026
93339e7
Fix typo
andrewxu319 Jun 9, 2026
20fbb0d
Add status returns to a few functions in LinAlgWorkspace.
andrewxu319 Jun 9, 2026
2c9ebe1
Remove duplicate allocates in testSysGmres.cpp
andrewxu319 Jun 9, 2026
cde9bfe
Remove 00-series test matrices for HyKKTSolver
andrewxu319 Jun 9, 2026
5e40d21
Add "return 0" to LinAlgWorkspaceHIP::initializeHandles()
andrewxu319 Jun 9, 2026
60cddb0
Remove duplicate allocates in LinSolverIterativeRandFGMRES.cpp
andrewxu319 Jun 9, 2026
7bec11d
Revert "Add "return 0" to LinAlgWorkspaceHIP::initializeHandles()"
andrewxu319 Jun 9, 2026
e5f7f5d
Revert "Add status returns to a few functions in LinAlgWorkspace."
andrewxu319 Jun 9, 2026
08633ce
Update CHANGELOG.md
andrewxu319 Jun 9, 2026
0c0477d
Apply pre-commmit fixes
andrewxu319 Jun 9, 2026
ee713ab
Remove unnecessary comment
andrewxu319 Jun 9, 2026
fea0cad
Remove unnecessary comments. The test only runs when the device is av…
andrewxu319 Jun 9, 2026
46f72fc
Simplify logic in MatrixHandlerTests::transpose()
andrewxu319 Jun 9, 2026
d6cecbe
Apply pre-commmit fixes
andrewxu319 Jun 9, 2026
64d2415
Change load-bearing assert() to out::error()
andrewxu319 Jun 9, 2026
8795970
Return after out::error()'s
andrewxu319 Jun 9, 2026
0a103e3
Add Logger includes for error logging
andrewxu319 Jun 9, 2026
3aa0f11
Apply pre-commmit fixes
andrewxu319 Jun 9, 2026
683af6a
Clarify comment in HyKKTSolver
andrewxu319 Jun 9, 2026
2c28a56
Remove confusing comment
andrewxu319 Jun 9, 2026
a2029ed
Call syncDevice() in sysRefactor only when GPU is enabled
andrewxu319 Jun 9, 2026
a2fd2a6
Apply pre-commmit fixes
andrewxu319 Jun 9, 2026
a0e50c1
Add return statements after errors in Vector
andrewxu319 Jun 9, 2026
8cfd2ca
Add more return statements after errors.
andrewxu319 Jun 9, 2026
35ff137
Apply pre-commmit fixes
andrewxu319 Jun 9, 2026
376e146
Fix syntax error in sysRefactor
andrewxu319 Jun 10, 2026
b8d573c
Fix logic error in LinAlgWorkspaceCUDA/HIP
andrewxu319 Jun 10, 2026
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
.DS_Store
build/*
_build
LastTest.log
CTestCostData.txt
install/*
*~
*.swp
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

- Added Developer Guide documentation for vector and matrix classes and handlers.

- Remove automatic memory allocation and memory syncing in various memory management functions and require the user to explicitly manage their own memory.

## Changes to Re::Solve in release 0.99.2

### Major Features
Expand Down
2 changes: 2 additions & 0 deletions examples/ExampleHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,15 @@ namespace ReSolve
if (res_ == nullptr)
{
res_ = new ReSolve::vector::Vector(A->getNumRows());
res_->allocate(memspace_);
}
else
{
if (res_->getSize() != A->getNumRows())
{
delete res_;
res_ = new ReSolve::vector::Vector(A->getNumRows());
res_->allocate(memspace_);
}
}

Expand Down
4 changes: 4 additions & 0 deletions examples/experimental/r_KLU_GLU_matrix_values_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ int main(int argc, char* argv[])
ReSolve::io::updateArrayFromFile(rhs_file, &rhs);
}
// Copy matrix data to device
A->allocateMatrixData(ReSolve::memory::DEVICE);
A->syncData(ReSolve::memory::DEVICE);

std::cout << "Finished reading the matrix and rhs, size: " << A->getNumRows() << " x " << A->getNumColumns()
Expand All @@ -133,10 +134,12 @@ int main(int argc, char* argv[])
// Update host and device data.
if (i < 1)
{
vec_rhs->allocate(ReSolve::memory::HOST);
vec_rhs->copyFromExternal(rhs, ReSolve::memory::HOST, ReSolve::memory::HOST);
}
else
{
vec_rhs->allocate(ReSolve::memory::DEVICE);
vec_rhs->copyFromExternal(rhs, ReSolve::memory::HOST, ReSolve::memory::DEVICE);
}
std::cout << "CSR matrix loaded. Expanded NNZ: " << A->getNnz() << std::endl;
Expand Down Expand Up @@ -173,6 +176,7 @@ int main(int argc, char* argv[])
status = GLU->solve(vec_rhs, vec_x);
std::cout << "CUSOLVER GLU solve status: " << status << std::endl;
}
vec_r->allocate(ReSolve::memory::DEVICE);
vec_r->copyFromExternal(rhs, ReSolve::memory::HOST, ReSolve::memory::DEVICE);

matrix_handler->setValuesChanged(true, ReSolve::memory::DEVICE);
Expand Down
4 changes: 4 additions & 0 deletions examples/experimental/r_KLU_cusolverrf_redo_factorization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ int main(int argc, char* argv[])
ReSolve::io::updateArrayFromFile(rhs_file, &rhs);
}
// Copy matrix data to device
A->allocateMatrixData(ReSolve::memory::DEVICE);
A->syncData(ReSolve::memory::DEVICE);

std::cout << "Finished reading the matrix and rhs, size: " << A->getNumRows() << " x " << A->getNumColumns()
Expand All @@ -129,10 +130,12 @@ int main(int argc, char* argv[])
// Update host and device data.
if (i < 2)
{
vec_rhs->allocate(ReSolve::memory::HOST);
vec_rhs->copyFromExternal(rhs, ReSolve::memory::HOST, ReSolve::memory::HOST);
}
else
{
vec_rhs->allocate(ReSolve::memory::DEVICE);
vec_rhs->copyFromExternal(rhs, ReSolve::memory::HOST, ReSolve::memory::DEVICE);
}
std::cout << "CSR matrix loaded. Expanded NNZ: " << A->getNnz() << std::endl;
Expand Down Expand Up @@ -182,6 +185,7 @@ int main(int argc, char* argv[])
}

// Make sure vec_r is properly initialized before using it.
vec_r->allocate(ReSolve::memory::DEVICE);
vec_r->copyFromExternal(rhs, ReSolve::memory::HOST, ReSolve::memory::DEVICE);

matrix_handler->setValuesChanged(true, ReSolve::memory::DEVICE);
Expand Down
5 changes: 5 additions & 0 deletions examples/experimental/r_KLU_rf_FGMRES_reuse_factorization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,15 @@ 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());
vec_r->allocate(ReSolve::memory::DEVICE);
}
else
{
ReSolve::io::updateMatrixFromFile(mat_file, A);
ReSolve::io::updateArrayFromFile(rhs_file, &rhs);
}
// Copy matrix data to device
A->allocateMatrixData(ReSolve::memory::DEVICE);
A->syncData(ReSolve::memory::DEVICE);

std::cout << "Finished reading the matrix and rhs, size: " << A->getNumRows() << " x " << A->getNumColumns()
Expand All @@ -126,11 +128,14 @@ int main(int argc, char* argv[])
// Update host and device data.
if (i < 2)
{
vec_rhs->allocate(ReSolve::memory::HOST);
vec_rhs->copyFromExternal(rhs, ReSolve::memory::HOST, ReSolve::memory::HOST);
vec_rhs->setDataUpdated(ReSolve::memory::HOST);
}
else
{
vec_rhs->allocate(ReSolve::memory::HOST);
vec_rhs->allocate(ReSolve::memory::DEVICE);
A->setUpdated(ReSolve::memory::HOST);
A->syncData(ReSolve::memory::DEVICE);
vec_rhs->copyFromExternal(rhs, ReSolve::memory::HOST, ReSolve::memory::DEVICE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ int main(int argc, char* argv[])
ReSolve::io::updateArrayFromFile(rhs_file, &rhs);
}
// Copy matrix data to device
A->allocateMatrixData(ReSolve::memory::DEVICE);
A->syncData(ReSolve::memory::DEVICE);

std::cout << "Finished reading the matrix and rhs, size: " << A->getNumRows() << " x " << A->getNumColumns()
Expand All @@ -118,10 +119,12 @@ int main(int argc, char* argv[])
// Update host and device data.
if (i < 2)
{
vec_rhs->allocate(ReSolve::memory::HOST);
vec_rhs->copyFromExternal(rhs, ReSolve::memory::HOST, ReSolve::memory::HOST);
}
else
{
vec_rhs->allocate(ReSolve::memory::DEVICE);
vec_rhs->copyFromExternal(rhs, ReSolve::memory::HOST, ReSolve::memory::DEVICE);
}
std::cout << "CSR matrix loaded. Expanded NNZ: " << A->getNnz() << std::endl;
Expand Down Expand Up @@ -158,6 +161,7 @@ int main(int argc, char* argv[])
}

// Check accuracy of the solution
vec_rhs->allocate(ReSolve::memory::DEVICE);
vec_r->copyFromExternal(rhs, ReSolve::memory::HOST, ReSolve::memory::DEVICE);
matrix_handler->setValuesChanged(true, ReSolve::memory::DEVICE);
matrix_handler->matvec(A, vec_x, vec_r, &ONE, &MINUS_ONE, ReSolve::memory::DEVICE);
Expand Down
2 changes: 2 additions & 0 deletions examples/gluRefactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,9 @@ int gluRefactor(int argc, char* argv[])
rhs_file.close();

// Copy data to device
A->allocateMatrixData(memory::DEVICE);
A->syncData(memory::DEVICE);
vec_rhs->allocate(memory::DEVICE);
vec_rhs->syncData(memory::DEVICE);
RESOLVE_RANGE_POP("File input");

Expand Down
2 changes: 2 additions & 0 deletions examples/gpuRefactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ int gpuRefactor(int argc, char* argv[])
rhs_file.close();

// Copy data to device
A->allocateMatrixData(memory::DEVICE);
A->syncData(memory::DEVICE);
vec_rhs->allocate(memory::DEVICE);
vec_rhs->syncData(memory::DEVICE);
RESOLVE_RANGE_POP("File input");

Expand Down
6 changes: 4 additions & 2 deletions examples/randGmres.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,10 @@ int runGmresExample(int argc, char* argv[])
vec_x->allocate(memspace);
if (memspace == memory::DEVICE)
{
A->syncData(memspace);
vec_rhs->syncData(memspace);
A->allocateMatrixData(memory::DEVICE);
A->syncData(memory::DEVICE);
vec_rhs->allocate(memory::DEVICE);
vec_rhs->syncData(memory::DEVICE);
}

printSystemInfo(matrix_pathname, A);
Expand Down
6 changes: 4 additions & 2 deletions examples/sysGmres.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,10 @@ int sysGmres(int argc, char* argv[])
if (memspace == memory::DEVICE)
{
// Copy data to the device
A->syncData(memspace);
vec_rhs->syncData(memspace);
A->allocateMatrixData(memory::DEVICE);
A->syncData(memory::DEVICE);
vec_rhs->allocate(memory::DEVICE);
vec_rhs->syncData(memory::DEVICE);
}

mat_file.close();
Expand Down
2 changes: 2 additions & 0 deletions examples/sysRefactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,9 @@ int sysRefactor(int argc, char* argv[])
// Ensure matrix data is synced to the device before any GPU operations
if (hw_backend == "CUDA" || hw_backend == "HIP")
{
A->allocateMatrixData(memory::DEVICE);
A->syncData(memory::DEVICE);
vec_rhs->allocate(memory::DEVICE);
vec_rhs->syncData(memory::DEVICE);
}

Expand Down
12 changes: 12 additions & 0 deletions resolve/GramSchmidt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,10 @@ namespace ReSolve
// copy H_col to aux, we will need it later
vec_Hcolumn_->setDataUpdated(memspace_);
vec_Hcolumn_->resize(i + 1);
if (memspace_ == memory::DEVICE)
{
vec_Hcolumn_->syncData(memory::HOST);
}
vec_Hcolumn_->copyToExternal(h_aux_, 0, memory::HOST, memory::HOST);

// Hcol = V(:,1:i)^T*V(:,i+1);
Expand All @@ -201,6 +205,10 @@ namespace ReSolve

// copy H_col to H
vec_Hcolumn_->setDataUpdated(memspace_);
if (memspace_ == memory::DEVICE)
{
vec_Hcolumn_->syncData(memory::HOST);
}
vec_Hcolumn_->copyToExternal(&H[idxmap(i, 0, num_vecs_ + 1)], 0, memory::HOST, memory::HOST);

// add both pieces together (unstable otherwise, careful here!!)
Expand Down Expand Up @@ -379,6 +387,10 @@ namespace ReSolve

// copy H_col to H
vec_Hcolumn_->setDataUpdated(memspace_);
if (memspace_ == memory::DEVICE)
{
vec_Hcolumn_->syncData(memory::HOST);
}
vec_Hcolumn_->resize(i + 1);
vec_Hcolumn_->copyToExternal(&H[idxmap(i, 0, num_vecs_ + 1)], 0, memory::HOST, memory::HOST);

Expand Down
3 changes: 3 additions & 0 deletions resolve/LinSolverDirectCuSolverGLU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ namespace ReSolve
return error_sum;
}

/**
* @brief Solve the system. Input vector data must be synced on the device.
*/
int LinSolverDirectCuSolverGLU::solve(vector_type* rhs, vector_type* x)
{
RESOLVE_RANGE_PUSH(__FUNCTION__);
Expand Down
2 changes: 1 addition & 1 deletion resolve/LinSolverDirectCuSolverRf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ namespace ReSolve
* @return 0 if successful, 1 otherwise
*/
int LinSolverDirectCuSolverRf::solve(vector_type* rhs, vector_type* x)
{
{ // CAREFUL: ANYTHING THAT CALLS THIS. DELETE THIS COMMENT
Comment thread
andrewxu319 marked this conversation as resolved.
Outdated
x->copyFromExternal(rhs->getData(memory::DEVICE), memory::DEVICE, memory::DEVICE);
x->setDataUpdated(memory::DEVICE);
status_cusolverrf_ = cusolverRfSolve(handle_cusolverrf_,
Expand Down
1 change: 1 addition & 0 deletions resolve/LinSolverDirectRocSolverRf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ namespace ReSolve
combineFactors(L, U);

M_->setUpdated(ReSolve::memory::HOST);
M_->allocateMatrixData(ReSolve::memory::DEVICE);
M_->syncData(ReSolve::memory::DEVICE);

// remember - P and Q are generally CPU variables
Expand Down
3 changes: 3 additions & 0 deletions resolve/SystemSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,8 @@ namespace ReSolve

L_ = factorizationSolver_->getLFactor();
U_ = factorizationSolver_->getUFactor();
L_->allocateMatrixData(memory::DEVICE);
U_->allocateMatrixData(memory::DEVICE);
P_ = factorizationSolver_->getPOrdering();
Q_ = factorizationSolver_->getQOrdering();

Expand Down Expand Up @@ -862,6 +864,7 @@ namespace ReSolve
else
{
resVector_->copyFromExternal(rhs, memory::HOST, memory::DEVICE);
resVector_->syncData(memory::HOST);
norm_b = std::sqrt(vectorHandler_->dot(resVector_, resVector_, memory::HOST));
// ms = memory::HOST;
}
Expand Down
Loading