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 : #ifndef HCCLV2_LOCAL_RMA_BUFFER_H
12 : #define HCCLV2_LOCAL_RMA_BUFFER_H
13 :
14 : #include <string>
15 : #include <memory>
16 : #include <vector>
17 :
18 : #include "buffer.h"
19 : #include "rma_type.h"
20 :
21 : #include "serializable.h"
22 : #include "rma_buffer_lite.h"
23 :
24 : namespace Hccl {
25 :
26 : class LocalRmaBuffer {
27 : public:
28 984 : LocalRmaBuffer(std::shared_ptr<Buffer> buf, RmaType type) : buf(buf), rmaType(type) {}
29 :
30 22 : LocalRmaBuffer(std::shared_ptr<Buffer> buf, RmaType type, bool isAlias) : buf(buf), rmaType(type), isAlias_(isAlias)
31 22 : {}
32 :
33 1004 : virtual ~LocalRmaBuffer() = default;
34 :
35 : virtual std::string Describe() const = 0;
36 :
37 392 : Buffer* GetBuf() const { return buf.get(); }
38 :
39 2 : RmaType GetRmaType() const // used for grant check
40 : {
41 2 : return rmaType;
42 : }
43 :
44 56 : bool IsAlias() const { return isAlias_; }
45 :
46 8 : u64 GetMemHandle() const { return memHandle; }
47 :
48 167 : size_t GetSize() const { return buf->GetSize(); }
49 :
50 169 : uintptr_t GetAddr() const { return buf->GetAddr(); }
51 :
52 0 : virtual std::unique_ptr<Serializable> GetExchangeDto()
53 : {
54 0 : HCCL_ERROR("this is base class, not support.");
55 0 : return nullptr;
56 : }
57 :
58 : protected:
59 : std::shared_ptr<Buffer> buf;
60 : RmaType rmaType;
61 : u64 memHandle{0};
62 : bool isAlias_{false}; // 区分该RmaBuffer对象是否为某一注册Buffer的子集
63 : };
64 :
65 : } // namespace Hccl
66 : #endif
|