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 "rmt_data_buffer_mgr.h"
12 : #include "null_ptr_exception.h"
13 : #include "log.h"
14 : #include "data_buffer.h"
15 : #include "exception_util.h"
16 : namespace Hccl {
17 :
18 2 : DataBuffer RmtDataBufferMgr::GetBuffer(const LinkData& linkData, BufferType bufferType)
19 : {
20 2 : if (algInfo_ == nullptr) {
21 0 : THROW<NullPtrException>("[%s] ERROR algInfo is null", __func__);
22 : }
23 2 : OpMode opMode = algInfo_->GetOpMode();
24 6 : HCCL_INFO(
25 : "[%s] linkData[%s] bufferType[%s] opMode[%s]", __func__, linkData.Describe().c_str(),
26 : bufferType.Describe().c_str(), opMode.Describe().c_str());
27 2 : MemTransportLite* memTransportLite = nullptr;
28 2 : if (opMode == OpMode::OPBASE) {
29 2 : CHECK_NULLPTR(memTransportLiteMgr_, "[RmtDataBufferMgr::GetBuffer] memTransportLiteMgr_ is nullptr!");
30 2 : memTransportLite = memTransportLiteMgr_->GetOpbase(linkData);
31 2 : if (memTransportLite == nullptr) {
32 1 : THROW<NullPtrException>("[%s] ERROR GetOpbase is null", __func__);
33 : }
34 1 : Buffer buffer = memTransportLite->GetRmtBuffer(bufferType);
35 3 : HCCL_INFO("[%s] buffer.GetAddr()[%lu] buffer.GetSize()[%llu]", __func__, buffer.GetAddr(), buffer.GetSize());
36 1 : return DataBuffer(buffer.GetAddr(), buffer.GetSize());
37 1 : } else {
38 0 : THROW<NullPtrException>("[%s] ERROR no support offload mode", __func__);
39 : }
40 : HCCL_WARNING("[%s] linkData[%p] getDatabuffer failed", __func__, linkData);
41 : std::size_t bufferSize = 0;
42 : return DataBuffer(bufferSize);
43 : }
44 :
45 : } // namespace Hccl
|