Line data Source code
1 : /**
2 : * Copyright (c) 2026 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 : #ifndef CHANNEL_MAKEBUFS_HELPER_H
12 : #define CHANNEL_MAKEBUFS_HELPER_H
13 :
14 : #include "buffer.h"
15 : #include "local_rma_buffer.h"
16 : #include "log.h"
17 : #include "hcomm_c_adpt.h"
18 :
19 : namespace hcomm {
20 :
21 18 : inline HcclResult MakeRmaBufferVecFromMemHandles(HcommMemHandle *memHandles, uint32_t memHandleNum,
22 : std::vector<Hccl::LocalRmaBuffer *> &bufferVec, const char *channelName)
23 : {
24 18 : bufferVec.clear();
25 29 : for (uint32_t i = 0; i < memHandleNum; ++i) {
26 15 : auto localRmaBuffer = reinterpret_cast<Hccl::LocalRmaBuffer *>(memHandles[i]);
27 16 : CHK_PTR_NULL(localRmaBuffer);
28 12 : auto buf = localRmaBuffer->GetBuf();
29 12 : CHK_PTR_NULL(buf);
30 11 : HCCL_INFO("[%s][%s] addr[0x%llx], size[0x%llx], memType[%d], memInfo[%s]",
31 : channelName, __func__,
32 : static_cast<unsigned long long>(localRmaBuffer->GetAddr()),
33 : static_cast<unsigned long long>(localRmaBuffer->GetSize()),
34 : static_cast<int>(buf->GetMemType()), buf->GetMemInfo().c_str());
35 11 : bufferVec.push_back(localRmaBuffer);
36 : }
37 14 : return HCCL_SUCCESS;
38 : }
39 :
40 : } // namespace hcomm
41 :
42 : #endif // CHANNEL_MAKEBUFS_HELPER_H
|