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 : #ifndef CPU_URMA_ENDPOINT_H
11 : #define CPU_URMA_ENDPOINT_H
12 :
13 : #include <cstdint>
14 : #include <memory>
15 : #include <mutex>
16 : #include <string>
17 : #include <unordered_map>
18 :
19 : #include "endpoint.h"
20 : #include "ccu_channel_ctx_pool.h"
21 : #include "proc_reged_mem_mgr_cache.h"
22 : #include "externalinput_pub.h"
23 :
24 : namespace hcomm {
25 : class CpuUrmaEndpoint : public Endpoint {
26 : public:
27 : explicit CpuUrmaEndpoint(const EndpointDesc &endpointDesc);
28 : ~CpuUrmaEndpoint() noexcept override;
29 :
30 : HcclResult Init() override;
31 :
32 : HcclResult ServerSocketListen(const uint32_t port) override;
33 : HcclResult ServerSocketStopListen(const uint32_t port) override;
34 : inline HcclResult ServerSocketStopListenImpl(const uint32_t port);
35 : HcclResult ServerSocketGetListenPort(uint32_t *port) override;
36 :
37 : static std::unordered_map<Hccl::PortData, std::unique_ptr<Hccl::Socket>> &GetServerSocketMap();
38 :
39 0 : std::shared_ptr<RegedMemMgr> GetRegedMemMgr() override {
40 0 : return regedMemMgr_;
41 : }
42 :
43 : HcclResult RegisterMemory(HcommMem mem, const char *memTag, void **memHandle) override;
44 : HcclResult UnregisterMemory(void* memHandle) override;
45 : HcclResult MemoryExport(void *memHandle, void **memDesc, uint32_t *memDescLen) override;
46 : HcclResult MemoryImport(const void *memDesc, uint32_t descLen, HcommMem *outMem) override;
47 : HcclResult MemoryUnimport(const void *memDesc, uint32_t descLen) override;
48 : HcclResult GetAllMemHandles(void **memHandles, uint32_t *memHandleNum) override;
49 :
50 : private:
51 : std::mutex portMutex_;
52 : u32 dynamicPort_{HCCL_INVALID_PORT};
53 : MemMgrCacheKey cacheKey_{};
54 : };
55 : }
56 :
57 : #endif // CPU_URMA_ENDPOINT_H
|