You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 13, 2022. It is now read-only.
Jan Stephan edited this page Dec 9, 2016
·
1 revision
Using allocators with pool_allocator
Allocators are needed when working with pool_allocator. There are 1D, 2D and 3D allocators for (pinned) host memory and device memory - the latter is pitched when using a 2D or 3D memory layout. They are also not interchangeable; a 1D allocator will never be able to allocate 2D memory and vice versa.
To declare them, pass the desired type and the memory layout as template parameters:
#include<glados/cuda/memory.h>using host_allocator_1D = glados::cuda::host_allocator<float, glados::memory_layout::pointer_1D>;
using device_allocator_2D = glados::cuda::device_allocator<float, glados::memory_layout::pointer_2D>;
using pool_allocator_host_1D = glados::pool_allocator<float, glados::memory_layout::pointer_1D, host_allocator_1D>;
using pool_allocator_device_2D = glados::pool_allocator<float, glados::memory_layout::pointer_2D, device_allocator_2D>;
Other use cases
GLADOS' allocators are designed to operate with GLADOS' pool_allocator - they have never been tested as a replacement for the STL's allocator. For almost all cases users will never need to call their member functions directly - the CUDA memory management section of this wiki will suffice. DO NOT CONTINUE TO FOLLOW THIS PATH unless you know exactly what you are doing. Using GLADOS' allocators in a program is error-prone and likely to cause memory leaks. You have been warned.
However, their interface is very similar to std::allocator while offering (template) specializations for 2D and 3D objects. If you know std::allocator you will easily grasp the concept of these allocators (just add the extra dimensions as needed).