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 Create(const void *blob, u64 blobBytes,
30 : const HcommDeviceInfo &deviceInfo,
31 : ChannelHandle &outHandle) override;
32 : bool Destroy(ChannelHandle handle) override;
33 :
34 : private:
35 : struct RoceSlot {
36 : DispatcherCtxPtr ctx{nullptr};
37 : std::shared_ptr<hccl::Transport> link;
38 : char commId[128]{};
39 : };
40 :
41 : std::unordered_map<ChannelHandle, RoceSlot> slots_;
42 : std::mutex mutex_;
43 : static u64 commSeq_;
44 : };
45 :
46 : #endif // DEV_AICPU_TS_ROCE_CHANNEL_H
|