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 __MC2_TILING_UTILS_INTERFACE_H__
12 : #define __MC2_TILING_UTILS_INTERFACE_H__
13 :
14 : #include "hccl/base.h"
15 : #include "kernel_tiling/kernel_tiling.h"
16 :
17 : #ifdef __cplusplus
18 : extern "C" {
19 : #endif // __cplusplus
20 :
21 22 : inline uint32_t MC2TilingGetVer(void *tiling) {
22 22 : return *(uint32_t *)tiling;
23 : }
24 :
25 13 : inline uint32_t MC2TilingGetHcommCnt(void *tiling) {
26 13 : return *(uint32_t *)((uint8_t *)tiling + sizeof(uint32_t));
27 : }
28 :
29 8 : inline Mc2HcommCfg *MC2TilingGetHcommCfg(void *tiling, uint32_t idx) {
30 8 : uint32_t cnt = MC2TilingGetHcommCnt(tiling);
31 8 : if (idx >= cnt) {
32 0 : return nullptr;
33 : }
34 8 : return (Mc2HcommCfg *)((uint8_t *)tiling + sizeof(uint32_t) + sizeof(uint32_t) + sizeof(Mc2ServerCfg) + idx * sizeof(Mc2HcommCfg));
35 : }
36 :
37 4 : inline Mc2ServerCfg *MC2TilingGetServerCfg(void *tiling) {
38 4 : return (Mc2ServerCfg *)((uint8_t *)tiling + sizeof(uint32_t) + sizeof(uint32_t));
39 : }
40 :
41 : #ifdef __cplusplus
42 : }
43 : #endif // __cplusplus
44 : #endif // __MC2_TILING_UTILS_INTERFACE_H__
|