Line data Source code
1 : /**
2 : * Copyright (c) 2026 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 DEV_AICPU_TS_ROCE_CHANNEL_H
12 : #define DEV_AICPU_TS_ROCE_CHANNEL_H
13 :
14 : #include <cstdint>
15 : #include <memory>
16 : #include <mutex>
17 : #include <unordered_map>
18 : #include "dev_aicpu_ts_channel.h"
19 : #include "hccl_dispatcher_ctx.h"
20 : #include "transport_pub.h"
21 :
22 : struct HcommRoceChannelRes;
23 :
24 : class DevAicpuTsRoceChannel : public DevAicpuTsChannel {
25 : public:
26 1 : DevAicpuTsRoceChannel() = default;
27 : ~DevAicpuTsRoceChannel() override;
28 :
29 : HcclResult
30 : Create(const void* blob, u64 blobBytes, const HcommDeviceInfo& deviceInfo, ChannelHandle& outHandle) override;
31 : bool Destroy(ChannelHandle handle) override;
32 :
33 : private:
34 : struct RoceSlot {
35 : DispatcherCtxPtr ctx{nullptr};
36 : std::shared_ptr<hccl::Transport> link;
37 : char commId[128]{};
38 : };
39 :
40 : std::unordered_map<ChannelHandle, RoceSlot> slots_;
41 : std::mutex mutex_;
42 : static u64 commSeq_;
43 : };
44 :
45 : #endif // DEV_AICPU_TS_ROCE_CHANNEL_H
|