1
Fork 0
mirror of https://github.com/Steffo99/unimore-hpc-assignments.git synced 2024-11-25 09:34:23 +00:00

Add HLS PIPELINE and UNROLL instructions

Co-authored-by: Fabio Zanichelli <274956@studenti.unimore.it>
Co-authored-by: Stefano Pigozzi <256895@studenti.unimore.it>
This commit is contained in:
Gattopandacorno 2022-12-19 10:43:10 +01:00
parent 8692e82290
commit ae5f2d0c52

View file

@ -17,6 +17,8 @@ void sobel(uint8_t *__restrict__ out, uint8_t *__restrict__ in, const int width,
esternoY: esternoY:
for (int y = 0; y < height - 2; y++) for (int y = 0; y < height - 2; y++)
{ {
#pragma HLS PIPELINE
esternoX: esternoX:
for (int x = 0; x < width - 2; x++) for (int x = 0; x < width - 2; x++)
{ {
@ -26,11 +28,15 @@ void sobel(uint8_t *__restrict__ out, uint8_t *__restrict__ in, const int width,
internoY: internoY:
for (int k = 0; k < 3; k++) for (int k = 0; k < 3; k++)
{ {
#pragma HLS UNROLL
const int inYOffset = (y + k) * width; const int inYOffset = (y + k) * width;
internoX: internoX:
for (int z = 0; z < 3; z++) for (int z = 0; z < 3; z++)
{ {
#pragma HLS UNROLL
const int inXOffset = x + z; const int inXOffset = x + z;
const int inOffset = inYOffset + inXOffset; const int inOffset = inYOffset + inXOffset;
@ -44,7 +50,7 @@ void sobel(uint8_t *__restrict__ out, uint8_t *__restrict__ in, const int width,
const int outYOffset = (y + 1) * width; const int outYOffset = (y + 1) * width;
const int outXOffset = (x + 1); const int outXOffset = (x + 1);
const int outOffset = outYOffset + outXOffset; const int outOffset = outYOffset + outXOffset;
out[outOffset] = sqrt((float)((dx * dx) + (dy * dy))); out[outOffset] = sqrt((float)((dx * dx) + (dy * dy)));
} }
} }