ForTrilinos icon indicating copy to clipboard operation
ForTrilinos copied to clipboard

Make testing macros work with NaN's

Open aprokop opened this issue 7 years ago • 9 comments

The reciprocal test was passing despite having the following:

TEST_FLOATING_ARRAY_EQUALITY(dots, one, epsilon(one))

Besides the fact that one should have been one*numLocal, the funny thing is that dots actually had NaN inside. However, this did not seem to fail. The question is: what is the result of abs(maxval(a-b)) when a or b contains NaNs? @tjfulle ?

aprokop avatar Dec 15 '17 22:12 aprokop

It seems like a compiler issue: it passed with gfortran but failed with flang.

aprokop avatar Dec 15 '17 22:12 aprokop

Maybe we should test testing macros 🤔

aprokop avatar Dec 15 '17 22:12 aprokop

which test exactly?

tjfulle avatar Dec 15 '17 23:12 tjfulle

MultiVector's reciprocal.

aprokop avatar Dec 15 '17 23:12 aprokop

To avoid this in the future I can add a check for NaN and INF in each testing macro that checks equality. Or, rather than add logic to every test for NaN, perhaps we can just set the appropriate compiler flags? In gfortran: -ffpe-trap=invalid, intel: -fpe0. I'm not sure about nag, pgi, sun, flang, and others. But, the checks would turn off if the flags are removed.

If this is a priority, I could do this pretty quick.

tjfulle avatar Dec 15 '17 23:12 tjfulle

I think I'd argue for updating test macros. I don't know a) how compiler flags are portable, b) would users frown upon subpackages adding to compiler flags.

aprokop avatar Dec 16 '17 00:12 aprokop

@aprokop , I agree. I'll put in checks while I finish up Import/Export tests.

tjfulle avatar Dec 16 '17 00:12 tjfulle

Was this fixed by#171 (which had some nan checks inside), or is it still in progress?

aprokop avatar Dec 16 '17 23:12 aprokop

The TEST_EQUALITY family of functions now check for NaN, but I haven’t specifically tested for NaN in any tests.

tjfulle avatar Dec 16 '17 23:12 tjfulle