Skip to content

amrex::Gpu::htod_memcpy and making ExampleCodes/GPU/CNS portable to MPI+OpenMP #2929

Answered by WeiqunZhang
colinmcnally asked this question in Q&A
Discussion options

You must be logged in to vote

That seems to work. Is there a tidier way to make this happen automatically? A different AMReX htod_memcpy which still exists and does something same when GPU support is not used so changes like the second one are not needed?

You could do amrex::copy(amrex::Gpu::hostToDevice, &CNS::h_prob_parm, &CNS::h_prob_parm+1, &CNS::d_prob_parm). That will call std::memcpy for CPU builds.

For the MFIter loops, if you want OpenMP, I agree with @BenWibking that you should try tiling. Note that you do have to make some changes in your CPU code for tiling. You can also change where the temporary Fabs are defined to make memory allocation more efficient by reusing the memory. So it will be something like

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@BenWibking
Comment options

@WeiqunZhang
Comment options

Answer selected by colinmcnally
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants