Commit 227b57ad authored by Sebastien Alaiwan's avatar Sebastien Alaiwan

Range check error message: only print input once

Also, print the actual out-of-bounds values,
instead of just printing the input buffer.

Change-Id: Ia6b73d98e41c3285d8fd9f39963f9d556d2d95f7
parent 2fa0a335
......@@ -19,24 +19,40 @@ void range_check_func(int32_t stage, const int32_t *input, const int32_t *buf,
const int64_t maxValue = (1LL << (bit - 1)) - 1;
const int64_t minValue = -(1LL << (bit - 1));
int in_range = 1;
for (int i = 0; i < size; ++i) {
if (buf[i] < minValue || buf[i] > maxValue) {
fprintf(stderr, "Error: coeffs contain out-of-range values\n");
fprintf(stderr, "stage: %d\n", stage);
fprintf(stderr, "node: %d\n", i);
fprintf(stderr, "allowed range: [%" PRId64 ";%" PRId64 "]\n", minValue,
maxValue);
fprintf(stderr, "coeffs: ");
fprintf(stderr, "[");
for (int j = 0; j < size; j++) {
if (j > 0) fprintf(stderr, ", ");
fprintf(stderr, "%d", input[j]);
}
fprintf(stderr, "]\n");
assert(0);
in_range = 0;
}
}
if (!in_range) {
fprintf(stderr, "Error: coeffs contain out-of-range values\n");
fprintf(stderr, "stage: %d\n", stage);
fprintf(stderr, "allowed range: [%" PRId64 ";%" PRId64 "]\n", minValue,
maxValue);
fprintf(stderr, "coeffs: ");
fprintf(stderr, "[");
for (int j = 0; j < size; j++) {
if (j > 0) fprintf(stderr, ", ");
fprintf(stderr, "%d", input[j]);
}
fprintf(stderr, "]\n");
fprintf(stderr, " buf: ");
fprintf(stderr, "[");
for (int j = 0; j < size; j++) {
if (j > 0) fprintf(stderr, ", ");
fprintf(stderr, "%d", buf[j]);
}
fprintf(stderr, "]\n\n");
}
assert(in_range);
}
#define range_check(stage, input, buf, size, bit) \
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment