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 URMA_DIRECT_TRANSPORT_H
12 : #define URMA_DIRECT_TRANSPORT_H
13 : #include "base_mem_transport.h"
14 : #include "task_param.h"
15 : #include "mc2_type.h"
16 : #include "orion_adapter_hccp.h"
17 : #include "dev_ub_connection.h"
18 :
19 : namespace Hccl {
20 :
21 : class UrmaDirectTransport : public BaseMemTransport {
22 : public:
23 : UrmaDirectTransport(
24 : CommonLocRes& commonLocRes, Attribution& attr, const LinkData& linkData, const Socket& socket,
25 : RdmaHandle rdmaHandle1);
26 : UrmaDirectTransport(
27 : CommonLocRes& commonLocRes, Attribution& attr, const LinkData& linkData, const Socket& socket,
28 : RdmaHandle rdmaHandle1, std::function<void(u32 streamId, u32 taskId, const TaskParam& taskParam)> callback);
29 :
30 : TransportStatus GetStatus() override;
31 :
32 : HcclAiRMAWQ GetAiRMAWQ();
33 : HcclAiRMACQ GetAiRMACQ();
34 :
35 : std::string Describe() const override;
36 :
37 : RemoteUbRmaBuffer* GetRmtBuffer() const;
38 :
39 : private:
40 : RdmaHandle rdmaHandle;
41 :
42 0 : MAKE_ENUM(UrmaStatus, INIT, SOCKET_OK, SEND_DATA, RECV_DATA, SEND_FIN, RECV_FIN, PROCESS_DATA, CONN_OK)
43 : UrmaStatus urmaStatus{UrmaStatus::INIT};
44 :
45 : using RemoteBufferVec = std::vector<std::unique_ptr<RemoteUbRmaBuffer>>;
46 : RemoteBufferVec rmtBufferVec; // 远端 buffer
47 :
48 : void SendExchangeData();
49 : void RecvExchangeData();
50 :
51 : void SendFinish();
52 : void RecvFinish();
53 :
54 : void BufferVecPack(BinaryStream& binaryStream);
55 :
56 : void RmtBufferVecUnpackProc(u32 locNum, BinaryStream& binaryStream, RemoteBufferVec& bufferVec);
57 : bool ConnVecUnpackProc(BinaryStream& binaryStream);
58 :
59 : std::vector<char> GetBufferUniqueId(RemoteBufferVec& bufferVec);
60 :
61 : bool IsResReady();
62 : bool IsConnsReady();
63 : bool RecvDataProcess();
64 :
65 : vector<char> sendData{};
66 : vector<char> recvData{};
67 : vector<char> sendFinishMsg{};
68 : vector<char> recvFinishMsg{};
69 : };
70 : } // namespace Hccl
71 : #endif
|