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

#include <mixedmem.h>

Public Types

enum  State {
  UNINITIALIZED, STATE_AT_CPU, STATE_AT_CUDA, STATE_AT_CNML,
  SYNCED
}
 

Public Member Functions

 MixedMemory ()
 Default Constructor. More...
 
 MixedMemory (const TypeMeta &meta, size_t nbytes)
 Constructor with the known meta and size. More...
 
 ~MixedMemory ()
 Deconstructor. More...
 
const void * cpu_data (size_t nbytes=0)
 Return the const data pointer on CPUContext. More...
 
const void * cuda_data (size_t nbytes=0)
 Return the const data pointer on CUDAContext. More...
 
const void * cnml_data ()
 Return the const data pointer on CNMLContext. More...
 
void * mutable_cpu_data (size_t nbytes=0)
 Return the mutable data pointer on CPUContext. More...
 
void * mutable_cuda_data (size_t nbytes=0)
 Return the mutable data pointer on CUDAContext. More...
 
void * mutable_cnml_data ()
 Return the mutable data pointer on CNMLContext. More...
 
void * malloc_cnml_data ()
 Allocate the mlu devive memory. More...
 
void fetch_cnml_data (void **data)
 Copy the mlu device memory to the host. More...
 
cnmlCpuTensor_tcnml_cpu_tensor ()
 Return the binding CNML cpu tensor. More...
 
cnmlTensor_tcnml_mlu_tensor ()
 Return the binding CNML mlu tensor. More...
 
void set_cpu_data (void *cpu_ptr, size_t nbytes)
 Set the cpu data pointer from external context. More...
 
void SwitchToDevice (int device_id)
 Switch to the specified device. More...
 
void SwitchToCUDADevice (int device_id)
 Switch to the specified cuda device. More...
 
size_t nbytes () const
 Return the total bytes of this memory. More...
 
size_t nchunks () const
 Return the chunks of this memory. More...
 
void set_nchunks (size_t nchunks)
 Set the chunks of this memory. More...
 
State state () const
 Return the state of this memory. More...
 
StorageOrder order () const
 Return or Set the storage order. More...
 
void set_order (StorageOrder order)
 Set the storage order. More...
 
int device_id () const
 Return the device id of the memory on device. More...
 
const Map< string, string > info () const
 Return a string to describe the internal structure. More...
 
void ToCPU (size_t nbytes=0)
 Control the state machine to CPUContext. More...
 
void ToCUDA (size_t nbytes=0)
 Control the state machine to CUDAContext. More...
 

Member Enumeration Documentation

◆ State

Enumerator
UNINITIALIZED 

Initial state.

STATE_AT_CPU 

Memory could be modified by CPUContext last time.

STATE_AT_CUDA 

Memory could be modified by CUDAContext last time.

STATE_AT_CNML 

Memory could be modified by CNMLContext last time.

SYNCED 

Host and Device now hold the same contents.

Constructor & Destructor Documentation

◆ MixedMemory() [1/2]

dragon::MixedMemory::MixedMemory ( )
inline

Default Constructor.

◆ MixedMemory() [2/2]

dragon::MixedMemory::MixedMemory ( const TypeMeta meta,
size_t  nbytes 
)
inline

Constructor with the known meta and size.

◆ ~MixedMemory()

dragon::MixedMemory::~MixedMemory ( )

Deconstructor.

Member Function Documentation

◆ cnml_cpu_tensor()

cnmlCpuTensor_t& dragon::MixedMemory::cnml_cpu_tensor ( )

Return the binding CNML cpu tensor.

◆ cnml_data()

const void * dragon::MixedMemory::cnml_data ( )

Return the const data pointer on CNMLContext.

◆ cnml_mlu_tensor()

cnmlTensor_t& dragon::MixedMemory::cnml_mlu_tensor ( )

Return the binding CNML mlu tensor.

◆ cpu_data()

const void * dragon::MixedMemory::cpu_data ( size_t  nbytes = 0)

Return the const data pointer on CPUContext.

◆ cuda_data()

const void * dragon::MixedMemory::cuda_data ( size_t  nbytes = 0)

Return the const data pointer on CUDAContext.

◆ device_id()

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

Return the device id of the memory on device.

◆ fetch_cnml_data()

void dragon::MixedMemory::fetch_cnml_data ( void **  data)

Copy the mlu device memory to the host.

◆ info()

const Map< string, string > dragon::MixedMemory::info ( ) const

Return a string to describe the internal structure.

◆ malloc_cnml_data()

void* dragon::MixedMemory::malloc_cnml_data ( )

Allocate the mlu devive memory.

◆ mutable_cnml_data()

void * dragon::MixedMemory::mutable_cnml_data ( )

Return the mutable data pointer on CNMLContext.

◆ mutable_cpu_data()

void * dragon::MixedMemory::mutable_cpu_data ( size_t  nbytes = 0)

Return the mutable data pointer on CPUContext.

◆ mutable_cuda_data()

void * dragon::MixedMemory::mutable_cuda_data ( size_t  nbytes = 0)

Return the mutable data pointer on CUDAContext.

◆ nbytes()

size_t dragon::MixedMemory::nbytes ( ) const
inline

Return the total bytes of this memory.

◆ nchunks()

size_t dragon::MixedMemory::nchunks ( ) const
inline

Return the chunks of this memory.

◆ order()

StorageOrder dragon::MixedMemory::order ( ) const
inline

Return or Set the storage order.

◆ set_cpu_data()

void dragon::MixedMemory::set_cpu_data ( void *  cpu_ptr,
size_t  nbytes 
)

Set the cpu data pointer from external context.

◆ set_nchunks()

void dragon::MixedMemory::set_nchunks ( size_t  nchunks)
inline

Set the chunks of this memory.

◆ set_order()

void dragon::MixedMemory::set_order ( StorageOrder  order)
inline

Set the storage order.

◆ state()

State dragon::MixedMemory::state ( ) const
inline

Return the state of this memory.

◆ SwitchToCUDADevice()

void dragon::MixedMemory::SwitchToCUDADevice ( int  device_id)

Switch to the specified cuda device.

◆ SwitchToDevice()

void dragon::MixedMemory::SwitchToDevice ( int  device_id)

Switch to the specified device.

◆ ToCPU()

void dragon::MixedMemory::ToCPU ( size_t  nbytes = 0)

Control the state machine to CPUContext.

◆ ToCUDA()

void dragon::MixedMemory::ToCUDA ( size_t  nbytes = 0)

Control the state machine to CUDAContext.


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