28 lines
964 B
C++
28 lines
964 B
C++
/**
|
|
* \brief A class handles device memory allocate and free
|
|
* \author Nan Zhou, nanzhou at kneron dot us
|
|
* \copyright 2019 Kneron Inc. All right reserved.
|
|
*/
|
|
|
|
#ifndef PIANO_DYNASTY_INCLUDE_CUDA_DEVICEARRAYMANAGER_H_
|
|
#define PIANO_DYNASTY_INCLUDE_CUDA_DEVICEARRAYMANAGER_H_
|
|
|
|
#include <cuda_runtime.h>
|
|
#include <cublas_v2.h>
|
|
|
|
namespace dynasty {
|
|
namespace cuda {
|
|
template<typename T>
|
|
class DeviceArrayManager {
|
|
public:
|
|
static T *Make1DArray(size_t n);
|
|
static void Free1DArray(T *device);
|
|
static void Copy1DArrayHostToDevice(T const *host, T *device, size_t n, cudaStream_t const &stream);
|
|
static void Copy1DArrayDeviceToHost(T const *device, T *host, size_t n, cudaStream_t const &stream);
|
|
static void Copy1DArrayDeviceToDevice(T const *src, T *dst, size_t n, cudaStream_t const &stream);
|
|
static void FillZero1DArray(T *device, size_t n, cudaStream_t const &stream);
|
|
};
|
|
}
|
|
}
|
|
#endif //PIANO_DYNASTY_INCLUDE_CUDA_DEVICEARRAYMANAGER_H_
|