Skip to content

Commit

Permalink
Lit test fix (Xilinx#402)
Browse files Browse the repository at this point in the history
* Changing tests to return non-zero value when failing to be seen by lit

* Fixing how we compile lit tests to correctly link against libxaie and rocr

* Fixing build-mlir-air-pcie.sh to work with virtualenv as well as enable board tests

* Updating tests to work again on the VCK5000

* Ignoring test 06 for now. Coming back to it

* Reverting a change to build-mlir-air-pcie.sh

* clang format
  • Loading branch information
eddierichter-amd authored Jan 26, 2024
1 parent 690ba0e commit fb50c06
Show file tree
Hide file tree
Showing 13 changed files with 88 additions and 16 deletions.
1 change: 1 addition & 0 deletions test/06_air_link_shared/run.lit
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//

// REQUIRES: false
// RUN: aircc.py --shared -row-offset=2 -col-offset=7 %S/air.mlir -o aie_ctrl.so
// RUN: %CLANG %S/test.cpp -Iair_project/segment_0 -I%HSA_DIR%/include -L%HSA_DIR%/lib -lhsa-runtime64 -I%LIBXAIE_DIR%/include -L%LIBXAIE_DIR%/lib -lxaiengine -I%AIE_RUNTIME_DIR%/test_lib/include -L%AIE_RUNTIME_DIR%/test_lib/lib -ltest_lib %airhost_libs% -o %T/test.elf
// RUN: %run_on_board %T/test.elf
29 changes: 25 additions & 4 deletions test/06_air_link_shared/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@

int main(int argc, char *argv[]) {

int errors = 0;
hsa_status_t init_status = air_init();

if (init_status != HSA_STATUS_SUCCESS) {
Expand Down Expand Up @@ -83,10 +84,32 @@ int main(int argc, char *argv[]) {

printf("loading aie_ctrl.so\n");
auto handle = air_module_load_from_file("./aie_ctrl.so", &agents[0], q);
assert(handle && "failed to load aie_ctrl.so");

if (!handle) {
printf("Failed to load aie_ctrl.so\n");
// Need to destroy the queue and shutdown hsa
hsa_queue_destroy(queues[0]);
hsa_status_t shut_down_ret = air_shut_down();
if (shut_down_ret != HSA_STATUS_SUCCESS) {
printf("[ERROR] air_shut_down() failed\n");
errors++;
}
return -1;
}

auto graph_fn = (void (*)(void*,void *))dlsym((void*)handle, "_mlir_ciface_graph");
assert(graph_fn && "failed to locate _mlir_ciface_graph in .so");

if (!graph_fn) {
printf("failed to locate _mlir_cifage_graph in .so\n");
// Need to destroy the queue and shutdown hsa
hsa_queue_destroy(queues[0]);
hsa_status_t shut_down_ret = air_shut_down();
if (shut_down_ret != HSA_STATUS_SUCCESS) {
printf("[ERROR] air_shut_down() failed\n");
errors++;
}
return -1;
}

tensor_t<uint32_t,2> input;
tensor_t<uint32_t,2> output;
Expand All @@ -109,8 +132,6 @@ int main(int argc, char *argv[]) {
o = &output;
graph_fn(i, o);

int errors = 0;

// Go look at the scratch buffer
for (int i=0;i<TILE_SIZE;i++) {
u32 rb = mlir_aie_read_buffer_scratch_0_0(xaie, i);
Expand Down
3 changes: 2 additions & 1 deletion test/11_mb_shim_dma_from_tile_dma/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,10 @@ main(int argc, char *argv[])

if (errs == 0) {
printf("PASS!\n");
return 0;
} else {
printf("fail %d/%d.\n",DMA_COUNT-errs, DMA_COUNT);
return -1;
}

return 0;
}
16 changes: 8 additions & 8 deletions test/13_mb_add_one/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,6 @@ main(int argc, char *argv[])
}
}


if (!errors) {
printf("PASS!\n");
} else {
printf("fail %d/%d.\n", errors, DMA_COUNT);
}

// destroying the queue
hsa_queue_destroy(queues[0]);
air_free(src);
Expand All @@ -212,5 +205,12 @@ main(int argc, char *argv[])
printf("[ERROR] air_shut_down() failed\n");
return -1;
}
return 0;

if (!errors) {
printf("PASS!\n");
return 0;
} else {
printf("fail %d/%d.\n", errors, DMA_COUNT);
return -1;
}
}
22 changes: 22 additions & 0 deletions test/15_dual_mb_dual_herd_add_one/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,17 @@ main(int argc, char *argv[])
return -1;
}

if (agents.size() < 2) {
std::cout << "WARNING: Test is unsuported with < 2 queues." << std::endl;

// Shutdown AIR and HSA
hsa_status_t shut_down_ret = air_shut_down();
if (shut_down_ret != HSA_STATUS_SUCCESS) {
printf("[ERROR] air_shut_down() failed\n");
}
return 0;
}

std::cout << "Found " << agents.size() << " agents" << std::endl;

uint32_t aie_max_queue_size(0);
Expand Down Expand Up @@ -225,6 +236,17 @@ main(int argc, char *argv[])
}
}

// destroying the queue
hsa_queue_destroy(queues[0]);
hsa_queue_destroy(queues[1]);

// Shutdown AIR and HSA
hsa_status_t shut_down_ret = air_shut_down();
if (shut_down_ret != HSA_STATUS_SUCCESS) {
printf("[ERROR] air_shut_down() failed\n");
errors++;
}

for (int i=0; i<DMA_COUNT; i++) {
uint32_t d = bram_ptr[2*DMA_COUNT+i];
if (d != (i+2)) {
Expand Down
7 changes: 7 additions & 0 deletions test/272_barrier_and_hello/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ int main(int argc, char *argv[]) {

if (agents.size() < 2) {
std::cout << "WARNING: Test is unsuported with < 2 queues." << std::endl;

// Shutdown AIR and HSA
hsa_status_t shut_down_ret = air_shut_down();
if (shut_down_ret != HSA_STATUS_SUCCESS) {
printf("[ERROR] air_shut_down() failed\n");
}

return 0;
}

Expand Down
7 changes: 7 additions & 0 deletions test/273_barrier_add_two/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ main(int argc, char *argv[])

if (agents.size() < 2) {
std::cout << "WARNING: Test is unsuported with < 2 queues." << std::endl;

// Shutdown AIR and HSA
hsa_status_t shut_down_ret = air_shut_down();
if (shut_down_ret != HSA_STATUS_SUCCESS) {
printf("[ERROR] air_shut_down() failed\n");
}

return 0;
}

Expand Down
3 changes: 2 additions & 1 deletion test/33_air_pipeline/run.lit
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
//
//===----------------------------------------------------------------------===//

// REQUIRES: false
// RUN: aircc.py -row-offset=3 -col-offset=3 %S/air.mlir -o %T/air.mlir.a
// RUN: %CLANG %S/test.cpp -ltest_lib -L%AIE_RUNTIME_DIR%/test_lib/lib -Wl,--whole-archive %T/air.mlir.a -Wl,--no-whole-archive -g -I%LIBXAIE_DIR%/include -L%LIBXAIE_DIR%/lib -lxaiengine -I%AIE_RUNTIME_DIR%/test_lib/include -I./ -I%air_runtime_lib%/airhost/include -rdynamic -lxaiengine %airhost_libs% -o %T/test.elf
// RUN: %run_on_board %T/test.elf
// XFAIL: *
// XFAIL: *
2 changes: 2 additions & 0 deletions test/45_air_segment_two_herd/run.lit
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
//
//===----------------------------------------------------------------------===//

// REQUIRES: false
// XFAIL: *
// RUN: aircc.py %S/air.mlir -o %T/air.a
// RUN: %CLANG %S/test.cpp -I%HSA_DIR%/include -L%HSA_DIR%/lib -lhsa-runtime64 -I%LIBXAIE_DIR%/include -L%LIBXAIE_DIR%/lib -lxaiengine -I%AIE_RUNTIME_DIR%/test_lib/include -L%AIE_RUNTIME_DIR%/test_lib/lib -ltest_lib %airhost_libs% -Wl,--whole-archive %T/air.a -Wl,--no-whole-archive -rdynamic -o %T/test.elf
// RUN: %run_on_board %T/test.elf
2 changes: 2 additions & 0 deletions test/51_air_mmult_2x2_channel_broadcast/run.lit
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
//
//===----------------------------------------------------------------------===//

// REQUIRES: false
// XFAIL: *
// RUN: aircc.py -row-offset=3 -col-offset=5 %S/air.mlir -o %T/air.a
// RUN: %CLANG %S/test.cpp -I%HSA_DIR%/include -L%HSA_DIR%/lib -lhsa-runtime64 -I%LIBXAIE_DIR%/include -L%LIBXAIE_DIR%/lib -lxaiengine -I%AIE_RUNTIME_DIR%/test_lib/include -L%AIE_RUNTIME_DIR%/test_lib/lib -ltest_lib %airhost_libs% -Wl,--whole-archive %T/air.a -Wl,--no-whole-archive -rdynamic -o %T/test.elf
// RUN: %run_on_board %T/test.elf
4 changes: 2 additions & 2 deletions test/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
config.substitutions.append(('%LIBXAIE_DIR%', config.libxaie_dir))
#config.substitutions.append(('%AIE_RUNTIME_DIR%', os.path.join(config.aie_obj_root, "runtime_lib", config.test_arch)))
config.substitutions.append(('%air_runtime_lib%', air_runtime_lib))
config.substitutions.append(('%airhost_libs%', "-I" + air_runtime_lib + "/airhost/include -L" + air_runtime_lib + "/airhost -Wl,--whole-archive -lairhost -Wl,--no-whole-archive -lpthread -lstdc++ -lsysfs -ldl -lrt -lelf"))
config.substitutions.append(('%airhost_libs%', "-I" + air_runtime_lib + "/airhost/include -L" + air_runtime_lib + "/airhost -Wl,--whole-archive -lairhost -Wl,-R{}/lib -Wl,-rpath,{}/lib -Wl,--whole-archive -Wl,--no-whole-archive -lpthread -lstdc++ -lsysfs -ldl -lrt -lelf".format(config.libxaie_dir, config.rocm_root)))
config.substitutions.append(('%AIE_RUNTIME_DIR%', os.path.join(config.aie_obj_root, "runtime_lib", config.test_arch)))
config.substitutions.append(('%HSA_DIR%', "/scratch/jefff/acdc/ROCm-air-platforms/rocm"))
config.substitutions.append(('%HSA_DIR%', "{}".format(config.rocm_root)))

if(config.enable_board_tests):
config.substitutions.append(('%run_on_board', "sudo"))
Expand Down
5 changes: 5 additions & 0 deletions test/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ config.air_runtime_lib_obj_root = "@AIR_BINARY_DIR@/runtime_lib"
# test_exec_root: The root path where tests should be run.
config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@"

# Getting the path to the ROCm directory. hsa-runtime64
# points to the cmake directory so need to go up
# three directories
config.rocm_root = "@hsa-runtime64_DIR@/../../../"

# pass on vitis settings
config.enable_chess_tests = @CONFIG_ENABLE_CHESS_TESTS@
config.enable_board_tests = @CONFIG_ENABLE_BOARD_TESTS@
Expand Down
3 changes: 3 additions & 0 deletions utils/build-mlir-air-pcie.sh
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,15 @@ cmake .. \
-Dpybind11_DIR=${PYTHON_ROOT}/pybind11/share/cmake/pybind11 \
-DVitisSysroot="" \
-DLibXAIE_ROOT=${LibXAIE_DIR} \
-DPython3_FIND_VIRTUALENV=ONLY \
-Dhsa-runtime64_DIR=${HSA_DIR} \
-Dhsakmt_DIR=${HSAKMT_DIR} \
-DCMAKE_BUILD_TYPE=Release \
-DARM_TOOLCHAIN_OPT="" \
-DAIR_RUNTIME_TARGETS="x86_64" \
-DBUILD_AIR_PCIE=ON \
-DBUILD_SHARED_LIBS=OFF \
-DENABLE_BOARD_TESTS=ON \
-DLLVM_USE_LINKER=lld \
|& tee cmake.log

Expand Down

0 comments on commit fb50c06

Please sign in to comment.