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 4f19d28
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 52 deletions.
35 changes: 19 additions & 16 deletions reference_designs/MM_2x2/circuit_switched_version/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
//===----------------------------------------------------------------------===//

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

#include <cassert>
#include <cmath>
#include <cstdio>
Expand Down Expand Up @@ -51,14 +53,15 @@ int main(int argc, char *argv[]) {

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,14 +75,14 @@ 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_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((u64)mem_ptr0);
mlir_aie_external_set_addr_LHS_tile1((u64)mem_ptr1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
//===----------------------------------------------------------------------===//

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

#include <cassert>
#include <cmath>
#include <cstdio>
Expand Down Expand Up @@ -51,14 +53,15 @@ int main(int argc, char *argv[]) {

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,14 +75,14 @@ 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_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((u64)mem_ptr0);
mlir_aie_external_set_addr_LHS_tile1((u64)mem_ptr1);
Expand Down
35 changes: 19 additions & 16 deletions reference_designs/MM_2x2/packet_switched_version/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
//===----------------------------------------------------------------------===//

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

#include <cassert>
#include <cmath>
#include <cstdio>
Expand Down Expand Up @@ -57,14 +59,15 @@ int main(int argc, char *argv[]) {

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,14 +86,14 @@ 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_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((u64)mem_ptr0);
mlir_aie_external_set_addr_LHS_tile1((u64)mem_ptr1);
Expand Down
6 changes: 4 additions & 2 deletions reference_designs/autocorrelation/objectFifo_version/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
//===----------------------------------------------------------------------===//

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

#include <cassert>
#include <cmath>
#include <cstdio>
Expand Down Expand Up @@ -41,8 +43,8 @@ int main(int argc, char *argv[]) {
int *input = mlir_aie_mem_alloc(_xaie, 0, 1024);
int *output = mlir_aie_mem_alloc(_xaie, 1, 1024);

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 Down
6 changes: 4 additions & 2 deletions reference_designs/autocorrelation/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
//===----------------------------------------------------------------------===//

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

#include <cassert>
#include <cmath>
#include <cstdio>
Expand Down Expand Up @@ -41,8 +43,8 @@ int main(int argc, char *argv[]) {
int *input = mlir_aie_mem_alloc(_xaie, 0, 1024);
int *output = mlir_aie_mem_alloc(_xaie, 1, 1024);

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 Down
1 change: 1 addition & 0 deletions runtime_lib/test_lib/memory_allocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#define AIE_MEMORY_ALLOCATOR_H

#include "target.h"

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
Expand Down

0 comments on commit 4f19d28

Please sign in to comment.