Macro for Device Architectures - 2025.2 English - UG1076

AI Engine Tools and Flows User Guide (UG1076)

Document ID
UG1076
Release Date
2025-11-20
Version
2025.2 English

Macro __AIE_ARCH__

The AI Engine compiler supports predefined macro __AIE_ARCH__ to differentiate different architectures:

  • __AIE_ARCH__=10: The AI Engine device has a predefined value of 10.
  • __AIE_ARCH__=20: The AI Engine-ML device has a predefined value of 20.

You can use the macro inside the AI Engine kernel or AI Engine graph code. When designing for different architectures, use the macro to guard for specific architectures.

For example, the kernel code uses the macro to choose architecture-specific API:

void fir24(input_buffer<cint16,...> &iwin, output_buffer<cint16> &owin) {
  ...
  #if __AIE_ARCH__==10
    acc=aie::sliding_mul_sym<4,4>(...);
  #elif __AIE_ARCH__==20
    acc=aie::sliding_mul<4,8>(...);
  #endif
  ...
}

The following example shows how to use the macro in the graph code to choose buffer sizes based on a specific architecture:

//Using __AIE_ARCH__ macro to define buffer size for AI Engine device
#if __AIE_ARCH__==10
  static const int NUM=4096;
//Using __AIE_ARCH__ macro to define buffer size for AI Engine-ML device
#elif __AIE_ARCH__==20
  static const int NUM=8192;
//Covering rest of the cases - recommended for PS compilation
#else
  static const int NUM=4096; 
#endif

using namespace adf;
class topgraph: public adf::graph
{
public:
	kernel k;
	
	topgraph(){
            ......
            k=kernel::create(mykernel);
            dimensions(k.in[0])={NUM};
            dimensions(k.out[0])={NUM};
	}
};
Note: If the PS code compilation includes the graph code, you must add -D__AIE_ARCH__=<NUM> preprocessor definition to the Arm cross compiler to differentiate the devices.