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