Using AMReX for GPUs - is_device_ptr equivalent? #4227
Unanswered
ElloiseFangelLloyd
asked this question in
Q&A
Replies: 1 comment 1 reply
-
Hi Elloise, The The -Andrew |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Edit: removed confusing leftovers in code.
Hello
I have a Monte Carlo particle code which is well optimised for GPU usage. I'd like to use the
MLPoisson
solver to update the fields at given intervals. I'm using OpenMP for parallelism and offloading.My implementation stores the particles - I'm simulating electrons - exclusively on the device - there is no copy on the host. When I do my simulations, I can specify
is_device_ptr()
in the#pragma omp target
statement, and then pass a pointer to the location of the particles in device memory. Then I can do operations on them. This all works well.I have a scheme to deposit these particles onto a
MultiFab
using theMFIter
, which is then fed to the solver. The scheme works well on the CPU, but I am encountering issues when working on the GPU. Passing the particle pointer gives aSegmentation fault
, presumably because AMReX looks in host memory and finds nothing. Is there a way to specify to AMReX that the information exists only on the device - and pass it an address? Similar to theis_device_ptr()
clause from OpenMP?I have looked at the very nice Electrostatic PIC in the AMReX example codes for inspiration - however, particle collisions are a very large part of my project here, and require careful handling on the GPU, hence building something from scratch.
My particle deposition scheme:
I get the segmentation fault in the line
size_t current_size = electrons->num_particles
, so when it tries to accesselectrons
and finds nothing.I have also tried enclosing the whole thing in a
#pragma omp target
region, but this gave compiler linker errors to theMFIter
file, and does not seem like the right approach.Does anyone know of any similar/equivalent approaches to the
is_device_ptr()
implemented in OpenMP - or other ideas?Thank you very much in advance!!
Beta Was this translation helpful? Give feedback.
All reactions