vecmem 1.18.0
Loading...
Searching...
No Matches
device_memory_resource.hpp
1/*
2 * VecMem project, part of the ACTS project (R&D line)
3 *
4 * (c) 2021-2025 CERN for the benefit of the ACTS project
5 *
6 * Mozilla Public License Version 2.0
7 */
8
9#pragma once
10
11// Local include(s).
12#include "vecmem/memory/memory_resource.hpp"
13#include "vecmem/vecmem_cuda_export.hpp"
14
16namespace vecmem::cuda {
17
25class device_memory_resource final : public memory_resource {
26
27public:
29 static constexpr int INVALID_DEVICE = -1;
30
45 explicit device_memory_resource(int device = INVALID_DEVICE);
49
50private:
53
56 void* do_allocate(std::size_t, std::size_t) override;
59 void do_deallocate(void* p, std::size_t, std::size_t) override;
62 bool do_is_equal(const memory_resource& other) const noexcept override;
63
65
67 const int m_device;
68
69}; // class device_memory_resource
70
71} // namespace vecmem::cuda
An allocator class that wraps a memory resource.
Definition allocator.hpp:37
Memory resource that wraps direct allocations on a CUDA device.
Definition device_memory_resource.hpp:25
VECMEM_CUDA_EXPORT void * do_allocate(std::size_t, std::size_t) override
Allocate memory on the selected device.
Definition device_memory_resource.cpp:36
VECMEM_CUDA_EXPORT bool do_is_equal(const memory_resource &other) const noexcept override
Compares *this for equality with other.
Definition device_memory_resource.cpp:69
VECMEM_CUDA_EXPORT ~device_memory_resource() override
Destructor.
static constexpr int INVALID_DEVICE
Invalid/default device identifier.
Definition device_memory_resource.hpp:29
VECMEM_CUDA_EXPORT void do_deallocate(void *p, std::size_t, std::size_t) override
De-allocate a previously allocated memory block on the selected device.
Definition device_memory_resource.cpp:53
Namespace holding types that work on/with CUDA.
Definition cuda_device_atomic_ref.hpp:19