函数:stream_wait_event
产品支持情况
产品 |
是否支持 |
---|---|
|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
|
√ |
功能说明
阻塞指定Stream的运行,直到指定的Event完成,支持多个Stream等待同一个Event的场景。异步接口。
提交到Stream上的所有后续任务都需要等待Event捕获的任务都完成后才能开始执行。具体见acl.rt.record_event接口了解Event捕获的细节。
函数原型
- C函数原型
1
aclError aclrtStreamWaitEvent(aclrtStream stream, aclrtEvent event)
- python函数
1
ret = acl.rt.stream_wait_event(stream, event)
参数说明
参数名 |
说明 |
---|---|
stream |
int,指定需要等待Event完成的Stream的指针地址。如果使用默认Stream,此处设置为0。 |
event |
int,需等待的Event的指针地址。 |
返回值说明
返回值 |
说明 |
---|---|
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.init接口初始化后,调用acl.rt.set_op_wait_timeout接口设置超时时间,本进程内后续调用acl.rt.stream_wait_event接口下发的任务支持在所设置的超时时间内等待,若等待的时间超过所设置的超时时间,则会返回报错。
由于acl.rt.stream_wait_event接口是异步接口,调用接口成功仅表示任务下发成功,不表示任务执行成功,因此若等待的时间超过所设置的超时时间,则在调用acl.rt.synchronize_stream接口后,会返回报错。