-
Notifications
You must be signed in to change notification settings - Fork 183
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
WIP: async GPU force/torque back-transfer, launch kernels earlier #2637
Open
RudolfWeeber
wants to merge
1
commit into
espressomd:python
Choose a base branch
from
RudolfWeeber:gpu_async2
base: python
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,12 @@ | |
#include "ParticleRange.hpp" | ||
#include "SystemInterface.hpp" | ||
|
||
#include "thrust/host_vector.h" | ||
#include "thrust/system/cuda/experimental/pinned_allocator.h" | ||
template <class T> | ||
using PinnedVectorHost = thrust::host_vector< | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be called |
||
T, thrust::system::cuda::experimental::pinned_allocator<T>>; | ||
|
||
#ifdef ENGINE | ||
// velocities which need to be copied from the GPU to the CPU to calculate a | ||
// torque | ||
|
@@ -122,6 +128,7 @@ typedef struct { | |
} CUDA_global_part_vars; | ||
|
||
void copy_forces_from_GPU(ParticleRange particles); | ||
void distribute_gpu_forces(ParticleRange particles); | ||
void copy_energy_from_GPU(); | ||
void copy_CUDA_energy_to_energy(CUDA_energy energy_host); | ||
void clear_energy_on_GPU(); | ||
|
@@ -158,8 +165,8 @@ void copy_part_data_to_gpu(ParticleRange particles); | |
* This is a collective call. | ||
*/ | ||
void cuda_mpi_send_forces(ParticleRange particles, | ||
std::vector<float> &host_forces, | ||
std::vector<float> &host_torques); | ||
PinnedVectorHost<float> &host_forces, | ||
PinnedVectorHost<float> &host_torques); | ||
void cuda_bcast_global_part_params(); | ||
void cuda_copy_to_device(void *host_data, void *device_data, size_t n); | ||
void cuda_copy_to_host(void *host_device, void *device_host, size_t n); | ||
|
@@ -170,6 +177,8 @@ void cuda_mpi_send_v_cs(ParticleRange particles, | |
std::vector<CUDA_v_cs> host_v_cs); | ||
#endif | ||
|
||
void free_cuda_buffers(); | ||
|
||
#endif /* ifdef CUDA */ | ||
|
||
#endif /* ifdef CUDA_INTERFACE_HPP */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -651,3 +651,5 @@ void on_ghost_flags_change() { | |
} | ||
#endif | ||
} | ||
|
||
void on_unload() { free_cuda_buffers(); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't like this construction. I a way this is worse than manual memory management, because it pretends to be RAII, but really isn't. As far as I can see there is not reason for these buffers to exist statically, couldn't you just create them e.g. when the integration starts, and release them after.
Depending on the cost of the allocation, it may even be feasible to create it in the force calculation.