External Memory to Core¶
The design in ext_to_core.py uses an ObjectFifo of_in to bring data from external memory to my_worker and another ObjectFifo of_out to send the data from the Worker to external memory. Each fifo uses a double buffer.
# Dataflow with ObjectFifos
of_in = ObjectFifo(tile_ty, name="in")
of_out = ObjectFifo(tile_ty, name="out")
Both consumer and producer processes are running on my_worker. The producer process acquires one object from of_in to consume and one object from of_out to produce into. It then reads the value of the input object and adds 1 to all its entries before releasing both objects.
The design is wrapped in @iron.jit, so a single command JIT-compiles and runs it on the attached NPU:
make run # builds + runs on the NPU (devicename={npu,npu2})
make emit-mlir # writes the lowered MLIR to build/aie.mlir without touching the NPU
The # To/from AIE-array data movement section of the design code is described in detail in Section 2d.
Other examples containing this data movement pattern are available in the programming_examples. A few notable ones are vector_reduce_add and vector_scalar_add.