2#include <cuda_runtime.h>
4#include "gint_helper.cuh"
18 this->
size_ = other.size_;
22 other.device_ptr_ =
nullptr;
23 other.host_ptr_ =
nullptr;
25 other.malloc_host_ =
false;
35 this->
size_ = other.size_;
39 other.device_ptr_ =
nullptr;
40 other.host_ptr_ =
nullptr;
42 other.malloc_host_ =
false;
49 cudaStream_t stream = 0,
50 bool malloc_host =
true)
123 checkCuda(cudaMemset(
device_ptr_, value, size *
sizeof(
T)));
145 checkCuda(cudaMemset(
host_ptr_, value, size *
sizeof(
T)));
Definition cuda_mem_wrapper.h:8
T * get_host_ptr()
Definition cuda_mem_wrapper.h:160
void free()
Definition cuda_mem_wrapper.h:153
T * get_device_ptr()
Definition cuda_mem_wrapper.h:159
CudaMemWrapper & operator=(CudaMemWrapper &&other) noexcept
Definition cuda_mem_wrapper.h:29
void memset_device_sync(const int value=0)
Definition cuda_mem_wrapper.h:126
CudaMemWrapper(const CudaMemWrapper &other)=delete
cudaStream_t stream_
Definition cuda_mem_wrapper.h:170
void copy_device_to_host_sync(size_t size)
Definition cuda_mem_wrapper.h:97
T * host_ptr_
Definition cuda_mem_wrapper.h:167
void memset_device_sync(const size_t size, const int value=0)
Definition cuda_mem_wrapper.h:121
void copy_host_to_device_async(size_t size)
Definition cuda_mem_wrapper.h:85
size_t get_size() const
Definition cuda_mem_wrapper.h:163
const T * get_host_ptr() const
Definition cuda_mem_wrapper.h:162
~CudaMemWrapper()
Definition cuda_mem_wrapper.h:68
void copy_device_to_host_async()
Definition cuda_mem_wrapper.h:116
void memset_device_async(const size_t size, const int value=0)
Definition cuda_mem_wrapper.h:131
void copy_device_to_host_sync()
Definition cuda_mem_wrapper.h:104
CudaMemWrapper(size_t size, cudaStream_t stream=0, bool malloc_host=true)
Definition cuda_mem_wrapper.h:48
void copy_host_to_device_async()
Definition cuda_mem_wrapper.h:92
bool malloc_host_
Definition cuda_mem_wrapper.h:169
size_t size_
Definition cuda_mem_wrapper.h:168
void memset_host(const int value=0)
Definition cuda_mem_wrapper.h:148
T * device_ptr_
Definition cuda_mem_wrapper.h:166
void copy_host_to_device_sync(size_t size)
Definition cuda_mem_wrapper.h:73
CudaMemWrapper & operator=(const CudaMemWrapper &other)=delete
void copy_host_to_device_sync()
Definition cuda_mem_wrapper.h:80
void memset_host(const size_t size, const int value=0)
Definition cuda_mem_wrapper.h:141
void copy_device_to_host_async(size_t size)
Definition cuda_mem_wrapper.h:109
CudaMemWrapper(CudaMemWrapper &&other) noexcept
Definition cuda_mem_wrapper.h:14
const T * get_device_ptr() const
Definition cuda_mem_wrapper.h:161
void memset_device_async(const int value=0)
Definition cuda_mem_wrapper.h:136
#define T
Definition exp.cpp:237
void WARNING_QUIT(const std::string &, const std::string &)
Combine the functions of WARNING and QUIT.
Definition test_delley.cpp:14