diff --git a/test/unit_tests/aievec_tests/bf16_max_reduce/bf16_max_reduce-llvm.mlir b/test/unit_tests/aievec_tests/bf16_max_reduce/bf16_max_reduce-llvm.mlir index 9b4e115e70..1cdef347c0 100644 --- a/test/unit_tests/aievec_tests/bf16_max_reduce/bf16_max_reduce-llvm.mlir +++ b/test/unit_tests/aievec_tests/bf16_max_reduce/bf16_max_reduce-llvm.mlir @@ -4,7 +4,6 @@ // REQUIRES: valid_xchess_license // REQUIRES: peano // RUN: mkdir -p %t/data; cd %t -// RUN: aie-opt %s %vector-to-aievec% -o aievec.mlir // RUN: aie-opt %s %vector-to-llvmir% -o llvmir.mlir // RUN: aie-translate llvmir.mlir %llvmir-to-ll% -o dut.ll // RUN: %PEANO_INSTALL_DIR/bin/clang %clang_aie2_args -c dut.ll -o dut.o diff --git a/test/unit_tests/aievec_tests/bf16_min_reduce/bf16_min_reduce-llvm.mlir b/test/unit_tests/aievec_tests/bf16_min_reduce/bf16_min_reduce-llvm.mlir index 9997c4d3ea..badfa132b7 100644 --- a/test/unit_tests/aievec_tests/bf16_min_reduce/bf16_min_reduce-llvm.mlir +++ b/test/unit_tests/aievec_tests/bf16_min_reduce/bf16_min_reduce-llvm.mlir @@ -4,7 +4,6 @@ // REQUIRES: valid_xchess_license // REQUIRES: peano // RUN: mkdir -p %t/data; cd %t -// RUN: aie-opt %s %vector-to-aievec% -o aievec.mlir // RUN: aie-opt %s %vector-to-llvmir% -o llvmir.mlir // RUN: aie-translate llvmir.mlir %llvmir-to-ll% -o dut.ll // RUN: %PEANO_INSTALL_DIR/bin/clang %clang_aie2_args -c dut.ll -o dut.o diff --git a/test/unit_tests/aievec_tests/bf16xbf16_mul_elem/bf16xbf16_mul_elem.mlir b/test/unit_tests/aievec_tests/bf16xbf16_mul_elem/bf16xbf16_mul_elem.mlir index 0422a1db32..00f3a98bbd 100644 --- a/test/unit_tests/aievec_tests/bf16xbf16_mul_elem/bf16xbf16_mul_elem.mlir +++ b/test/unit_tests/aievec_tests/bf16xbf16_mul_elem/bf16xbf16_mul_elem.mlir @@ -5,7 +5,7 @@ // RUN: mkdir -p %t/data; cd %t // RUN: aie-opt %s -affine-super-vectorize="virtual-vector-size=16" --convert-vector-to-aievec="aie-target=aieml" -lower-affine | aie-translate -aieml=true --aievec-to-cpp -o dut.cc // RUN: xchesscc_wrapper %xchesscc_aie2_args +w work +o work -I%S -I. -c dut.cc -o dut.o -// RUN: xchesscc_wrapper %xchesscc_aie2_args -DTO_CPP +w work +o work -I%S -I. %S/testbench.cc work/dut.o +// RUN: xchesscc_wrapper %xchesscc_aie2_args +w work +o work -I%S -I. %S/testbench.cc work/dut.o // RUN: xca_udm_dbg --aiearch aie-ml -qf -T -P %aietools/data/aie_ml/lib/ -t "%S/../profiling.tcl ./work/a.out" >& xca_udm_dbg.stdout // RUN: FileCheck --input-file=./xca_udm_dbg.stdout %s // CHECK: TEST PASSED diff --git a/test/unit_tests/aievec_tests/bf16xbf16_mul_elem/testbench.cc b/test/unit_tests/aievec_tests/bf16xbf16_mul_elem/testbench.cc index fdf7d54693..d521a10aa9 100644 --- a/test/unit_tests/aievec_tests/bf16xbf16_mul_elem/testbench.cc +++ b/test/unit_tests/aievec_tests/bf16xbf16_mul_elem/testbench.cc @@ -5,17 +5,12 @@ #include #include -#ifdef TO_CPP +#ifdef TO_LLVM +extern "C" { +#endif void dut(bfloat16 *restrict in0, bfloat16 *restrict in1, bfloat16 *restrict out0); -#elif TO_LLVM -extern "C" { -void dut(bfloat16 *in0_allocated, bfloat16 *in0_aligned, int64_t in0_offset, - int64_t in0_sizes_0, int64_t in0_strides_0, bfloat16 *in1_allocated, - bfloat16 *in1_aligned, int64_t in1_offset, int64_t in1_sizes_0, - int64_t in1_strides_0, bfloat16 *out0_allocated, - bfloat16 *out0_aligned, int64_t out0_offset, int64_t out0_sizes_0, - int64_t out0_strides_0); +#ifdef TO_LLVM } #endif @@ -39,11 +34,7 @@ int main(int argc, char *argv[]) { chess_memory_fence(); auto cyclesBegin = chess_cycle_count(); -#ifdef TO_CPP dut(g_in0, g_in1, g_out0); -#elif TO_LLVM - dut(g_in0, g_in0, 0, 0, 0, g_in1, g_in1, 0, 0, 0, g_out0, g_out0, 0, 0, 0); -#endif auto cyclesEnd = chess_cycle_count(); chess_memory_fence(); diff --git a/test/unit_tests/aievec_tests/bf16xbf16_mul_elem_2/bf16xbf16_mul_elem.mlir b/test/unit_tests/aievec_tests/bf16xbf16_mul_elem_2/bf16xbf16_mul_elem.mlir index 4b8cade6f2..83834ecda0 100644 --- a/test/unit_tests/aievec_tests/bf16xbf16_mul_elem_2/bf16xbf16_mul_elem.mlir +++ b/test/unit_tests/aievec_tests/bf16xbf16_mul_elem_2/bf16xbf16_mul_elem.mlir @@ -5,7 +5,7 @@ // RUN: mkdir -p %t/data; cd %t // RUN: aie-opt %s --convert-vector-to-aievec="aie-target=aieml" -lower-affine | aie-translate -aieml=true --aievec-to-cpp -o dut.cc // RUN: xchesscc_wrapper %xchesscc_aie2_args +w work +o work -I%S -I. -c dut.cc -o dut.o -// RUN: xchesscc_wrapper %xchesscc_aie2_args -DTO_CPP +w work +o work -I%S -I. %S/testbench.cc work/dut.o +// RUN: xchesscc_wrapper %xchesscc_aie2_args +w work +o work -I%S -I. %S/testbench.cc work/dut.o // RUN: xca_udm_dbg --aiearch aie-ml -qf -T -P %aietools/data/aie_ml/lib/ -t "%S/../profiling.tcl ./work/a.out" >& xca_udm_dbg.stdout // RUN: FileCheck --input-file=./xca_udm_dbg.stdout %s // CHECK: TEST PASSED diff --git a/test/unit_tests/aievec_tests/bf16xbf16_mul_elem_2/testbench.cc b/test/unit_tests/aievec_tests/bf16xbf16_mul_elem_2/testbench.cc index 9415fa761c..69a532871e 100644 --- a/test/unit_tests/aievec_tests/bf16xbf16_mul_elem_2/testbench.cc +++ b/test/unit_tests/aievec_tests/bf16xbf16_mul_elem_2/testbench.cc @@ -5,15 +5,11 @@ #include #include -#ifdef TO_CPP -void dut(bfloat16 *restrict in0, bfloat16 *restrict in1, float *restrict out0); -#elif TO_LLVM +#ifdef TO_LLVM extern "C" { -void dut(bfloat16 *in0_allocated, bfloat16 *in0_aligned, int64_t in0_offset, - int64_t in0_sizes_0, int64_t in0_strides_0, bfloat16 *in1_allocated, - bfloat16 *in1_aligned, int64_t in1_offset, int64_t in1_sizes_0, - int64_t in1_strides_0, float *out0_allocated, float *out0_aligned, - int64_t out0_offset, int64_t out0_sizes_0, int64_t out0_strides_0); +#endif +void dut(bfloat16 *restrict in0, bfloat16 *restrict in1, float *restrict out0); +#ifdef TO_LLVM } #endif @@ -37,11 +33,7 @@ int main(int argc, char *argv[]) { chess_memory_fence(); auto cyclesBegin = chess_cycle_count(); -#ifdef TO_CPP dut(g_in0, g_in1, g_out0); -#elif TO_LLVM - dut(g_in0, g_in0, 0, 0, 0, g_in1, g_in1, 0, 0, 0, g_out0, g_out0, 0, 0, 0); -#endif auto cyclesEnd = chess_cycle_count(); chess_memory_fence(); diff --git a/test/unit_tests/aievec_tests/floatxfloat_mul_elem/floatxfloat_mul_elem.mlir b/test/unit_tests/aievec_tests/floatxfloat_mul_elem/floatxfloat_mul_elem.mlir index f0863b63ad..48e54ce293 100644 --- a/test/unit_tests/aievec_tests/floatxfloat_mul_elem/floatxfloat_mul_elem.mlir +++ b/test/unit_tests/aievec_tests/floatxfloat_mul_elem/floatxfloat_mul_elem.mlir @@ -5,7 +5,7 @@ // RUN: mkdir -p %t/data; cd %t // RUN: aie-opt %s -affine-super-vectorize="virtual-vector-size=16" --convert-vector-to-aievec="aie-target=aieml" -lower-affine | aie-translate -aieml=true --aievec-to-cpp -o dut.cc // RUN: xchesscc_wrapper %xchesscc_aie2_args +w work +o work -I%S -I. -c dut.cc -o dut.o -// RUN: xchesscc_wrapper %xchesscc_aie2_args -DTO_CPP +w work +o work -I%S -I. %S/testbench.cc work/dut.o +// RUN: xchesscc_wrapper %xchesscc_aie2_args +w work +o work -I%S -I. %S/testbench.cc work/dut.o // RUN: xca_udm_dbg --aiearch aie-ml -qf -T -P %aietools/data/aie_ml/lib/ -t "%S/../profiling.tcl ./work/a.out" >& xca_udm_dbg.stdout // RUN: FileCheck --input-file=./xca_udm_dbg.stdout %s // CHECK: TEST PASSED diff --git a/test/unit_tests/aievec_tests/floatxfloat_mul_elem/testbench.cc b/test/unit_tests/aievec_tests/floatxfloat_mul_elem/testbench.cc index 0d3289b841..1c51360146 100644 --- a/test/unit_tests/aievec_tests/floatxfloat_mul_elem/testbench.cc +++ b/test/unit_tests/aievec_tests/floatxfloat_mul_elem/testbench.cc @@ -5,15 +5,11 @@ #include #include -#ifdef TO_CPP -void dut(float *restrict in0, float *restrict in1, float *restrict out0); -#elif TO_LLVM +#ifdef TO_LLVM extern "C" { -void dut(float *in0_allocated, float *in0_aligned, int64_t in0_offset, - int64_t in0_sizes_0, int64_t in0_strides_0, float *in1_allocated, - float *in1_aligned, int64_t in1_offset, int64_t in1_sizes_0, - int64_t in1_strides_0, float *out0_allocated, float *out0_aligned, - int64_t out0_offset, int64_t out0_sizes_0, int64_t out0_strides_0); +#endif +void dut(float *restrict in0, float *restrict in1, float *restrict out0); +#ifdef TO_LLVM } #endif @@ -37,11 +33,7 @@ int main(int argc, char *argv[]) { chess_memory_fence(); auto cyclesBegin = chess_cycle_count(); -#ifdef TO_CPP dut(g_in0, g_in1, g_out0); -#elif TO_LLVM - dut(g_in0, g_in0, 0, 0, 0, g_in1, g_in1, 0, 0, 0, g_out0, g_out0, 0, 0, 0); -#endif auto cyclesEnd = chess_cycle_count(); chess_memory_fence(); diff --git a/test/unit_tests/aievec_tests/i16_max_reduce/i16_max_reduce-llvm.mlir b/test/unit_tests/aievec_tests/i16_max_reduce/i16_max_reduce-llvm.mlir new file mode 100644 index 0000000000..5b2cc863d3 --- /dev/null +++ b/test/unit_tests/aievec_tests/i16_max_reduce/i16_max_reduce-llvm.mlir @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// Copyright (C) 2024, Advanced Micro Devices, Inc. + +// REQUIRES: valid_xchess_license +// REQUIRES: peano +// RUN: mkdir -p %t/data; cd %t +// RUN: aie-opt %s %vector-to-llvmir% -o llvmir.mlir +// RUN: aie-translate llvmir.mlir %llvmir-to-ll% -o dut.ll +// RUN: %PEANO_INSTALL_DIR/bin/clang %clang_aie2_args -c dut.ll -o dut.o +// RUN: xchesscc_wrapper %xchesscc_aie2_args -DTO_LLVM +w work +o work -I%S -I. %S/testbench.cc dut.o +// RUN: xca_udm_dbg --aiearch aie-ml -qf -T -P %aietools/data/aie_ml/lib/ -t "%S/../profiling.tcl ./work/a.out" >& xca_udm_dbg.stdout +// RUN: FileCheck --input-file=./xca_udm_dbg.stdout %s +// CHECK: TEST PASSED + +module { + func.func @dut(%arg0: memref<1024xi16>, %arg1: memref) { + memref.assume_alignment %arg0, 32 : memref<1024xi16> + %c0_i16 = arith.constant 0 : i16 + %cst = arith.constant dense<-32768> : vector<32xi16> + %0 = affine.for %arg2 = 0 to 1024 step 32 iter_args(%arg3 = %cst) -> (vector<32xi16>) { + %2 = vector.transfer_read %arg0[%arg2], %c0_i16 : memref<1024xi16>, vector<32xi16> + %3 = arith.maxsi %arg3, %2 : vector<32xi16> + affine.yield %3 : vector<32xi16> + } + %1 = vector.reduction , %0 : vector<32xi16> into i16 + affine.store %1, %arg1[] : memref + return + } +} diff --git a/test/unit_tests/aievec_tests/i16_max_reduce/i16_max_reduce.mlir b/test/unit_tests/aievec_tests/i16_max_reduce/i16_max_reduce.mlir index c565737063..ebc90c0e55 100644 --- a/test/unit_tests/aievec_tests/i16_max_reduce/i16_max_reduce.mlir +++ b/test/unit_tests/aievec_tests/i16_max_reduce/i16_max_reduce.mlir @@ -1,7 +1,11 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// Copyright (C) 2023-2024, Advanced Micro Devices, Inc. + +// REQUIRES: valid_xchess_license +// RUN: mkdir -p %t/data; cd %t // RUN: aie-opt %s --convert-vector-to-aievec="aie-target=aieml" -lower-affine | aie-translate -aieml=true --aievec-to-cpp -o dut.cc -// RUN: xchesscc_wrapper aie2 -f -g +s +w work +o work -I%S -I. -c dut.cc -o dut.o -// RUN: xchesscc_wrapper aie2 -f -g +s +w work +o work -I%S -I. %S/testbench.cc work/dut.o -// RUN: mkdir -p data +// RUN: xchesscc_wrapper %xchesscc_aie2_args +w work +o work -I%S -I. -c dut.cc -o dut.o +// RUN: xchesscc_wrapper %xchesscc_aie2_args +w work +o work -I%S -I. %S/testbench.cc work/dut.o // RUN: xca_udm_dbg --aiearch aie-ml -qf -T -P %aietools/data/aie_ml/lib/ -t "%S/../profiling.tcl ./work/a.out" >& xca_udm_dbg.stdout // RUN: FileCheck --input-file=./xca_udm_dbg.stdout %s // CHECK: TEST PASSED diff --git a/test/unit_tests/aievec_tests/i16_max_reduce/testbench.cc b/test/unit_tests/aievec_tests/i16_max_reduce/testbench.cc index 9db86eacfe..b2efdc8578 100644 --- a/test/unit_tests/aievec_tests/i16_max_reduce/testbench.cc +++ b/test/unit_tests/aievec_tests/i16_max_reduce/testbench.cc @@ -6,7 +6,14 @@ #include #include +#ifdef TO_LLVM +extern "C" { +#endif void dut(int16_t *restrict in0, int16_t *restrict out0); +#ifdef TO_LLVM +} +#endif + void dut_ref(int16_t *in0, int16_t *out0); alignas(32) int16_t g_in0[IN0_SIZE]; diff --git a/test/unit_tests/aievec_tests/i16_min_reduce/i16_min_reduce-llvm.mlir b/test/unit_tests/aievec_tests/i16_min_reduce/i16_min_reduce-llvm.mlir new file mode 100644 index 0000000000..4fbe03c27e --- /dev/null +++ b/test/unit_tests/aievec_tests/i16_min_reduce/i16_min_reduce-llvm.mlir @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// Copyright (C) 2024, Advanced Micro Devices, Inc. + +// REQUIRES: valid_xchess_license +// REQUIRES: peano +// RUN: mkdir -p %t/data; cd %t +// RUN: aie-opt %s %vector-to-llvmir% -o llvmir.mlir +// RUN: aie-translate llvmir.mlir %llvmir-to-ll% -o dut.ll +// RUN: %PEANO_INSTALL_DIR/bin/clang %clang_aie2_args -c dut.ll -o dut.o +// RUN: xchesscc_wrapper %xchesscc_aie2_args -DTO_LLVM +w work +o work -I%S -I. %S/testbench.cc dut.o +// RUN: xca_udm_dbg --aiearch aie-ml -qf -T -P %aietools/data/aie_ml/lib/ -t "%S/../profiling.tcl ./work/a.out" >& xca_udm_dbg.stdout +// RUN: FileCheck --input-file=./xca_udm_dbg.stdout %s +// CHECK: TEST PASSED + +module { + func.func @dut(%arg0: memref<1024xi16>, %arg1: memref) { + memref.assume_alignment %arg0, 32 : memref<1024xi16> + %c0_i16 = arith.constant 0 : i16 + %cst = arith.constant dense<32767> : vector<32xi16> + %0 = affine.for %arg2 = 0 to 1024 step 32 iter_args(%arg3 = %cst) -> (vector<32xi16>) { + %2 = vector.transfer_read %arg0[%arg2], %c0_i16 : memref<1024xi16>, vector<32xi16> + %3 = arith.minsi %arg3, %2 : vector<32xi16> + affine.yield %3 : vector<32xi16> + } + %1 = vector.reduction , %0 : vector<32xi16> into i16 + affine.store %1, %arg1[] : memref + return + } +} diff --git a/test/unit_tests/aievec_tests/i16_min_reduce/i16_min_reduce.mlir b/test/unit_tests/aievec_tests/i16_min_reduce/i16_min_reduce.mlir index 06c8d12d9b..d3a33caf2f 100644 --- a/test/unit_tests/aievec_tests/i16_min_reduce/i16_min_reduce.mlir +++ b/test/unit_tests/aievec_tests/i16_min_reduce/i16_min_reduce.mlir @@ -1,7 +1,11 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// Copyright (C) 2023-2024, Advanced Micro Devices, Inc. + +// REQUIRES: valid_xchess_license +// RUN: mkdir -p %t/data; cd %t // RUN: aie-opt %s --convert-vector-to-aievec="aie-target=aieml" -lower-affine | aie-translate -aieml=true --aievec-to-cpp -o dut.cc -// RUN: xchesscc_wrapper aie2 -f -g +s +w work +o work -I%S -I. -c dut.cc -o dut.o -// RUN: xchesscc_wrapper aie2 -f -g +s +w work +o work -I%S -I. %S/testbench.cc work/dut.o -// RUN: mkdir -p data +// RUN: xchesscc_wrapper %xchesscc_aie2_args +w work +o work -I%S -I. -c dut.cc -o dut.o +// RUN: xchesscc_wrapper %xchesscc_aie2_args +w work +o work -I%S -I. %S/testbench.cc work/dut.o // RUN: xca_udm_dbg --aiearch aie-ml -qf -T -P %aietools/data/aie_ml/lib/ -t "%S/../profiling.tcl ./work/a.out" >& xca_udm_dbg.stdout // RUN: FileCheck --input-file=./xca_udm_dbg.stdout %s // CHECK: TEST PASSED diff --git a/test/unit_tests/aievec_tests/i16_min_reduce/testbench.cc b/test/unit_tests/aievec_tests/i16_min_reduce/testbench.cc index 0d8314492c..52f1cee4fd 100644 --- a/test/unit_tests/aievec_tests/i16_min_reduce/testbench.cc +++ b/test/unit_tests/aievec_tests/i16_min_reduce/testbench.cc @@ -6,7 +6,14 @@ #include #include +#ifdef TO_LLVM +extern "C" { +#endif void dut(int16_t *restrict in0, int16_t *restrict out0); +#ifdef TO_LLVM +} +#endif + void dut_ref(int16_t *in0, int16_t *out0); alignas(32) int16_t g_in0[IN0_SIZE]; diff --git a/test/unit_tests/aievec_tests/i32_max_reduce/i32_max_reduce-llvm.mlir b/test/unit_tests/aievec_tests/i32_max_reduce/i32_max_reduce-llvm.mlir new file mode 100644 index 0000000000..6f469c2055 --- /dev/null +++ b/test/unit_tests/aievec_tests/i32_max_reduce/i32_max_reduce-llvm.mlir @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// Copyright (C) 2024, Advanced Micro Devices, Inc. + +// REQUIRES: valid_xchess_license +// REQUIRES: peano +// RUN: mkdir -p %t/data; cd %t +// RUN: aie-opt %s %vector-to-llvmir% -o llvmir.mlir +// RUN: aie-translate llvmir.mlir %llvmir-to-ll% -o dut.ll +// RUN: %PEANO_INSTALL_DIR/bin/clang %clang_aie2_args -c dut.ll -o dut.o +// RUN: xchesscc_wrapper %xchesscc_aie2_args -DTO_LLVM +w work +o work -I%S -I. %S/testbench.cc dut.o +// RUN: xca_udm_dbg --aiearch aie-ml -qf -T -P %aietools/data/aie_ml/lib/ -t "%S/../profiling.tcl ./work/a.out" >& xca_udm_dbg.stdout +// RUN: FileCheck --input-file=./xca_udm_dbg.stdout %s +// CHECK: TEST PASSED + +module { + func.func @dut(%arg0: memref<1024xi32>, %arg1: memref) { + memref.assume_alignment %arg0, 32 : memref<1024xi32> + %c0_i32 = arith.constant 0 : i32 + %cst = arith.constant dense<-2147483648> : vector<16xi32> + %0 = affine.for %arg2 = 0 to 1024 step 16 iter_args(%arg3 = %cst) -> (vector<16xi32>) { + %2 = vector.transfer_read %arg0[%arg2], %c0_i32 : memref<1024xi32>, vector<16xi32> + %3 = arith.maxsi %arg3, %2 : vector<16xi32> + affine.yield %3 : vector<16xi32> + } + %1 = vector.reduction , %0 : vector<16xi32> into i32 + affine.store %1, %arg1[] : memref + return + } +} diff --git a/test/unit_tests/aievec_tests/i32_max_reduce/i32_max_reduce.mlir b/test/unit_tests/aievec_tests/i32_max_reduce/i32_max_reduce.mlir index dd8982208c..4bc6721456 100644 --- a/test/unit_tests/aievec_tests/i32_max_reduce/i32_max_reduce.mlir +++ b/test/unit_tests/aievec_tests/i32_max_reduce/i32_max_reduce.mlir @@ -1,7 +1,11 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// Copyright (C) 2023-2024, Advanced Micro Devices, Inc. + +// REQUIRES: valid_xchess_license +// RUN: mkdir -p %t/data; cd %t // RUN: aie-opt %s --convert-vector-to-aievec="aie-target=aieml" -lower-affine | aie-translate -aieml=true --aievec-to-cpp -o dut.cc -// RUN: xchesscc_wrapper aie2 -f -g +s +w work +o work -I%S -I. -c dut.cc -o dut.o -// RUN: xchesscc_wrapper aie2 -f -g +s +w work +o work -I%S -I. %S/testbench.cc work/dut.o -// RUN: mkdir -p data +// RUN: xchesscc_wrapper %xchesscc_aie2_args +w work +o work -I%S -I. -c dut.cc -o dut.o +// RUN: xchesscc_wrapper %xchesscc_aie2_args +w work +o work -I%S -I. %S/testbench.cc work/dut.o // RUN: xca_udm_dbg --aiearch aie-ml -qf -T -P %aietools/data/aie_ml/lib/ -t "%S/../profiling.tcl ./work/a.out" >& xca_udm_dbg.stdout // RUN: FileCheck --input-file=./xca_udm_dbg.stdout %s // CHECK: TEST PASSED diff --git a/test/unit_tests/aievec_tests/i32_max_reduce/testbench.cc b/test/unit_tests/aievec_tests/i32_max_reduce/testbench.cc index 8159fd9e46..69fc94e467 100644 --- a/test/unit_tests/aievec_tests/i32_max_reduce/testbench.cc +++ b/test/unit_tests/aievec_tests/i32_max_reduce/testbench.cc @@ -6,7 +6,14 @@ #include #include +#ifdef TO_LLVM +extern "C" { +#endif void dut(int32_t *restrict in0, int32_t *restrict out0); +#ifdef TO_LLVM +} +#endif + void dut_ref(int32_t *in0, int32_t *out0); alignas(32) int32_t g_in0[IN0_SIZE]; diff --git a/test/unit_tests/aievec_tests/i32_min_reduce/i32_min_reduce-llvm.mlir b/test/unit_tests/aievec_tests/i32_min_reduce/i32_min_reduce-llvm.mlir new file mode 100644 index 0000000000..ef7d6f7104 --- /dev/null +++ b/test/unit_tests/aievec_tests/i32_min_reduce/i32_min_reduce-llvm.mlir @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// Copyright (C) 2024, Advanced Micro Devices, Inc. + +// REQUIRES: valid_xchess_license +// REQUIRES: peano +// RUN: mkdir -p %t/data; cd %t +// RUN: aie-opt %s %vector-to-llvmir% -o llvmir.mlir +// RUN: aie-translate llvmir.mlir %llvmir-to-ll% -o dut.ll +// RUN: %PEANO_INSTALL_DIR/bin/clang %clang_aie2_args -c dut.ll -o dut.o +// RUN: xchesscc_wrapper %xchesscc_aie2_args -DTO_LLVM +w work +o work -I%S -I. %S/testbench.cc dut.o +// RUN: xca_udm_dbg --aiearch aie-ml -qf -T -P %aietools/data/aie_ml/lib/ -t "%S/../profiling.tcl ./work/a.out" >& xca_udm_dbg.stdout +// RUN: FileCheck --input-file=./xca_udm_dbg.stdout %s +// CHECK: TEST PASSED + +module { + func.func @dut(%arg0: memref<1024xi32>, %arg1: memref) { + memref.assume_alignment %arg0, 32 : memref<1024xi32> + %c0_i32 = arith.constant 0 : i32 + %cst = arith.constant dense<2147483647> : vector<16xi32> + %0 = affine.for %arg2 = 0 to 1024 step 16 iter_args(%arg3 = %cst) -> (vector<16xi32>) { + %2 = vector.transfer_read %arg0[%arg2], %c0_i32 : memref<1024xi32>, vector<16xi32> + %3 = arith.minsi %arg3, %2 : vector<16xi32> + affine.yield %3 : vector<16xi32> + } + %1 = vector.reduction , %0 : vector<16xi32> into i32 + affine.store %1, %arg1[] : memref + return + } +} diff --git a/test/unit_tests/aievec_tests/i32_min_reduce/i32_min_reduce.mlir b/test/unit_tests/aievec_tests/i32_min_reduce/i32_min_reduce.mlir index 3747d248f0..3ffb0e255f 100644 --- a/test/unit_tests/aievec_tests/i32_min_reduce/i32_min_reduce.mlir +++ b/test/unit_tests/aievec_tests/i32_min_reduce/i32_min_reduce.mlir @@ -1,7 +1,11 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// Copyright (C) 2023-2024, Advanced Micro Devices, Inc. + +// REQUIRES: valid_xchess_license +// RUN: mkdir -p %t/data; cd %t // RUN: aie-opt %s --convert-vector-to-aievec="aie-target=aieml" -lower-affine | aie-translate -aieml=true --aievec-to-cpp -o dut.cc -// RUN: xchesscc_wrapper aie2 -f -g +s +w work +o work -I%S -I. -c dut.cc -o dut.o -// RUN: xchesscc_wrapper aie2 -f -g +s +w work +o work -I%S -I. %S/testbench.cc work/dut.o -// RUN: mkdir -p data +// RUN: xchesscc_wrapper %xchesscc_aie2_args +w work +o work -I%S -I. -c dut.cc -o dut.o +// RUN: xchesscc_wrapper %xchesscc_aie2_args +w work +o work -I%S -I. %S/testbench.cc work/dut.o // RUN: xca_udm_dbg --aiearch aie-ml -qf -T -P %aietools/data/aie_ml/lib/ -t "%S/../profiling.tcl ./work/a.out" >& xca_udm_dbg.stdout // RUN: FileCheck --input-file=./xca_udm_dbg.stdout %s // CHECK: TEST PASSED diff --git a/test/unit_tests/aievec_tests/i32_min_reduce/testbench.cc b/test/unit_tests/aievec_tests/i32_min_reduce/testbench.cc index ae92078347..59d4a8afca 100644 --- a/test/unit_tests/aievec_tests/i32_min_reduce/testbench.cc +++ b/test/unit_tests/aievec_tests/i32_min_reduce/testbench.cc @@ -6,7 +6,14 @@ #include #include +#ifdef TO_LLVM +extern "C" { +#endif void dut(int32_t *restrict in0, int32_t *restrict out0); +#ifdef TO_LLVM +} +#endif + void dut_ref(int32_t *in0, int32_t *out0); alignas(32) int32_t g_in0[IN0_SIZE]; diff --git a/test/unit_tests/aievec_tests/i8_max_reduce/i8_max_reduce-llvm.mlir b/test/unit_tests/aievec_tests/i8_max_reduce/i8_max_reduce-llvm.mlir new file mode 100644 index 0000000000..cf01f11640 --- /dev/null +++ b/test/unit_tests/aievec_tests/i8_max_reduce/i8_max_reduce-llvm.mlir @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// Copyright (C) 2024, Advanced Micro Devices, Inc. + +// REQUIRES: valid_xchess_license +// REQUIRES: peano +// RUN: mkdir -p %t/data; cd %t +// RUN: aie-opt %s %vector-to-llvmir% -o llvmir.mlir +// RUN: aie-translate llvmir.mlir %llvmir-to-ll% -o dut.ll +// RUN: %PEANO_INSTALL_DIR/bin/clang %clang_aie2_args -c dut.ll -o dut.o +// RUN: xchesscc_wrapper %xchesscc_aie2_args -DTO_LLVM +w work +o work -I%S -I. %S/testbench.cc dut.o +// RUN: xca_udm_dbg --aiearch aie-ml -qf -T -P %aietools/data/aie_ml/lib/ -t "%S/../profiling.tcl ./work/a.out" >& xca_udm_dbg.stdout +// RUN: FileCheck --input-file=./xca_udm_dbg.stdout %s +// CHECK: TEST PASSED + +module { + func.func @dut(%arg0: memref<1024xi8>, %arg1: memref) { + memref.assume_alignment %arg0, 32 : memref<1024xi8> + %c0_i8 = arith.constant 0 : i8 + %cst = arith.constant dense<-128> : vector<64xi8> + %0 = affine.for %arg2 = 0 to 1024 step 64 iter_args(%arg3 = %cst) -> (vector<64xi8>) { + %2 = vector.transfer_read %arg0[%arg2], %c0_i8 : memref<1024xi8>, vector<64xi8> + %3 = arith.maxsi %arg3, %2 : vector<64xi8> + affine.yield %3 : vector<64xi8> + } + %1 = vector.reduction , %0 : vector<64xi8> into i8 + affine.store %1, %arg1[] : memref + return + } +} diff --git a/test/unit_tests/aievec_tests/i8_max_reduce/i8_max_reduce.mlir b/test/unit_tests/aievec_tests/i8_max_reduce/i8_max_reduce.mlir index 207f93c53a..083cf0549d 100644 --- a/test/unit_tests/aievec_tests/i8_max_reduce/i8_max_reduce.mlir +++ b/test/unit_tests/aievec_tests/i8_max_reduce/i8_max_reduce.mlir @@ -1,7 +1,11 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// Copyright (C) 2023-2024, Advanced Micro Devices, Inc. + +// REQUIRES: valid_xchess_license +// RUN: mkdir -p %t/data; cd %t // RUN: aie-opt %s --convert-vector-to-aievec="aie-target=aieml" -lower-affine | aie-translate -aieml=true --aievec-to-cpp -o dut.cc -// RUN: xchesscc_wrapper aie2 -f -g +s +w work +o work -I%S -I. -c dut.cc -o dut.o -// RUN: xchesscc_wrapper aie2 -f -g +s +w work +o work -I%S -I. %S/testbench.cc work/dut.o -// RUN: mkdir -p data +// RUN: xchesscc_wrapper %xchesscc_aie2_args +w work +o work -I%S -I. -c dut.cc -o dut.o +// RUN: xchesscc_wrapper %xchesscc_aie2_args +w work +o work -I%S -I. %S/testbench.cc work/dut.o // RUN: xca_udm_dbg --aiearch aie-ml -qf -T -P %aietools/data/aie_ml/lib/ -t "%S/../profiling.tcl ./work/a.out" >& xca_udm_dbg.stdout // RUN: FileCheck --input-file=./xca_udm_dbg.stdout %s // CHECK: TEST PASSED diff --git a/test/unit_tests/aievec_tests/i8_max_reduce/testbench.cc b/test/unit_tests/aievec_tests/i8_max_reduce/testbench.cc index 8adff0ea75..30fe5a7e48 100644 --- a/test/unit_tests/aievec_tests/i8_max_reduce/testbench.cc +++ b/test/unit_tests/aievec_tests/i8_max_reduce/testbench.cc @@ -6,7 +6,14 @@ #include #include +#ifdef TO_LLVM +extern "C" { +#endif void dut(int8_t *restrict in0, int8_t *restrict out0); +#ifdef TO_LLVM +} +#endif + void dut_ref(int8_t *in0, int8_t *out0); alignas(32) int8_t g_in0[IN0_SIZE]; diff --git a/test/unit_tests/aievec_tests/i8_min_reduce/i8_min_reduce-llvm.mlir b/test/unit_tests/aievec_tests/i8_min_reduce/i8_min_reduce-llvm.mlir new file mode 100644 index 0000000000..40be3da261 --- /dev/null +++ b/test/unit_tests/aievec_tests/i8_min_reduce/i8_min_reduce-llvm.mlir @@ -0,0 +1,29 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// Copyright (C) 2024, Advanced Micro Devices, Inc. + +// REQUIRES: valid_xchess_license +// REQUIRES: peano +// RUN: mkdir -p %t/data; cd %t +// RUN: aie-opt %s %vector-to-llvmir% -o llvmir.mlir +// RUN: aie-translate llvmir.mlir %llvmir-to-ll% -o dut.ll +// RUN: %PEANO_INSTALL_DIR/bin/clang %clang_aie2_args -c dut.ll -o dut.o +// RUN: xchesscc_wrapper %xchesscc_aie2_args -DTO_LLVM +w work +o work -I%S -I. %S/testbench.cc dut.o +// RUN: xca_udm_dbg --aiearch aie-ml -qf -T -P %aietools/data/aie_ml/lib/ -t "%S/../profiling.tcl ./work/a.out" >& xca_udm_dbg.stdout +// RUN: FileCheck --input-file=./xca_udm_dbg.stdout %s +// CHECK: TEST PASSED + +module { + func.func @dut(%arg0: memref<1024xi8>, %arg1: memref) { + memref.assume_alignment %arg0, 32 : memref<1024xi8> + %c0_i8 = arith.constant 0 : i8 + %cst = arith.constant dense<127> : vector<64xi8> + %0 = affine.for %arg2 = 0 to 1024 step 64 iter_args(%arg3 = %cst) -> (vector<64xi8>) { + %2 = vector.transfer_read %arg0[%arg2], %c0_i8 : memref<1024xi8>, vector<64xi8> + %3 = arith.minsi %arg3, %2 : vector<64xi8> + affine.yield %3 : vector<64xi8> + } + %1 = vector.reduction , %0 : vector<64xi8> into i8 + affine.store %1, %arg1[] : memref + return + } +} diff --git a/test/unit_tests/aievec_tests/i8_min_reduce/i8_min_reduce.mlir b/test/unit_tests/aievec_tests/i8_min_reduce/i8_min_reduce.mlir index 92753de7b9..74f32610a8 100644 --- a/test/unit_tests/aievec_tests/i8_min_reduce/i8_min_reduce.mlir +++ b/test/unit_tests/aievec_tests/i8_min_reduce/i8_min_reduce.mlir @@ -1,7 +1,11 @@ +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// Copyright (C) 2023-2024, Advanced Micro Devices, Inc. + +// REQUIRES: valid_xchess_license +// RUN: mkdir -p %t/data; cd %t // RUN: aie-opt %s --convert-vector-to-aievec="aie-target=aieml" -lower-affine | aie-translate -aieml=true --aievec-to-cpp -o dut.cc -// RUN: xchesscc_wrapper aie2 -f -g +s +w work +o work -I%S -I. -c dut.cc -o dut.o -// RUN: xchesscc_wrapper aie2 -f -g +s +w work +o work -I%S -I. %S/testbench.cc work/dut.o -// RUN: mkdir -p data +// RUN: xchesscc_wrapper %xchesscc_aie2_args +w work +o work -I%S -I. -c dut.cc -o dut.o +// RUN: xchesscc_wrapper %xchesscc_aie2_args +w work +o work -I%S -I. %S/testbench.cc work/dut.o // RUN: xca_udm_dbg --aiearch aie-ml -qf -T -P %aietools/data/aie_ml/lib/ -t "%S/../profiling.tcl ./work/a.out" >& xca_udm_dbg.stdout // RUN: FileCheck --input-file=./xca_udm_dbg.stdout %s // CHECK: TEST PASSED diff --git a/test/unit_tests/aievec_tests/i8_min_reduce/testbench.cc b/test/unit_tests/aievec_tests/i8_min_reduce/testbench.cc index 5b1c29be63..2c05e17ca2 100644 --- a/test/unit_tests/aievec_tests/i8_min_reduce/testbench.cc +++ b/test/unit_tests/aievec_tests/i8_min_reduce/testbench.cc @@ -6,7 +6,14 @@ #include #include +#ifdef TO_LLVM +extern "C" { +#endif void dut(int8_t *restrict in0, int8_t *restrict out0); +#ifdef TO_LLVM +} +#endif + void dut_ref(int8_t *in0, int8_t *out0); alignas(32) int8_t g_in0[IN0_SIZE];