-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgpu_memory.h
39 lines (32 loc) · 1.35 KB
/
gpu_memory.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//
// Created by andrey on 06.03.2021.
//
#ifndef MOTIF_FINDER_GPU_MEMORY_H
#define MOTIF_FINDER_GPU_MEMORY_H
#include <memory>
#include <driver_types.h>
class IGpuMemory {
public:
virtual cudaError_t MALLOC(void **devPtr, std::size_t size) = 0;
virtual void *MEMCPY_TO_DEVICE(void *dest, const void *src, std::size_t count) = 0;
virtual void *MEMCPY_TO_HOST(void *dest, const void *src, std::size_t count) = 0;
virtual void *MEMSET(void *ptr, int value, std::size_t num) = 0;
virtual ~IGpuMemory();
};
class UnifiedGpuMemory : public IGpuMemory {
public:
cudaError_t MALLOC(void **devPtr, std::size_t size) override;
void *MEMCPY_TO_DEVICE(void *dest, const void *src, std::size_t count) override;
void *MEMCPY_TO_HOST(void *dest, const void *src, std::size_t count) override;
void *MEMSET(void *ptr, int value, std::size_t num) override;
};
class NonUnifiedGpuMemory : public IGpuMemory {
public:
cudaError_t MALLOC(void **devPtr, std::size_t size) override;
void *MEMCPY_TO_DEVICE(void *dest, const void *src, std::size_t count) override;
void *MEMCPY_TO_HOST(void *dest, const void *src, std::size_t count) override;
void *MEMSET(void *ptr, int value, std::size_t num) override;
};
using GpuMemoryPtr = std::shared_ptr<IGpuMemory>;
GpuMemoryPtr create_memory_allocator(bool unified);
#endif //MOTIF_FINDER_GPU_MEMORY_H