@@ -71,6 +71,20 @@ class AIETargetModel {
7171 TK_AIE2_Last = TK_AIE2_NPU2_Last,
7272 };
7373
74+ // One-hot encoded list of target model properties.
75+ enum ModelProperty {
76+ // Device uses semaphore locks.
77+ UsesSemaphoreLocks = 1U << 0 ,
78+ // Device is an NPU-based device.
79+ // There are several special cases for handling the NPU at the moment.
80+ IsNPU = 1U << 1 ,
81+ // Device model is virtualized.
82+ // This is used during CDO code generation to configure aie-rt properly.
83+ IsVirtualized = 1U << 2 ,
84+ // Device uses multi-dimensional buffer descriptors.
85+ UsesMultiDimensionalBDs = 1U << 3 ,
86+ };
87+
7488private:
7589 const TargetModelKind kind;
7690
@@ -232,9 +246,11 @@ class AIETargetModel {
232246 // Run consistency checks on the target model.
233247 void validate () const ;
234248
235- // Return true if this is an NPU-based device
236- // There are several special cases for handling the NPU at the moment.
237- virtual bool isNPU () const { return false ; }
249+ // Return true if this device has a given property.
250+ uint32_t ModelProperties = 0 ;
251+ bool hasProperty (ModelProperty Prop) const {
252+ return (ModelProperties & Prop) == Prop;
253+ }
238254
239255 // Return the bit offset of the column within a tile address.
240256 // This is used to compute the control address of a tile from it's column
@@ -318,7 +334,11 @@ class AIE1TargetModel : public AIETargetModel {
318334
319335class AIE2TargetModel : public AIETargetModel {
320336public:
321- AIE2TargetModel (TargetModelKind k) : AIETargetModel(k) {}
337+ AIE2TargetModel (TargetModelKind k) : AIETargetModel(k) {
338+ // Device properties initialization
339+ ModelProperties |= AIETargetModel::UsesSemaphoreLocks;
340+ ModelProperties |= AIETargetModel::UsesMultiDimensionalBDs;
341+ }
322342
323343 AIEArch getTargetArch () const override ;
324344
@@ -502,7 +522,10 @@ class VE2802TargetModel : public AIE2TargetModel {
502522
503523class BaseNPUTargetModel : public AIE2TargetModel {
504524public:
505- BaseNPUTargetModel (TargetModelKind k) : AIE2TargetModel(k) {}
525+ BaseNPUTargetModel (TargetModelKind k) : AIE2TargetModel(k) {
526+ // Device properties initialization
527+ ModelProperties |= AIETargetModel::IsNPU;
528+ }
506529
507530 int rows () const override {
508531 return 6 ; /* 1 Shim row, 1 memtile row, and 4 Core rows. */
@@ -521,12 +544,6 @@ class BaseNPUTargetModel : public AIE2TargetModel {
521544
522545 uint32_t getNumMemTileRows () const override { return 1 ; }
523546
524- // Return true if the device model is virtualized. This is used
525- // during CDO code generation to configure aie-rt properly.
526- virtual bool isVirtualized () const = 0;
527-
528- virtual bool isNPU () const override { return true ; }
529-
530547 static bool classof (const AIETargetModel *model) {
531548 return model->getKind () >= TK_AIE2_NPU1 &&
532549 model->getKind () < TK_AIE2_NPU2_Last;
@@ -549,8 +566,6 @@ class NPUTargetModel : public BaseNPUTargetModel {
549566 return row == 0 && col == 0 ;
550567 }
551568
552- bool isVirtualized () const override { return false ; }
553-
554569 static bool classof (const AIETargetModel *model) {
555570 return model->getKind () == TK_AIE2_NPU1;
556571 }
@@ -565,16 +580,17 @@ class VirtualizedNPUTargetModel : public BaseNPUTargetModel {
565580 : BaseNPUTargetModel(static_cast <TargetModelKind>(
566581 static_cast <std::underlying_type_t <TargetModelKind>>(TK_AIE2_NPU1) +
567582 _cols)),
568- cols (_cols) {}
583+ cols (_cols) {
584+ // Device properties initialization
585+ ModelProperties |= AIETargetModel::IsVirtualized;
586+ }
569587
570588 uint32_t getAddressGenGranularity () const override { return 32 ; }
571589
572590 int columns () const override { return cols; }
573591
574592 bool isShimNOCTile (int col, int row) const override { return row == 0 ; }
575593
576- bool isVirtualized () const override { return true ; }
577-
578594 static bool classof (const AIETargetModel *model) {
579595 return model->getKind () >= TK_AIE2_NPU1_1Col &&
580596 model->getKind () < TK_AIE2_NPU1_Last;
@@ -594,8 +610,6 @@ class NPU2TargetModel : public BaseNPUTargetModel {
594610
595611 bool isShimPLTile (int col, int row) const override { return false ; }
596612
597- bool isVirtualized () const override { return false ; }
598-
599613 static bool classof (const AIETargetModel *model) {
600614 return model->getKind () == TK_AIE2_NPU2;
601615 }
0 commit comments