How to correctly copy particle data from GPU to CPU in AMReX? #4683
-
|
Hello everyone, I’m currently developing a custom solver based on the I followed a suggestion from a previous discussion and tried the following approach: However, I encounter different errors depending on which option I use: Option 1:I get a runtime error during the copyParticles call: Option 2:The code compiles and runs past the copy stage, but it crashes at:
Some additional context:
My main question is: What is the correct and recommended way to copy particle data from GPU memory to CPU memory so that I can safely access it on the host?If there are specific examples or idiomatic patterns for doing this in AMReX, I would greatly appreciate any pointers or code snippets. Thank you very much! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
I think there was a mistake in the answer to the first discussion. This should work; however, from a performance standpoint, I would expect it to be better to not copy the particles to the CPU and to instead copy the solver output to the GPU and use ParallelFor to update the particles. |
Beta Was this translation helpful? Give feedback.
I think there was a mistake in the answer to the first discussion.
std::allocatoris allocated and accessible on the CPU; however, it is not accessible by the GPU. Instead,amrex::PinnedArenaAllocatorshould be used, which is also allocated in CPU memory but is accessible by both the CPU and GPU.This should work; however, from a performance standpoint, I would expect it to be better to not copy the particles to the CPU and to instead copy the solver output to the GPU and use ParallelFor to update the particles.