Consider the following program:

- Code: Select all
`#include <float.h>`

#include <math.h>

#include <stdio.h>

int main(void) {

float min_val = 0.0f;

#pragma omp parallel reduction(min:min_val) num_threads(1)

if (isinf(min_val))

printf("initial min_val: inf\n");

else if (min_val == FLT_MAX)

printf("initial min_val: FLT_MAX\n");

}

Out of four compilers I tested, two resulted in an output of "FLT_MAX", while the other two resulted in an output of "inf".

I think that infinity makes more sense, but it isn't clear to me whether or not the C11 standard considers infinity a "representable value" for real floating types.

If FLT_MAX is the correct answer, it would be beneficial to change the wording in the OpenMP spec on p. 104, l. 1 to:

max Least representable finite value in the reduction list item type

min Largest representable finite value in the reduction list item type

If infinity is the correct answer for C/C++ implementations supporting infinities, it would be helpful to make that explicit in the OpenMP spec.