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