Skip to main content

aclrtAllocatorSetAllocFuncToDesc

aclrtAllocatorCreateDesc

函数功能

创建aclrtAllocatorDesc类型的数据,表示Allocator描述信息,主要用于注册回调函数。同步接口。

函数原型

aclrtAllocatorDesc aclrtAllocatorCreateDesc**()**

返回值说明

  • 返回aclrtAllocatorDesc类型的指针,表示成功。
  • 返回NULL,表示失败。

父主题: aclrtAllocatorDesc

aclrtAllocatorDestroyDesc

函数功能

销毁通过aclrtAllocatorCreateDesc接口创建的aclrtAllocatorDesc类型的数据。同步接口。

原型

aclErroraclrtAllocatorDestroyDesc(aclrtAllocatorDesc allocatorDesc)

参数说明

参数名输入/输出说明
allocatorDesc输入待销毁的aclrtAllocatorDesc类型的数据。

返回值说明

返回0表示成功,返回其它值表示失败。

父主题: aclrtAllocatorDesc

aclrtAllocatorSetObjToDesc

函数功能

使用用户提供的Allocator场景下,向Allocator描述信息中设置Allocator对象。

函数原型

aclErroraclrtAllocatorSetObjToDesc(aclrtAllocatorDesc allocatorDesc, aclrtAllocator allocator)

参数说明

参数名输入/输出说明
allocatorDesc输入Allocator描述符指针。 需提前调用aclrtAllocatorCreateDesc接口设置Allocator描述信息。
allocator输入用户提供的Allocator对象指针。

返回值说明

返回0表示成功,返回其它值表示失败。

父主题: aclrtAllocatorDesc

aclrtAllocatorSetAllocFuncToDesc

函数功能

使用用户提供的Allocator场景下,设置"申请内存block"的回调函数。

函数原型

aclError aclrtAllocatorSetAllocFuncToDesc(aclrtAllocatorDesc allocatorDesc, aclrtAllocatorAllocFunc func)

参数说明

参数名输入/输出说明
allocatorDesc输入Allocator描述符指针。 需提前调用aclrtAllocatorCreateDesc接口设置Allocator描述信息。
func输入申请内存block的回调函数。 回调函数定义如下: text<br>typedef void *(*aclrtAllocatorAllocFunc)(aclrtAllocator allocator, size_t size);<br> aclrtAllocator的定义如下: text<br>typedef void *aclrtAllocator;<br>

返回值说明

返回0表示成功,返回其它值表示失败。

父主题: aclrtAllocatorDesc

aclrtAllocatorSetAllocAdviseFuncToDesc

函数功能

使用用户提供的Allocator场景下,设置"根据建议地址申请内存block"的回调函数,一般用于内存复用场景。

函数原型

aclError aclrtAllocatorSetAllocAdviseFuncToDesc(aclrtAllocatorDesc allocatorDesc, aclrtAllocatorAllocAdviseFunc func)

参数说明

参数名输入/输出说明
allocatorDesc输入Allocator描述符指针。 需提前调用aclrtAllocatorCreateDesc接口设置Allocator描述信息。
func输入根据建议地址申请内存block的回调函数。 回调函数定义如下:
text<br>typedef void *(*aclrtAllocatorAllocAdviseFunc)(aclrtAllocator allocator, size_t size, aclrtAllocatorAddr addr);<br>
aclrtAllocator、aclrtAllocatorAddr的定义如下:
text<br>typedef void *aclrtAllocator;<br>typedef void *aclrtAllocatorAddr;<br>

返回值说明

返回0表示成功,返回其它值表示失败。

父主题: aclrtAllocatorDesc

aclrtAllocatorSetFreeFuncToDesc

函数功能

使用用户提供的Allocator场景下,设置"释放内存block"的回调函数。

函数原型

aclError aclrtAllocatorSetFreeFuncToDesc(aclrtAllocatorDesc allocatorDesc, aclrtAllocatorFreeFunc func)

参数说明

参数名输入/输出说明
allocatorDesc输入Allocator描述符指针。 需提前调用aclrtAllocatorCreateDesc接口设置Allocator描述信息。
func输入释放内存block的回调函数。 回调函数定义如下:
text<br>typedef void (*aclrtAllocatorFreeFunc)(aclrtAllocator allocator, aclrtAllocatorBlock block);<br>
aclrtAllocator、aclrtAllocatorBlock的定义如下:
text<br>typedef void *aclrtAllocator;<br>typedef void *aclrtAllocatorBlock;<br>

返回值说明

返回0表示成功,返回其它值表示失败。

父主题: aclrtAllocatorDesc

aclrtAllocatorSetGetAddrFromBlockFuncToDesc

函数功能

使用用户提供的Allocator场景下,设置"根据申请来的block获取device内存地址"的回调函数。

函数原型

aclError aclrtAllocatorSetGetAddrFromBlockFuncToDesc**(aclrtAllocatorDesc allocatorDesc, aclrtAllocatorGetAddrFromBlockFunc func)**

参数说明

参数名输入/输出说明
allocatorDesc输入Allocator描述符指针。 需提前调用aclrtAllocatorCreateDesc接口设置Allocator描述信息。
func输入根据申请来的block获取device内存地址的回调函数。 回调函数定义如下:
text<br>typedef void *(*aclrtAllocatorGetAddrFromBlockFunc)(aclrtAllocatorBlock block);<br>
aclrtAllocatorBlock的定义如下:
text<br>typedef void *aclrtAllocatorBlock;<br>

返回值说明

返回0表示成功,返回其它值表示失败。

父主题: aclrtAllocatorDesc

在线提单