Merged
feat(machine): Support ASCEND_RT_LAUNCH_BLOCKING for AICPU scheduling blocking #5823
wan_jianfenAdd on Aug 31
feat(machine): Support ASCEND_RT_LAUNCH_BLOCKING for AICPU scheduling blocking #5823
Merged
wan_jianfenAdd on Aug 31
Total: 12 files changed+211-1
@@ -188,6 +188,20 @@ AclError AclRtGetStreamAttribute(AclRtStream stream, AclRtStreamAttr stmAttrType
188 return StubRtGetStreamAttribute(stream, stmAttrType, value);188 return StubRtGetStreamAttribute(stream, stmAttrType, value);
189}189}
190 190 
191+AclError AclRtSetStreamAttribute(AclRtStream stream, AclRtStreamAttr stmAttrType, AclRtStreamAttrValue* value)
192+{
193+#ifdef BUILD_WITH_CANN
194+ void* func = AdapterManager::Instance().GetAclAdapter().GetFunction(AclFunc::RtSetStreamAttribute);
195+ if (func != nullptr) {
196+ aclError (*aclFunc)(aclrtStream, aclrtStreamAttr, aclrtStreamAttrValue*) = reinterpret_cast<aclError (*)(
197+ aclrtStream, aclrtStreamAttr, aclrtStreamAttrValue*)>(func);
198+ return aclFunc(stream, static_cast<aclrtStreamAttr>(stmAttrType),
199+ reinterpret_cast<aclrtStreamAttrValue*>(value));
200+ }
201+#endif
202+ return StubRtSetStreamAttribute(stream, stmAttrType, value);
203+}
204+ 
191AclError AclRtCacheLastTaskOpInfo(const void* const infoPtr, size_t infoSize)205AclError AclRtCacheLastTaskOpInfo(const void* const infoPtr, size_t infoSize)
192{206{
193#ifdef BUILD_WITH_CANN207#ifdef BUILD_WITH_CANN
@@ -317,6 +331,35 @@ AclError AclSysGetVersionStr(const char* pkgName, char* versionStr)
317#endif331#endif
318 return StubSysGetVersionStr(pkgName, versionStr);332 return StubSysGetVersionStr(pkgName, versionStr);
319}333}
334+ 
335+AclError AclRtNoBlockingLaunchBegin(AclRtStream stream, uint64_t flag)
336+{
337+#ifdef BUILD_WITH_CANN
338+ void* func = AdapterManager::Instance().GetAclNewAdapter().GetFunction(AclNewFunc::NoBlockingLaunchBegin);
339+ if (func != nullptr) {
340+ aclError (*aclFunc)(AclRtStream, uint64_t) = reinterpret_cast<aclError (*)(AclRtStream, uint64_t)>(func);
341+ return aclFunc(stream, flag);
342+ }
343+#endif
344+ (void)stream;
345+ (void)flag;
346+ return 0;
347+}
348+ 
349+AclError AclRtNoBlockingLaunchEnd(AclRtStream stream, uint64_t flag)
350+{
351+#ifdef BUILD_WITH_CANN
352+ void* func = AdapterManager::Instance().GetAclNewAdapter().GetFunction(AclNewFunc::NoBlockingLaunchEnd);
353+ if (func != nullptr) {
354+ aclError (*aclFunc)(AclRtStream, uint64_t) = reinterpret_cast<aclError (*)(AclRtStream, uint64_t)>(func);
355+ return aclFunc(stream, flag);
356+ }
357+#endif
358+ (void)stream;
359+ (void)flag;
360+ return 0;
361+}
362+ 
320#ifdef BUILD_WITH_CANN363#ifdef BUILD_WITH_CANN
321static_assert(std::is_same<AclError, aclError>::value);364static_assert(std::is_same<AclError, aclError>::value);
322static_assert(std::is_same<AclRtStream, aclrtStream>::value);365static_assert(std::is_same<AclRtStream, aclrtStream>::value);
@@ -29,6 +29,7 @@ AclError AclRtCreateEventExWithFlag(AclRtEvent* event, uint32_t flag);
29AclError AclRtStreamWaitEvent(AclRtStream stream, AclRtEvent event);29AclError AclRtStreamWaitEvent(AclRtStream stream, AclRtEvent event);
30AclError AclRtGetStreamResLimit(AclRtStream stream, AclRtDevResLimitType type, uint32_t* value);30AclError AclRtGetStreamResLimit(AclRtStream stream, AclRtDevResLimitType type, uint32_t* value);
31AclError AclRtGetStreamAttribute(AclRtStream stream, AclRtStreamAttr stmAttrType, AclRtStreamAttrValue* value);31AclError AclRtGetStreamAttribute(AclRtStream stream, AclRtStreamAttr stmAttrType, AclRtStreamAttrValue* value);
32+AclError AclRtSetStreamAttribute(AclRtStream stream, AclRtStreamAttr stmAttrType, AclRtStreamAttrValue* value);
32AclError AclRtCacheLastTaskOpInfo(const void* const infoPtr, size_t infoSize);33AclError AclRtCacheLastTaskOpInfo(const void* const infoPtr, size_t infoSize);
33AclError AclRtSetExceptionInfoCallback(AclRtExceptionInfoCallback callback);34AclError AclRtSetExceptionInfoCallback(AclRtExceptionInfoCallback callback);
34AclError AclMdlRICaptureGetInfo(AclRtStream stream, AclMdlRICaptureStatus* status, AclMdlRI* modelRI);35AclError AclMdlRICaptureGetInfo(AclRtStream stream, AclMdlRICaptureStatus* status, AclMdlRI* modelRI);
@@ -41,4 +42,6 @@ AclError AclRtDestroyStream(AclRtStream stream);
41AclError AclRtBinaryLoadFromFile(const char* binPath, AclRtBinaryLoadOptions* options, AclRtBinHandle* binHandle);42AclError AclRtBinaryLoadFromFile(const char* binPath, AclRtBinaryLoadOptions* options, AclRtBinHandle* binHandle);
42AclError AclRtBinaryGetFunction(AclRtBinHandle binHandle, const char* kernelName, AclRtFuncHandle* funcHandle);43AclError AclRtBinaryGetFunction(AclRtBinHandle binHandle, const char* kernelName, AclRtFuncHandle* funcHandle);
43AclError AclSysGetVersionStr(const char* pkgName, char* versionStr);44AclError AclSysGetVersionStr(const char* pkgName, char* versionStr);
45+AclError AclRtNoBlockingLaunchBegin(AclRtStream stream, uint64_t flag);
46+AclError AclRtNoBlockingLaunchEnd(AclRtStream stream, uint64_t flag);
44} // namespace npu::tile_fwk47} // namespace npu::tile_fwk
@@ -85,6 +85,8 @@ enum class AclRtStreamAttr {
85 FLOAT_OVERFLOW_CHECK = 2,85 FLOAT_OVERFLOW_CHECK = 2,
86 USER_CUSTOM_TAG = 3,86 USER_CUSTOM_TAG = 3,
87 CACHE_OP_INFO = 4,87 CACHE_OP_INFO = 4,
88+ STREAM_ATTR_PRIORITY = 5,
89+ STREAM_ATTR_LAUNCH_BLOCKING = 6,
88};90};
89 91 
90typedef union {92typedef union {
@@ -92,7 +94,9 @@ typedef union {
92 uint32_t overflowSwitch;94 uint32_t overflowSwitch;
93 uint32_t userCustomTag;95 uint32_t userCustomTag;
94 uint32_t cacheOpInfoSwitch;96 uint32_t cacheOpInfoSwitch;
95- uint32_t reserve[4];97+ uint32_t streamPriority;
98+ uint8_t launchBlockingMode;
99+ uint32_t rsv[4];
96} AclRtStreamAttrValue;100} AclRtStreamAttrValue;
97 101 
98enum class AclRtDevResLimitType {102enum class AclRtDevResLimitType {
@@ -30,6 +30,12 @@ AdapterManager::AdapterManager()
30 ADAPTER_LOGI("Acl adapter has been initialized from library[%s] successfully.", kAclLibName.c_str());30 ADAPTER_LOGI("Acl adapter has been initialized from library[%s] successfully.", kAclLibName.c_str());
31 }31 }
32 32 
33+ if (!aclNewAdapter_.Initialize(newAclLibName, aclNewFuncStrMap)) {
34+ ADAPTER_LOGI("New Acl adapter has not been initialized from library[%s].", newAclLibName.c_str());
35+ } else {
36+ ADAPTER_LOGI("New Acl adapter has been initialized from library[%s] successfully.", newAclLibName.c_str());
37+ }
38+ 
33 if (!adumpAdapter_.Initialize(kAdumpLibName, kAdumpFuncStrMap)) {39 if (!adumpAdapter_.Initialize(kAdumpLibName, kAdumpFuncStrMap)) {
34 ADAPTER_LOGI("Adump adapter has not been initialized from library[%s].", kAdumpLibName.c_str());40 ADAPTER_LOGI("Adump adapter has not been initialized from library[%s].", kAdumpLibName.c_str());
35 } else {41 } else {
@@ -33,11 +33,13 @@ public:
33 const CannAdapter<HcclFunc>& GetHcclAdapter() const { return hcclAdapter_; }33 const CannAdapter<HcclFunc>& GetHcclAdapter() const { return hcclAdapter_; }
34 const CannAdapter<MsprofFunc>& GetMsprofAdapter() const { return msprofAdapter_; }34 const CannAdapter<MsprofFunc>& GetMsprofAdapter() const { return msprofAdapter_; }
35 const CannAdapter<RuntimeFunc>& GetRuntimeAdapter() const { return runtimeAdapter_; }35 const CannAdapter<RuntimeFunc>& GetRuntimeAdapter() const { return runtimeAdapter_; }
36+ const CannAdapter<AclNewFunc>& GetAclNewAdapter() const { return aclNewAdapter_; }
36 37 
37private:38private:
38 AdapterManager();39 AdapterManager();
39 ~AdapterManager();40 ~AdapterManager();
40 CannAdapter<AclFunc> aclAdapter_;41 CannAdapter<AclFunc> aclAdapter_;
42+ CannAdapter<AclNewFunc> aclNewAdapter_;
41 CannAdapter<AdumpFunc> adumpAdapter_;43 CannAdapter<AdumpFunc> adumpAdapter_;
42 CannAdapter<HalFunc> halAdapter_;44 CannAdapter<HalFunc> halAdapter_;
43 CannAdapter<HcclFunc> hcclAdapter_;45 CannAdapter<HcclFunc> hcclAdapter_;
@@ -31,6 +31,7 @@ enum class AclFunc {
31 RtStreamWaitEvent,31 RtStreamWaitEvent,
32 RtGetStreamResLimit,32 RtGetStreamResLimit,
33 RtGetStreamAttribute,33 RtGetStreamAttribute,
34+ RtSetStreamAttribute,
34 RtCacheLastTaskOpInfo,35 RtCacheLastTaskOpInfo,
35 RtSetExceptionInfoCallback,36 RtSetExceptionInfoCallback,
36 MdlRICaptureGetInfo,37 MdlRICaptureGetInfo,
@@ -59,6 +60,7 @@ const std::map<AclFunc, std::string> kAclFuncStrMap{
59 {AclFunc::RtStreamWaitEvent, "aclrtStreamWaitEvent"},60 {AclFunc::RtStreamWaitEvent, "aclrtStreamWaitEvent"},
60 {AclFunc::RtGetStreamResLimit, "aclrtGetStreamResLimit"},61 {AclFunc::RtGetStreamResLimit, "aclrtGetStreamResLimit"},
61 {AclFunc::RtGetStreamAttribute, "aclrtGetStreamAttribute"},62 {AclFunc::RtGetStreamAttribute, "aclrtGetStreamAttribute"},
63+ {AclFunc::RtSetStreamAttribute, "aclrtSetStreamAttribute"},
62 {AclFunc::RtCacheLastTaskOpInfo, "aclrtCacheLastTaskOpInfo"},64 {AclFunc::RtCacheLastTaskOpInfo, "aclrtCacheLastTaskOpInfo"},
63 {AclFunc::RtSetExceptionInfoCallback, "aclrtSetExceptionInfoCallback"},65 {AclFunc::RtSetExceptionInfoCallback, "aclrtSetExceptionInfoCallback"},
64 {AclFunc::MdlRICaptureGetInfo, "aclmdlRICaptureGetInfo"},66 {AclFunc::MdlRICaptureGetInfo, "aclmdlRICaptureGetInfo"},
@@ -71,4 +73,12 @@ const std::map<AclFunc, std::string> kAclFuncStrMap{
71 {AclFunc::BinaryLoadFromFile, "aclrtBinaryLoadFromFile"},73 {AclFunc::BinaryLoadFromFile, "aclrtBinaryLoadFromFile"},
72 {AclFunc::BinaryGetFunction, "aclrtBinaryGetFunction"},74 {AclFunc::BinaryGetFunction, "aclrtBinaryGetFunction"},
73 {AclFunc::SysGetVersionStr, "aclsysGetVersionStr"}};75 {AclFunc::SysGetVersionStr, "aclsysGetVersionStr"}};
76+ 
77+enum class AclNewFunc { NoBlockingLaunchBegin, NoBlockingLaunchEnd, Bottom };
78+ 
79+const std::string newAclLibName = "libacl_rt.so";
80+const std::map<AclNewFunc, std::string> aclNewFuncStrMap{
81+ {AclNewFunc::NoBlockingLaunchBegin, "aclrtNoBlockingLaunchBegin"},
82+ {AclNewFunc::NoBlockingLaunchEnd, "aclrtNoBlockingLaunchEnd"},
83+};
74} // namespace npu::tile_fwk84} // namespace npu::tile_fwk
@@ -124,6 +124,15 @@ AclError StubRtGetStreamAttribute(AclRtStream stream, AclRtStreamAttr stmAttrTyp
124 return ACLRT_SUCCESS;124 return ACLRT_SUCCESS;
125}125}
126 126 
127+AclError StubRtSetStreamAttribute(AclRtStream stream, AclRtStreamAttr stmAttrType, AclRtStreamAttrValue* value)
128+{
129+ ADAPTER_LOGD("Enter stub function of AclRtSetStreamAttribute.");
130+ (void)stream;
131+ (void)stmAttrType;
132+ (void)value;
133+ return ACLRT_SUCCESS;
134+}
135+ 
127AclError StubRtCacheLastTaskOpInfo(const void* const infoPtr, size_t infoSize)136AclError StubRtCacheLastTaskOpInfo(const void* const infoPtr, size_t infoSize)
128{137{
129 ADAPTER_LOGD("Enter stub function of AclRtCacheLastTaskOpInfo.");138 ADAPTER_LOGD("Enter stub function of AclRtCacheLastTaskOpInfo.");
@@ -31,6 +31,7 @@ AclError StubRtCreateEventExWithFlag(AclRtEvent* event, uint32_t flag);
31AclError StubRtStreamWaitEvent(AclRtStream stream, AclRtEvent event);31AclError StubRtStreamWaitEvent(AclRtStream stream, AclRtEvent event);
32AclError StubRtGetStreamResLimit(AclRtStream stream, AclRtDevResLimitType type, uint32_t* value);32AclError StubRtGetStreamResLimit(AclRtStream stream, AclRtDevResLimitType type, uint32_t* value);
33AclError StubRtGetStreamAttribute(AclRtStream stream, AclRtStreamAttr stmAttrType, AclRtStreamAttrValue* value);33AclError StubRtGetStreamAttribute(AclRtStream stream, AclRtStreamAttr stmAttrType, AclRtStreamAttrValue* value);
34+AclError StubRtSetStreamAttribute(AclRtStream stream, AclRtStreamAttr stmAttrType, AclRtStreamAttrValue* value);
34AclError StubRtCacheLastTaskOpInfo(const void* const infoPtr, size_t infoSize);35AclError StubRtCacheLastTaskOpInfo(const void* const infoPtr, size_t infoSize);
35AclError StubRtSetExceptionInfoCallback(AclRtExceptionInfoCallback callback);36AclError StubRtSetExceptionInfoCallback(AclRtExceptionInfoCallback callback);
36AclError StubRtCreateStream(AclRtStream* stream);37AclError StubRtCreateStream(AclRtStream* stream);
@@ -485,6 +485,17 @@ inline bool IsAicoreResolveEnabled()
485 return result;485 return result;
486}486}
487 487 
488+// 判断环境变量 export ASCEND_RT_LAUNCH_BLOCKING是否为1
489+inline bool IsLaunchBlockingEnabled()
490+{
491+ static const bool result = []() {
492+ std::string value = GetEnvVar("ASCEND_RT_LAUNCH_BLOCKING", true, true);
493+ return (value == "1");
494+ }();
495+ 
496+ return result;
497+}
498+ 
488// 向上取整除法499// 向上取整除法
489inline int CeilDiv(int a, int b)500inline int CeilDiv(int a, int b)
490{501{
@@ -553,6 +553,33 @@ int DeviceLauncher::LaunchAicoreKernel(AclRtStream aicoreStream, void* kernel, R
553 return ret;553 return ret;
554}554}
555 555 
556+// 在这个范围之类的流不受ASCENT_RT_LAUNCH_BLOCKING的影响, 依旧是异步
557+int32_t DeviceLauncher::SetLaunchNoBlocking(const AclRtStream& aicoreStream)
558+{
559+ auto schedStream = GetStreamContext().GetScheStream();
560+ auto ctrlStream = GetStreamContext().GetCtrlStream();
561+ int32_t ret = 0;
562+ AclRtStreamAttrValue attrValue;
563+ attrValue.launchBlockingMode = 1;
564+ ret = AclRtSetStreamAttribute(schedStream, npu::tile_fwk::AclRtStreamAttr::STREAM_ATTR_LAUNCH_BLOCKING, &attrValue);
565+ if (ret != 0) {
566+ MACHINE_LOGW("ScheStream Launch set no blocking failed, ret: %d", ret);
567+ return static_cast<int32_t>(MachineError::HOST_LAUNCHER);
568+ }
569+ ret = AclRtSetStreamAttribute(ctrlStream, npu::tile_fwk::AclRtStreamAttr::STREAM_ATTR_LAUNCH_BLOCKING, &attrValue);
570+ if (ret != 0) {
571+ MACHINE_LOGW("CtrlStream Launch set no blocking failed, ret: %d", ret);
572+ return static_cast<int32_t>(MachineError::HOST_LAUNCHER);
573+ }
574+ ret = AclRtSetStreamAttribute(aicoreStream, npu::tile_fwk::AclRtStreamAttr::STREAM_ATTR_LAUNCH_BLOCKING,
575+ &attrValue);
576+ if (ret != 0) {
577+ MACHINE_LOGW("AicoreStream Launch set no blocking failed, ret: %d", ret);
578+ return static_cast<int32_t>(MachineError::HOST_LAUNCHER);
579+ }
580+ return ret;
581+}
582+ 
556int DeviceLauncher::LaunchKernel(AclRtStream aicoreStream, uint8_t* ctrlFlowCache, KernelBinary* kernel,583int DeviceLauncher::LaunchKernel(AclRtStream aicoreStream, uint8_t* ctrlFlowCache, KernelBinary* kernel,
557 int64_t* workspace, const std::vector<DeviceTensorData>& tensors, bool isDebugMode,584 int64_t* workspace, const std::vector<DeviceTensorData>& tensors, bool isDebugMode,
558 int launchEarlyMode)585 int launchEarlyMode)
@@ -593,6 +620,13 @@ int DeviceLauncher::LaunchKernel(AclRtStream aicoreStream, uint8_t* ctrlFlowCach
593 if (!isCaptureMode) {620 if (!isCaptureMode) {
594 args->kArgs.toSubMachineConfig = kernel->GetMachineConfig();621 args->kArgs.toSubMachineConfig = kernel->GetMachineConfig();
595 }622 }
623+ bool isEnableBlocking = IsLaunchBlockingEnabled();
624+ if (!isCaptureMode && isEnableBlocking) {
625+ // 更新runtime 包场景这里失败需要中断,当前考虑CI和本地无runtime 包更新场景暂时warn 提示下
626+ if (SetLaunchNoBlocking(aicoreStream) != 0) {
627+ MACHINE_LOGW("May exect failed, please update CANN Package");
628+ }
629+ }
596 ret = LaunchAicpuKernel(aicpuLaunchDesc, debugEnable, kernel->GetFunction(), tensors);630 ret = LaunchAicpuKernel(aicpuLaunchDesc, debugEnable, kernel->GetFunction(), tensors);
597 MACHINE_ASSERT(ret == RT_SUCCESS) << "launch aicpu failed: " << ret;631 MACHINE_ASSERT(ret == RT_SUCCESS) << "launch aicpu failed: " << ret;
598 632 
@@ -495,6 +495,7 @@ public:
495 bool debugEnable, [[maybe_unused]] Function* function);495 bool debugEnable, [[maybe_unused]] Function* function);
496 static int LaunchKernel(AclRtStream aicoreStream, uint8_t* ctrlFlowCache, KernelBinary* kernel, int64_t* workspace,496 static int LaunchKernel(AclRtStream aicoreStream, uint8_t* ctrlFlowCache, KernelBinary* kernel, int64_t* workspace,
497 const std::vector<DeviceTensorData>& tensors, bool isDebugMode, int launchEarlyMode);497 const std::vector<DeviceTensorData>& tensors, bool isDebugMode, int launchEarlyMode);
498+ static int32_t SetLaunchNoBlocking(const AclRtStream& aicoreStream);
498 static int DeviceRunOnce(Function* function, DevControlFlowCache* hostCtrlCache = nullptr,499 static int DeviceRunOnce(Function* function, DevControlFlowCache* hostCtrlCache = nullptr,
499 const DeviceLauncherConfig& config = DeviceLauncherConfig());500 const DeviceLauncherConfig& config = DeviceLauncherConfig());
500 static void EmulationLaunch(Function* function, const std::vector<DeviceTensorData>& tensors,501 static void EmulationLaunch(Function* function, const std::vector<DeviceTensorData>& tensors,
@@ -0,0 +1,86 @@
1+#!/usr/bin/env python3
2+# coding: utf-8
3+# Copyright (c) 2025-2026 Huawei Technologies Co., Ltd.
4+# This program is free software, you can redistribute it and/or modify it under the terms and conditions of
5+# CANN Open Software License Agreement Version 2.0 (the "License").
6+# Please refer to the License for details. You may not use this file except in compliance with the License.
7+# THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
8+# INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
9+# See LICENSE in the root of the software repository for the full text of the License.
10+# -----------------------------------------------------------------------------------------------------------
11+"""
12+profiling of aicpu pref test for PyPTO
13+"""
14+ 
15+import multiprocessing as mp
16+import os
17+ 
18+import pytest
19+import torch
20+import torch_npu
21+ 
22+import pypto
23+ 
24+ 
25+@pypto.frontend.jit()
26+def matmul_add(
27+ a: pypto.Tensor([pypto.STATIC, pypto.STATIC], pypto.DT_INT8),
28+ b: pypto.Tensor([pypto.STATIC, pypto.STATIC], pypto.DT_INT8),
29+ c: pypto.Tensor([pypto.STATIC, pypto.STATIC], pypto.DT_INT32),
30+ out: pypto.Tensor([pypto.STATIC, pypto.STATIC], pypto.DT_INT32),
31+):
32+ tiling = 32
33+ n, k, m = tiling * 8, tiling * 8, tiling * 8
34+ pypto.set_vec_tile_shapes(tiling, tiling)
35+ pypto.set_cube_tile_shapes([tiling, tiling], [tiling, tiling], [tiling, tiling])
36+ for _ in pypto.loop(1, name="s0", idx_name="i"):
37+ a0 = pypto.view(a, [n, k], [0, 0])
38+ b0 = pypto.view(b, [k, m], [0, 0])
39+ out.move(pypto.add(pypto.matmul(a0, b0, pypto.DT_INT32), c))
40+ 
41+ 
42+def device_run_data_from_device_mix_nodep():
43+ pypto.set_pass_options(enable_slice=False)
44+ device_id = int(os.environ.get('TILE_FWK_DEVICE_ID', 0))
45+ torch.npu.set_device(device_id)
46+ 
47+ tiling = 32
48+ n, k, m = tiling * 8, tiling * 8, tiling * 8
49+ 
50+ # prepare data
51+ c_data_list = []
52+ d_data_list = []
53+ 
54+ count = 1
55+ 
56+ a_rawdata = torch.tensor([[1] * k] * n)
57+ b_rawdata = torch.tensor([[1] * m] * k)
58+ a_data = a_rawdata.to(dtype=torch.int8, device=f'npu:{device_id}')
59+ b_data = b_rawdata.to(dtype=torch.int8, device=f'npu:{device_id}')
60+ 
61+ for idx in range(count):
62+ c_rawdata = torch.tensor([[idx] * m] * n)
63+ c_data = c_rawdata.to(dtype=torch.int32, device=f'npu:{device_id}')
64+ c_data_list.append(c_data)
65+ 
66+ d_data = torch.zeros((n, m), dtype=torch.int32, device=f'npu:{device_id}')
67+ d_data_list.append(d_data)
68+ 
69+ # def inputs and outputs
70+ matmul_add(a_data, b_data, c_data, d_data)
71+ 
72+ torch_npu.npu.synchronize()
73+ 
74+ for idx in range(count):
75+ golden = torch.matmul(a_rawdata.to(torch.int32), b_rawdata.to(torch.int32)) + torch.tensor([[idx] * m] * n)
76+ assert torch.equal(d_data_list[idx].cpu(), golden)
77+ 
78+ 
79+@pytest.mark.soc("910", "950")
80+def test_launch_blocking():
81+ os.environ["ASCEND_RT_LAUNCH_BLOCKING"] = "1"
82+ mp.set_start_method('spawn', force=True)
83+ p = mp.Process(target=device_run_data_from_device_mix_nodep)
84+ p.start()
85+ p.join()
86+ assert p.exitcode == 0, f"child process exited with code {p.exitcode}"