forked from Xilinx/mlir-aie
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
75 lines (63 loc) · 2.49 KB
/
test.cpp
File metadata and controls
75 lines (63 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//===- test.cpp -------------------------------------------------*- C++ -*-===//
//
// This file is licensed under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
// Copyright (C) 2023, Advanced Micro Devices, Inc.
//
//===----------------------------------------------------------------------===//
#include "xrt_test_wrapper.h"
#include <cstdint>
//*****************************************************************************
// Modify this section to customize buffer datatypes, initialization functions,
// and verify function. The other place to reconfigure your design is the
// Makefile.
//*****************************************************************************
#ifndef DATATYPES_USING_DEFINED
#define DATATYPES_USING_DEFINED
// ------------------------------------------------------
// Configure this to match your buffer data type
// ------------------------------------------------------
using DATATYPE_IN1 = std::uint8_t;
using DATATYPE_OUT = std::uint8_t;
#endif
// Initialize Input buffer 1
void initialize_bufIn1(DATATYPE_IN1 *bufIn1, int SIZE) {
for (int i = 0; i < SIZE; i++)
bufIn1[i] = i;
}
// Initialize Output buffer
void initialize_bufOut(DATATYPE_OUT *bufOut, int SIZE) {
memset(bufOut, 0, SIZE);
}
// Functional correctness verifyer
int verify_passthrough_kernel(DATATYPE_IN1 *bufIn1, DATATYPE_OUT *bufOut,
int SIZE, int verbosity) {
int errors = 0;
for (int i = 0; i < SIZE; i++) {
int32_t ref = bufIn1[i];
int32_t test = bufOut[i];
if (test != ref) {
if (verbosity >= 1)
std::cout << "Error in output " << test << " != " << ref << std::endl;
errors++;
} else {
if (verbosity >= 1)
std::cout << "Correct output " << test << " == " << ref << std::endl;
}
}
return errors;
}
//*****************************************************************************
// Should not need to modify below section
//*****************************************************************************
int main(int argc, const char *argv[]) {
constexpr int IN1_VOLUME = IN1_SIZE / sizeof(DATATYPE_IN1);
constexpr int OUT_VOLUME = OUT_SIZE / sizeof(DATATYPE_OUT);
args myargs = parse_args(argc, argv);
int res = setup_and_run_aie<DATATYPE_IN1, DATATYPE_OUT, initialize_bufIn1,
initialize_bufOut, verify_passthrough_kernel>(
IN1_VOLUME, OUT_VOLUME, myargs);
return res;
}