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 : #include "rmt_rma_buffer_lite.h"
11 : #include "string_util.h"
12 : #include "log.h"
13 : namespace Hccl {
14 1 : RmtRmaBufferLite::RmtRmaBufferLite(u64 addr, u64 size) : type_(RmaType::IPC), addr_(addr), size_(size)
15 : {
16 3 : HCCL_INFO("RmtRmaBufferLite::RmtRmaBufferLite:%s", Describe().c_str());
17 1 : }
18 :
19 82 : RmtRmaBufferLite::RmtRmaBufferLite(u64 addr, u64 size, u32 rkey)
20 82 : : type_(RmaType::RDMA),
21 82 : addr_(addr),
22 82 : size_(size),
23 82 : rkey_(rkey)
24 : {
25 246 : HCCL_INFO("RmtRmaBufferLite::RmtRmaBufferLite:%s", Describe().c_str());
26 82 : }
27 :
28 1 : RmtRmaBufferLite::RmtRmaBufferLite(u64 addr, u64 size, u32 tokenId, u32 tokenValue)
29 1 : : type_(RmaType::UB),
30 1 : addr_(addr),
31 1 : size_(size),
32 1 : tokenId_(tokenId),
33 1 : tokenValue_(tokenValue)
34 : {
35 3 : HCCL_INFO("RmtRmaBufferLite::RmtRmaBufferLite:%s", Describe().c_str());
36 1 : }
37 :
38 1 : RmtRmaBufSliceLite RmtRmaBufferLite::GetRmtRmaBufSliceLite(u64 offset, u64 sliceSize) const
39 : {
40 1 : return RmtRmaBufSliceLite(addr_ + offset, sliceSize, rkey_, tokenId_, tokenValue_, UINT32_MAX);
41 : }
42 :
43 169 : std::string RmtRmaBufferLite::Describe() const
44 : {
45 : return StringFormat(
46 169 : "RmtRmaBufferLite[type=%s, addr=0x%llx, size=0x%x, rkey=%u]", type_.Describe().c_str(), addr_, size_, rkey_);
47 : }
48 : } // namespace Hccl
|