mirror of
https://github.com/Steffo99/unimore-hpc-assignments.git
synced 2024-11-24 09:04:23 +00:00
Fix ring buffer dimensions
This commit is contained in:
parent
6f1f6bc1b6
commit
a229dfad5f
1 changed files with 5 additions and 5 deletions
|
@ -17,8 +17,8 @@ void sobel(uint8_t *__restrict__ out, uint8_t *__restrict__ in)
|
||||||
};
|
};
|
||||||
|
|
||||||
// Carica le prime tre righe nel buffer
|
// Carica le prime tre righe nel buffer
|
||||||
uint8_t inBuffer[3*HEIGHT];
|
uint8_t inBuffer[3*WIDTH];
|
||||||
memcpy(inBuffer, in, 3*HEIGHT*sizeof(uint8_t));
|
memcpy(inBuffer, in, 3*WIDTH*sizeof(uint8_t));
|
||||||
|
|
||||||
esternoY:
|
esternoY:
|
||||||
for (int y = 0; y < HEIGHT - 2; y++)
|
for (int y = 0; y < HEIGHT - 2; y++)
|
||||||
|
@ -37,14 +37,14 @@ void sobel(uint8_t *__restrict__ out, uint8_t *__restrict__ in)
|
||||||
{
|
{
|
||||||
#pragma HLS UNROLL
|
#pragma HLS UNROLL
|
||||||
|
|
||||||
const int inYOffset = ((y + k) % 3) * 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
|
#pragma HLS UNROLL
|
||||||
|
|
||||||
const int inXOffset = x + z;
|
const int inXOffset = (x + z) % 3;
|
||||||
|
|
||||||
const int inOffset = inYOffset + inXOffset;
|
const int inOffset = inYOffset + inXOffset;
|
||||||
const int inElement = inBuffer[inOffset];
|
const int inElement = inBuffer[inOffset];
|
||||||
|
@ -61,6 +61,6 @@ void sobel(uint8_t *__restrict__ out, uint8_t *__restrict__ in)
|
||||||
out[outOffset] = sqrt((float)((dx * dx) + (dy * dy)));
|
out[outOffset] = sqrt((float)((dx * dx) + (dy * dy)));
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(inBuffer, in + (y % 3) * HEIGHT, HEIGHT*sizeof(uint8_t));
|
memcpy(inBuffer, in + y * WIDTH, WIDTH*sizeof(uint8_t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue