Skip to content

Re::Solve SUNMatrix class#3

Open
JeffZ594 wants to merge 22 commits into
resolve-developfrom
resolve/sunmatrix_resolve
Open

Re::Solve SUNMatrix class#3
JeffZ594 wants to merge 22 commits into
resolve-developfrom
resolve/sunmatrix_resolve

Conversation

@JeffZ594

@JeffZ594 JeffZ594 commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Creation of the SUNMatrix_ReSolve class

  • Please target the resolve-develop branch not main.
  • Review our Contributing Guide, and ensure that you sign your last commit (at minimum) as per the guide.
  • Provide a concise description of what your pull request does, and why it is needed/benefical.
  • Add a note about your change to the CHANGELOG.md and docs/shared/RecentChanges.rst files. Notice that the former is a markdown file and the latter is reStructuredText, so the formatting is slightly different.
  • After your PR is opened, ensure that all of the tests are passing (a SUNDIALS developer will have to allow the testing to run).

@JeffZ594 JeffZ594 requested a review from pelesh June 12, 2026 17:27
@JeffZ594 JeffZ594 self-assigned this Jun 12, 2026
@JeffZ594 JeffZ594 added the enhancement New feature or request label Jun 12, 2026

@pelesh pelesh left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few minor, mainly nitpicking changes. It would be good to check why tests are failing.

Comment on lines +206 to +207
"Enable the SUNMATRIX_RESOLVE module (requires Re::Solve)" ON
DEPENDS_ON SUNDIALS_ENABLE_RESOLVE

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be set to off for now.

@JeffZ594 JeffZ594 Jun 24, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe DEPENDS_ON is a macro from cmake/macros/SundialsOption.cmake that will automatically set this to OFF if SUNDIALS_ENABLE_RESOLVE is not enabled. When I set it to OFF even with SUNDIALS_ENABLE_RESOLVE=ON the ReSolve tests are not created so I think this should be left as ON.

Comment thread doc/shared/sundials/Install.rst Outdated
Comment on lines +2162 to +2163
-D CMAKE_CUDA_ARCHITECTURES="60"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to set an old CUDA architecture? Perhaps instructions should say something like "Optionally set your CUDA architecture, e.g. -D CMAKE_CUDA_ARCHITECTURES="80".

Comment thread doc/shared/sundials/Install.rst Outdated
Comment on lines +2187 to +2188
Default: ``ON``

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re::Solve support should be by default off.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This default: ON is referring to the the compatibility checks. Looking at the documentation for the other TPL's these compatibility checks seems to always be default ON. Re::Solve support is default set to OFF above.

Comment thread doc/shared/sunmatrix/SUNMatrix_ReSolve.rst
Comment on lines 23 to 24
- resolve~cuda~rocm arch=x86_64 %gcc@9.4.0
config:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you verify that installing SUNDIALS with Spack works with this change?

Comment thread include/sunmatrix/sunmatrix_resolve.h Outdated
Comment thread src/sunmatrix/resolve/CMakeLists.txt Outdated
Comment on lines +24 to +30
# if(SUNDIALS_MAGMA_BACKENDS MATCHES "CUDA")
# set_source_files_properties(sunmatrix_magmadense.cpp PROPERTIES LANGUAGE CUDA)
# set(_libs_needed sundials_nveccuda)
# elseif(SUNDIALS_MAGMA_BACKENDS MATCHES "HIP")
# set_source_files_properties(sunmatrix_magmadense.cpp PROPERTIES LANGUAGE CXX)
# set(_libs_needed sundials_nvechip hip::device)
# endif()

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this code commented out?

Comment on lines +235 to +255
/**
Utility function to print an array on the device for debugging
*/
// void SUNMatrix_ReSolve_Print_Array(SUNMatrix A)
// {
// if (RESOLVE_MEMSPACE(A) == ReSolve::memory::HOST) {return;}

// ReSolve::memory::MemorySpace memspace = RESOLVE_MEMSPACE(A);
// sunrealtype* d_data = SUNMatrix_ReSolve_Data(A, memspace);
// sunrealtype* h_data = new sunrealtype[SUNMatrix_ReSolve_NNZ(A)];

// cudaMemcpy(h_data, d_data,
// SUNMatrix_ReSolve_NNZ(A) * sizeof(sunrealtype),
// cudaMemcpyDeviceToHost);

// for (int i = 0; i < SUNMatrix_ReSolve_NNZ(A); i++)
// {
// printf("data[%d] = %f\n", i, h_data[i]);
// }
// delete[] h_data;
// }

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest we remove commented out debugging code before merging.

Comment on lines +320 to +332
// Zero out the values of these arrays
for (i = 0; i < RESOLVE_NNZ(A); i++)
{
values[i] = ZERO;
index_values[i] = 0;
}

for (i = 0; i < RESOLVE_M(A); i++)
{
index_pointers[i] = ZERO;
}

(index_pointers)[RESOLVE_M(A)] = 0;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would use memset functions here.

Comment on lines +334 to +343
SUNMatrix_ReSolve_SetUpdated(A, ReSolve::memory::HOST);

// Sync to device if necessary
if (RESOLVE_MEMSPACE(A) != ReSolve::memory::HOST)
{
SUNMatrix_ReSolve_SyncData(A, RESOLVE_MEMSPACE(A));
}

return SUN_SUCCESS;
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this SUNMatrix public method? I think this is specific to Re::Solve matrix.

I think this function should be defined above

/* --------------------------------------------------------------------------
 * Implementation of generic SUNMatrix operations.
 * -------------------------------------------------------------------------- */

comment.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at this again there isn't a function definition here these are both calls by the generic SUNMatZero function to the Re::Solve specific functions SetUpdated and SyncData defined above the comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants