Apache Singa
A General Distributed Deep Learning Library
|
Allocate memory and execute Tensor operations. More...
#include <device.h>
Public Member Functions | |
Device (int id, int num_executors) | |
Constructor with device ID, num of executors (e.g., cuda streams), max mem size to use (in MB) | |
virtual void | SetRandSeed (unsigned seed)=0 |
Block * | NewBlock (int size) |
Called by Tensor. | |
void | FreeBlock (Block *block) |
Called by Tensor. | |
virtual size_t | GetAllocatedMem () |
Return the size (bytes) of memory in use TODO(wangwei) override this function for all devices. More... | |
virtual void | CopyDataToFrom (Block *dst, Block *src, size_t nBytes, CopyDirection direction, int dst_offset, int src_offset) |
Copy data within or across devices. | |
void | CopyDataFromHostPtr (Block *dst, const void *src, size_t nBytes, size_t dst_offset=0) |
void | Exec (function< void(Context *)> &&fn, const vector< Block *> read_blocks, const vector< Block *> write_blocks, bool use_rand_generator=false) |
Submit the operation to the device, which may execute it right now or delay it depending on the scheduler. More... | |
void | Sync () |
wait for all operations submitted to this device. | |
LangType | lang () const |
Return the programming language for this device. | |
virtual std::shared_ptr< Device > | host () const |
Context * | context (int k) |
int | id () const |
Protected Member Functions | |
virtual void | DoExec (function< void(Context *)> &&fn, int executor)=0 |
Execute one operation on one executor. | |
virtual void | CopyToFrom (void *dst, const void *src, size_t nBytes, CopyDirection direction, Context *ctx)=0 |
virtual void * | Malloc (int size)=0 |
Allocate device memory. | |
virtual void | Free (void *ptr)=0 |
Free device memory. | |
Protected Attributes | |
int | id_ = 0 |
int | num_executors_ = 0 |
unsigned | seed_ = 0 |
LangType | lang_ |
Programming language type, could be kCpp, kCuda, kOpencl. | |
std::shared_ptr< Device > | host_ |
The host device. | |
Context | ctx_ |
Allocate memory and execute Tensor operations.
There are three types of devices distinguished by their programming languages, namely cpp, cuda and opencl.
void singa::Device::Exec | ( | function< void(Context *)> && | fn, |
const vector< Block *> | read_blocks, | ||
const vector< Block *> | write_blocks, | ||
bool | use_rand_generator = false |
||
) |
Submit the operation to the device, which may execute it right now or delay it depending on the scheduler.
|
inlinevirtual |
Return the size (bytes) of memory in use TODO(wangwei) override this function for all devices.