Skip to content

PMacc data types [Buffer]

Axel Huebl edited this page Sep 8, 2015 · 11 revisions

You are here: Home > Developer Documentation


This page gives an overview of the data containers in PMacc.

Their according iterators are called Box(es) in PMacc.

Naming

Buffer is a container that holds or points to memory

Array Based Buffers

  • array buffers are located in libPMacc/include/memory/buffers
  • buffers:
    • are container of real memory, which is located on either an accelerator/host or both
    • or can be constructed from a combination of other buffers

Buffers with Real Memory

In the most cases buffer types are a combination of [memory location]Buffer (the interface), Buffer (generic interface) and [memory location]BufferIntern (implementation).

  • DeviceBuffer/ DeviceBufferIntern
    • contains device memory
    • memory is set to zero on initialization
    • line by line aligned (if multi dimensional)
    • number of elements (current size) is available on device (optional)
    • can point to existing device memory (optional)
  • HostBuffer/ HostBufferIntern
    • contains host memory
    • memory is set to zero on initialization
    • multi dimensional memory is not aligned
  • Exchange/ExchangeIntern
    • buffer to communicate guarding cells (ghost cells)
    • contains host buffer
    • points to a subset of an existing device buffer (host and device size are the same)
    • linear device double buffer of subset were the device buffer points to (only existing on multi dimensional exchanges) [ used to speed up memory copies from host2device and device2host ]
  • MappedBuffer
    • contains host buffer that can be accessed directly from a device
    • memory is set to zero on initialization
    • same interface like DeviceBuffer
    • not aligned

Combined Buffers

  • GridBuffer
    • complex buffer that contains a DeviceBuffer and a HostBuffer
    • ExchangeBuffer can be added at runtime for every surface of the memory (1D -- <=2 exchanges, 2D -- <= 8 exchanges, 3D -- <=26 exchanges)
    • contains methods for asynchronous communication of the exchanges
    • definition: GridBuffer<DataType, DIM1> *myGridBuffer; (psychocoderHPC: we shouln't show interfaces in the WIKI, maybe we can add a example code section here?)
    • initialization: myGridBuffer = new GridBuffer<DataType, DIM1 > (DataSpace<DIM1 > (NumberOfElements));
    • copy to host: myGridBuffer->deviceToHost();
    • get pointer to memory on host: myGridBuffer->getHostBuffer().getBasePointer()
    • get pointer to memory on the device: myGridBuffer->getDeviceBuffer().getDataBox()
    • free buffer: __delete(myGridBuffer);
    • delete data on device: myGridBuffer->getDeviceBuffer().reset(false);
  • MultiGridBuffer
    • creates multiple GridBuffers of the same native data type and size in one big memory chunk
    • every GridBuffer can be accessed by an enum
    • exchanges can be set separately for one GridBuffer or for all
    • the used iterator MultiBox has a small memory footprint in contrast to multiple GridBuffers

Particle Buffers

Particle buffers are located in libPMacc/include/particles/memory/buffers

  • HeapBuffer
    • not longer needed and supported after we switched to the memory controller mallocMC
  • RingBuffer
    • not longer needed and supported after we switched to the memory controller mallocMC
  • StackExchangeBuffer
    • ???
  • ParticleBuffer
    • cool stuff