25#ifndef GPU_CUDA_DEVICE_H
26#define GPU_CUDA_DEVICE_H
28#include <cuda_runtime_api.h>
52void copyToHost(
void* src,
void* dst, std::size_t count);
54void copyToDevice(
void* src,
void* dst, std::size_t count);
58T*
malloc(std::size_t size);
67 const std::size_t size = ((count *
sizeof(T) - 1) / page_size + 1) * page_size;
68 const std::size_t volume = size /
sizeof(T);
70 if (size % page_size != 0) {
71 throw std::invalid_argument(
"Buffer size must be multiple of PAGE_SIZE");
123 cudaStream_t _stream;
126 Stream(
unsigned int flags);
138void asyncCopyToHost(Stream& stream,
void* src,
void* dst, std::size_t count);
Basic wrapper for device stream.
Stream(unsigned int flags)
Managed pointer for device-side memory.
unique_ptr & operator=(unique_ptr &&rhs)
unique_ptr & operator=(T *ptr)
unique_ptr(unique_ptr &&rhs)
std::size_t getDevicePageSize()
Returns device memory page size.
void copyToHost(void *src, void *dst, std::size_t count)
Copy data from device to host.
std::size_t getPageAlignedCount(std::size_t count)
Returns count rounded up to be a multiple of getDevicePageSize
void copyToDevice(void *src, void *dst, std::size_t count)
Copy data from host to device.
int getCount()
Return number of available devices.
void asyncCopyToDevice(Stream &stream, void *src, void *dst, std::size_t count)
Copy data from host to device (async)
void asyncCopyToHost(Stream &stream, void *src, void *dst, std::size_t count)
Copy data from device to host (async)
void check()
Check errors.
int get()
Get current device.
T * malloc(std::size_t size)
Allocate data on device.
void synchronize()
Synchronize device.
Top level namespace for all of OpenLB.