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) { return *(uint32_t*)tiling; }
22 :
23 13 : inline uint32_t MC2TilingGetHcommCnt(void* tiling) { return *(uint32_t*)((uint8_t*)tiling + sizeof(uint32_t)); }
24 :
25 8 : inline Mc2HcommCfg* MC2TilingGetHcommCfg(void* tiling, uint32_t idx)
26 : {
27 8 : uint32_t cnt = MC2TilingGetHcommCnt(tiling);
28 8 : if (idx >= cnt) {
29 0 : return nullptr;
30 : }
31 : return (Mc2HcommCfg*)((uint8_t*)tiling + sizeof(uint32_t) + sizeof(uint32_t) + sizeof(Mc2ServerCfg)
32 8 : + idx * sizeof(Mc2HcommCfg));
33 : }
34 :
35 4 : inline Mc2ServerCfg* MC2TilingGetServerCfg(void* tiling)
36 : {
37 4 : return (Mc2ServerCfg*)((uint8_t*)tiling + sizeof(uint32_t) + sizeof(uint32_t));
38 : }
39 :
40 : #ifdef __cplusplus
41 : }
42 : #endif // __cplusplus
43 : #endif // __MC2_TILING_UTILS_INTERFACE_H__
|