Skip to content

Commit

Permalink
grid: Check floating point exceptions in grid_collocate_replay
Browse files Browse the repository at this point in the history
  • Loading branch information
oschuett committed Sep 19, 2020
1 parent 06ab5f4 commit 4ce1476
Show file tree
Hide file tree
Showing 3 changed files with 916 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/grid/grid_collocate_replay.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define _XOPEN_SOURCE 700 /* Enable POSIX 2008/13 */

#include <assert.h>
#include <fenv.h>
#include <float.h>
#include <limits.h>
#include <math.h>
Expand Down Expand Up @@ -453,6 +454,20 @@ double grid_collocate_replay(const char *filename, const int cycles,
free(grid_ref);
free(grid_test);

// Check floating point exceptions.
if (fetestexcept(FE_INVALID) != 0) {
fprintf(stderr, "Error: Floating point exception FE_INVALID.\n");
exit(1);
}
if (fetestexcept(FE_DIVBYZERO) != 0) {
fprintf(stderr, "Error: Floating point exception FE_DIVBYZERO.\n");
exit(1);
}
if (fetestexcept(FE_OVERFLOW) != 0) {
fprintf(stderr, "Error: Floating point exception FE_OVERFLOW.\n");
exit(1);
}

return max_diff;
}

Expand Down
3 changes: 2 additions & 1 deletion src/grid/grid_collocate_unittest.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@ int main(int argc, char *argv[]) {
errors += run_test(argv[1], "collocate_ortho_density_l2200.task");
errors += run_test(argv[1], "collocate_ortho_density_l3300.task");
errors += run_test(argv[1], "collocate_ortho_density_l3333.task");
errors += run_test(argv[1], "collocate_ortho_non_periodic.task");
errors += run_test(argv[1], "collocate_ortho_tau.task");
errors += run_test(argv[1], "collocate_general_density.task");
errors += run_test(argv[1], "collocate_general_tau.task");
errors += run_test(argv[1], "collocate_general_subpatch0.task");
errors += run_test(argv[1], "collocate_general_subpatch16.task");
errors += run_test(argv[1], "collocate_ortho_non_periodic.task");
errors += run_test(argv[1], "collocate_general_overflow.task");

grid_library_print_stats(&mpi_sum_func, 0, &print_func, 0);
grid_library_finalize();
Expand Down

0 comments on commit 4ce1476

Please sign in to comment.