Skip to content

Conversation

lwJi
Copy link
Contributor

@lwJi lwJi commented Oct 14, 2025

No description provided.

@lwJi lwJi requested review from eschnett and rhaas80 October 14, 2025 02:42
@eschnett
Copy link
Collaborator

Why do you want to use pinned particles? What is the advantage?

@lwJi
Copy link
Contributor Author

lwJi commented Oct 14, 2025

Why do you want to use pinned particles? What is the advantage?

I was using the Multipole which uses the interpolator when interpolating Psi4 on to a few spheres. I noticed that running it on GPU (nvidia) is much slower compare to run it on CPU. So I timer all the functions carefully and found out these segments of codes cause the slowdown. Then I post my problem on AMREX discussion and the AMReX people suggest to use pinned memory to solve the issue, which it did.
AMReX-Codes/amrex#4506

@eschnett
Copy link
Collaborator

Does this improve the speed? I do not understand how it works.

The code that uses pinned memory runs in the CPU, it's the code inserting particles into the AMReX data structures. In the end, these data structures are copied out of the pinned and into the regular memory again.

@eschnett
Copy link
Collaborator

Do you have a test case?

@rhaas80
Copy link
Member

rhaas80 commented Oct 14, 2025

Does this improve the speed? I do not understand how it works.

The code that uses pinned memory runs in the CPU, it's the code inserting particles into the AMReX data structures. In the end, these data structures are copied out of the pinned and into the regular memory again.

It seems to mostly follow the code in AMReX-Codes/amrex#4506 (reply in thread) which was judged "basic approach looks right to me" by the AMReX crowd). But not tested by them.

@lwJi
Copy link
Contributor Author

lwJi commented Oct 14, 2025

The fix to the old version worked and it was much faster.
I'm testing the current fix now and make sure it works and improve the speed as well

@lwJi
Copy link
Contributor Author

lwJi commented Oct 14, 2025

Does this improve the speed? I do not understand how it works.

The code that uses pinned memory runs in the CPU, it's the code inserting particles into the AMReX data structures. In the end, these data structures are copied out of the pinned and into the regular memory again.

One of the comments from the AMReX discussion mentioned that push_back actually launches a GPU kernel

@eschnett
Copy link
Collaborator

#354

@lwJi lwJi closed this Oct 14, 2025
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 this pull request may close these issues.

3 participants