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 "rma_buffer_lite.h"
12 : #include "log.h"
13 : #include "string_util.h"
14 : namespace Hccl {
15 1 : RmaBufferLite::RmaBufferLite(u64 addr, u64 size) : type_(RmaType::IPC), addr_(addr), size_(size)
16 : {
17 3 : HCCL_INFO("RmaBufferLite::RmaBufferLite:%s", Describe().c_str());
18 1 : }
19 :
20 191 : RmaBufferLite::RmaBufferLite(u64 addr, u64 size, u32 lkey) : type_(RmaType::RDMA), addr_(addr), size_(size), lkey_(lkey)
21 : {
22 565 : HCCL_INFO("RmaBufferLite::RmaBufferLite:%s", Describe().c_str());
23 191 : }
24 :
25 28 : RmaBufferLite::RmaBufferLite(u64 addr, u64 size, u32 tokenId, u32 tokenValue)
26 28 : : type_(RmaType::UB),
27 28 : addr_(addr),
28 28 : size_(size),
29 28 : tokenId_(tokenId),
30 28 : tokenValue_(tokenValue)
31 : {
32 84 : HCCL_INFO("RmaBufferLite::RmaBufferLite:%s", Describe().c_str());
33 28 : }
34 :
35 1 : RmaBufSliceLite RmaBufferLite::GetRmaBufSliceLite(u64 offset, u32 sliceSize) const
36 : {
37 1 : return RmaBufSliceLite(addr_ + offset, sliceSize, lkey_, tokenId_);
38 : }
39 :
40 254 : std::string RmaBufferLite::Describe() const
41 : {
42 254 : return StringFormat("RmaBufferLite[type=%s, addr=0x%llx, size=0x%llx", type_.Describe().c_str(), addr_, size_);
43 : }
44 : } // namespace Hccl
|