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 HCCL_INDEPENDENT_COMMON_H
12 : #define HCCL_INDEPENDENT_COMMON_H
13 :
14 : #include "hccl/hccl_res.h"
15 : #include "hccl_common.h"
16 : #include "hcomm_res_defs.h"
17 : #include "hccl_mem_defs.h"
18 : #ifdef __cplusplus
19 : extern "C" {
20 : #endif // __cplusplus
21 :
22 : typedef enum {
23 : RANK_GRAPH_RESERVED = -1,
24 : RANK_GRAPH_910_93 = 0,
25 : RANK_GRAPH_910_95 = 1,
26 : } GraphType;
27 :
28 : typedef enum {
29 : NOTIFY_TYPE_RESERVED = -1,
30 : NOTIFY_TYPE_RTS_NOTIFY = 0,
31 : NOTIFY_TYPE_RTS_EVENT = 1,
32 : NOTIFY_TYPE_DEVICE_MEM = 2,
33 : } NotifyType;
34 :
35 : typedef uint64_t NotifyHandle;
36 :
37 : typedef union {
38 : struct {
39 : uint64_t requireShare : 1;
40 : uint64_t rsvd : 63;
41 : };
42 : uint64_t value;
43 : } HcclRegMemAttr;
44 :
45 : typedef struct {
46 : HcclMemType type;
47 : void *addr;
48 : u64 size;
49 : } CommBuffer;
50 :
51 : extern HcclResult HcclGetNotifyNumInThread(HcclComm comm, ThreadHandle thread,
52 : CommEngine engine, uint32_t *notifyNum);
53 :
54 : constexpr u32 NOTIFY_MAX_NUM = 2048;
55 67 : inline bool IsValidCommEngine(CommEngine engine)
56 : {
57 67 : switch (engine) {
58 64 : case COMM_ENGINE_CPU:
59 : case COMM_ENGINE_CPU_TS:
60 : case COMM_ENGINE_AICPU:
61 : case COMM_ENGINE_AICPU_TS:
62 : case COMM_ENGINE_AIV:
63 : case COMM_ENGINE_CCU:
64 64 : return true;
65 3 : default:
66 3 : return false;
67 : }
68 : }
69 :
70 0 : inline bool IsValidNotify(NotifyType notifyType)
71 : {
72 0 : switch (notifyType) {
73 0 : case NOTIFY_TYPE_RESERVED:
74 : case NOTIFY_TYPE_RTS_NOTIFY:
75 : case NOTIFY_TYPE_RTS_EVENT:
76 : case NOTIFY_TYPE_DEVICE_MEM:
77 0 : return true;
78 0 : default:
79 0 : return false;
80 : }
81 : }
82 :
83 : #ifdef __cplusplus
84 : }
85 : #endif // __cplusplus
86 :
87 :
88 : #endif
|