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

Vector initialization functions do not set "updated" flags correctly #216

Open
pelesh opened this issue Jan 23, 2025 · 1 comment
Open
Assignees
Labels
bug Something isn't working

Comments

@pelesh
Copy link
Collaborator

pelesh commented Jan 23, 2025

Methods for vector initialization Vector::setToConst and Vector::setToZero do not set flags cpu_updated_ or gpu_updated_. This means that other functions would see the initialized memory space of vector as out of date and could overwrite it.

The fix is to call setDataUpdated method inside the initialization function.

CC @kswirydo

@pelesh pelesh added the bug Something isn't working label Jan 23, 2025
@pelesh pelesh self-assigned this Jan 23, 2025
@pelesh pelesh added this to the Release 0.99.2 milestone Feb 5, 2025
@pelesh
Copy link
Collaborator Author

pelesh commented Mar 5, 2025

This issue becomes a little more complicated when initializing multivectors. Consider following code:

vector::Vector v(10, 2);

// allocate a multivector

v.setToZero(0, memory::DEVICE);
v.setToZero(1, memory::HOST);

Which memory space should be updated after this?

A few possible solutions:

  1. Always set to "updated" the memory space that was modified last. However, in the example above, executing sync(memory::DEVICE); would overwrite vector 0 on the device with old data.
  2. Instead of a single flag for the entire multivector memory space, have a separate flags to track update status for each subvector. This would be a complete solution but perhaps cumbersome to implement.
  3. Document that initialization functions (setToZero, setToConst) do not set "updated" flags, so it is user's responsibility to do so after these functions are called. This would leave inconsistent behavior among matrix and vector class methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant