...
Prototype for front-end library loading returning an MXNet context has be implemented here: https://github.com/samskalicky/incubator-mxnet/tree/accel_api
Accelerator libraries will implement the functions defined in the header file "mxnet_acc.h": https://github.com/samskalicky/incubator-mxnet/blob/95a7ab06b6ab30a014a497db0d98cf62fa35df84/include/mxnet/mxnet_acc.h
Here is an example library implementation: https://github.com/samskalicky/incubator-mxnet/blob/95a7ab06b6ab30a014a497db0d98cf62fa35df84/example/accel_api/myacc.cpp
For data allocation, MXNet already has an abstraction for managing storage StorageManager. For this feature, we inherit from this class to call functions from the accelerator library.
Memory Management | https://github.com/samskalicky/incubator-mxnet/blob/95a7ab06b6ab30a014a497db0d98cf62fa35df84/src/storage/acc_storage_manager.h#L68-L84 |
---|---|
Allocate on acc | extern"C"void* alloc(std::size_t size); |
free on acc | extern "C" void free(void*); |
direct-free on acc | extern "C" void directFree(void*); |
release all (free all) | extern "C" void releaseAll(); |
For data movement, MXNet already has a templated Copy<to,from> approach. For this feature, we'll just leverage this to call functions from the accelerator library.
Data movement | https://github.com/samskalicky/incubator-mxnet/blob/accel_api/src/ndarray/ndarray_function.cc#L54-L88 |
---|---|
Copy from host-to-acc | extern "C" int copyTo(void* dst, void* src, size_t size); |
Copy from acc-to-host | extern "C" int copyFrom(void* dst, void* src, size_t size); |
Copy within acc | extern "C" int copyBetween(void* dst, void* src, size_t size); |
Addition of New APIs
Python - context.py | |
---|---|
def load_acc(path_to_lib) | Inputs: path to accelerator library Returns: context to first instance of accelerator (0) |
...