Skip to content

Commit

Permalink
fix cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
makslevental committed Dec 20, 2023
1 parent d27c3dd commit 8c83263
Show file tree
Hide file tree
Showing 13 changed files with 140 additions and 110 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/buildAndTestAieTools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,4 +117,6 @@ jobs:
fi
sed -i.bak 's/-sv --timeout 600/-sv --timeout 600 -j1/g' ../test/CMakeLists.txt
sed -i.bak 's/-sv --timeout 300/-sv --timeout 600 -j1 --show-unsupported/g' ../reference_designs/CMakeLists.txt
LIT_FILTER="$LIT_FILTER" PATH=/opt/Xilinx/Vitis/2023.2/aietools/bin:$PATH ninja check-aie
PATH=/opt/Xilinx/Vitis/2023.2/aietools/bin:$PATH ninja check-reference-designs
6 changes: 2 additions & 4 deletions .github/workflows/buildAndTestRyzenAI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ defaults:
shell: bash

concurrency:
# A PR number if a pull request and otherwise the commit hash. This cancels
# queued and in-progress runs for the same PR (presubmit) or commit
# (postsubmit).
group: ci-build-test-ryzenai-${{ github.event.number || github.sha }}
group: ci-build-test-ryzenai

env:
DEBIAN_FRONTEND: noninteractive
Expand Down Expand Up @@ -74,5 +71,6 @@ jobs:
ninja install
sed -i.bak 's/-sv --timeout 600/-sv --timeout 600 -j12 --show-unsupported/g' $PWD/../test/CMakeLists.txt
sed -i.bak 's/-sv --timeout 300/-sv --timeout 600 -j12 --show-unsupported/g' $PWD/../reference_designs/CMakeLists.txt
ninja check-aie
ninja check-reference-designs
58 changes: 30 additions & 28 deletions reference_designs/MM_2x2/circuit_switched_version/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
//
//===----------------------------------------------------------------------===//

#include "memory_allocator.h"
#include "test_library.h"

#include <cassert>
#include <cmath>
#include <cstdio>
Expand Down Expand Up @@ -46,19 +48,19 @@ int main(int argc, char *argv[]) {
usleep(sleep_u);
printf("before configure DMA\n");
mlir_aie_configure_dmas(_xaie);
mlir_aie_init_mems(_xaie, 8);
int errors = 0;

printf("Finish configure\n");
#define DMA_COUNT 1024
int *mem_ptr0 = mlir_aie_mem_alloc(_xaie, 0, DMA_COUNT);
int *mem_ptr1 = mlir_aie_mem_alloc(_xaie, 1, DMA_COUNT);
int *mem_ptr2 = mlir_aie_mem_alloc(_xaie, 2, DMA_COUNT);
int *mem_ptr3 = mlir_aie_mem_alloc(_xaie, 3, DMA_COUNT);
int *mem_ptr4 = mlir_aie_mem_alloc(_xaie, 4, DMA_COUNT);
int *mem_ptr5 = mlir_aie_mem_alloc(_xaie, 5, DMA_COUNT);
int *mem_ptr6 = mlir_aie_mem_alloc(_xaie, 6, DMA_COUNT);
int *mem_ptr7 = mlir_aie_mem_alloc(_xaie, 7, DMA_COUNT);
ext_mem_model_t buf0, buf1, buf2, buf3, buf4, buf5, buf6, buf7;
int *mem_ptr0 = mlir_aie_mem_alloc(_xaie, buf0, DMA_COUNT);
int *mem_ptr1 = mlir_aie_mem_alloc(_xaie, buf1, DMA_COUNT);
int *mem_ptr2 = mlir_aie_mem_alloc(_xaie, buf2, DMA_COUNT);
int *mem_ptr3 = mlir_aie_mem_alloc(_xaie, buf3, DMA_COUNT);
int *mem_ptr4 = mlir_aie_mem_alloc(_xaie, buf4, DMA_COUNT);
int *mem_ptr5 = mlir_aie_mem_alloc(_xaie, buf5, DMA_COUNT);
int *mem_ptr6 = mlir_aie_mem_alloc(_xaie, buf6, DMA_COUNT);
int *mem_ptr7 = mlir_aie_mem_alloc(_xaie, buf7, DMA_COUNT);

// initialize the external buffers
for (int i = 0; i < DMA_COUNT; i++) {
Expand All @@ -72,23 +74,23 @@ int main(int argc, char *argv[]) {
*(mem_ptr7 + i) = 99; // Out_tile1
}

mlir_aie_sync_mem_dev(_xaie, 0); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 1); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 2); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 3); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 4); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 5); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 6); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 7); // only used in libaiev2

mlir_aie_external_set_addr_LHS_tile0((u64)mem_ptr0);
mlir_aie_external_set_addr_LHS_tile1((u64)mem_ptr1);
mlir_aie_external_set_addr_RHS_tile0((u64)mem_ptr2);
mlir_aie_external_set_addr_RHS_tile1((u64)mem_ptr3);
mlir_aie_external_set_addr_RHS_tile2((u64)mem_ptr4);
mlir_aie_external_set_addr_RHS_tile3((u64)mem_ptr5);
mlir_aie_external_set_addr_Out_tile0((u64)mem_ptr6);
mlir_aie_external_set_addr_Out_tile1((u64)mem_ptr7);
mlir_aie_sync_mem_dev(buf0); // only used in libaiev2
mlir_aie_sync_mem_dev(buf1); // only used in libaiev2
mlir_aie_sync_mem_dev(buf2); // only used in libaiev2
mlir_aie_sync_mem_dev(buf3); // only used in libaiev2
mlir_aie_sync_mem_dev(buf4); // only used in libaiev2
mlir_aie_sync_mem_dev(buf5); // only used in libaiev2
mlir_aie_sync_mem_dev(buf6); // only used in libaiev2
mlir_aie_sync_mem_dev(buf7); // only used in libaiev2

mlir_aie_external_set_addr_LHS_tile0(_xaie, (u64)mem_ptr0);
mlir_aie_external_set_addr_LHS_tile1(_xaie, (u64)mem_ptr1);
mlir_aie_external_set_addr_RHS_tile0(_xaie, (u64)mem_ptr2);
mlir_aie_external_set_addr_RHS_tile1(_xaie, (u64)mem_ptr3);
mlir_aie_external_set_addr_RHS_tile2(_xaie, (u64)mem_ptr4);
mlir_aie_external_set_addr_RHS_tile3(_xaie, (u64)mem_ptr5);
mlir_aie_external_set_addr_Out_tile0(_xaie, (u64)mem_ptr6);
mlir_aie_external_set_addr_Out_tile1(_xaie, (u64)mem_ptr7);
mlir_aie_configure_shimdma_60(_xaie);
mlir_aie_configure_shimdma_70(_xaie);
mlir_aie_configure_shimdma_100(_xaie);
Expand Down Expand Up @@ -141,8 +143,8 @@ int main(int argc, char *argv[]) {

mlir_aie_acquire_Out_tile0_lock(_xaie, 0, 0);
mlir_aie_acquire_Out_tile1_lock(_xaie, 0, 0);
mlir_aie_sync_mem_cpu(_xaie, 6); // only used in libaiev2
mlir_aie_sync_mem_cpu(_xaie, 7); // only used in libaiev2
mlir_aie_sync_mem_cpu(buf6); // only used in libaiev2
mlir_aie_sync_mem_cpu(buf7); // only used in libaiev2

for (int idx0 = 0; idx0 < 1024; ++idx0) {
if (mem_ptr6[idx0] != 352) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// RUN: aiecc.py %VitisSysrootFlag% --host-target=%aieHostTargetTriplet% %s -I%host_runtime_lib%/test_lib/include %extraAieCcFlags% -L%host_runtime_lib%/test_lib/lib -ltest_lib %S/test.cpp -o test.elf
// RUN: %run_on_board ./test.elf

module @MM_2x2 {
AIE.device(xcvc1902) {
%t60 = AIE.tile(6, 0)
%t63 = AIE.tile(6, 3)
%t64 = AIE.tile(6, 4)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
//
//===----------------------------------------------------------------------===//

#include "memory_allocator.h"
#include "test_library.h"

#include <cassert>
#include <cmath>
#include <cstdio>
Expand Down Expand Up @@ -46,19 +48,19 @@ int main(int argc, char *argv[]) {
usleep(sleep_u);
printf("before configure DMA\n");
mlir_aie_configure_dmas(_xaie);
mlir_aie_init_mems(_xaie, 8);
int errors = 0;

printf("Finish configure\n");
#define DMA_COUNT 1024
int *mem_ptr0 = mlir_aie_mem_alloc(_xaie, 0, DMA_COUNT);
int *mem_ptr1 = mlir_aie_mem_alloc(_xaie, 1, DMA_COUNT);
int *mem_ptr2 = mlir_aie_mem_alloc(_xaie, 2, DMA_COUNT);
int *mem_ptr3 = mlir_aie_mem_alloc(_xaie, 3, DMA_COUNT);
int *mem_ptr4 = mlir_aie_mem_alloc(_xaie, 4, DMA_COUNT);
int *mem_ptr5 = mlir_aie_mem_alloc(_xaie, 5, DMA_COUNT);
int *mem_ptr6 = mlir_aie_mem_alloc(_xaie, 6, DMA_COUNT);
int *mem_ptr7 = mlir_aie_mem_alloc(_xaie, 7, DMA_COUNT);
ext_mem_model_t buf0, buf1, buf2, buf3, buf4, buf5, buf6, buf7;
int *mem_ptr0 = mlir_aie_mem_alloc(_xaie, buf0, DMA_COUNT);
int *mem_ptr1 = mlir_aie_mem_alloc(_xaie, buf1, DMA_COUNT);
int *mem_ptr2 = mlir_aie_mem_alloc(_xaie, buf2, DMA_COUNT);
int *mem_ptr3 = mlir_aie_mem_alloc(_xaie, buf3, DMA_COUNT);
int *mem_ptr4 = mlir_aie_mem_alloc(_xaie, buf4, DMA_COUNT);
int *mem_ptr5 = mlir_aie_mem_alloc(_xaie, buf5, DMA_COUNT);
int *mem_ptr6 = mlir_aie_mem_alloc(_xaie, buf6, DMA_COUNT);
int *mem_ptr7 = mlir_aie_mem_alloc(_xaie, buf7, DMA_COUNT);

// initialize the external buffers
for (int i = 0; i < DMA_COUNT; i++) {
Expand All @@ -72,23 +74,23 @@ int main(int argc, char *argv[]) {
*(mem_ptr7 + i) = 99; // Out_tile1
}

mlir_aie_sync_mem_dev(_xaie, 0); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 1); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 2); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 3); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 4); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 5); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 6); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 7); // only used in libaiev2

mlir_aie_external_set_addr_LHS_tile0((u64)mem_ptr0);
mlir_aie_external_set_addr_LHS_tile1((u64)mem_ptr1);
mlir_aie_external_set_addr_RHS_tile0((u64)mem_ptr2);
mlir_aie_external_set_addr_RHS_tile1((u64)mem_ptr3);
mlir_aie_external_set_addr_RHS_tile2((u64)mem_ptr4);
mlir_aie_external_set_addr_RHS_tile3((u64)mem_ptr5);
mlir_aie_external_set_addr_Out_tile0((u64)mem_ptr6);
mlir_aie_external_set_addr_Out_tile1((u64)mem_ptr7);
mlir_aie_sync_mem_dev(buf0); // only used in libaiev2
mlir_aie_sync_mem_dev(buf1); // only used in libaiev2
mlir_aie_sync_mem_dev(buf2); // only used in libaiev2
mlir_aie_sync_mem_dev(buf3); // only used in libaiev2
mlir_aie_sync_mem_dev(buf4); // only used in libaiev2
mlir_aie_sync_mem_dev(buf5); // only used in libaiev2
mlir_aie_sync_mem_dev(buf6); // only used in libaiev2
mlir_aie_sync_mem_dev(buf7); // only used in libaiev2

mlir_aie_external_set_addr_LHS_tile0(_xaie, (u64)mem_ptr0);
mlir_aie_external_set_addr_LHS_tile1(_xaie, (u64)mem_ptr1);
mlir_aie_external_set_addr_RHS_tile0(_xaie, (u64)mem_ptr2);
mlir_aie_external_set_addr_RHS_tile1(_xaie, (u64)mem_ptr3);
mlir_aie_external_set_addr_RHS_tile2(_xaie, (u64)mem_ptr4);
mlir_aie_external_set_addr_RHS_tile3(_xaie, (u64)mem_ptr5);
mlir_aie_external_set_addr_Out_tile0(_xaie, (u64)mem_ptr6);
mlir_aie_external_set_addr_Out_tile1(_xaie, (u64)mem_ptr7);
mlir_aie_configure_shimdma_60(_xaie);
mlir_aie_configure_shimdma_70(_xaie);
mlir_aie_configure_shimdma_100(_xaie);
Expand All @@ -108,8 +110,8 @@ int main(int argc, char *argv[]) {

mlir_aie_acquire_of_out0_cons_lock_0(_xaie, 1, 0);
mlir_aie_acquire_of_out1_cons_lock_0(_xaie, 1, 0);
mlir_aie_sync_mem_cpu(_xaie, 6); // only used in libaiev2
mlir_aie_sync_mem_cpu(_xaie, 7); // only used in libaiev2
mlir_aie_sync_mem_cpu(buf6); // only used in libaiev2
mlir_aie_sync_mem_cpu(buf7); // only used in libaiev2

for (int idx0 = 0; idx0 < 1024; ++idx0) {
if (mem_ptr6[idx0] != 352) {
Expand Down
58 changes: 30 additions & 28 deletions reference_designs/MM_2x2/packet_switched_version/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
//
//===----------------------------------------------------------------------===//

#include "memory_allocator.h"
#include "test_library.h"

#include <cassert>
#include <cmath>
#include <cstdio>
Expand Down Expand Up @@ -52,19 +54,19 @@ int main(int argc, char *argv[]) {
printf("before configure DMA\n");

mlir_aie_configure_dmas(_xaie);
mlir_aie_init_mems(_xaie, 8);
int errors = 0;

printf("Finish configure\n");
#define DMA_COUNT 1024
int *mem_ptr0 = mlir_aie_mem_alloc(_xaie, 0, DMA_COUNT);
int *mem_ptr1 = mlir_aie_mem_alloc(_xaie, 1, DMA_COUNT);
int *mem_ptr2 = mlir_aie_mem_alloc(_xaie, 2, DMA_COUNT);
int *mem_ptr3 = mlir_aie_mem_alloc(_xaie, 3, DMA_COUNT);
int *mem_ptr4 = mlir_aie_mem_alloc(_xaie, 4, DMA_COUNT);
int *mem_ptr5 = mlir_aie_mem_alloc(_xaie, 5, DMA_COUNT);
int *mem_ptr6 = mlir_aie_mem_alloc(_xaie, 6, DMA_COUNT + 1);
int *mem_ptr7 = mlir_aie_mem_alloc(_xaie, 7, DMA_COUNT + 1);
ext_mem_model_t buf0, buf1, buf2, buf3, buf4, buf5, buf6, buf7;
int *mem_ptr0 = mlir_aie_mem_alloc(_xaie, buf0, DMA_COUNT);
int *mem_ptr1 = mlir_aie_mem_alloc(_xaie, buf1, DMA_COUNT);
int *mem_ptr2 = mlir_aie_mem_alloc(_xaie, buf2, DMA_COUNT);
int *mem_ptr3 = mlir_aie_mem_alloc(_xaie, buf3, DMA_COUNT);
int *mem_ptr4 = mlir_aie_mem_alloc(_xaie, buf4, DMA_COUNT);
int *mem_ptr5 = mlir_aie_mem_alloc(_xaie, buf5, DMA_COUNT);
int *mem_ptr6 = mlir_aie_mem_alloc(_xaie, buf6, DMA_COUNT + 1);
int *mem_ptr7 = mlir_aie_mem_alloc(_xaie, buf7, DMA_COUNT + 1);

// initialize the external buffers
for (int i = 0; i < DMA_COUNT + 1; i++) {
Expand All @@ -83,23 +85,23 @@ int main(int argc, char *argv[]) {
}
}

mlir_aie_sync_mem_dev(_xaie, 0); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 1); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 2); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 3); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 4); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 5); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 6); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 7); // only used in libaiev2

mlir_aie_external_set_addr_LHS_tile0((u64)mem_ptr0);
mlir_aie_external_set_addr_LHS_tile1((u64)mem_ptr1);
mlir_aie_external_set_addr_RHS_tile0((u64)mem_ptr2);
mlir_aie_external_set_addr_RHS_tile1((u64)mem_ptr3);
mlir_aie_external_set_addr_RHS_tile2((u64)mem_ptr4);
mlir_aie_external_set_addr_RHS_tile3((u64)mem_ptr5);
mlir_aie_external_set_addr_Out_tile0((u64)mem_ptr6);
mlir_aie_external_set_addr_Out_tile1((u64)mem_ptr7);
mlir_aie_sync_mem_dev(buf0); // only used in libaiev2
mlir_aie_sync_mem_dev(buf1); // only used in libaiev2
mlir_aie_sync_mem_dev(buf2); // only used in libaiev2
mlir_aie_sync_mem_dev(buf3); // only used in libaiev2
mlir_aie_sync_mem_dev(buf4); // only used in libaiev2
mlir_aie_sync_mem_dev(buf5); // only used in libaiev2
mlir_aie_sync_mem_dev(buf6); // only used in libaiev2
mlir_aie_sync_mem_dev(buf7); // only used in libaiev2

mlir_aie_external_set_addr_LHS_tile0(_xaie, (u64)mem_ptr0);
mlir_aie_external_set_addr_LHS_tile1(_xaie, (u64)mem_ptr1);
mlir_aie_external_set_addr_RHS_tile0(_xaie, (u64)mem_ptr2);
mlir_aie_external_set_addr_RHS_tile1(_xaie, (u64)mem_ptr3);
mlir_aie_external_set_addr_RHS_tile2(_xaie, (u64)mem_ptr4);
mlir_aie_external_set_addr_RHS_tile3(_xaie, (u64)mem_ptr5);
mlir_aie_external_set_addr_Out_tile0(_xaie, (u64)mem_ptr6);
mlir_aie_external_set_addr_Out_tile1(_xaie, (u64)mem_ptr7);
mlir_aie_configure_shimdma_70(_xaie);
mlir_aie_configure_shimdma_60(_xaie);

Expand Down Expand Up @@ -147,8 +149,8 @@ int main(int argc, char *argv[]) {
errors);
}

mlir_aie_sync_mem_cpu(_xaie, 6); // only used in libaiev2
mlir_aie_sync_mem_cpu(_xaie, 7); // only used in libaiev2
mlir_aie_sync_mem_cpu(buf6); // only used in libaiev2
mlir_aie_sync_mem_cpu(buf7); // only used in libaiev2

// Check if the external buffer receives the correct result
int Header0 = mem_ptr6[0] & 31;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

// REQUIRES: valid_xchess_license
// RUN: aiecc.py %VitisSysrootFlag% --host-target=%aieHostTargetTriplet% %s -I%host_runtime_lib%/test_lib/include %extraAieCcFlags% -L%host_runtime_lib%/test_lib/lib -ltest_lib %S/test.cpp -o test.elf
// RUN: %run_on_board ./test.elf
// RUN: %run_on_board ./test.elf

// XFAIL: *

module @autocorrelation {
%tile0_1 = AIE.tile(2, 1)
Expand Down
21 changes: 12 additions & 9 deletions reference_designs/autocorrelation/objectFifo_version/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
//
//===----------------------------------------------------------------------===//

#include "memory_allocator.h"
#include "test_library.h"

#include <cassert>
#include <cmath>
#include <cstdio>
Expand Down Expand Up @@ -37,12 +39,13 @@ int main(int argc, char *argv[]) {

int errors = 0;

mlir_aie_init_mems(_xaie, 2);
int *input = mlir_aie_mem_alloc(_xaie, 0, 1024);
int *output = mlir_aie_mem_alloc(_xaie, 1, 1024);
#define DMA_COUNT 1024
ext_mem_model_t buf0, buf1;
int *input = mlir_aie_mem_alloc(_xaie, buf0, DMA_COUNT);
int *output = mlir_aie_mem_alloc(_xaie, buf1, DMA_COUNT);

mlir_aie_external_set_addr_input((u64)input);
mlir_aie_external_set_addr_output((u64)output);
mlir_aie_external_set_addr_input(_xaie, (u64)input);
mlir_aie_external_set_addr_output(_xaie, (u64)output);

mlir_aie_configure_shimdma_70(_xaie);
mlir_aie_start_cores(_xaie);
Expand All @@ -51,8 +54,8 @@ int main(int argc, char *argv[]) {
input[i] = rand() & 0xFF;
}

mlir_aie_sync_mem_dev(_xaie, 0); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 1); // only used in libaiev2
mlir_aie_sync_mem_dev(buf0); // only used in libaiev2
mlir_aie_sync_mem_dev(buf1); // only used in libaiev2

mlir_aie_release_of_in_lock_0(_xaie, 1, 10000);

Expand All @@ -61,8 +64,8 @@ int main(int argc, char *argv[]) {
printf("ERROR: timeout hit!\n");
}

mlir_aie_sync_mem_dev(_xaie, 0); // only used in libaiev2
mlir_aie_sync_mem_dev(_xaie, 1); // only used in libaiev2
mlir_aie_sync_mem_dev(buf0); // only used in libaiev2
mlir_aie_sync_mem_dev(buf1); // only used in libaiev2

for (int i = 0; i < 64; i++) {
printf("output[%d] = %d\n", i, output[i]);
Expand Down
Loading

0 comments on commit 8c83263

Please sign in to comment.