MPSContext¶
- class
MPSContext¶ The MPS device context.
Constructors¶
- inline
dragon::MPSContext::MPSContext()¶ Constructor.
- inline explicit
dragon::MPSContext::MPSContext(int device)¶ Constructor with the device index.
- inline explicit
dragon::MPSContext::MPSContext(const DeviceOption &option)¶ Constructor with the device option.
Public Properties¶
current_device¶
- static inline int
dragon::MPSContext::current_device()¶ Return the device index of current thread.
device¶
- inline int
dragon::MPSContext::device() const¶ Return the device index.
mps_stream¶
- inline MPSStream *
dragon::MPSContext::mps_stream()¶ Return the current mps stream.
mutex¶
- static std::mutex &
dragon::MPSContext::mutex()¶ Return the shared context mutex.
objects¶
- static MPSObjects &
dragon::MPSContext::objects()¶ Return the thread-local mps objects.
rand_generator¶
- inline std::mt19937 *
dragon::MPSContext::rand_generator()¶ Return the random generator.
stream¶
- inline int
dragon::MPSContext::stream() const¶ Return the stream index.
workspace¶
- inline Workspace *
dragon::MPSContext::workspace()¶ Return the current workspace.
workspace¶
- inline Workspace *
dragon::MPSContext::workspace(
int device,
int stream)¶ Return the specified workspace.
set_stream¶
- inline void
dragon::MPSContext::set_stream(int stream)¶ Set the stream index.
Public Functions¶
Delete¶
- static void
dragon::MPSContext::Delete(void *ptr)¶ Deallocate a buffer.
FinishDeviceComputation¶
- inline void
dragon::MPSContext::FinishDeviceComputation()¶ Wait for the dispatched computation to complete.
Memset¶
- static void
dragon::MPSContext::Memset(
size_t n,
void *ptr,
int value = 0)¶ Set a buffer to the given value.
MemsetAsync¶
- void
dragon::MPSContext::MemsetAsync(
size_t n,
void *ptr,
int value = 0)¶ Set a buffer to the given value asynchronously.
Memcpy¶
- template<class
DestContext, classSrcContext>
static inline voiddragon::MPSContext::Memcpy(
size_t n,
void *dest,
const void *src)¶ Copy a buffer to the destination.
Memcpy¶
- template<class
DestContext, classSrcContext>
static voiddragon::MPSContext::Memcpy(
size_t n,
void *dest,
const void *src,
int device)¶ Copy a bufferto the destination using given device.
MemcpyAsync¶
- template<class
DestContext, classSrcContext>
voiddragon::MPSContext::MemcpyAsync(
size_t n,
void *dest,
const void *src)¶ Copy a buffer to the destination asynchronously.
New¶
- static void *
dragon::MPSContext::New(size_t size)¶ Allocate a device buffer.
SwitchToDevice¶
- inline void
dragon::MPSContext::SwitchToDevice(int stream_id = 0)¶ Switch to the device and select given stream in current thread.
SynchronizeStream¶
- static inline void
dragon::MPSContext::SynchronizeStream(MPSStream *stream)¶ Synchronize the given stream.