Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
8d94456
Initial CPU implementation of scalAddI.
quantumsteve Nov 12, 2025
e8878b8
cache sparsity pattern
quantumsteve Nov 14, 2025
de25a65
unnecessary branch
quantumsteve Nov 14, 2025
5c4f903
memory leak!
quantumsteve Nov 14, 2025
473146f
fix memory leak?
quantumsteve Nov 14, 2025
56092da
update function name
quantumsteve Nov 14, 2025
25eedad
cleanup
quantumsteve Nov 14, 2025
adcc3b8
fix documentation
quantumsteve Nov 14, 2025
fa0c360
test reuse sparsity pattern
quantumsteve Nov 15, 2025
5026698
Apply pre-commmit fixes
quantumsteve Nov 15, 2025
8b6f599
use std:vector instead for c-style array
quantumsteve Nov 17, 2025
100ef28
fix GPU build
quantumsteve Nov 17, 2025
6665612
use camelCase
quantumsteve Nov 17, 2025
c0652a2
checkpoint
quantumsteve Nov 17, 2025
a6efc94
scaleAddB passing test
quantumsteve Nov 17, 2025
6cd01c1
checkpoint
quantumsteve Nov 17, 2025
5cfa679
working?
quantumsteve Nov 17, 2025
2bc7762
silence CUDA/HIP warnings
quantumsteve Nov 17, 2025
bdf049a
Apply pre-commmit fixes
quantumsteve Nov 17, 2025
d06ecc9
Simpler test found missing boolean flag
quantumsteve Nov 18, 2025
42af7a8
Apply pre-commmit fixes
quantumsteve Nov 18, 2025
c32eee3
CUDA implementation not working!
quantumsteve Nov 17, 2025
3f10bc4
memory leak
quantumsteve Nov 17, 2025
0dbd91a
fix nullptr check
quantumsteve Nov 18, 2025
e98fca6
pointed at wrong matrix
quantumsteve Nov 18, 2025
1b60823
Simpler test found missing boolean flag
quantumsteve Nov 18, 2025
1327d9d
CUDA implementation not working!
quantumsteve Nov 17, 2025
0b490d7
working?
quantumsteve Nov 18, 2025
c9432cb
working?
quantumsteve Nov 18, 2025
47002b2
checkpoint
quantumsteve Nov 18, 2025
319b6b6
checkpoint
quantumsteve Nov 18, 2025
b2f52bc
set error code
quantumsteve Nov 19, 2025
b54dd5e
Apply pre-commmit fixes
quantumsteve Nov 19, 2025
8396551
Update memory deletion for scale add buffers
quantumsteve Nov 19, 2025
cf0d394
checkpoint
quantumsteve Nov 19, 2025
6bc7d7b
fix build
quantumsteve Nov 20, 2025
ef71cdb
working?
quantumsteve Nov 20, 2025
a893f2a
simplify design
quantumsteve Nov 20, 2025
1db9ced
match changes on HIP
quantumsteve Nov 20, 2025
ae6889b
Apply pre-commmit fixes
quantumsteve Nov 20, 2025
cc4f865
fix warnings
quantumsteve Nov 20, 2025
7393501
MatrixHandler: fix return value
quantumsteve Nov 20, 2025
95609e8
update CHANGELOG.md
quantumsteve Nov 20, 2025
1c3da0c
Move ScaleAddBuffer to a new file
quantumsteve Nov 24, 2025
2e1e760
Apply pre-commmit fixes
quantumsteve Nov 24, 2025
cce2624
fix HIP build
quantumsteve Nov 24, 2025
6801bfd
Apply pre-commmit fixes
quantumsteve Nov 24, 2025
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

- Added cmake-format

- The MatrixHandler::scaleAddI function was added to calculate A := cA + I

- The MatrixHandler::scaleAddB function was added to calculate A := cA + B

## Changes to Re::Solve in release 0.99.2

### Major Features
Expand Down
2 changes: 2 additions & 0 deletions resolve/LinSolverDirectRocSolverRf.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "LinSolverDirectRocSolverRf.hpp"

#include <cassert>

#include <resolve/hip/hipKernels.h>

#include <resolve/Profiling.hpp>
Expand Down
2 changes: 1 addition & 1 deletion resolve/MemoryUtils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace ReSolve
*
* @brief Provides basic memory allocation, free and copy functions.
*
* This class provedes abstractions for memory management functiosn for
* This class provedes abstractions for memory management functions for
* different GPU programming models.
*
* @tparam Policy - Memory management policy (vendor specific)
Expand Down
51 changes: 51 additions & 0 deletions resolve/matrix/MatrixHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,57 @@ namespace ReSolve
}
}

/**
* @brief Multiply csr matrix by a constant and add I.
* @param[in,out] A - Sparse CSR matrix
* @param[in] alpha - scalar parameter
* @param[in] memspace - Device where the operation is computed
* @return 0 if successful, 1 otherwise
*/
int MatrixHandler::scaleAddI(matrix::Csr* A, real_type alpha, memory::MemorySpace memspace)
{
assert(A->getSparseFormat() == matrix::Sparse::COMPRESSED_SPARSE_ROW && "Matrix is assumed to be in CSR format.\n");
assert((A->getValues(memspace) != nullptr || A->getNnz() == 0) && "Matrix values are null!\n");
assert(A->getNumRows() == A->getNumColumns() && "Matrix must be square.\n");
using namespace ReSolve::memory;
switch (memspace)
{
case HOST:
return cpuImpl_->scaleAddI(A, alpha);
break;
case DEVICE:
return devImpl_->scaleAddI(A, alpha);
break;
}
return 1;
}

/**
* @brief Multiply csr matrix by a constant and add B.
* @param[in,out] A - Sparse CSR matrix
* @param[in] alpha - scalar parameter
* @param[in] B - Sparse CSR matrix
* @param[in] memspace - Device where the operation is computed
* @return 0 if successful, 1 otherwise
*/
int MatrixHandler::scaleAddB(matrix::Csr* A, real_type alpha, matrix::Csr* B, memory::MemorySpace memspace)
{
assert(A->getSparseFormat() == matrix::Sparse::COMPRESSED_SPARSE_ROW && "Matrix is assumed to be in CSR format.\n");
assert(A->getValues(memspace) != nullptr && "Matrix values are null!\n");
assert(A->getNumRows() == A->getNumColumns() && "Matrix must be square.\n");
using namespace ReSolve::memory;
switch (memspace)
{
case HOST:
return cpuImpl_->scaleAddB(A, alpha, B);
break;
case DEVICE:
return devImpl_->scaleAddB(A, alpha, B);
break;
}
return 1;
}

/**
* @brief If CUDA support is enabled in the handler.
*
Expand Down
4 changes: 4 additions & 0 deletions resolve/matrix/MatrixHandler.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ namespace ReSolve

void addConst(matrix::Sparse* A, real_type alpha, memory::MemorySpace memspace);

int scaleAddI(matrix::Csr* A, real_type alpha, memory::MemorySpace memspace);

int scaleAddB(matrix::Csr* A, real_type alpha, matrix::Csr* B, memory::MemorySpace memspace);

/// Should compute vec_result := alpha*A*vec_x + beta*vec_result, but at least on cpu alpha and beta are flipped
int matvec(matrix::Sparse* A,
vector_type* vec_x,
Expand Down
Loading