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

Missing compilation error when manipulating VectorFields #111

Open
EmilyBourne opened this issue Feb 24, 2025 · 0 comments · May be fixed by #112
Open

Missing compilation error when manipulating VectorFields #111

EmilyBourne opened this issue Feb 24, 2025 · 0 comments · May be fixed by #112

Comments

@EmilyBourne
Copy link
Member

The result of a call to VectorField::operator() is a Vector object. However this object is created from copies of the elements of the vectors. This happens because the memory returned from VectorField is non-contiguous. One solution would be to use std::tuple in Tensor and allow the ElementType to be a reference. This was tried in #109 however std::tuple methods are not supported on GPU. For now we have to live with this restriction. This prevents us from doing things like:

void update_element(host_t<VectorField<double, IdxRangeXY, NDTag<X, Y>>> my_vec_field, DVector<X, Y> new_val, IdxXY pos) {
    my_vec_field(pos) = new_val;
}

However currently this code does not raise an error. It simply modifies the temporary Vector that was created, leaving my_vec_field unchanged. Instead VectorField::operator() should return a const object to ensure that an error is raised to avoid accidental bugs when writing code like this.

@EmilyBourne EmilyBourne linked a pull request Feb 24, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant