Line data Source code
1 : /**
2 : * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3 : * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4 : * CANN Open Software License Agreement Version 2.0 (the "License").
5 : * Please refer to the License for details. You may not use this file except in compliance with the License.
6 : * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7 : * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8 : * See LICENSE in the root of the software repository for the full text of the License.
9 : */
10 :
11 : #include "tensor_data_transfer.h"
12 : #include <map>
13 : #include <mutex>
14 : #include <sstream>
15 : #include <unordered_map>
16 :
17 : #include "data_common.h"
18 : #include "tdt_host_interface.h"
19 :
20 : #include "log_inner.h"
21 : #include "acl/acl_tdt_queue.h"
22 : #include "acl_tdt_queue/queue.h"
23 : #include "runtime/rt_mem_queue.h"
24 : #include "runtime/mem.h"
25 : #include "runtime/context.h"
26 : #include "runtime/rts/rts_mem.h"
27 : #include "utils/file_utils.h"
28 : #include "utils/data_type_utils.h"
29 :
30 : namespace {
31 : std::mutex aclChannleMutex;
32 : std::map<std::string, acltdtChannelHandle*> aclChannleMap;
33 : std::map<std::string, aclDataType> aclDataTypeStrMap = {
34 : {"bool", ACL_BOOL}, {"int8", ACL_INT8}, {"uint8", ACL_UINT8}, {"half", ACL_FLOAT16}, {"int16", ACL_INT16},
35 : {"uint16", ACL_UINT16}, {"float", ACL_FLOAT}, {"int32", ACL_INT32}, {"uint32", ACL_UINT32}, {"int64", ACL_INT64},
36 : {"uint64", ACL_UINT64}, {"double", ACL_DOUBLE}, {"string", ACL_STRING}};
37 : constexpr uint32_t VERSION_NAME = 1U;
38 : constexpr size_t TDT_TENSOR_ALIGNE_UNIT = 64UL;
39 : const std::vector<size_t> GEAR_SIZE{
40 : 1U * 1024U * 1024U, 10U * 1024U * 1024U, 100U * 1024U * 1024U, 500U * 1024U * 1024U};
41 6 : size_t Get64AlignedSize(const size_t size)
42 : {
43 6 : return (size + TDT_TENSOR_ALIGNE_UNIT - 1UL) / TDT_TENSOR_ALIGNE_UNIT * TDT_TENSOR_ALIGNE_UNIT;
44 : }
45 :
46 : using TdtHostInitFunc = int32_t (*)(uint32_t);
47 : using TdtHostPreparePopDataFunc = int32_t (*)();
48 : using TdtHostPopDataFunc = int32_t (*)(const std::string&, std::vector<tdt::DataItem>&);
49 : using TdtHostPushDataFunc = int32_t (*)(const std::string&, const std::vector<tdt::DataItem>&, uint32_t deviceId);
50 : using TdtHostStopFunc = int32_t (*)(const std::string&);
51 : using TdtHostDestroyFunc = int32_t (*)();
52 :
53 : #ifndef RUN_TEST
54 : void* GetHandler()
55 : {
56 : std::string soPath;
57 : if (acl::file_utils::GetSoRealPath(soPath) != ACL_SUCCESS) {
58 : ACL_LOG_ERROR("Get libacl_tdt_channel.so path failed.");
59 : return nullptr;
60 : }
61 : std::string soName = soPath + "libdatatransfer.so";
62 : // Load the "libdatatransfer.so" library until the program ends. During the process, Dlclose is not invoked
63 : // to prevent the destruction of the global state information saved in ibdatatransfer.so.
64 : void* handler = mmDlopen(soName.c_str(), RTLD_NOW | RTLD_GLOBAL);
65 : if (handler == nullptr) {
66 : ACL_LOG_ERROR(
67 : "The corresponding dependent dynamic library cannot be found. "
68 : "Please confirm whether the environment supports it and if the extension package has been correctly "
69 : "installed. "
70 : "soName is %s.",
71 : soName.c_str());
72 : }
73 : return handler;
74 : }
75 : #endif
76 :
77 6 : void* GetFunction(const std::string& func_name)
78 : {
79 : #ifdef RUN_TEST
80 : std::unordered_map<std::string, void*> stubFunctionMap = {
81 0 : {"TdtHostInit", reinterpret_cast<void*>(&tdt::TdtHostInit)},
82 0 : {"TdtHostPushData", reinterpret_cast<void*>(&tdt::TdtHostPushData)},
83 0 : {"TdtHostDestroy", reinterpret_cast<void*>(&tdt::TdtHostDestroy)},
84 0 : {"TdtHostPreparePopData", reinterpret_cast<void*>(&tdt::TdtHostPreparePopData)},
85 0 : {"TdtHostPopData", reinterpret_cast<void*>(&tdt::TdtHostPopData)},
86 48 : {"TdtHostStop", reinterpret_cast<void*>(&tdt::TdtHostStop)}};
87 6 : auto it = stubFunctionMap.find(func_name);
88 6 : if (it != stubFunctionMap.end()) {
89 6 : return it->second;
90 : }
91 0 : return nullptr;
92 : #else
93 : static void* handler = GetHandler();
94 : if (handler == nullptr) {
95 : ACL_LOG_ERROR("Get handler failed when get %s function.", func_name.c_str());
96 : return nullptr;
97 : }
98 : void* func_ptr = mmDlsym(handler, func_name.c_str());
99 : if (func_ptr == nullptr) {
100 : ACL_LOG_ERROR(
101 : "The corresponding symbol cannot be found. Please confirm whether the installed extension package is "
102 : "correct, %s.",
103 : mmDlerror());
104 : }
105 : return func_ptr;
106 : #endif
107 12 : }
108 : } // namespace
109 :
110 : namespace acl {
111 5 : bool GetTensorShape(const std::string& dimsStr, std::vector<int64_t>& dims)
112 : {
113 : // change "[32,224,224,3]" => "32,224,224,3"
114 : // tensor_shape.size() - 2 is the second to last
115 5 : if (dimsStr.size() < 2) {
116 2 : ACL_LOG_INNER_ERROR("[Check][dimsStr]Invalid shape string: %s", dimsStr.c_str());
117 2 : return false;
118 : }
119 :
120 3 : std::string str = dimsStr.substr(1, dimsStr.size() - 2);
121 3 : if (!str.empty()) {
122 2 : std::string::size_type index = 0;
123 2 : while ((index = str.find(' ', index)) != std::string::npos) {
124 0 : (void)str.erase(index, 1);
125 : }
126 : }
127 3 : std::string split = ",";
128 3 : std::string::size_type pos2 = str.find(split);
129 3 : std::string::size_type pos1 = 0;
130 4 : while (pos2 != std::string::npos) {
131 : try {
132 1 : dims.push_back(std::stoll(str.substr(pos1, pos2 - pos1)));
133 0 : } catch (...) {
134 0 : ACL_LOG_INNER_ERROR("[Check][Shape]Invalid shape string: %s", dimsStr.c_str());
135 0 : return false;
136 0 : }
137 : // string::size_type can store the length of any string object
138 1 : pos1 = pos2 + split.size();
139 1 : pos2 = str.find(split, pos1);
140 : }
141 3 : if (pos1 != str.length()) {
142 : try {
143 3 : dims.push_back(std::stoll(str.substr(pos1)));
144 1 : } catch (...) {
145 1 : ACL_LOG_INNER_ERROR("[Check][Shape]Invalid shape string: %s", dimsStr.c_str());
146 1 : return false;
147 1 : }
148 : }
149 2 : return true;
150 3 : }
151 :
152 6 : aclError GetTdtDataTypeByAclDataType(acltdtTensorType aclType, tdt::TdtDataType& tdtDataType)
153 : {
154 6 : switch (aclType) {
155 1 : case ACL_TENSOR_DATA_END_OF_SEQUENCE: {
156 1 : tdtDataType = tdt::TDT_END_OF_SEQUENCE;
157 1 : break;
158 : }
159 2 : case ACL_TENSOR_DATA_TENSOR: {
160 2 : tdtDataType = tdt::TDT_TENSOR;
161 2 : break;
162 : }
163 1 : case ACL_TENSOR_DATA_ABNORMAL: {
164 1 : tdtDataType = tdt::TDT_ABNORMAL;
165 1 : break;
166 : }
167 2 : default: {
168 2 : acl::AclErrorLogManager::ReportInputError(
169 4 : acl::INVALID_VALUE_MSG, std::vector<const char*>({"func", "value", "param", "expect"}),
170 2 : std::vector<const char*>(
171 4 : {"Obtaining the tdt data type", acl::GetTensorTypeDesc(aclType), "aclType",
172 4 : "ACL_TENSOR_DATA_END_OF_SEQUENCE or ACL_TENSOR_DATA_TENSOR or ACL_TENSOR_DATA_ABNORMAL"}));
173 2 : return ACL_ERROR_INVALID_PARAM;
174 : }
175 : }
176 4 : return ACL_SUCCESS;
177 : }
178 :
179 13 : aclError GetTdtDataTypeByAclDataTypeV2(acltdtTensorType aclType, int32_t& tdtDataType)
180 : {
181 13 : switch (aclType) {
182 1 : case ACL_TENSOR_DATA_END_OF_SEQUENCE: {
183 1 : tdtDataType = 1;
184 1 : break;
185 : }
186 7 : case ACL_TENSOR_DATA_TENSOR: {
187 7 : tdtDataType = 0;
188 7 : break;
189 : }
190 1 : case ACL_TENSOR_DATA_ABNORMAL: {
191 1 : tdtDataType = 2;
192 1 : break;
193 : }
194 4 : default: {
195 4 : acl::AclErrorLogManager::ReportInputError(
196 8 : acl::INVALID_VALUE_MSG, std::vector<const char*>({"func", "value", "param", "expect"}),
197 4 : std::vector<const char*>(
198 8 : {"Obtaining the tdt data type", acl::GetTensorTypeDesc(aclType), "aclType",
199 8 : "ACL_TENSOR_DATA_END_OF_SEQUENCE or ACL_TENSOR_DATA_TENSOR or ACL_TENSOR_DATA_ABNORMAL"}));
200 4 : return ACL_ERROR_INVALID_PARAM;
201 : }
202 : }
203 9 : return ACL_SUCCESS;
204 : }
205 :
206 8 : aclError GetAclTypeByTdtDataType(tdt::TdtDataType tdtDataType, acltdtTensorType& aclType)
207 : {
208 8 : switch (tdtDataType) {
209 2 : case tdt::TDT_END_OF_SEQUENCE: {
210 2 : aclType = ACL_TENSOR_DATA_END_OF_SEQUENCE;
211 2 : break;
212 : }
213 3 : case tdt::TDT_TENSOR: {
214 3 : aclType = ACL_TENSOR_DATA_TENSOR;
215 3 : break;
216 : }
217 1 : case tdt::TDT_ABNORMAL: {
218 1 : aclType = ACL_TENSOR_DATA_ABNORMAL;
219 1 : break;
220 : }
221 2 : default: {
222 2 : acl::AclErrorLogManager::ReportInputError(
223 4 : acl::INVALID_VALUE_MSG, std::vector<const char*>({"func", "value", "param", "expect"}),
224 2 : std::vector<const char*>(
225 4 : {"Obtaining the tensor data type", acl::GetTdtDataTypeDesc(tdtDataType), "tdtDataType",
226 4 : "TDT_END_OF_SEQUENCE or TDT_TENSOR or TDT_ABNORMAL"}));
227 2 : return ACL_ERROR_UNSUPPORTED_DATA_TYPE;
228 : }
229 : }
230 6 : return ACL_SUCCESS;
231 : }
232 :
233 11 : aclError GetAclTypeByTdtDataTypeV2(int32_t tdtDataType, acltdtTensorType& aclType)
234 : {
235 11 : switch (tdtDataType) {
236 1 : case 1: {
237 1 : aclType = ACL_TENSOR_DATA_END_OF_SEQUENCE;
238 1 : break;
239 : }
240 6 : case 0: {
241 6 : aclType = ACL_TENSOR_DATA_TENSOR;
242 6 : break;
243 : }
244 1 : case 2: {
245 1 : aclType = ACL_TENSOR_DATA_ABNORMAL;
246 1 : break;
247 : }
248 1 : case 3: {
249 1 : aclType = ACL_TENSOR_DATA_SLICE_TENSOR;
250 1 : break;
251 : }
252 1 : case 4: {
253 1 : aclType = ACL_TENSOR_DATA_END_TENSOR;
254 1 : break;
255 : }
256 1 : default: {
257 1 : acl::AclErrorLogManager::ReportInputError(
258 2 : acl::INVALID_VALUE_MSG, std::vector<const char*>({"func", "value", "param", "expect"}),
259 1 : std::vector<const char*>(
260 2 : {"Obtaining the tensor data type", acl::GetTdtDataTypeDescV2(tdtDataType), "tdtDataType",
261 : "[TDT_TENSOR(0), TDT_END_OF_SEQUENCE(1), TDT_ABNORMAL(2), TDT_SLICE_TENSOR(3), "
262 2 : "TDT_END_TENSOR(4)]"}));
263 1 : return ACL_ERROR_UNSUPPORTED_DATA_TYPE;
264 : }
265 : }
266 10 : return ACL_SUCCESS;
267 : }
268 :
269 9 : aclError TensorDatasetSerializes(const acltdtDataset* dataset, std::vector<tdt::DataItem>& itemVec)
270 : {
271 9 : ACL_REQUIRES_NOT_NULL(dataset);
272 :
273 10 : for (size_t i = 0; i < dataset->blobs.size(); ++i) {
274 2 : tdt::DataItem item;
275 : tdt::TdtDataType tdtDataType;
276 2 : const auto ret = GetTdtDataTypeByAclDataType(dataset->blobs[i]->tdtType, tdtDataType);
277 2 : if (ret != ACL_SUCCESS) {
278 1 : ACL_LOG_INNER_ERROR(
279 : "[Check][Dataset]TensorDatasetSerializes failed, "
280 : "invalid tdt type %s",
281 : acl::GetTensorTypeDesc(dataset->blobs[i]->tdtType));
282 1 : itemVec.clear();
283 1 : return ret;
284 : }
285 :
286 1 : item.dataType_ = tdtDataType;
287 1 : item.tensorShape_ = dataset->blobs[i]->dimsStr;
288 1 : item.tensorType_ = dataset->blobs[i]->dataTypeStr;
289 1 : item.dataLen_ = dataset->blobs[i]->dataLen;
290 1 : item.dataPtr_ = dataset->blobs[i]->dataPtr;
291 1 : itemVec.emplace_back(item);
292 2 : }
293 8 : return ACL_SUCCESS;
294 : }
295 :
296 10 : aclError TensorDatasetSerializesV2(const acltdtDataset* dataset, std::vector<acl::aclTdtDataItemInfo>& itemVec)
297 : {
298 10 : ACL_REQUIRES_NOT_NULL(dataset);
299 17 : for (size_t i = 0; i < dataset->blobs.size(); ++i) {
300 10 : acl::aclTdtDataItemInfo item;
301 : int32_t tdtDataType;
302 10 : const auto ret = GetTdtDataTypeByAclDataTypeV2(dataset->blobs[i]->tdtType, tdtDataType);
303 10 : if (ret != ACL_SUCCESS) {
304 3 : ACL_LOG_INNER_ERROR(
305 : "[Check][Dataset]TensorDatasetSerializes failed, "
306 : "invalid tdt type %s",
307 : acl::GetTensorTypeDesc(dataset->blobs[i]->tdtType));
308 3 : return ret;
309 : }
310 :
311 7 : item.ctrlInfo.dataType = tdtDataType;
312 7 : item.ctrlInfo.tensorType = dataset->blobs[i]->dataType;
313 7 : item.ctrlInfo.dimNum = dataset->blobs[i]->dims.size();
314 7 : item.dims = dataset->blobs[i]->dims;
315 7 : item.ctrlInfo.dataLen = dataset->blobs[i]->dataLen;
316 7 : item.dataPtr = dataset->blobs[i]->dataPtr;
317 7 : itemVec.emplace_back(item);
318 7 : ACL_LOG_DEBUG(
319 : "TensorDatasetSerializesWithQueue, dataType %d, tensorType %d, dimNum %u, dataLen %lu",
320 : item.ctrlInfo.dataType, item.ctrlInfo.tensorType, item.ctrlInfo.dimNum, item.ctrlInfo.dataLen);
321 10 : }
322 7 : return ACL_SUCCESS;
323 : }
324 :
325 10 : aclError TensorDatasetDeserializes(const std::vector<tdt::DataItem>& itemVec, acltdtDataset* dataset)
326 : {
327 10 : ACL_REQUIRES_NOT_NULL(dataset);
328 10 : if (dataset->blobs.size() != 0) {
329 4 : const std::string sizeVal = std::to_string(dataset->blobs.size());
330 4 : acl::AclErrorLogManager::ReportInputError(
331 8 : acl::INVALID_PARAM_REASON_MSG, std::vector<const char*>({"func", "value", "param", "reason"}),
332 4 : std::vector<const char*>(
333 4 : {"tdt data deserialization", sizeVal.c_str(), "dataset->blobs.size",
334 8 : "dataset must be empty before deserialization"}));
335 4 : return ACL_ERROR_INVALID_PARAM;
336 4 : }
337 6 : aclError ret = ACL_SUCCESS;
338 8 : for (size_t i = 0; i < itemVec.size(); ++i) {
339 : acltdtTensorType aclType;
340 5 : ret = GetAclTypeByTdtDataType(itemVec[i].dataType_, aclType);
341 5 : if (ret != ACL_SUCCESS) {
342 2 : ACL_LOG_INNER_ERROR(
343 : "[Check][Dataset]TensorDatasetDeserializes failed, invalid data type %s",
344 : acl::GetTdtDataTypeDesc(itemVec[i].dataType_));
345 3 : break;
346 : }
347 :
348 3 : if (aclType == ACL_TENSOR_DATA_TENSOR) {
349 2 : std::vector<int64_t> dims;
350 2 : if (!GetTensorShape(itemVec[i].tensorShape_, dims)) {
351 1 : ACL_LOG_INNER_ERROR(
352 : "[Check][TensorDataset]TensorDatasetDeserializes failed, "
353 : "invalid tensor shape[%s]",
354 : itemVec[i].tensorShape_.c_str());
355 1 : ret = ACL_ERROR_INTERNAL_ERROR;
356 1 : break;
357 : }
358 :
359 1 : std::map<std::string, aclDataType>::const_iterator iter = aclDataTypeStrMap.find(itemVec[i].tensorType_);
360 1 : if (iter == aclDataTypeStrMap.cend()) {
361 0 : ACL_LOG_INNER_ERROR(
362 : "[Deserialize][TensorDataset]TensorDatasetDeserializes failed, "
363 : "unknown data type[%s]",
364 : itemVec[i].tensorType_.c_str());
365 0 : ret = ACL_ERROR_INTERNAL_ERROR;
366 0 : break;
367 : }
368 1 : const aclDataType dataType = iter->second;
369 : acltdtDataItem* item = new (std::nothrow) acltdtDataItem(
370 1 : aclType, dims.empty() ? nullptr : dims.data(), dims.size(), itemVec[i].tensorShape_, dataType,
371 2 : itemVec[i].tensorType_, itemVec[i].dataPtr_, itemVec[i].dataLen_);
372 1 : if (item == nullptr) {
373 0 : ACL_LOG_ERROR("[Check][Item]TensorDatasetDeserializes alloc failed");
374 0 : std::string sizeStr = std::to_string(sizeof(acltdtDataItem));
375 0 : acl::AclErrorLogManager::ReportInputError(
376 0 : acl::ALLOC_MEMORY_FAILED_MSG, std::vector<const char*>({"buf_size", "alloc_interface"}),
377 0 : std::vector<const char*>({sizeStr.c_str(), "new"}));
378 0 : ret = ACL_ERROR_BAD_ALLOC;
379 0 : break;
380 0 : }
381 1 : dataset->blobs.push_back(item);
382 2 : } else {
383 : acltdtDataItem* item = new (std::nothrow) acltdtDataItem(
384 1 : aclType, nullptr, 0, itemVec[i].tensorShape_, ACL_DT_UNDEFINED, itemVec[i].tensorType_,
385 2 : itemVec[i].dataPtr_, itemVec[i].dataLen_);
386 1 : if (item == nullptr) {
387 0 : ACL_LOG_INNER_ERROR("[Check][Item]TensorDatasetDeserializes alloc failed");
388 0 : ret = ACL_ERROR_BAD_ALLOC;
389 0 : break;
390 : }
391 1 : dataset->blobs.push_back(item);
392 : }
393 : }
394 :
395 6 : if (ret != ACL_SUCCESS) {
396 3 : for (size_t i = 0; i < dataset->blobs.size(); ++i) {
397 0 : ACL_DELETE_AND_SET_NULL(dataset->blobs[i]);
398 : }
399 3 : dataset->blobs.clear();
400 : }
401 6 : dataset->freeSelf = true;
402 6 : return ret;
403 : }
404 :
405 6 : aclError TensorDatasetDeserializesV2(const std::vector<acl::aclTdtDataItemInfo>& itemVec, acltdtDataset* dataset)
406 : {
407 6 : ACL_REQUIRES_NOT_NULL(dataset);
408 6 : if (!dataset->blobs.empty() && !dataset->freeSelf) {
409 1 : const std::string sizeVal = std::to_string(dataset->blobs.size());
410 1 : acl::AclErrorLogManager::ReportInputError(
411 2 : acl::INVALID_PARAM_REASON_MSG, std::vector<const char*>({"func", "value", "param", "reason"}),
412 1 : std::vector<const char*>(
413 1 : {"tdt data deserialization", sizeVal.c_str(), "dataset->blobs.size",
414 2 : "dataset must be empty or freeSelf must be true before deserialization"}));
415 1 : return ACL_ERROR_INVALID_PARAM;
416 1 : }
417 10 : for (auto it = dataset->blobs.begin(); it != dataset->blobs.end(); ++it) {
418 0 : ACL_DELETE_AND_SET_NULL(*it);
419 : }
420 5 : dataset->blobs.clear();
421 5 : aclError ret = ACL_SUCCESS;
422 11 : for (size_t i = 0; i < itemVec.size(); ++i) {
423 : acltdtTensorType aclType;
424 6 : ret = GetAclTypeByTdtDataTypeV2(itemVec[i].ctrlInfo.dataType, aclType);
425 6 : if (ret != ACL_SUCCESS) {
426 0 : ACL_LOG_INNER_ERROR(
427 : "[Check][Dataset]Failed to convert TdtDataType %d to acltdtTensorType.", itemVec[i].ctrlInfo.dataType);
428 0 : break;
429 : }
430 6 : if ((aclType == ACL_TENSOR_DATA_TENSOR) || (aclType == ACL_TENSOR_DATA_SLICE_TENSOR) ||
431 1 : (aclType == ACL_TENSOR_DATA_END_TENSOR)) {
432 5 : if (itemVec[i].ctrlInfo.version == static_cast<int32_t>(VERSION_NAME)) {
433 : void* dataReal =
434 3 : (itemVec[i].priorityDataPtr_ != nullptr) ? itemVec[i].priorityDataPtr_ : itemVec[i].dataPtr.get();
435 3 : dataset->name.assign(static_cast<char*>(dataReal), itemVec[i].ctrlInfo.dataLen);
436 3 : ACL_LOG_INFO("get dataset name is %s", dataset->name.c_str());
437 3 : continue;
438 3 : }
439 2 : std::vector<int64_t> dims = itemVec[i].dims;
440 2 : const aclDataType dataType = static_cast<aclDataType>(itemVec[i].ctrlInfo.tensorType);
441 : acltdtDataItem* item = new (std::nothrow) acltdtDataItem(
442 11 : aclType, dims.empty() ? nullptr : dims.data(), dims.size(), "", dataType, "", itemVec[i].dataPtr,
443 11 : itemVec[i].ctrlInfo.dataLen);
444 2 : if (item == nullptr) {
445 0 : ACL_LOG_INNER_ERROR("[Check][Item]TensorDatasetDeserializes alloc failed");
446 0 : ret = ACL_ERROR_BAD_ALLOC;
447 0 : break;
448 : }
449 2 : item->sliceNum = itemVec[i].ctrlInfo.sliceNum;
450 2 : item->sliceId = itemVec[i].ctrlInfo.sliceId;
451 2 : item->priorityData_ = itemVec[i].priorityDataPtr_;
452 2 : dataset->blobs.push_back(item);
453 4 : } else {
454 : acltdtDataItem* item = new (std::nothrow) acltdtDataItem(
455 5 : aclType, nullptr, 0, "", ACL_DT_UNDEFINED, "", itemVec[i].dataPtr, itemVec[i].ctrlInfo.dataLen);
456 1 : if (item == nullptr) {
457 0 : ACL_LOG_INNER_ERROR("[Check][Item]TensorDatasetDeserializes alloc failed");
458 0 : ret = ACL_ERROR_BAD_ALLOC;
459 0 : break;
460 : }
461 1 : item->priorityData_ = itemVec[i].priorityDataPtr_;
462 1 : dataset->blobs.push_back(item);
463 : }
464 : }
465 :
466 5 : if (ret != ACL_SUCCESS) {
467 0 : for (size_t i = 0; i < dataset->blobs.size(); ++i) {
468 0 : ACL_DELETE_AND_SET_NULL(dataset->blobs[i]);
469 : }
470 0 : dataset->blobs.clear();
471 : }
472 5 : dataset->freeSelf = true;
473 5 : return ret;
474 : }
475 :
476 28 : void GetTensorDimsString(const int64_t* dims, size_t dimNum, std::string& dimsStr)
477 : {
478 91 : for (size_t i = 0; i < dimNum; ++i) {
479 84 : dimsStr += std::to_string(dims[i]);
480 84 : if (i + 1 == dimNum) {
481 21 : break;
482 : }
483 63 : dimsStr.push_back(',');
484 : }
485 28 : dimsStr += "]";
486 28 : }
487 :
488 6 : aclError SaveCtrlSharedPtrToVec(
489 : const datasetMemType memType, rtMemQueueBuffInfo& qItem, const std::shared_ptr<uint8_t>& ctrlSharedPtr,
490 : std::vector<std::shared_ptr<uint8_t>>& ctrlSharedPtrVec)
491 : {
492 6 : void* ctrlPtr = ctrlSharedPtr.get();
493 6 : if (memType == MEM_DEVICE) {
494 3 : uint8_t* devPtr = nullptr;
495 3 : std::shared_ptr<uint8_t> ctrlSharedDevPtr;
496 3 : ctrlSharedDevPtr.reset(devPtr, [](void* p) {
497 3 : if (p != nullptr) {
498 0 : (void)rtFree(p);
499 : }
500 3 : });
501 3 : ACL_REQUIRES_RTS_OK_WARN_NOT_SUPPORT(
502 : rtMalloc(reinterpret_cast<void**>(&devPtr), qItem.len, RT_MEMORY_DEFAULT, acl::ACL_MODE_ID_U16), rtMalloc);
503 3 : ACL_REQUIRES_RTS_OK_WARN_NOT_SUPPORT(
504 : rtMemcpy(devPtr, qItem.len, ctrlPtr, qItem.len, RT_MEMCPY_HOST_TO_DEVICE), rtMemcpy);
505 3 : qItem.addr = devPtr;
506 3 : ctrlSharedPtrVec.push_back(ctrlSharedDevPtr);
507 3 : } else {
508 3 : qItem.addr = ctrlPtr;
509 3 : ctrlSharedPtrVec.push_back(ctrlSharedPtr);
510 : }
511 6 : return ACL_SUCCESS;
512 : }
513 :
514 4 : aclError UnpackageRecvDataInfo(uint8_t* outputHostAddr, size_t size, std::vector<acl::aclTdtDataItemInfo>& itemVec)
515 : {
516 4 : ItemInfo* head = reinterpret_cast<ItemInfo*>(outputHostAddr);
517 4 : uint32_t cnt = head->cnt;
518 4 : ACL_LOG_INFO("get tensor cnt is %u", cnt);
519 4 : size_t offset = 0;
520 5 : for (uint32_t i = 0; i < cnt; ++i) {
521 3 : if (offset + sizeof(ItemInfo) > size) {
522 1 : ACL_LOG_ERROR("offset is %zu, size is %zu", offset, size);
523 2 : return ACL_ERROR_FAILURE;
524 : }
525 2 : acl::aclTdtDataItemInfo item;
526 2 : ItemInfo* tmp = reinterpret_cast<ItemInfo*>(outputHostAddr + offset);
527 2 : item.ctrlInfo = *tmp;
528 2 : ACL_LOG_INFO(
529 : "UnpackInfo version %d, dataType %d, curCnt %u, cnt %u, tensorType %d, dimNum %u, "
530 : "dynamicBitSize %u, sliceNum %u, sliceId %u, dataLen %lu",
531 : tmp->version, tmp->dataType, tmp->curCnt, tmp->cnt, tmp->tensorType, tmp->dimNum, tmp->dynamicBitSize,
532 : static_cast<uint32_t>(tmp->sliceNum), static_cast<uint32_t>(tmp->sliceId), tmp->dataLen);
533 2 : offset += sizeof(ItemInfo);
534 :
535 3 : for (uint32_t j = 0; j < tmp->dimNum; ++j) {
536 2 : if (offset + sizeof(int64_t) > size) {
537 1 : ACL_LOG_ERROR("offset is %zu, size is %zu", offset, size);
538 1 : return ACL_ERROR_FAILURE;
539 : }
540 1 : int64_t dimTmp = *(reinterpret_cast<int64_t*>(outputHostAddr + offset));
541 1 : item.dims.push_back(dimTmp);
542 1 : ACL_LOG_INFO("current dims[%u] is %ld", j, dimTmp);
543 1 : offset += sizeof(int64_t);
544 : }
545 :
546 1 : if (offset + tmp->dataLen > size) {
547 0 : ACL_LOG_ERROR("offset is %zu, data len is %lu, size is %zu", offset, tmp->dataLen, size);
548 0 : return ACL_ERROR_FAILURE;
549 : }
550 1 : if (tmp->dataLen > 0U) {
551 1 : item.priorityDataPtr_ = outputHostAddr + offset;
552 1 : offset += tmp->dataLen;
553 : } else {
554 0 : ACL_LOG_INFO("data length is 0");
555 : }
556 1 : ACL_LOG_INFO("after %u tensor, offset is %zu", i + 1, offset);
557 1 : itemVec.push_back(item);
558 2 : }
559 2 : return ACL_SUCCESS;
560 : }
561 :
562 6 : aclError TensorDataitemSerialize(
563 : std::vector<acl::aclTdtDataItemInfo>& itemVec, const datasetMemType memType,
564 : std::vector<rtMemQueueBuffInfo>& qBufVec, std::vector<std::shared_ptr<uint8_t>>& ctrlSharedPtrVec)
565 : {
566 6 : uint32_t currentCnt = 0;
567 6 : size_t lastDataSize = 0U;
568 12 : for (size_t i = 0; i < itemVec.size(); ++i) {
569 6 : itemVec[i].ctrlInfo.curCnt = currentCnt;
570 6 : itemVec[i].ctrlInfo.cnt = itemVec.size();
571 6 : const size_t ctrlSize = sizeof(ItemInfo) + itemVec[i].dims.size() * sizeof(int64_t);
572 : // 64n + lastDataSize + 64n - lastDataSize
573 6 : const size_t alignedSize = Get64AlignedSize(ctrlSize + lastDataSize) - lastDataSize;
574 6 : itemVec[i].ctrlInfo.dynamicBitSize = alignedSize - sizeof(ItemInfo);
575 : std::shared_ptr<uint8_t> ctrlSharedPtr(
576 6 : new (std::nothrow) uint8_t[alignedSize], std::default_delete<uint8_t[]>());
577 6 : ACL_CHECK_MALLOC_RESULT_REPORT_RET(ctrlSharedPtr.get(), alignedSize, "new", ACL_ERROR_BAD_ALLOC);
578 6 : void* ctrlPtr = ctrlSharedPtr.get();
579 6 : ACL_LOG_DEBUG(
580 : "TensorDataitemSerialize alignedSize is %zu, ctrlSize is %zu, dynamicBitSize is %u, i is %zu,"
581 : " lastDataSize is %zu, shape size is %zu",
582 : alignedSize, ctrlSize, itemVec[i].ctrlInfo.dynamicBitSize, i, lastDataSize, itemVec[i].dims.size());
583 6 : auto memcpyRet = memcpy_s(ctrlPtr, alignedSize, &itemVec[i].ctrlInfo, sizeof(ItemInfo));
584 6 : if (memcpyRet != EN_OK) {
585 0 : ACL_LOG_INNER_ERROR(
586 : "[Call][MemCpy]call memcpy failed, result=%d, srcLen=%zu, dstLen=%zu", memcpyRet, sizeof(ItemInfo),
587 : alignedSize);
588 : }
589 6 : size_t offset = sizeof(ItemInfo);
590 30 : for (size_t j = 0; j < itemVec[i].dims.size(); ++j) {
591 24 : memcpyRet = memcpy_s(
592 24 : reinterpret_cast<uint8_t*>(ctrlPtr) + offset, alignedSize - offset, &itemVec[i].dims[j],
593 : sizeof(int64_t));
594 24 : if (memcpyRet != EN_OK) {
595 0 : ACL_LOG_INNER_ERROR(
596 : "[Call][MemCpy]call memcpy failed, result=%d, srcLen=%zu, dstLen=%zu", memcpyRet, sizeof(int64_t),
597 : alignedSize - offset);
598 : }
599 24 : offset += sizeof(int64_t);
600 : }
601 6 : rtMemQueueBuffInfo qItem = {};
602 6 : qItem.len = alignedSize;
603 6 : ACL_REQUIRES_OK(SaveCtrlSharedPtrToVec(memType, qItem, ctrlSharedPtr, ctrlSharedPtrVec));
604 6 : qBufVec.push_back(qItem);
605 :
606 6 : if (itemVec[i].ctrlInfo.dataLen > 0U) {
607 6 : rtMemQueueBuffInfo tmpQItem = {itemVec[i].dataPtr.get(), itemVec[i].ctrlInfo.dataLen};
608 6 : qBufVec.push_back(tmpQItem);
609 : } else {
610 0 : ACL_LOG_DEBUG("no need to insert data buf");
611 : }
612 : // current total size is (64n + lastDataSize)
613 6 : lastDataSize = itemVec[i].ctrlInfo.dataLen;
614 6 : ++currentCnt;
615 6 : }
616 6 : return ACL_SUCCESS;
617 : }
618 :
619 8 : aclError acltdtSendTensorV2(const acltdtChannelHandle* handle, const acltdtDataset* dataset, int32_t timeout)
620 : {
621 8 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(handle);
622 8 : std::vector<acl::aclTdtDataItemInfo> itemVec;
623 8 : auto ret = acl::TensorDatasetSerializesV2(dataset, itemVec);
624 8 : if (ret != ACL_SUCCESS) {
625 2 : ACL_LOG_INNER_ERROR(
626 : "[Serialize][Dataset]Failed to TensorDatasetSerializesV2, device is %u, name is %s.", handle->devId,
627 : handle->name.c_str());
628 2 : itemVec.clear();
629 2 : return ret;
630 : }
631 6 : std::vector<std::shared_ptr<uint8_t>> ctrlSharedPtrVec;
632 6 : std::vector<rtMemQueueBuffInfo> queueBufInfoVec;
633 6 : ret = acl::TensorDataitemSerialize(itemVec, dataset->memType, queueBufInfoVec, ctrlSharedPtrVec);
634 6 : if (ret != ACL_SUCCESS) {
635 0 : ACL_LOG_INNER_ERROR(
636 : "[Serialize][Dataset]Failed to TensorDataitemSerialize, device is %u, name is %s.", handle->devId,
637 : handle->name.c_str());
638 0 : return ret;
639 : }
640 :
641 6 : rtMemQueueBuff_t queueBuf = {nullptr, 0U, nullptr, 0U};
642 6 : queueBuf.buffCount = queueBufInfoVec.size();
643 6 : queueBuf.buffInfo = queueBufInfoVec.data();
644 6 : ret = rtMemQueueEnQueueBuff(handle->devId, handle->qid, &queueBuf, timeout);
645 6 : if (ret == ACL_ERROR_RT_QUEUE_FULL) {
646 2 : ACL_LOG_DEBUG("queue is full, device is %u, name is %s", handle->devId, handle->name.c_str());
647 2 : return ret;
648 : }
649 4 : if (ret != RT_ERROR_NONE) {
650 2 : return ret;
651 : }
652 2 : ACL_LOG_DEBUG("success to execute acltdtSendTensor, device is %u, name is %s", handle->devId, handle->name.c_str());
653 2 : return ACL_SUCCESS;
654 8 : }
655 :
656 11 : aclError EnsureCurrentThreadHasContext(const acltdtChannelHandle* handle)
657 : {
658 11 : rtContext_t rtCtx = nullptr;
659 11 : const rtError_t rtRet = rtCtxGetCurrent(&rtCtx);
660 11 : if ((rtRet != ACL_RT_SUCCESS) && (rtRet != ACL_ERROR_RT_CONTEXT_NULL)) {
661 1 : return rtRet;
662 : }
663 10 : if (rtCtx == nullptr) {
664 10 : if (handle->ctx_ == nullptr) {
665 10 : ACL_LOG_INFO("current thread need to create new context");
666 10 : ACL_REQUIRES_RTS_OK_WARN_NOT_SUPPORT(
667 : rtCtxCreateEx(&rtCtx, static_cast<uint32_t>(RT_CTX_NORMAL_MODE), static_cast<int32_t>(handle->devId)),
668 : rtCtxCreateEx);
669 10 : const_cast<acltdtChannelHandle*>(handle)->ctx_.reset(rtCtx, [](void* p) {
670 10 : if (p != nullptr) {
671 0 : (void)rtCtxDestroyEx(p);
672 : }
673 10 : });
674 : }
675 10 : ACL_REQUIRES_RTS_OK_WARN_NOT_SUPPORT(rtCtxSetCurrent(handle->ctx_.get()), rtCtxSetCurrent);
676 : }
677 10 : return ACL_SUCCESS;
678 : }
679 :
680 7 : static size_t GetMallocSize(const size_t bufLen)
681 : {
682 : // 超出当前档位就是bufLen, 在档位内就是上限值,并保存当前申请的值
683 28 : for (const size_t& size : GEAR_SIZE) {
684 19 : if (bufLen <= size) {
685 5 : return size;
686 : }
687 : }
688 2 : return bufLen;
689 : }
690 :
691 11 : aclError GetOrMallocHostMem(const acltdtChannelHandle* handle, acltdtDataset* dataset, size_t bufLen, void*& hostPtr)
692 : {
693 11 : ACL_LOG_INFO("current need size is %zu, current mem size is %zu", bufLen, dataset->sharedMemSize_);
694 11 : ACL_REQUIRES_OK(EnsureCurrentThreadHasContext(handle));
695 10 : if (bufLen > dataset->sharedMemSize_) {
696 7 : const size_t mallocSize = GetMallocSize(bufLen);
697 7 : ACL_LOG_INFO("need mallochost size %zu, bufLen is %zu", mallocSize, bufLen);
698 7 : void* outHostAddr = nullptr;
699 7 : ACL_REQUIRES_RTS_OK_WARN_NOT_SUPPORT(
700 : rtMallocHost(&outHostAddr, mallocSize, acl::ACL_MODE_ID_U16), rtMallocHost);
701 7 : ACL_CHECK_MALLOC_RESULT(outHostAddr);
702 7 : dataset->sharedMem_.reset(outHostAddr, [](void* p) {
703 7 : if (p != nullptr) {
704 7 : (void)rtFreeHost(p);
705 : }
706 7 : });
707 7 : dataset->sharedMemSize_ = mallocSize;
708 : }
709 10 : hostPtr = dataset->sharedMem_.get();
710 10 : return ACL_SUCCESS;
711 : }
712 :
713 5 : aclError acltdtReceiveTensorV2(const acltdtChannelHandle* handle, acltdtDataset* dataset, int32_t timeout)
714 : {
715 5 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(handle);
716 5 : size_t bufLen = 0;
717 5 : auto ret = rtMemQueuePeek(handle->devId, handle->qid, &bufLen, timeout);
718 5 : if (ret == ACL_ERROR_RT_QUEUE_EMPTY) {
719 1 : ACL_LOG_INFO("queue is empty, device is %u, name is %s", handle->devId, handle->name.c_str());
720 1 : return ret;
721 : }
722 4 : if (ret != RT_ERROR_NONE) {
723 1 : ACL_LOG_ERROR("peek queue [%u] failed", handle->qid);
724 1 : return ret;
725 : }
726 3 : ACL_LOG_INFO("peek queue [%u] success, bufLen is %zu", handle->qid, bufLen);
727 3 : if (bufLen == 0) {
728 0 : ACL_LOG_INNER_ERROR("[Check][bufLen]peek queue len cannot be 0");
729 0 : return ACL_ERROR_FAILURE;
730 : }
731 3 : void* hostPtr = nullptr;
732 3 : ACL_REQUIRES_OK(GetOrMallocHostMem(handle, dataset, bufLen, hostPtr));
733 :
734 3 : rtMemQueueBuff_t queueBuf = {nullptr, 0U, nullptr, 0U};
735 3 : rtMemQueueBuffInfo queueBufInfo = {hostPtr, bufLen};
736 3 : queueBuf.buffCount = 1;
737 3 : queueBuf.buffInfo = &queueBufInfo;
738 3 : ret = rtMemQueueDeQueueBuff(handle->devId, handle->qid, &queueBuf, 0);
739 3 : if (ret == ACL_ERROR_RT_QUEUE_EMPTY) {
740 1 : ACL_LOG_INFO("queue is empty, device is %u, name is %s", handle->devId, handle->name.c_str());
741 1 : return ret;
742 : }
743 2 : if (ret != RT_ERROR_NONE) {
744 1 : ACL_LOG_ERROR("Failed to rtMemQueueDeQueueBuf, device is %u, name is %s.", handle->devId, handle->name.c_str());
745 1 : return ret;
746 : }
747 :
748 1 : std::vector<acl::aclTdtDataItemInfo> itemVec;
749 1 : ret = acl::UnpackageRecvDataInfo(static_cast<uint8_t*>(hostPtr), bufLen, itemVec);
750 1 : if (ret != ACL_SUCCESS) {
751 0 : ACL_LOG_ERROR(
752 : "Failed to unpackage received data, device is %u, name is %s.", handle->devId, handle->name.c_str());
753 0 : return ret;
754 : }
755 1 : ret = acl::TensorDatasetDeserializesV2(itemVec, dataset);
756 1 : if (ret != ACL_SUCCESS) {
757 0 : ACL_LOG_INNER_ERROR(
758 : "[Deserialize][Dataset]Failed to deserialize tensor dataset, device is %u, name is %s.", handle->devId,
759 : handle->name.c_str());
760 0 : return ret;
761 : }
762 1 : ACL_LOG_INFO(
763 : "success to execute acltdtReceiveTensorV2, device is %u, name is %s.", handle->devId, handle->name.c_str());
764 1 : return ACL_SUCCESS;
765 1 : }
766 : } // namespace acl
767 :
768 2 : acltdtTensorType acltdtGetTensorTypeFromItem(const acltdtDataItem* dataItem)
769 : {
770 6 : ACL_REQUIRES_NOT_NULL_RET_INPUT_REPORT(dataItem, ACL_TENSOR_DATA_UNDEFINED);
771 1 : return dataItem->tdtType;
772 : }
773 :
774 2 : aclDataType acltdtGetDataTypeFromItem(const acltdtDataItem* dataItem)
775 : {
776 6 : ACL_REQUIRES_NOT_NULL_RET_INPUT_REPORT(dataItem, ACL_DT_UNDEFINED);
777 1 : return dataItem->dataType;
778 : }
779 :
780 1 : void* acltdtGetDataAddrFromItem(const acltdtDataItem* dataItem)
781 : {
782 1 : ACL_REQUIRES_NOT_NULL_RET_NULL_INPUT_REPORT(dataItem);
783 1 : if (dataItem->priorityData_ != nullptr) {
784 1 : return dataItem->priorityData_;
785 : }
786 0 : return dataItem->dataPtr.get();
787 : }
788 :
789 2 : size_t acltdtGetDataSizeFromItem(const acltdtDataItem* dataItem)
790 : {
791 6 : ACL_REQUIRES_NOT_NULL_RET_INPUT_REPORT(dataItem, 0);
792 1 : return dataItem->dataLen;
793 : }
794 :
795 3 : size_t acltdtGetDimNumFromItem(const acltdtDataItem* dataItem)
796 : {
797 7 : ACL_REQUIRES_NOT_NULL_RET_INPUT_REPORT(dataItem, 0);
798 2 : return dataItem->dims.size();
799 : }
800 :
801 1 : aclError acltdtGetSliceInfoFromItem(const acltdtDataItem* dataItem, size_t* sliceNum, size_t* sliceId)
802 : {
803 1 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(dataItem);
804 1 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(sliceNum);
805 1 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(sliceId);
806 1 : *sliceNum = dataItem->sliceNum;
807 1 : *sliceId = dataItem->sliceId;
808 1 : return ACL_SUCCESS;
809 : }
810 :
811 5 : aclError acltdtGetDimsFromItem(const acltdtDataItem* dataItem, int64_t* dims, size_t dimNum)
812 : {
813 5 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(dataItem);
814 : // check dims and dimNum
815 5 : if (dims == nullptr && dimNum != 0) {
816 2 : ACL_LOG_ERROR("[Check][Params]acltdtGetDimsFromItem failed, invalid dims and dimNum[%zu]", dimNum);
817 2 : std::string value = "nullptr/" + std::to_string(dimNum);
818 2 : acl::AclErrorLogManager::ReportInputError(
819 4 : acl::INVALID_PARAM_REASON_MSG, std::vector<const char*>({"func", "value", "param", "reason"}),
820 2 : std::vector<const char*>(
821 4 : {__func__, value.c_str(), "dims/dimNum", "If dims is nullptr, dimNum should be 0"}));
822 2 : return ACL_ERROR_INVALID_PARAM;
823 2 : }
824 :
825 3 : if (dims != nullptr && dimNum == 0) {
826 1 : ACL_LOG_ERROR("[Check][Params]acltdtGetDimsFromItem failed, invalid dims and dimNum[%zu]", dimNum);
827 1 : std::string value = std::to_string(*dims) + "/" + std::to_string(dimNum);
828 1 : acl::AclErrorLogManager::ReportInputError(
829 2 : acl::INVALID_PARAM_REASON_MSG, std::vector<const char*>({"func", "value", "param", "reason"}),
830 1 : std::vector<const char*>(
831 2 : {__func__, value.c_str(), "dims/dimNum", "If dims is not nullptr, dimNum should be greater than 0"}));
832 1 : return ACL_ERROR_INVALID_PARAM;
833 1 : }
834 :
835 2 : if (dimNum < dataItem->dims.size()) {
836 1 : ACL_LOG_ERROR(
837 : "[Check][dimNum]output dimNum[%zu] cannot be less than dims number[%zu]", dimNum, dataItem->dims.size());
838 1 : const std::string dimNumVal = std::to_string(dimNum);
839 : std::string errMsg = acl::AclErrorLogManager::FormatStr(
840 1 : "dimNum %zu cannot be less than the size of dataItem's dims %zu", dimNum, dataItem->dims.size());
841 1 : acl::AclErrorLogManager::ReportInputError(
842 2 : acl::INVALID_PARAM_REASON_MSG, std::vector<const char*>({"func", "value", "param", "reason"}),
843 2 : std::vector<const char*>({__func__, dimNumVal.c_str(), "dimNum", errMsg.c_str()}));
844 1 : return ACL_ERROR_INVALID_PARAM;
845 1 : }
846 :
847 5 : for (size_t i = 0; i < dataItem->dims.size(); ++i) {
848 4 : dims[i] = dataItem->dims[i];
849 : }
850 :
851 1 : return ACL_SUCCESS;
852 : }
853 :
854 5 : const char* acltdtGetDatasetName(const acltdtDataset* dataset)
855 : {
856 9 : ACL_REQUIRES_NOT_NULL_RET_INPUT_REPORT(dataset, nullptr);
857 4 : return dataset->name.c_str();
858 : }
859 :
860 32 : acltdtDataItem* acltdtCreateDataItem(
861 : acltdtTensorType tdtType, const int64_t* dims, size_t dimNum, aclDataType dataType, void* data, size_t size)
862 : {
863 32 : if (dims == nullptr && dimNum != 0) {
864 0 : ACL_LOG_ERROR("[Check][Params]acltdtCreateDataItem failed, invalid dims and dimNum[%zu]", dimNum);
865 0 : std::string value = "nullptr/" + std::to_string(dimNum);
866 0 : acl::AclErrorLogManager::ReportInputError(
867 0 : acl::INVALID_PARAM_REASON_MSG, std::vector<const char*>({"func", "value", "param", "reason"}),
868 0 : std::vector<const char*>(
869 0 : {__func__, value.c_str(), "dims/dimNum", "If dims is nullptr, dimNum should be 0"}));
870 0 : return nullptr;
871 0 : }
872 :
873 32 : if (dims != nullptr && dimNum == 0) {
874 2 : ACL_LOG_ERROR("[Check][Params]acltdtCreateDataItem failed, invalid dims and dimNum[%zu]", dimNum);
875 2 : std::string value = std::to_string(*dims) + "/" + std::to_string(dimNum);
876 2 : acl::AclErrorLogManager::ReportInputError(
877 4 : acl::INVALID_PARAM_REASON_MSG, std::vector<const char*>({"func", "value", "param", "reason"}),
878 2 : std::vector<const char*>(
879 4 : {__func__, value.c_str(), "dims/dimNum", "If dims is not nullptr, dimNum should be greater than 0"}));
880 2 : return nullptr;
881 2 : }
882 :
883 30 : constexpr size_t MAX_DIM_CNT = 128UL;
884 30 : if (dimNum > MAX_DIM_CNT) {
885 1 : ACL_LOG_ERROR(
886 : "[Check][Dimnum]acltdtCreateDataItem failed, dimNum[%zu] can't be larger than "
887 : "MAX_DIM_CNT[%zu]",
888 : dimNum, MAX_DIM_CNT);
889 1 : std::string expect = "less than or equal to " + std::to_string(MAX_DIM_CNT);
890 1 : const std::string dimNumVal = std::to_string(dimNum);
891 1 : acl::AclErrorLogManager::ReportInputError(
892 2 : acl::INVALID_VALUE_MSG, std::vector<const char*>({"func", "value", "param", "expect"}),
893 2 : std::vector<const char*>({__func__, dimNumVal.c_str(), "dimNum", expect.c_str()}));
894 1 : return nullptr;
895 1 : }
896 :
897 29 : if (tdtType != ACL_TENSOR_DATA_TENSOR) {
898 1 : if (dims != nullptr) {
899 1 : ACL_LOG_ERROR(
900 : "[Check][Dims]acltdtCreateDataItem failed, "
901 : "dims must be nullptr. tdtType is %d",
902 : tdtType);
903 1 : const std::string dimsVal = std::to_string(reinterpret_cast<uintptr_t>(dims));
904 1 : acl::AclErrorLogManager::ReportInputError(
905 2 : acl::INVALID_VALUE_MSG, std::vector<const char*>({"func", "value", "param", "expect"}),
906 2 : std::vector<const char*>({__func__, dimsVal.c_str(), "dims", "nullptr"}));
907 1 : return nullptr;
908 1 : }
909 0 : return new (std::nothrow) acltdtDataItem(tdtType, dims, dimNum, "[]", ACL_DT_UNDEFINED, "", nullptr, 0);
910 : }
911 :
912 : // tdtType: ACL_TENSOR_DATA_TENSOR
913 28 : std::string dimsStr = "[";
914 28 : acl::GetTensorDimsString(dims, dimNum, dimsStr);
915 :
916 28 : std::string typeStr;
917 184 : for (const auto& item : aclDataTypeStrMap) {
918 184 : if (item.second == dataType) {
919 28 : typeStr = item.first;
920 28 : break;
921 : }
922 : }
923 28 : std::shared_ptr<void> dataPtr;
924 28 : dataPtr.reset(data, [](const void*) {});
925 28 : return new (std::nothrow) acltdtDataItem(tdtType, dims, dimNum, dimsStr, dataType, typeStr, dataPtr, size);
926 28 : }
927 :
928 33 : aclError acltdtDestroyDataItem(acltdtDataItem* dataItem)
929 : {
930 33 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(dataItem);
931 32 : ACL_DELETE_AND_SET_NULL(dataItem);
932 32 : return ACL_SUCCESS;
933 : }
934 :
935 40 : acltdtDataset* acltdtCreateDataset() { return new (std::nothrow) acltdtDataset(); }
936 :
937 39 : aclError acltdtDestroyDataset(acltdtDataset* dataset)
938 : {
939 39 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(dataset);
940 39 : ACL_DELETE_AND_SET_NULL(dataset);
941 39 : return ACL_SUCCESS;
942 : }
943 :
944 33 : aclError acltdtAddDataItem(acltdtDataset* dataset, acltdtDataItem* dataItem)
945 : {
946 33 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(dataset);
947 33 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(dataItem);
948 32 : if (dataset->freeSelf) {
949 1 : acl::AclErrorLogManager::ReportInputError(
950 2 : acl::UNSUPPORTED_FEATURE_MSG, std::vector<const char*>({"feature", "reason"}),
951 2 : std::vector<const char*>({__func__, "item cannot be added because internal item already exists"}));
952 1 : return ACL_ERROR_FEATURE_UNSUPPORTED;
953 : }
954 31 : datasetMemType currentMemType = MEM_UNKNOWN;
955 31 : if (dataItem->dataPtr != nullptr) {
956 23 : rtPtrAttributes_t attr = {};
957 23 : ACL_REQUIRES_RTS_OK_WARN_NOT_SUPPORT(
958 : rtsPointerGetAttributes(dataItem->dataPtr.get(), &attr), rtsPointerGetAttributes);
959 23 : if ((attr.location.type == RT_MEMORY_LOC_HOST) || (attr.location.type == RT_MEMORY_LOC_UNREGISTERED)) {
960 13 : currentMemType = MEM_HOST;
961 : } else {
962 10 : currentMemType = MEM_DEVICE;
963 : }
964 : }
965 31 : if (dataset->memType == MEM_UNKNOWN) {
966 : // only MEM_UNKNOWN status can be refreshed
967 19 : dataset->memType = currentMemType;
968 : }
969 :
970 31 : if ((dataset->memType != MEM_UNKNOWN) && (currentMemType != MEM_UNKNOWN)) {
971 23 : if (dataset->memType != currentMemType) {
972 6 : ACL_LOG_ERROR("The memTypes in the dataset must be all host-side or device-side address");
973 6 : const std::string memTypeVal = acl::DatasetMemTypeToString(dataset->memType);
974 6 : acl::AclErrorLogManager::ReportInputError(
975 12 : acl::INVALID_PARAM_REASON_MSG, std::vector<const char*>({"func", "value", "param", "reason"}),
976 6 : std::vector<const char*>(
977 6 : {__func__, memTypeVal.c_str(), "dataset->memType",
978 12 : "The memTypes in the dataset must be all host-side or device-side address"}));
979 6 : return ACL_ERROR_INVALID_PARAM;
980 6 : }
981 : }
982 25 : dataset->blobs.push_back(dataItem);
983 25 : return ACL_SUCCESS;
984 : }
985 :
986 7 : acltdtDataItem* acltdtGetDataItem(const acltdtDataset* dataset, size_t index)
987 : {
988 11 : ACL_REQUIRES_NOT_NULL_RET_NULL_INPUT_REPORT(dataset);
989 6 : if (index >= dataset->blobs.size()) {
990 : std::string errMsg = acl::AclErrorLogManager::FormatStr(
991 4 : "index %zu is greater than or equal to dataset size %zu", index, dataset->blobs.size());
992 4 : const std::string indexVal = std::to_string(index);
993 4 : acl::AclErrorLogManager::ReportInputError(
994 8 : acl::INVALID_PARAM_REASON_MSG, std::vector<const char*>({"func", "value", "param", "reason"}),
995 8 : std::vector<const char*>({__func__, indexVal.c_str(), "index", errMsg.c_str()}));
996 4 : return nullptr;
997 4 : }
998 :
999 2 : return dataset->blobs[index];
1000 : }
1001 :
1002 5 : size_t acltdtGetDatasetSize(const acltdtDataset* dataset)
1003 : {
1004 9 : ACL_REQUIRES_NOT_NULL_RET_INPUT_REPORT(dataset, 0);
1005 4 : return dataset->blobs.size();
1006 : }
1007 :
1008 19 : acltdtChannelHandle* acltdtCreateChannel(uint32_t deviceId, const char* name)
1009 : {
1010 19 : ACL_REQUIRES_NOT_NULL_RET_NULL_INPUT_REPORT(name);
1011 21 : static TdtHostInitFunc tdtHostInit = (TdtHostInitFunc)GetFunction("TdtHostInit");
1012 19 : if (tdtHostInit == nullptr) {
1013 0 : return nullptr;
1014 : }
1015 19 : const auto ret = tdtHostInit(deviceId);
1016 19 : if (ret != 0) {
1017 1 : ACL_LOG_INNER_ERROR("[Init][Tdt]tdt host init failed, tdt result = %d", ret);
1018 1 : return nullptr;
1019 : }
1020 18 : acltdtChannelHandle* handle = new (std::nothrow) acltdtChannelHandle(deviceId, name);
1021 18 : if (handle != nullptr) {
1022 18 : if (!handle->recvName.empty()) {
1023 : static TdtHostPreparePopDataFunc tdtHostPreparePopData =
1024 3 : (TdtHostPreparePopDataFunc)GetFunction("TdtHostPreparePopData");
1025 1 : if (tdtHostPreparePopData == nullptr) {
1026 0 : return nullptr;
1027 : }
1028 1 : (void)tdtHostPreparePopData();
1029 : }
1030 : {
1031 18 : std::unique_lock<std::mutex> lk(aclChannleMutex);
1032 36 : aclChannleMap[name] = handle;
1033 18 : }
1034 : }
1035 18 : return handle;
1036 : }
1037 :
1038 9 : acltdtChannelHandle* acltdtCreateChannelWithCapacity(uint32_t deviceId, const char* name, size_t capacity)
1039 : {
1040 9 : ACL_REQUIRES_NOT_NULL_RET_NULL_INPUT_REPORT(name);
1041 9 : ACL_LOG_INFO("acltdtCreateChannelWithCapacity devId is %u, name is %s, capacity is %zu", deviceId, name, capacity);
1042 9 : if (strnlen(name, RT_MQ_MAX_NAME_LEN) + 1 > RT_MQ_MAX_NAME_LEN) {
1043 1 : ACL_LOG_ERROR("name [%s] length %zu cannot be larger than %d", name, (strlen(name) + 1U), RT_MQ_MAX_NAME_LEN);
1044 : std::string errMsg = acl::AclErrorLogManager::FormatStr(
1045 1 : "name [%s] length %zu cannot be larger than %d", name, (strlen(name) + 1U), RT_MQ_MAX_NAME_LEN);
1046 1 : acl::AclErrorLogManager::ReportInputError(
1047 2 : acl::INVALID_PARAM_REASON_MSG, std::vector<const char*>({"func", "value", "param", "reason"}),
1048 2 : std::vector<const char*>({__func__, name, "name", errMsg.c_str()}));
1049 1 : return nullptr;
1050 1 : }
1051 8 : acltdtChannelHandle* handle = new (std::nothrow) acltdtChannelHandle(deviceId, name);
1052 8 : ACL_CHECK_MALLOC_RESULT_REPORT_RET(handle, sizeof(acltdtChannelHandle), "new", nullptr);
1053 8 : handle->isTdtProcess = false;
1054 8 : acltdtQueueAttr attr{};
1055 8 : const size_t count = strlen(name) + 1U;
1056 8 : const auto ret = memcpy_s(attr.name, RT_MQ_MAX_NAME_LEN, name, count);
1057 8 : if (ret != EN_OK) {
1058 0 : const std::string retCode = std::to_string(ret);
1059 0 : std::stringstream ss;
1060 0 : ss << std::hex << "name=0x" << reinterpret_cast<uintptr_t>(name) << ", dest=0x"
1061 0 : << reinterpret_cast<uintptr_t>(attr.name) << std::dec << ", dest_max=" << RT_MQ_MAX_NAME_LEN
1062 0 : << ", count=" << count << ".";
1063 0 : const std::string extendInfo = ss.str();
1064 0 : acl::AclErrorLogManager::ReportInputError(
1065 : acl::STANDARD_FUNC_FAILED_MSG,
1066 0 : std::vector<const char*>({"func1", "func2", "ret_code", "reason", "extend_info"}),
1067 0 : std::vector<const char*>({__func__, "memcpy_s", retCode.c_str(), strerror(ret), extendInfo.c_str()}));
1068 0 : ACL_LOG_ERROR(
1069 : "[Call][MemCpy]call memcpy failed, result=%d, srcLen=%zu, dstLen=%d", ret, count, RT_MQ_MAX_NAME_LEN);
1070 0 : ACL_DELETE_AND_SET_NULL(handle);
1071 0 : return nullptr;
1072 0 : }
1073 8 : attr.depth = static_cast<uint32_t>(capacity);
1074 8 : attr.workMode = RT_MQ_MODE_DEFAULT;
1075 8 : attr.flowCtrlFlag = false;
1076 8 : attr.flowCtrlDropTime = 0;
1077 8 : attr.overWriteFlag = false;
1078 : // queue init should be invoked when device is open
1079 8 : const auto rtError = rtMemQueueInit(deviceId);
1080 8 : if (rtError == ACL_ERROR_RT_FEATURE_NOT_SUPPORT) {
1081 1 : ACL_LOG_INFO("queue init failed due to runtime does not support.");
1082 1 : ACL_DELETE_AND_SET_NULL(handle);
1083 1 : return nullptr;
1084 : }
1085 7 : if ((rtError != RT_ERROR_NONE) && (rtError != ACL_ERROR_RT_REPEATED_INIT)) {
1086 1 : ACL_LOG_INNER_ERROR("queue init failed, rtError is %d", rtError);
1087 1 : ACL_DELETE_AND_SET_NULL(handle);
1088 1 : return nullptr;
1089 : }
1090 6 : const rtError_t rtErr = rtMemQueueCreate(static_cast<int32_t>(deviceId), &attr, &handle->qid);
1091 6 : if (rtErr != RT_ERROR_NONE) {
1092 1 : ACL_DELETE_AND_SET_NULL(handle);
1093 1 : return nullptr;
1094 : }
1095 5 : ACL_LOG_INFO(
1096 : "acltdtCreateChannelWithCapacity devId is %u, name is %s, real name is %s, qid is %u", deviceId,
1097 : handle->name.c_str(), name, handle->qid);
1098 5 : return handle;
1099 : }
1100 :
1101 2 : aclError acltdtStopChannel(acltdtChannelHandle* handle)
1102 : {
1103 2 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(handle);
1104 2 : ACL_LOG_INFO("start to acltdtStopChannel, device is %u, name is %s", handle->devId, handle->name.c_str());
1105 2 : if (!handle->isTdtProcess) {
1106 0 : ACL_LOG_INFO("new process , stop channel is no use");
1107 0 : return ACL_SUCCESS;
1108 : }
1109 2 : if (!handle->recvName.empty()) {
1110 3 : static TdtHostStopFunc tdtHostStop = (TdtHostStopFunc)GetFunction("TdtHostStop");
1111 1 : if (tdtHostStop == nullptr) {
1112 0 : return ACL_ERROR_FAILURE;
1113 : }
1114 1 : const auto ret = tdtHostStop(handle->recvName);
1115 1 : if (ret != 0) {
1116 1 : ACL_LOG_INNER_ERROR(
1117 : "[Init][Tdt]tdt host stop failed for channel %s, tdt result = %d", handle->name.c_str(), ret);
1118 1 : return ACL_ERROR_FAILURE;
1119 : }
1120 : }
1121 1 : ACL_LOG_INFO("acltdtStopChannel success, device is %u, name is %s", handle->devId, handle->name.c_str());
1122 1 : return ACL_SUCCESS;
1123 : }
1124 :
1125 23 : aclError acltdtDestroyChannel(acltdtChannelHandle* handle)
1126 : {
1127 23 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(handle);
1128 23 : ACL_LOG_INFO("start to acltdtDestroyChannel, device is %u, name is %s", handle->devId, handle->name.c_str());
1129 23 : if (!handle->isTdtProcess) {
1130 7 : ACL_REQUIRES_RTS_OK_WARN_NOT_SUPPORT(
1131 : rtMemQueueDestroy(static_cast<int32_t>(handle->devId), handle->qid), rtMemQueueDestroy);
1132 7 : ACL_LOG_INFO("acltdtDestroyChannel success, device is %u, name is %s", handle->devId, handle->name.c_str());
1133 7 : ACL_DELETE_AND_SET_NULL(handle);
1134 7 : return ACL_SUCCESS;
1135 : }
1136 16 : std::unique_lock<std::mutex> lk(aclChannleMutex);
1137 16 : (void)aclChannleMap.erase(handle->name);
1138 16 : if (aclChannleMap.size() == 0) {
1139 17 : static TdtHostDestroyFunc tdtHostDestroy = (TdtHostDestroyFunc)GetFunction("TdtHostDestroy");
1140 15 : if (tdtHostDestroy == nullptr) {
1141 0 : return ACL_ERROR_FAILURE;
1142 : }
1143 15 : const auto ret = tdtHostDestroy();
1144 15 : if (ret != 0) {
1145 1 : ACL_LOG_INNER_ERROR("[Destroy][Tdt]TdtHostDestroy failed, tdt result = %d", ret);
1146 : }
1147 : }
1148 :
1149 16 : ACL_DELETE_AND_SET_NULL(handle);
1150 16 : return ACL_SUCCESS;
1151 16 : }
1152 :
1153 5 : aclError acltdtCleanChannel(acltdtChannelHandle* handle)
1154 : {
1155 5 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(handle);
1156 4 : ACL_LOG_INFO("start to acltdtCleanChannel, device is %u, name is %s", handle->devId, handle->name.c_str());
1157 4 : if (!handle->isTdtProcess) {
1158 2 : ACL_REQUIRES_RTS_OK_WARN_NOT_SUPPORT(rtMemQueueReset(handle->devId, handle->qid), rtMemQueueReset);
1159 1 : ACL_LOG_INFO("acltdtCleanChannel success, device is %u, name is %s", handle->devId, handle->name.c_str());
1160 1 : return ACL_SUCCESS;
1161 : }
1162 2 : return ACL_ERROR_FEATURE_UNSUPPORTED;
1163 : }
1164 :
1165 8 : aclError acltdtSendTensor(const acltdtChannelHandle* handle, const acltdtDataset* dataset, int32_t timeout)
1166 : {
1167 8 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(handle);
1168 7 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(dataset);
1169 6 : ACL_LOG_DEBUG("start to execute acltdtSendTensor, device is %u, name is %s", handle->devId, handle->name.c_str());
1170 6 : if (!handle->isTdtProcess) {
1171 2 : ACL_LOG_DEBUG("new process, use queue process");
1172 2 : return acl::acltdtSendTensorV2(handle, dataset, timeout);
1173 : }
1174 : // -1 represents infinite wait, it is must be -1 now
1175 7 : ACL_CHECK_INVALID_PARAM_WITH_REASON(
1176 : timeout != -1, timeout, "Only never timeout is supported, timeout can only be set to -1");
1177 :
1178 3 : std::vector<tdt::DataItem> itemVec;
1179 3 : const auto ret = acl::TensorDatasetSerializes(dataset, itemVec);
1180 3 : if (ret != ACL_SUCCESS) {
1181 0 : ACL_LOG_INNER_ERROR(
1182 : "[Serialize][Dataset]Failed to TensorDatasetSerializes, device is %u, name is %s.", handle->devId,
1183 : handle->name.c_str());
1184 0 : itemVec.clear();
1185 0 : return ret;
1186 : }
1187 :
1188 5 : static TdtHostPushDataFunc tdtHostPushData = (TdtHostPushDataFunc)GetFunction("TdtHostPushData");
1189 3 : if (tdtHostPushData == nullptr) {
1190 0 : return ACL_ERROR_FAILURE;
1191 : }
1192 3 : int32_t sendRet = tdtHostPushData(handle->name, itemVec, 0);
1193 3 : if (sendRet != 0) {
1194 2 : ACL_LOG_INNER_ERROR(
1195 : "[Push][Data]Failed to push data, tdt result = %d, device is %u, name is %s.", sendRet, handle->devId,
1196 : handle->name.c_str());
1197 2 : return ACL_ERROR_FAILURE;
1198 : }
1199 :
1200 1 : ACL_LOG_DEBUG("success to execute acltdtSendTensor, device is %u, name is %s", handle->devId, handle->name.c_str());
1201 1 : return ACL_SUCCESS;
1202 3 : }
1203 :
1204 7 : aclError acltdtReceiveTensor(const acltdtChannelHandle* handle, acltdtDataset* dataset, int32_t timeout)
1205 : {
1206 7 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(handle);
1207 6 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(dataset);
1208 5 : ACL_LOG_INFO("start to execute acltdtReceiveTensor, device is %u, name is %s", handle->devId, handle->name.c_str());
1209 5 : if (!handle->isTdtProcess) {
1210 0 : ACL_LOG_INFO("new process, use queue process");
1211 0 : return acl::acltdtReceiveTensorV2(handle, dataset, timeout);
1212 : }
1213 : // -1 represents infinite wait, it is must be -1 now
1214 8 : ACL_CHECK_INVALID_PARAM_WITH_REASON(
1215 : timeout != -1, timeout, "Only never timeout is supported, timeout can only be set to -1");
1216 :
1217 4 : if (handle->recvName.empty()) {
1218 2 : ACL_LOG_ERROR(
1219 : "[Check][Recvname]it is not a receive channel, failed to receive, device is %u, name is %s", handle->devId,
1220 : handle->name.c_str());
1221 2 : return ACL_ERROR_INVALID_PARAM;
1222 : }
1223 :
1224 2 : std::vector<tdt::DataItem> itemVec;
1225 4 : static TdtHostPopDataFunc tdtHostPopData = (TdtHostPopDataFunc)GetFunction("TdtHostPopData");
1226 2 : if (tdtHostPopData == nullptr) {
1227 0 : return ACL_ERROR_FAILURE;
1228 : }
1229 2 : const int32_t recvRet = tdtHostPopData(handle->recvName, itemVec);
1230 2 : if (recvRet != 0) {
1231 1 : ACL_LOG_INNER_ERROR(
1232 : "[Pop][Data]Failed to receive, tdt result = %d, device is %u, name is %s.", recvRet, handle->devId,
1233 : handle->name.c_str());
1234 1 : return ACL_ERROR_FAILURE;
1235 : }
1236 :
1237 1 : const auto ret = acl::TensorDatasetDeserializes(itemVec, dataset);
1238 1 : if (ret != ACL_SUCCESS) {
1239 0 : ACL_LOG_INNER_ERROR(
1240 : "[Deserialize][Dataset]Failed to TensorDatasetDeserializes, device is %u, name is %s.", handle->devId,
1241 : handle->name.c_str());
1242 0 : return ret;
1243 : }
1244 :
1245 1 : ACL_LOG_INFO(
1246 : "success to execute acltdtReceiveTensor, device is %u, name is %s", handle->devId, handle->name.c_str());
1247 1 : return ACL_SUCCESS;
1248 2 : }
1249 :
1250 5 : aclError acltdtQueryChannelSize(const acltdtChannelHandle* handle, size_t* size)
1251 : {
1252 5 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(handle);
1253 4 : ACL_REQUIRES_NOT_NULL_WITH_INPUT_REPORT(size);
1254 3 : if (handle->isTdtProcess) {
1255 1 : ACL_LOG_DEBUG("acltdtQueryChannelSize is not supported");
1256 1 : return ACL_ERROR_FEATURE_UNSUPPORTED;
1257 : }
1258 2 : ACL_LOG_DEBUG("start to execute acltdtQueryChannelSize, device is %u, qid is %u", handle->devId, handle->qid);
1259 : rtMemQueueInfo_t info;
1260 2 : ACL_REQUIRES_RTS_OK(rtMemQueueQueryInfo(static_cast<int32_t>(handle->devId), handle->qid, &info));
1261 1 : *size = static_cast<size_t>(info.size);
1262 1 : ACL_LOG_DEBUG(
1263 : "success to execute acltdtQueryChannelSize, size is %zu, device is %u, qid is %u", *size, handle->devId,
1264 : handle->qid);
1265 1 : return ACL_SUCCESS;
1266 : }
|