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 "rma_connection.h"
12 :
13 : namespace Hccl {
14 :
15 124 : RmaConnection::RmaConnection(Socket* socket, const RmaConnType rmaConnType) : socket(socket), rmaConnType(rmaConnType)
16 : {
17 124 : status = RmaConnStatus::INIT;
18 124 : }
19 :
20 124 : RmaConnection::~RmaConnection()
21 : {
22 124 : if (status != RmaConnStatus::CLOSE) {
23 124 : remoteBufs.clear();
24 124 : status = RmaConnStatus::CLOSE;
25 : }
26 124 : }
27 :
28 0 : void RmaConnection::Close()
29 : {
30 0 : remoteBufs.clear();
31 0 : status = RmaConnStatus::CLOSE;
32 0 : }
33 :
34 0 : RmaConnStatus RmaConnection::GetStatus() { return status; }
35 :
36 1 : void RmaConnection::Bind(RemoteRmaBuffer* remoteRmaBuf, BufferType bufType)
37 : {
38 3 : HCCL_INFO(
39 : "[RmaConnection][%s] bind bufType[%s] Buffer[%s].", Describe().c_str(), bufType.Describe().c_str(),
40 : remoteRmaBuf->Describe().c_str());
41 1 : remoteBufs[bufType] = remoteRmaBuf;
42 1 : }
43 :
44 2 : RemoteRmaBuffer* RmaConnection::GetRemoteRmaBuffer(const BufferType& bufType)
45 : {
46 2 : auto iter = remoteBufs.find(bufType);
47 2 : if (iter != remoteBufs.end()) {
48 1 : return remoteBufs[bufType];
49 : } else {
50 1 : return nullptr;
51 : }
52 : }
53 :
54 : unique_ptr<BaseTask>
55 2 : RmaConnection::PrepareRead(const MemoryBuffer& remoteMemBuf, const MemoryBuffer& localMemBuf, const SqeConfig& config)
56 : {
57 8 : MACRO_THROW(NotSupportException, StringFormat("RmaConnection not support this function."));
58 : }
59 :
60 0 : unique_ptr<BaseTask> RmaConnection::PrepareReadReduce(
61 : const MemoryBuffer& remoteMemBuf, const MemoryBuffer& localMemBuf, DataType datatype, ReduceOp reduceOp,
62 : const SqeConfig& config)
63 : {
64 0 : MACRO_THROW(NotSupportException, StringFormat("RmaConnection not support this function."));
65 : }
66 :
67 : unique_ptr<BaseTask>
68 0 : RmaConnection::PrepareWrite(const MemoryBuffer& remoteMemBuf, const MemoryBuffer& localMemBuf, const SqeConfig& config)
69 : {
70 0 : MACRO_THROW(NotSupportException, StringFormat("RmaConnection not support this function."));
71 : }
72 :
73 1 : unique_ptr<BaseTask> RmaConnection::PrepareWriteReduce(
74 : const MemoryBuffer& remoteMemBuf, const MemoryBuffer& localMemBuf, DataType datatype, ReduceOp reduceOp,
75 : const SqeConfig& config)
76 : {
77 4 : MACRO_THROW(NotSupportException, StringFormat("RmaConnection not support this function."));
78 : }
79 :
80 : unique_ptr<BaseTask>
81 1 : RmaConnection::PrepareInlineWrite(const MemoryBuffer& remoteMemBuf, u64 data, const SqeConfig& config)
82 : {
83 4 : MACRO_THROW(NotSupportException, StringFormat("RmaConnection not support this function."));
84 : }
85 :
86 0 : unique_ptr<BaseTask> RmaConnection::PrepareWriteWithNotify(
87 : const MemoryBuffer& remoteMemBuf, const MemoryBuffer& localMemBuf, u64 data, const MemoryBuffer& remoteNotifyMemBuf,
88 : const SqeConfig& config)
89 : {
90 0 : MACRO_THROW(NotSupportException, StringFormat("RmaConnection not support this function."));
91 : }
92 :
93 0 : unique_ptr<BaseTask> RmaConnection::PrepareWriteReduceWithNotify(
94 : const MemoryBuffer& remoteMemBuf, const MemoryBuffer& localMemBuf, DataType datatype, ReduceOp reduceOp, u64 data,
95 : const MemoryBuffer& remoteNotifyMemBuf, const SqeConfig& config)
96 : {
97 0 : MACRO_THROW(NotSupportException, StringFormat("RmaConnection not support this function."));
98 : }
99 :
100 : } // namespace Hccl
|