CPUContext¶
- class
CPUContext¶ The cpu device context.
Constructors¶
- inline
dragon::CPUContext::CPUContext()¶ Constructor.
- inline explicit
dragon::CPUContext::CPUContext(unsigned int random_seed)¶ Constructor with the random seed.
- inline explicit
dragon::CPUContext::CPUContext(const DeviceOption &option)¶ Constructor with the device option.
Public Properties¶
device¶
- inline int
dragon::CPUContext::device() const¶ Return the device index.
rand_generator¶
- inline std::mt19937 *
dragon::CPUContext::rand_generator()¶ Return the random generator.
stream¶
- inline int
dragon::CPUContext::stream() const¶ Return the stream index.
workspace¶
- Workspace *
dragon::CPUContext::workspace()¶ Return the current workspace.
set_stream¶
- inline void
dragon::CPUContext::set_stream(int stream)¶ Set the stream index.
Public Functions¶
Copy¶
- template<typename
T, classDestContext, classSrcContext>
static inline voiddragon::CPUContext::Copy(
int n,
T *dest,
const T *src)¶ Copy a typed memory block to the destination.
Delete¶
- static inline void
dragon::CPUContext::Delete(void *ptr)¶ Deallocate a memory block.
FinishDeviceComputation¶
- inline void
dragon::CPUContext::FinishDeviceComputation()¶ Wait for the dispatched computation to complete.
Memset¶
- static inline void
dragon::CPUContext::Memset(
size_t n,
void *ptr,
int value = 0)¶ Set a memory block to the given value.
MemsetAsync¶
- inline void
dragon::CPUContext::MemsetAsync(
size_t n,
void *ptr,
int value)¶ Set a memory block to the given value asynchronously.
Memcpy¶
- template<class
DestContext, classSrcContext>
static inline voiddragon::CPUContext::Memcpy(
size_t n,
void *dest,
const void *src)¶ Copy a memory block to the destination.
MemcpyAsync¶
- template<class
DestContext, classSrcContext>
inline voiddragon::CPUContext::MemcpyAsync(
size_t n,
void *dest,
const void *src)¶ Copy a memory block to the destination asynchronously.
New¶
- static inline void *
dragon::CPUContext::New(size_t size)¶ Allocate a block of memory.
SwitchToDevice¶
- inline void
dragon::CPUContext::SwitchToDevice(int stream_id = 0)¶ Switch to the device and select given stream in current thread.