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

exercise_2 updated

This commit is contained in:
Gianluca Brilli 2021-05-17 18:55:52 +02:00
parent 7cbe5bad64
commit 9dc14ab0c7
2 changed files with 2 additions and 8 deletions

View file

@ -21,9 +21,6 @@ void nearest_neighbor(int *out, const int *points,
int best_i = 0;
int best_dist = INT_MAX;
int s_point[NUM_DIMS];
memcpy(s_point, search_point, NUM_DIMS*sizeof(int));
// TODO: merge upper_loop and lower loop
// TODO: insert pipeline directive
@ -37,7 +34,7 @@ void nearest_neighbor(int *out, const int *points,
#pragma HLS LOOP_TRIPCOUNT max=num_dims min=num_dims
int dx = points[dim*p + c] - s_point[c];
int dx = points[dim*p + c] - search_point[c];
dist += dx * dx;
}

View file

@ -22,9 +22,6 @@ void nearest_neighbor(int *out, const int *points,
int best_i = 0;
int best_dist = INT_MAX;
int s_point[NUM_DIMS];
memcpy(s_point, search_point, NUM_DIMS*sizeof(int));
int dist = 0;
int iterations = len * dim;
@ -34,7 +31,7 @@ void nearest_neighbor(int *out, const int *points,
#pragma HLS PIPELINE
#pragma HLS LOOP_TRIPCOUNT max=max_iterations min=max_iterations
int dx = points[dim * p + c] - s_point[c];
int dx = points[dim * p + c] - search_point[c];
dist += dx * dx;
if (c == dim - 1) {
if (dist < best_dist) {