5#ifndef GKO_PUBLIC_CORE_BASE_MEMORY_HPP_
6#define GKO_PUBLIC_CORE_BASE_MEMORY_HPP_
9#include <ginkgo/core/base/fwd_decls.hpp>
10#include <ginkgo/core/base/types.hpp>
24 virtual void* allocate(
size_type num_bytes) = 0;
26 virtual void deallocate(
void* ptr) = 0;
41 friend class CudaExecutor;
55 virtual bool check_environment(
int device_id, CUstream_st* stream)
const
66 friend class HipExecutor;
80 virtual bool check_environment(
int device_id,
81 GKO_HIP_STREAM_STRUCT* stream)
const
93 void* allocate(
size_type num_bytes)
override;
95 void deallocate(
void* ptr)
override;
104 void* allocate(
size_type num_bytes)
override;
106 void deallocate(
void* ptr)
override;
115 void* allocate(
size_type num_bytes)
override;
117 void deallocate(
void* ptr)
override;
119 CudaAsyncAllocator(CUstream_st* stream);
124 CUstream_st* stream_;
133 void* allocate(
size_type num_bytes)
override;
135 void deallocate(
void* ptr)
override;
137 CudaUnifiedAllocator(
int device_id);
139 CudaUnifiedAllocator(
int device_id,
unsigned int flags);
142 bool check_environment(
int device_id, CUstream_st* stream)
const override;
155 void* allocate(
size_type num_bytes)
override;
157 void deallocate(
void* ptr)
override;
159 CudaHostAllocator(
int device_id);
162 bool check_environment(
int device_id, CUstream_st* stream)
const override;
174 void* allocate(
size_type num_bytes)
override;
176 void deallocate(
void* ptr)
override;
185 void* allocate(
size_type num_bytes)
override;
187 void deallocate(
void* ptr)
override;
189 HipAsyncAllocator(GKO_HIP_STREAM_STRUCT* stream);
192 bool check_environment(
int device_id,
193 GKO_HIP_STREAM_STRUCT* stream)
const override;
196 GKO_HIP_STREAM_STRUCT* stream_;
205 void* allocate(
size_type num_bytes)
override;
207 void deallocate(
void* ptr)
override;
209 HipUnifiedAllocator(
int device_id);
211 HipUnifiedAllocator(
int device_id,
unsigned int flags);
214 bool check_environment(
int device_id,
215 GKO_HIP_STREAM_STRUCT* stream)
const override;
228 void* allocate(
size_type num_bytes)
override;
230 void deallocate(
void* ptr)
override;
232 HipHostAllocator(
int device_id);
235 bool check_environment(
int device_id,
236 GKO_HIP_STREAM_STRUCT* stream)
const override;
Provides generic allocation and deallocation functionality to be used by an Executor.
Definition memory.hpp:20
Implement this interface to provide an allocator for OmpExecutor or ReferenceExecutor.
Definition memory.hpp:34
Allocator using new/delete.
Definition memory.hpp:91
Implement this interface to provide an allocator for CudaExecutor.
Definition memory.hpp:40
Allocator using cudaMalloc.
Definition memory.hpp:102
bool check_environment(int device_id, CUstream_st *stream) const override
Checks if the allocator can be used safely with the provided device ID and stream.
Implement this interface to provide an allocator for HipExecutor.
Definition memory.hpp:65
Definition memory.hpp:172
The Ginkgo namespace.
Definition abstract_factory.hpp:20
std::size_t size_type
Integral type used for allocation quantities.
Definition types.hpp:90