RegisterExternalAllocator
产品支持情况
头文件/库文件
- 头文件:#include <ge/ge_api_v2.h>
- 库文件:libge_runner_v2.so
功能说明
用户将自己的Allocator注册给GE,适用于使用用户的内存池场景。
此接口需要配合LoadGraph、RunGraphWithStreamAsync接口使用,并且需要在LoadGraph接口调用前注册。
函数原型
Status RegisterExternalAllocator(const void *const stream, AllocatorPtr allocator) const
参数说明
用户Allocator对象的智能指针。Allocator基于Allocator派生。 |
返回值说明
约束说明
-
对于同一条流,多次调用本接口,以最后一次注册为准。
-
对于不同流,如果用户使用同一个Allocator,不可以多条流并发执行,在执行下一条Stream前,需要对上一Stream做流同步。
-
将Allocator中的内存释放给操作系统前,需要先调用acl接口“aclrtSynchronizeStream”执行流同步,确保Stream中的任务已执行完成。
acl接口详细说明请参见《应用开发指南 (C&C++)》。