Skip to content

Add const getData methods to Vector class#412

Merged
pelesh merged 3 commits intodevelopfrom
slaven/remove-sloppy-syncing
Feb 26, 2026
Merged

Add const getData methods to Vector class#412
pelesh merged 3 commits intodevelopfrom
slaven/remove-sloppy-syncing

Conversation

@pelesh
Copy link
Collaborator

@pelesh pelesh commented Feb 26, 2026

Description

Add const methods to access raw vector data. Non-constant vector data getters are syncing data between host and device as needed. While convenient in some instances, these methods are changing member data in Vector, so calling them prevents passing cont references to the Vector object.

We should probably do away with "sloppy" syncing altogether. This PR is a first step to enable using const references to Vector objects.

Proposed changes

Implements following methods to vector::Vector class:

      const real_type* getData(MemorySpace memspace) const;
      const real_type* getData(index_type i, MemorySpace memspace) const;

Checklist

  • All tests pass (make test and make test_install per testing instructions). Code tested on
    • CPU backend
    • CUDA backend
    • HIP backend
  • I have manually run the non-experimental examples and verified that residuals are close to machine precision. (In your build directory run:
    ./examples/<your_example>.exe -h to get instructions how to run examples). Code tested on:
    • CPU backend
    • CUDA backend
    • HIP backend
  • Code compiles cleanly with flags -Wall -Wpedantic -Wconversion -Wextra.
  • The new code follows Re::Solve style guidelines.
  • There are unit tests for the new code.
  • The new code is documented.
  • The feature branch is rebased with respect to the target branch.
  • I have updated CHANGELOG.md to reflect the changes in this PR. If this is a minor PR that is part of a larger fix already included in the file, state so.

Further comments

@pelesh pelesh added this to the Release 0.99.3 milestone Feb 26, 2026
@pelesh pelesh self-assigned this Feb 26, 2026
@pelesh pelesh added the enhancement New feature or request label Feb 26, 2026
@alexander-novo
Copy link
Collaborator

You actually read my mind on this - I was going to ask you about this exact problem.

@pelesh
Copy link
Collaborator Author

pelesh commented Feb 26, 2026

You actually read my mind on this - I was going to ask you about this exact problem.

It's been on our to-do list for a while. Thanks for your initiative!

Copy link
Collaborator

@shakedregev shakedregev left a comment

Choose a reason for hiding this comment

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

Looks good, testing before approving.

Copy link
Collaborator

@shakedregev shakedregev left a comment

Choose a reason for hiding this comment

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

Tests pass. Approving pending my minor tweak suggestions and a Changelog modification

@pelesh pelesh merged commit 3d712ca into develop Feb 26, 2026
6 checks passed
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.

3 participants