forked from Xilinx/mlir-aie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
passThrough.cc
71 lines (52 loc) · 2.08 KB
/
passThrough.cc
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
//===- passThrough.cc -------------------------------------------*- 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) 2022, Advanced Micro Devices, Inc.
//
//===----------------------------------------------------------------------===//
// #define __AIENGINE__ 1
#define NOCPP
#include <stdint.h>
#include <stdlib.h>
#include <aie_api/aie.hpp>
template <typename T, int N>
__attribute__((noinline)) void passThrough_aie(T *restrict in, T *restrict out,
const int32_t height,
const int32_t width) {
event0();
v64uint8 *restrict outPtr = (v64uint8 *)out;
v64uint8 *restrict inPtr = (v64uint8 *)in;
for (int j = 0; j < (height * width); j += N) // Nx samples per loop
chess_prepare_for_pipelining chess_loop_range(6, ) { *outPtr++ = *inPtr++; }
event1();
}
extern "C" {
#if BIT_WIDTH == 8
void passThroughLine(uint8_t *in, uint8_t *out, int32_t lineWidth) {
passThrough_aie<uint8_t, 64>(in, out, 1, lineWidth);
}
void passThroughTile(uint8_t *in, uint8_t *out, int32_t tileHeight,
int32_t tileWidth) {
passThrough_aie<uint8_t, 64>(in, out, tileHeight, tileWidth);
}
#elif BIT_WIDTH == 16
void passThroughLine(int16_t *in, int16_t *out, int32_t lineWidth) {
passThrough_aie<int16_t, 32>(in, out, 1, lineWidth);
}
void passThroughTile(int16_t *in, int16_t *out, int32_t tileHeight,
int32_t tileWidth) {
passThrough_aie<int16_t, 32>(in, out, tileHeight, tileWidth);
}
#else // 32
void passThroughLine(int32_t *in, int32_t *out, int32_t lineWidth) {
passThrough_aie<int32_t, 16>(in, out, 1, lineWidth);
}
void passThroughTile(int32_t *in, int32_t *out, int32_t tileHeight,
int32_t tileWidth) {
passThrough_aie<int32_t, 16>(in, out, tileHeight, tileWidth);
}
#endif
} // extern "C"