函数:destroy_event
函数:create_event_with_flag
| C函数原型 | aclError aclrtCreateEventWithFlag(aclrtEvent *event, uint32_t flag) |
|---|---|
| Python函数 | event, ret = acl.rt.create_event_with_flag(flag) |
| 函数功能 | 创建一个带标识的Event,不同标识的Event用于不同的功能,同步接口。 |
| 输入说明 | flag:int,Event的flag,可支持以下选项。 - ACL_EVENT_TIME_LINE = 0x00000008,表示创建的Event数量不受限制且创建出来的Event可用于统计两个Event之间的耗时。 - A****CL_EVENT_SYNC = 0x00000001,表示创建的Event数量受限且创建出来的可用于多Stream间的同步等待。 “flag”为bitmap,支持对单个flag或者多个flag进行操作,例如:acl.rt.create_event_with_flag( ACL_EVENT_TIME_LINE | ACL_EVENT_SYNC )。使用本接口创建Event时,若“flag”参数值包含“ACL_EVENT_SYNC”,则创建出来的Event数量受限,具体参考如下: Atlas 200/500 A2推理产品,单个Device上最多支持1023个Event。 |
| 返回值说明 | event:int,创建的Event对象指针地址。 ret:int,错误码。 - 返回0表示成功。 - 返回其它值表示失败。 |
| 约束说明 | 无 |
| 相关接口 | 您也可以使用acl.rt.create_event接口创建Event,Event数量有限,创建出来的Event可用于统计两个Event之间的耗时、多Stream场景下的同步等待、Event内的同步等待等场景。 |
| 参考资源 | - 接口调用流程,参见多Stream接口调用流程。 - 接口调用示例,参见关于Event的同步等待、关于Stream间任务的同步等待。 |
父主题: 同步等待
函数:destroy_event
| C函数原型 | aclError aclrtDestroyEvent(aclrtEvent event) |
|---|---|
| Python函数 | ret = acl.rt.destroy_event(event) |
| 函数功能 | 销毁一个Event,只能销毁通过acl.rt.create_event/acl.rt.create_event_with_flag接口创建的Event,同步接口。 在销毁时,用户需确保等待acl.rt.synchronize_event接口或acl.rt.stream_wait_event接口涉及的任务都结束后再销毁。 |
| 输入说明 | event:int,待销毁的Event指针地址。 |
| 返回值说明 | ret:int,错误码。 - 返回0表示成功。 - 返回其它值表示失败。 |
| 约束说明 | 在调用acl.rt.destroy_event接口销毁指定Event时,需确保其它接口没有正在使用该Event。 |
| 参考资源 | - 接口调用流程,参见多Stream接口调用流程。 - 接口调用示例,参见关于Event的同步等待、关于Stream间任务的同步等待。 |
父主题: 同步等待
函数:record_event
| C函数原型 | aclError aclrtRecordEvent(aclrtEvent event, aclrtStream stream) |
|---|---|
| Python函数 | ret = acl.rt.record_event(event, stream) |
| 函数功能 | 在Stream中记录一个Event。 |
| 输入说明 | event:int,待记录的Event的指针地址。 stream:int,将该Event记录在指定的Stream(指针地址)中,如果使用默认Stream,此处设置为0。 |
| 返回值说明 | ret:int,错误码。 - 返回0表示成功。 - 返回其它值表示失败。 |
| 约束说明 | - 该接口是异步接口,调用接口成功仅表示任务下发成功,不表示任务执行成功。调用该接口后,需调用同步等待接口(例如,acl.rt.synchronize_stream)确保任务已执行完成。 - acl.rt.record_event接口与acl.rt.stream_wait_event接口配合使用时,主要用于多Stream之间同步的场景,在调用acl.rt.record_event接口时,系统内部会申请Event资源,在调用acl.rt.stream_wait_event接口之后,请及时调用acl.rt.reset_event接口释放Event资源。 接口调用顺序:acl.rt.create_event-->acl.rt.record_event-->acl.rt.stream_wait_event-->acl.rt.reset_event - 由于在调用acl.rt.record_event接口,系统内部会申请Event资源,因此会受Event数量的限制,具体参考如下: Atlas 200/500 A2推理产品,单个Device上最多支持1023个Event。 |
| 参考资源 | - 接口调用流程,参见多Stream接口调用流程。 - 接口调用示例,参见关于Event的同步等待、关于Stream间任务的同步等待。 |
父主题: 同步等待
函数:reset_event
| C函数原型 | aclError aclrtResetEvent(aclrtEvent event, aclrtStream stream) |
|---|---|
| Python函数 | ret = acl.rt.reset_event(event, stream) |
| 函数功能 | 复位一个Event。用户需确保等待Stream中的任务都完成后,再复位Event,异步接口。 |
| 输入说明 | event:int,待复位的Event对象的指针地址。 stream:int,指定Event所在的Stream对象的指针地址。 |
| 返回值说明 | ret:int,错误码。 - 返回0表示成功。 - 返回其它值表示失败。 |
| 约束说明 | 在复位Event时,涉及重置Event的状态,Event的状态是在调用acl.rt.record_event接口时记录,因此在调用acl.rt.reset_event接口前,需要先调用acl.rt.record_event接口。 接口调用顺序:acl.rt.create_event-->acl.rt.record_event-->acl.rt.reset_event-->acl.rt.synchronize_stream |
父主题: 同步等待
在线提单