MLIR-AIE
Classes | Macros | Functions
test_library.h File Reference
#include "target.h"
#include <stdio.h>
#include <stdlib.h>
+ Include dependency graph for test_library.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  EventMonitor
 

Macros

#define mlir_aie_check(s, r, v, errors)
 
#define mlir_aie_check_float(s, r, v, errors)
 

Functions

aie_libxaie_ctx_tmlir_aie_init_libxaie ()
 Initialize libXAIE and allocate a new context object.
 
void mlir_aie_deinit_libxaie (aie_libxaie_ctx_t *)
 Release access to the libXAIE context.
 
int mlir_aie_init_device (aie_libxaie_ctx_t *ctx, uint32_t device_id=0)
 Initialize the device represented by the context.
 
int mlir_aie_acquire_lock (aie_libxaie_ctx_t *ctx, int col, int row, int lockid, int lockval, int timeout)
 Acquire a physical lock.
 
int mlir_aie_release_lock (aie_libxaie_ctx_t *ctx, int col, int row, int lockid, int lockval, int timeout)
 Release a physical lock.
 
u32 mlir_aie_read32 (aie_libxaie_ctx_t *ctx, u64 addr)
 Read the AIE configuration memory at the given physical address.
 
void mlir_aie_write32 (aie_libxaie_ctx_t *ctx, u64 addr, u32 val)
 Write the AIE configuration memory at the given physical address.
 
u32 mlir_aie_data_mem_rd_word (aie_libxaie_ctx_t *ctx, int col, int row, u64 addr)
 Read a value from the data memory of a particular tile memory.
 
void mlir_aie_data_mem_wr_word (aie_libxaie_ctx_t *ctx, int col, int row, u64 addr, u32 data)
 Write a value to the data memory of a particular tile memory.
 
u64 mlir_aie_get_tile_addr (aie_libxaie_ctx_t *ctx, int col, int row)
 Return the base address of the given tile.
 
void mlir_aie_dump_tile_memory (aie_libxaie_ctx_t *ctx, int col, int row)
 Dump the contents of the memory associated with the given tile.
 
void mlir_aie_clear_tile_memory (aie_libxaie_ctx_t *ctx, int col, int row)
 Clear the contents of the memory associated with the given tile.
 
void mlir_aie_print_dma_status (aie_libxaie_ctx_t *ctx, int col, int row)
 Print the status of a dma represented by the given tile.
 
void mlir_aie_print_memtiledma_status (aie_libxaie_ctx_t *ctx, int col, int row)
 Print the status of a memtiledma represented by the given location.
 
void mlir_aie_print_shimdma_status (aie_libxaie_ctx_t *ctx, int col, int row)
 Print the status of a shimdma represented by the given location (row = 0).
 
void mlir_aie_print_tile_status (aie_libxaie_ctx_t *ctx, int col, int row)
 Print the status of a core represented by the given tile.
 
void mlir_aie_clear_config (aie_libxaie_ctx_t *ctx, int col, int row)
 Zero out the program and configuration memory of the tile.
 
void mlir_aie_clear_shim_config (aie_libxaie_ctx_t *ctx, int col, int row)
 Zero out the configuration memory of the shim tile.
 
void computeStats (u32 performance_counter[], int n)
 Given an array of values, compute and print statistics about those values.
 

Macro Definition Documentation

◆ mlir_aie_check

#define mlir_aie_check (   s,
  r,
  v,
  errors 
)
Value:
if (r != v) { \
printf("ERROR %s: %s expected %d, but was %d!\n", s, #r, v, r); \
errors++; \
}

Definition at line 32 of file test_library.h.

◆ mlir_aie_check_float

#define mlir_aie_check_float (   s,
  r,
  v,
  errors 
)
Value:
if (r != v) { \
printf("ERROR %s: %s expected %f, but was %f!\n", s, #r, v, r); \
errors++; \
}

Definition at line 37 of file test_library.h.

Function Documentation

◆ computeStats()

void computeStats ( u32  performance_counter[],
int  n 
)

Given an array of values, compute and print statistics about those values.

Parameters
performance_counterAn array of values
nThe number of values

Definition at line 1104 of file test_library.cpp.

◆ mlir_aie_acquire_lock()

int mlir_aie_acquire_lock ( aie_libxaie_ctx_t ctx,
int  col,
int  row,
int  lockid,
int  lockval,
int  timeout 
)

Acquire a physical lock.

Parameters
ctxThe context
colThe column of the lock
rowThe row of the lock
lockidThe ID of the lock in the tile.
lockvalThe value to acquire the lock with.
timeoutThe number of microseconds to wait
Returns
Return non-zero on success, i.e. the operation did not timeout.

Definition at line 304 of file test_library.cpp.

References aie_libxaie_ctx_t::DevInst.

◆ mlir_aie_clear_config()

void mlir_aie_clear_config ( aie_libxaie_ctx_t ctx,
int  col,
int  row 
)

Zero out the program and configuration memory of the tile.

Zero out the program and configuration memory of the tile.

This includes: clearing the program memory, data memory, DMA descriptors, and stream switch configuration.

Definition at line 1046 of file test_library.cpp.

References aie_libxaie_ctx_t::DevInst, and mlir_aie_get_tile_addr().

◆ mlir_aie_clear_shim_config()

void mlir_aie_clear_shim_config ( aie_libxaie_ctx_t ctx,
int  col,
int  row 
)

Zero out the configuration memory of the shim tile.

Zero out the configuration memory of the shim tile.

This includes: clearing the program memory, data memory, DMA descriptors, and stream switch configuration.

Definition at line 1076 of file test_library.cpp.

References aie_libxaie_ctx_t::DevInst, and mlir_aie_get_tile_addr().

◆ mlir_aie_clear_tile_memory()

void mlir_aie_clear_tile_memory ( aie_libxaie_ctx_t ctx,
int  col,
int  row 
)

Clear the contents of the memory associated with the given tile.

Clear the contents of the memory associated with the given tile.

Values that are zero are not shown

Definition at line 378 of file test_library.cpp.

References aie_libxaie_ctx_t::DevInst.

◆ mlir_aie_data_mem_rd_word()

u32 mlir_aie_data_mem_rd_word ( aie_libxaie_ctx_t ctx,
int  col,
int  row,
u64  addr 
)

Read a value from the data memory of a particular tile memory.

Parameters
addrThe address in the given tile.
Returns
The data

Definition at line 341 of file test_library.cpp.

References aie_libxaie_ctx_t::DevInst.

◆ mlir_aie_data_mem_wr_word()

void mlir_aie_data_mem_wr_word ( aie_libxaie_ctx_t ctx,
int  col,
int  row,
u64  addr,
u32  data 
)

Write a value to the data memory of a particular tile memory.

Parameters
addrThe address in the given tile.
dataThe data

Definition at line 351 of file test_library.cpp.

References aie_libxaie_ctx_t::DevInst.

◆ mlir_aie_deinit_libxaie()

void mlir_aie_deinit_libxaie ( aie_libxaie_ctx_t ctx)

Release access to the libXAIE context.

Parameters
ctxThe context

Definition at line 153 of file test_library.cpp.

References aie_libxaie_ctx_t::DevInst.

◆ mlir_aie_dump_tile_memory()

void mlir_aie_dump_tile_memory ( aie_libxaie_ctx_t ctx,
int  col,
int  row 
)

Dump the contents of the memory associated with the given tile.

Dump the contents of the memory associated with the given tile.

Definition at line 366 of file test_library.cpp.

References aie_libxaie_ctx_t::DevInst.

◆ mlir_aie_get_tile_addr()

u64 mlir_aie_get_tile_addr ( aie_libxaie_ctx_t ctx,
int  col,
int  row 
)

Return the base address of the given tile.

The configuration address space of most tiles is very similar, relative to this base address.

Definition at line 359 of file test_library.cpp.

References aie_libxaie_ctx_t::DevInst.

Referenced by mlir_aie_clear_config(), mlir_aie_clear_shim_config(), mlir_aie_print_dma_status(), mlir_aie_print_memtiledma_status(), mlir_aie_print_shimdma_status(), mlir_aie_print_tile_status(), and print_aie2_lock_status().

◆ mlir_aie_init_device()

int mlir_aie_init_device ( aie_libxaie_ctx_t ctx,
uint32_t  device_id 
)

Initialize the device represented by the context.

Parameters
ctxThe context
Returns
Zero on success

Definition at line 171 of file test_library.cpp.

References aie_libxaie_ctx_t::AieConfigPtr, aie_libxaie_ctx_t::DevInst, and SYSFS_PATH_MAX.

◆ mlir_aie_init_libxaie()

aie_libxaie_ctx_t * mlir_aie_init_libxaie ( )

Initialize libXAIE and allocate a new context object.

Returns
A pointer to the context

◆ mlir_aie_print_dma_status()

void mlir_aie_print_dma_status ( aie_libxaie_ctx_t ctx,
int  col,
int  row 
)

Print the status of a dma represented by the given tile.

Print the status of a dma represented by the given tile.

Definition at line 508 of file test_library.cpp.

References aie_libxaie_ctx_t::AieConfigPtr, aie_libxaie_ctx_t::DevInst, and mlir_aie_get_tile_addr().

◆ mlir_aie_print_memtiledma_status()

void mlir_aie_print_memtiledma_status ( aie_libxaie_ctx_t ctx,
int  col,
int  row 
)

Print the status of a memtiledma represented by the given location.

Print the status of a memtiledma represented by the given location.

Definition at line 713 of file test_library.cpp.

References aie_libxaie_ctx_t::AieConfigPtr, aie_libxaie_ctx_t::DevInst, mlir_aie_get_tile_addr(), and print_aie2_lock_status().

◆ mlir_aie_print_shimdma_status()

void mlir_aie_print_shimdma_status ( aie_libxaie_ctx_t ctx,
int  col,
int  row 
)

Print the status of a shimdma represented by the given location (row = 0).

Print the status of a shimdma represented by the given location (row = 0).

Definition at line 775 of file test_library.cpp.

References aie_libxaie_ctx_t::AieConfigPtr, aie_libxaie_ctx_t::DevInst, mlir_aie_get_tile_addr(), and print_aie2_lock_status().

◆ mlir_aie_print_tile_status()

void mlir_aie_print_tile_status ( aie_libxaie_ctx_t ctx,
int  col,
int  row 
)

Print the status of a core represented by the given tile.

Print the status of a core represented by the given tile.

Definition at line 945 of file test_library.cpp.

References aie_libxaie_ctx_t::AieConfigPtr, aie_libxaie_ctx_t::DevInst, mlir_aie_get_tile_addr(), and print_aie2_lock_status().

◆ mlir_aie_read32()

u32 mlir_aie_read32 ( aie_libxaie_ctx_t ctx,
u64  addr 
)

Read the AIE configuration memory at the given physical address.

Definition at line 325 of file test_library.cpp.

References aie_libxaie_ctx_t::DevInst.

◆ mlir_aie_release_lock()

int mlir_aie_release_lock ( aie_libxaie_ctx_t ctx,
int  col,
int  row,
int  lockid,
int  lockval,
int  timeout 
)

Release a physical lock.

Parameters
ctxThe context
colThe column of the lock
rowThe row of the lock
lockidThe ID of the lock in the tile.
lockvalThe value to acquire the lock with.
timeoutThe number of microseconds to wait
Returns
Return non-zero on success, i.e. the operation did not timeout.

Definition at line 318 of file test_library.cpp.

References aie_libxaie_ctx_t::DevInst.

◆ mlir_aie_write32()

void mlir_aie_write32 ( aie_libxaie_ctx_t ctx,
u64  addr,
u32  val 
)

Write the AIE configuration memory at the given physical address.

It's almost always better to use some more indirect method of accessing configuration registers, but this is provided as a last resort.

Definition at line 334 of file test_library.cpp.

References aie_libxaie_ctx_t::DevInst.