IPPL (Independent Parallel Particle Layer)
IPPL
Loading...
Searching...
No Matches
Buffers.cpp
Go to the documentation of this file.
1
//
2
// Buffers.cpp
3
// Interface for globally accessible buffer factory for communication
4
//
5
// Data sent between MPI ranks has to be stored in a buffer for sending and receiving.
6
// To reduce the number of times memory has to be allocated and freed, the buffer
7
// factory interface allows buffers to be reused. This is especially relevant on
8
// GPUs, as Cuda allocation calls are expensive. To avoid reallocating the buffers
9
// in the case that the amount of data to be exchanged increases, when a new buffer
10
// is created, an amount of memory greater than the requested size is allocated
11
// for the new buffer. The factor by which memory is overallocated is determined by
12
// a data member in Communicator, which can be set and queried at runtime. Only new
13
// buffers are overallocated. If a buffer is requested with the same ID as a buffer
14
// that has been previously allocated, the same buffer will be used. If the requested
15
// size exceeds the buffer size, that buffer will be resized to have exactly
16
// the requested size.
17
//
18
// Currently, the buffer factory is used for application of periodic boundary
19
// conditions; halo cell exchange along faces, edges, and vertices; as well as
20
// exchanging particle data between ranks.
21
//
22
23
#include "
Ippl.h
"
24
25
#include "
Communicator.h
"
26
27
namespace
ippl
{
28
namespace
mpi
{
29
30
void
Communicator::setDefaultOverallocation
(
double
factor) {
31
defaultOveralloc_m
= factor;
32
}
33
34
void
Communicator::deleteAllBuffers
() {
35
buffer_handlers_m
.forAll([]<
typename
BufferHandler
>(
BufferHandler
&& bh) {
36
bh.deleteAllBuffers();
37
});
38
}
39
40
void
Communicator::freeAllBuffers
() {
41
buffer_handlers_m
.forAll([]<
typename
BufferHandler
>(
BufferHandler
&& bh) {
42
bh.freeAllBuffers();
43
});
44
}
45
46
}
// namespace mpi
47
}
// namespace ippl
Communicator.h
Ippl.h
ippl
Definition
Archive.h:20
ippl::mpi
Definition
Buffers.cpp:28
ippl::BufferHandler
Interface for memory buffer handling.
Definition
BufferHandler.h:21
ippl::mpi::Communicator::setDefaultOverallocation
void setDefaultOverallocation(double factor)
Definition
Buffers.cpp:30
ippl::mpi::Communicator::freeAllBuffers
void freeAllBuffers()
Definition
Buffers.cpp:40
ippl::mpi::Communicator::defaultOveralloc_m
double defaultOveralloc_m
Definition
Communicator.h:206
ippl::mpi::Communicator::deleteAllBuffers
void deleteAllBuffers()
Definition
Buffers.cpp:34
ippl::mpi::Communicator::buffer_handlers_m
buffer_handler_type buffer_handlers_m
Definition
Communicator.h:204