Dragon - C++ API
A Computation Graph Virtual Machine Based Deep Learning Framework
Public Member Functions | Static Public Member Functions | List of all members
dragon::CNMLContext Class Reference

#include <context_cnml.h>

Public Member Functions

 CNMLContext (const DeviceOption &option)
 Default Constructor. More...
 
 CNMLContext (const int device_id=0)
 Constructor with the specified device id. More...
 
void SwitchToDevice (int stream_id)
 Switch to the device with the given stream. More...
 
void SwitchToDevice ()
 Switch to the device of this context. More...
 
void FinishDeviceCompution ()
 Synchronize the dispatched operations. More...
 
void MemsetAsync (size_t nbytes, void *ptr)
 Zero-Reset the memory asynchronously. More...
 
template<class DstContext , class SrcContext >
void MemcpyAsync (size_t nbytes, void *dst, const void *src)
 Copy the memory with given type asynchronously. More...
 
int device_id () const
 Return the device id. More...
 
int stream_id () const
 Return the stream id. More...
 
void set_stream_id (int stream_id)
 Set the stream id. More...
 
cnrtStream_t cnrt_stream ()
 Return the internal cnrt stream. More...
 

Static Public Member Functions

static void * New (size_t nbytes)
 Malloc the memory. More...
 
static void Memset (size_t nbytes, void *ptr)
 Zero-Reset the memory. More...
 
template<class DstContext , class SrcContext >
static void Memcpy (size_t nbytes, void *dst, const void *src)
 Copy the memory. More...
 
static void Delete (void *data)
 Free the memory. More...
 
static cnrtStream_t cnrt_stream (int device_id, int stream_id)
 Return the specified cnrt stream. More...
 
static std::mutex & mutex ()
 Return the global context locker. More...
 
static CNRTObject * obj ()
 Return the thread local cnrt object. More...
 

Constructor & Destructor Documentation

◆ CNMLContext() [1/2]

dragon::CNMLContext::CNMLContext ( const DeviceOption &  option)
inline

Default Constructor.

◆ CNMLContext() [2/2]

dragon::CNMLContext::CNMLContext ( const int  device_id = 0)
inline

Constructor with the specified device id.

Member Function Documentation

◆ cnrt_stream() [1/2]

cnrtStream_t dragon::CNMLContext::cnrt_stream ( )
inline

Return the internal cnrt stream.

◆ cnrt_stream() [2/2]

static cnrtStream_t dragon::CNMLContext::cnrt_stream ( int  device_id,
int  stream_id 
)
static

Return the specified cnrt stream.

◆ Delete()

static void dragon::CNMLContext::Delete ( void *  data)
static

Free the memory.

◆ device_id()

int dragon::CNMLContext::device_id ( ) const
inline

Return the device id.

◆ FinishDeviceCompution()

void dragon::CNMLContext::FinishDeviceCompution ( )

Synchronize the dispatched operations.

◆ Memcpy()

template<class DstContext , class SrcContext >
static void dragon::CNMLContext::Memcpy ( size_t  nbytes,
void *  dst,
const void *  src 
)
static

Copy the memory.

◆ MemcpyAsync()

template<class DstContext , class SrcContext >
void dragon::CNMLContext::MemcpyAsync ( size_t  nbytes,
void *  dst,
const void *  src 
)
inline

Copy the memory with given type asynchronously.

◆ Memset()

static void dragon::CNMLContext::Memset ( size_t  nbytes,
void *  ptr 
)
static

Zero-Reset the memory.

◆ MemsetAsync()

void dragon::CNMLContext::MemsetAsync ( size_t  nbytes,
void *  ptr 
)
inline

Zero-Reset the memory asynchronously.

◆ mutex()

static std::mutex& dragon::CNMLContext::mutex ( )
inlinestatic

Return the global context locker.

◆ New()

static void* dragon::CNMLContext::New ( size_t  nbytes)
static

Malloc the memory.

◆ obj()

static CNRTObject* dragon::CNMLContext::obj ( )
static

Return the thread local cnrt object.

◆ set_stream_id()

void dragon::CNMLContext::set_stream_id ( int  stream_id)
inline

Set the stream id.

◆ stream_id()

int dragon::CNMLContext::stream_id ( ) const
inline

Return the stream id.

◆ SwitchToDevice() [1/2]

void dragon::CNMLContext::SwitchToDevice ( int  stream_id)

Switch to the device with the given stream.

◆ SwitchToDevice() [2/2]

void dragon::CNMLContext::SwitchToDevice ( )
inline

Switch to the device of this context.


The documentation for this class was generated from the following file: