27#include "communication.hpp"
29#include "system/System.hpp"
36#include <boost/serialization/array.hpp>
37#include <boost/serialization/is_bitwise_serializable.hpp>
38#include <boost/serialization/split_free.hpp>
42void GpuParticleData::enable_particle_transfer() {
43 if (m_need_particles_update and not m_communication_enabled) {
45 gpu_init_particle_comm();
47 m_communication_enabled =
true;
51void GpuParticleData::copy_particles_to_device() {
53 copy_particles_to_device(cell_structure.local_particles(),
::this_node);
59 result = has_compatible_device_impl();
68namespace serialization {
69template <
typename Archive>
71 ar >> make_array(
reinterpret_cast<char *
>(&p),
74template <
typename Archive>
76 ar << make_array(reinterpret_cast<char const *>(&p),
87 unsigned long int i = 0
u;
88 for (
auto const &p : particles) {
89 buffer[i].p =
static_cast<Utils::Vector3f>(box.folded_position(p.pos()));
94 buffer[i].q =
static_cast<float>(p.q());
96 buffer[i].identity = p.id();
101void GpuParticleData::gather_particle_data(
107 static std::vector<GpuParticle> buffer;
108 buffer.resize(n_part);
114 particle_data_host.resize(n_part);
134 unsigned long int i = 0
u;
135 for (
auto &p : particles) {
136 for (
unsigned long int j = 0
u; j < 3u; j++) {
137 p.force()[j] +=
static_cast<double>(forces[3ul * i + j]);
139 p.torque()[j] +=
static_cast<double>(torques[3ul * i + j]);
157void GpuParticleData::particles_scatter_forces(
162 auto const n_elements =
static_cast<int>(size);
165 static std::vector<float> buffer_forces;
166 static std::vector<float> buffer_torques;
168 buffer_forces.resize(size);
171 buffer_torques.resize(size);
std::vector< T, CudaHostAllocator< T > > pinned_vector
static void add_forces_and_torques(ParticleRange const &particles, Utils::Span< const float > forces, Utils::Span< const float > torques)
Add a flat force (and torque) array to a range of particles.
static void pack_particles(ParticleRange const &particles, GpuParticleData::GpuParticle *buffer)
Vector implementation and trait types for boost qvm interoperability.
Particle data communication manager for the GPU.
bool has_compatible_device() const
base_type::size_type size() const
std::shared_ptr< CellStructure > cell_structure
std::shared_ptr< BoxGeometry > box_geo
A stripped-down version of std::span from C++17.
DEVICE_QUALIFIER constexpr pointer data() const
boost::mpi::communicator comm_cart
The communicator.
int this_node
The number of this node.
This file contains the defaults for ESPResSo.
ParticleRange particles(Utils::Span< Cell *const > cells)
void gather_buffer(std::vector< T, Allocator > &buffer, boost::mpi::communicator const &comm, int root=0)
Gather buffer with different size on each node.
void scatter_buffer(T *buffer, int n_elem, boost::mpi::communicator comm, int root=0)
Scatter buffer with different size on each node.
void load(Archive &ar, GpuParticleData::GpuParticle &p, unsigned const)
void save(Archive &ar, GpuParticleData::GpuParticle const &p, unsigned const)
Subset of Particle which is copied to the GPU.