MLIR-AIE
TargetModel.h
Go to the documentation of this file.
1//===- TargetModel.h --------------------------------------------*- C++ -*-===//
2//
3// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7// (c) Copyright 2024 Advanced Micro Devices, Inc.
8//
9//===----------------------------------------------------------------------===//
10
11#ifndef AIE_C_TARGETMODEL_H
12#define AIE_C_TARGETMODEL_H
13
14#include "mlir-c/IR.h"
15
16#ifdef __cplusplus
17extern "C" {
18#endif
19
20//===----------------------------------------------------------------------===//
21// Opaque type declarations.
22//
23// Types are exposed to C bindings as structs containing opaque pointers. They
24// are not supposed to be inspected from C. This allows the underlying
25// representation to change without affecting the API users. The use of structs
26// instead of typedefs enables some type safety as structs are not implicitly
27// convertible to each other.
28//
29// Instances of these types may or may not own the underlying object. The
30// ownership semantics is defined by how an instance of the type was obtained.
31//===----------------------------------------------------------------------===//
32
33#define DEFINE_C_API_STRUCT(name, storage) \
34 struct name { \
35 storage d; \
36 }; \
37 typedef struct name name
38
39DEFINE_C_API_STRUCT(AieTargetModel, uint64_t);
40
41#undef DEFINE_C_API_STRUCT
42
43MLIR_CAPI_EXPORTED AieTargetModel aieGetTargetModel(uint32_t device);
44
45/// Returns the data bus width for the target model.
46MLIR_CAPI_EXPORTED uint32_t
47aieGetTargetModelAddressGenGranularity(AieTargetModel targetModel);
48
49/// Returns the number of columns in the target model.
50MLIR_CAPI_EXPORTED int aieTargetModelColumns(AieTargetModel targetModel);
51
52/// Returns the number of rows in the target model.
53MLIR_CAPI_EXPORTED int aieTargetModelRows(AieTargetModel targetModel);
54
55/// Returns true if this is an NPU target model.
56MLIR_CAPI_EXPORTED bool aieTargetModelIsNPU(AieTargetModel targetModel);
57
58MLIR_CAPI_EXPORTED bool aieTargetModelIsCoreTile(AieTargetModel targetModel,
59 int col, int row);
60
61MLIR_CAPI_EXPORTED bool aieTargetModelIsMemTile(AieTargetModel targetModel,
62 int col, int row);
63
64MLIR_CAPI_EXPORTED bool aieTargetModelIsShimNOCTile(AieTargetModel targetModel,
65 int col, int row);
66
67MLIR_CAPI_EXPORTED bool aieTargetModelIsShimPLTile(AieTargetModel targetModel,
68 int col, int row);
69
70MLIR_CAPI_EXPORTED bool
71aieTargetModelIsShimNOCorPLTile(AieTargetModel targetModel, int col, int row);
72
73MLIR_CAPI_EXPORTED bool aieTargetModelIsInternal(AieTargetModel targetModel,
74 int src_col, int src_row,
75 int dst_col, int dst_row);
76
77MLIR_CAPI_EXPORTED bool aieTargetModelIsWest(AieTargetModel targetModel,
78 int src_col, int src_row,
79 int dst_col, int dst_row);
80
81MLIR_CAPI_EXPORTED bool aieTargetModelIsEast(AieTargetModel targetModel,
82 int src_col, int src_row,
83 int dst_col, int dst_row);
84
85MLIR_CAPI_EXPORTED bool aieTargetModelIsNorth(AieTargetModel targetModel,
86 int src_col, int src_row,
87 int dst_col, int dst_row);
88
89MLIR_CAPI_EXPORTED bool aieTargetModelIsSouth(AieTargetModel targetModel,
90 int src_col, int src_row,
91 int dst_col, int dst_row);
92
93MLIR_CAPI_EXPORTED bool aieTargetModelIsMemWest(AieTargetModel targetModel,
94 int src_col, int src_row,
95 int dst_col, int dst_row);
96
97MLIR_CAPI_EXPORTED bool aieTargetModelIsMemEast(AieTargetModel targetModel,
98 int src_col, int src_row,
99 int dst_col, int dst_row);
100
101MLIR_CAPI_EXPORTED bool aieTargetModelIsMemNorth(AieTargetModel targetModel,
102 int src_col, int src_row,
103 int dst_col, int dst_row);
104
105MLIR_CAPI_EXPORTED bool aieTargetModelIsMemSouth(AieTargetModel targetModel,
106 int src_col, int src_row,
107 int dst_col, int dst_row);
108
109MLIR_CAPI_EXPORTED bool
110aieTargetModelIsLegalMemAffinity(AieTargetModel targetModel, int src_col,
111 int src_row, int dst_col, int dst_row);
112
113MLIR_CAPI_EXPORTED uint32_t
114aieTargetModelGetMemSouthBaseAddress(AieTargetModel targetModel);
115
116MLIR_CAPI_EXPORTED uint32_t
117aieTargetModelGetMemNorthBaseAddress(AieTargetModel targetModel);
118
119MLIR_CAPI_EXPORTED uint32_t
120aieTargetModelGetMemEastBaseAddress(AieTargetModel targetModel);
121
122MLIR_CAPI_EXPORTED uint32_t
123aieTargetModelGetMemWestBaseAddress(AieTargetModel targetModel);
124
125MLIR_CAPI_EXPORTED uint32_t
126aieTargetModelGetLocalMemorySize(AieTargetModel targetModel);
127
128MLIR_CAPI_EXPORTED uint32_t
129aieTargetModelGetNumLocks(AieTargetModel targetModel, int col, int row);
130
131MLIR_CAPI_EXPORTED uint32_t aieTargetModelGetNumBDs(AieTargetModel targetModel,
132 int col, int row);
133
134MLIR_CAPI_EXPORTED uint32_t
135aieTargetModelGetNumMemTileRows(AieTargetModel targetModel);
136
137MLIR_CAPI_EXPORTED uint32_t
138aieTargetModelGetMemTileSize(AieTargetModel targetModel);
139
140MLIR_CAPI_EXPORTED uint32_t
141aieTargetModelGetNumBanks(AieTargetModel targetModel, int col, int row);
142
143/// Returns true if this is an NPU target model.
144MLIR_CAPI_EXPORTED bool aieTargetModelIsNPU(AieTargetModel targetModel);
145
146MLIR_CAPI_EXPORTED uint32_t
147aieTargetModelGetColumnShift(AieTargetModel targetModel);
148
149MLIR_CAPI_EXPORTED uint32_t
150aieTargetModelGetRowShift(AieTargetModel targetModel);
151
152#ifdef __cplusplus
153}
154#endif
155
156#endif // AIE_C_TARGETMODEL_H
MLIR_CAPI_EXPORTED bool aieTargetModelIsWest(AieTargetModel targetModel, int src_col, int src_row, int dst_col, int dst_row)
MLIR_CAPI_EXPORTED uint32_t aieTargetModelGetMemWestBaseAddress(AieTargetModel targetModel)
MLIR_CAPI_EXPORTED int aieTargetModelColumns(AieTargetModel targetModel)
Returns the number of columns in the target model.
MLIR_CAPI_EXPORTED uint32_t aieTargetModelGetLocalMemorySize(AieTargetModel targetModel)
MLIR_CAPI_EXPORTED int aieTargetModelRows(AieTargetModel targetModel)
Returns the number of rows in the target model.
MLIR_CAPI_EXPORTED bool aieTargetModelIsMemTile(AieTargetModel targetModel, int col, int row)
MLIR_CAPI_EXPORTED uint32_t aieTargetModelGetNumBanks(AieTargetModel targetModel, int col, int row)
MLIR_CAPI_EXPORTED uint32_t aieGetTargetModelAddressGenGranularity(AieTargetModel targetModel)
Returns the data bus width for the target model.
MLIR_CAPI_EXPORTED uint32_t aieTargetModelGetNumLocks(AieTargetModel targetModel, int col, int row)
#define DEFINE_C_API_STRUCT(name, storage)
Definition TargetModel.h:33
MLIR_CAPI_EXPORTED bool aieTargetModelIsMemEast(AieTargetModel targetModel, int src_col, int src_row, int dst_col, int dst_row)
MLIR_CAPI_EXPORTED bool aieTargetModelIsInternal(AieTargetModel targetModel, int src_col, int src_row, int dst_col, int dst_row)
MLIR_CAPI_EXPORTED bool aieTargetModelIsNPU(AieTargetModel targetModel)
Returns true if this is an NPU target model.
MLIR_CAPI_EXPORTED bool aieTargetModelIsLegalMemAffinity(AieTargetModel targetModel, int src_col, int src_row, int dst_col, int dst_row)
MLIR_CAPI_EXPORTED uint32_t aieTargetModelGetNumBDs(AieTargetModel targetModel, int col, int row)
MLIR_CAPI_EXPORTED bool aieTargetModelIsShimNOCorPLTile(AieTargetModel targetModel, int col, int row)
MLIR_CAPI_EXPORTED uint32_t aieTargetModelGetMemNorthBaseAddress(AieTargetModel targetModel)
MLIR_CAPI_EXPORTED bool aieTargetModelIsShimNOCTile(AieTargetModel targetModel, int col, int row)
MLIR_CAPI_EXPORTED bool aieTargetModelIsEast(AieTargetModel targetModel, int src_col, int src_row, int dst_col, int dst_row)
MLIR_CAPI_EXPORTED bool aieTargetModelIsCoreTile(AieTargetModel targetModel, int col, int row)
MLIR_CAPI_EXPORTED bool aieTargetModelIsMemSouth(AieTargetModel targetModel, int src_col, int src_row, int dst_col, int dst_row)
MLIR_CAPI_EXPORTED bool aieTargetModelIsMemWest(AieTargetModel targetModel, int src_col, int src_row, int dst_col, int dst_row)
MLIR_CAPI_EXPORTED AieTargetModel aieGetTargetModel(uint32_t device)
MLIR_CAPI_EXPORTED uint32_t aieTargetModelGetMemTileSize(AieTargetModel targetModel)
MLIR_CAPI_EXPORTED uint32_t aieTargetModelGetMemEastBaseAddress(AieTargetModel targetModel)
MLIR_CAPI_EXPORTED uint32_t aieTargetModelGetMemSouthBaseAddress(AieTargetModel targetModel)
MLIR_CAPI_EXPORTED bool aieTargetModelIsNorth(AieTargetModel targetModel, int src_col, int src_row, int dst_col, int dst_row)
MLIR_CAPI_EXPORTED bool aieTargetModelIsSouth(AieTargetModel targetModel, int src_col, int src_row, int dst_col, int dst_row)
MLIR_CAPI_EXPORTED uint32_t aieTargetModelGetNumMemTileRows(AieTargetModel targetModel)
MLIR_CAPI_EXPORTED uint32_t aieTargetModelGetColumnShift(AieTargetModel targetModel)
MLIR_CAPI_EXPORTED bool aieTargetModelIsShimPLTile(AieTargetModel targetModel, int col, int row)
MLIR_CAPI_EXPORTED uint32_t aieTargetModelGetRowShift(AieTargetModel targetModel)
MLIR_CAPI_EXPORTED bool aieTargetModelIsMemNorth(AieTargetModel targetModel, int src_col, int src_row, int dst_col, int dst_row)