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

DeviceAgentVector out of scope. #522

Closed
Robadob opened this issue May 5, 2021 · 0 comments · Fixed by #751
Closed

DeviceAgentVector out of scope. #522

Robadob opened this issue May 5, 2021 · 0 comments · Fixed by #751
Labels

Comments

@Robadob
Copy link
Member

Robadob commented May 5, 2021

FLAMEGPU_HOST_FUNCTION(DeviceAgentVectorBirth) {
    DeviceAgentVector vec_a = FLAMEGPU->agent("agent", "a").getPopulationData();
    DeviceAgentVector vec_b = FLAMEGPU->agent("agent", "b").getPopulationData();
    const uint32_t birth_ct_a = vec_a.size();  // Access violation here
    const uint32_t birth_ct_b = vec_b.size();
}

vec_a is owned by the temporary object created by FLAMEGPU->agent("agent", "a"), as such by the time it is used it has been deallocated.

Presumed fix would be centralise the storage inside the main HostAPI object or the respective CUDAAgent.

@Robadob Robadob added the bug label May 5, 2021
@Robadob Robadob added this to the v2.0.0-alpha.N milestone Aug 25, 2021
Robadob added a commit that referenced this issue Dec 10, 2021
DeviceAgentVector's root shared_ptr is now owned by the CUDAAgent.

This has a tiny optimisation benefit of reducing unnecessary syncs, if consecutive host fns use the same device vector.

Closes #522
Robadob added a commit that referenced this issue Dec 10, 2021
DeviceAgentVector's root shared_ptr is now owned by the CUDAAgent.

This has a tiny optimisation benefit of reducing unnecessary syncs, if consecutive host fns use the same device vector.

Closes #522
mondus pushed a commit that referenced this issue Dec 14, 2021
DeviceAgentVector's root shared_ptr is now owned by the CUDAAgent.

This has a tiny optimisation benefit of reducing unnecessary syncs, if consecutive host fns use the same device vector.

Closes #522
@Robadob Robadob modified the milestones: v2.0.0-alpha.N, v2.0.0-alpha.3 Jan 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant