---
title: 注意事项
description: "- 流（Stream）是Device侧的概念，多流并行是Device侧的并行运行。"
url: https://www.hiascend.com/document/detail/zh/canncommercial/latest/API/ascendtb/ascendtb_0092.html
sourcePath: /source/zh/canncommercial/900/API/ascendtb/ascendtb_0092.html
indexId: 9e4e537b8aa1b2c7effe050e0199103bfad6775d99b881eb87869663e918aeaa61
---
# 注意事项

- 流（Stream）是Device侧的概念，多流并行是Device侧的并行运行。
- 如果场景中有先Wait再Record的场景建议使用aclrtCreateEventWithFlag(https://www.hiascend.com/document/detail/zh/canncommercial/900/API/runtimeapi/aclcppdevg_03_0080.html)()创建flag为ACL_EVENT_SYNC的aclrtEvent。
- 如果在一个线程上先调用OperatorType=WAIT的EventOperation（WaitOp），再调用流同步接口（aclrtSynchronizeStream(https://www.hiascend.com/document/detail/zh/canncommercial/900/API/runtimeapi/aclcppdevg_03_0076.html)），最后调用OperatorType=RECORD（RecordOp）的EventOperation，会出现死锁现象。这是因为先调用WaitOp的时候会下发一个EVENT_WAIT到device侧阻塞当前的Stream直到调用RecordOp，但是这之间调用了流同步接口，导致host侧会阻塞直到对应的Stream上的任务运行完成，从而导致host侧和device侧互锁。
- 使用流间同步的时候切勿使用aclrtSynchronizeDevice(https://www.hiascend.com/document/detail/zh/canncommercial/900/API/runtimeapi/aclcppdevg_03_0056.html)，会导致Device侧和Host侧互锁，因为该接口会阻塞Host侧直到使用的Device上的所有流上的所有任务全部执行完。
- 一定要确保不同流上的通信算子不会并发执行。
- Cube算子和Cube算子或者Vector算子和Vector算子在不同流上并行执行时因为会抢占计算资源会导致算子执行时长变长或者运行异常。
- 单线程调用不支持设置ATB加速库环境变量ATB_STREAM_SYNC_EVERY_OPERATION_ENABLE=1。
