EventOperation
功能说明
同张卡的流间同步功能。Record或者Wait Event。建议使用aclrtSetOpWaitTimeout设置等待Event完成的超时时间。
支持先Wait再Record以及先Record再Wait时,建议使用aclrtCreateEventWithFlag接口创建Flag为ACL_EVENT_SYNC的Event。
算子上下文
定义
struct EventParam { enum OperatorType : int { UNDEFINED = 0, RECORD, WAIT }; aclrtEvent event; OperatorType operatorType = UNDEFINED; uint8_t rsv[16] = {0}; };
参数列表
成员名称 |
类型 |
默认值 |
描述 |
---|---|---|---|
OperatorType |
int |
UNDEFINED |
OperatorType支持的值。
|
event |
aclrtEvent |
- |
需要RECORD或者WAIT的Event。 |
operatorType |
OperatorType |
UNDEFINED |
OperatorType,支持UNDEFINED、RECORD和WAIT。 |
rsv[16] |
uint8_t |
{0} |
预留参数。 |
功能列表
- 跳过功能
当operatorType设置为UNDEFINED时,调用Execute接口时,将不会进行任何操作。
- Record功能
调用Execute接口时,会调用aclrtRecordEvent接口在Stream中记录EventOperation的Param中传入的aclrtEvent。
1 2 3 4 5 6
atb::common::EventParam param; param.operatorType = atb::common::EventParam::OperatorType::RECORD; aclrtEvent event = nullptr; param.event = event; atb::Operation *operation = nullptr; Status st = atb::CreateOperation(param, &operation);
- Wait功能
调用Execute接口时,会调用aclrtStreamWaitEvent接口和aclrtResetEvent接口。会先阻塞该Operation所使用的Stream的运行,直到使用Record功能记录该event,然后再复位该event,使得该event可以反复被Record或者Wait(反复的被EventOperation所使用)。
1 2 3 4 5 6 7
atb::common::EventParam param; param.operatorType = atb::common::EventParam::OperatorType::WAIT; aclrtEvent event; aclrtCreateEventWithFlag(&event, ACL_EVENT_SYNC); param.event = event; atb::Operation *operation = nullptr; atb::CreateOperation(param, &operation);