C omp reduction max and min operators were included in OpenMP 3.1 standard, but I'm still looking for a widely available compiler which implements it. gcc testsuite includes Fortran but not c or c++ tests for max or min reduction. OpenMP 4.0 defines both parallel and simd capabilities for min and max reduction; apparently, Intel compilers will advertise OpenMP 4 support before these have been implemented. Other OpenMP 4 reductions are supported now in current icc.
icpc does an excellent job without omp simd reduction directive of vectorizing std::max(). Sometimes, icc can vectorize equivalent C code, possibly with the help of #pragma vector; more often, gcc can accomplish max/min vectorization. Cilk(tm) Plus includes equivalent reducers, but they seem to be less reliably optimized than gcc is with standard C source code.
The inclusion of min/max as reduction in C would be of great value for me. I have a nearest neighbor search big problem, for surface registration that is calling for that. The lack of min/max reduction force alternative implementations that look like to be suboptimal and not clear.
I beg your pardon, English is not native language and sometimes I can not express myself in the right way. I was trying to support the idea of adopting the OpenMP 3.1 min/max reduction for C and C++ , not asking for C or C++ standard modification !
I only want to use something like :
#pragma omp parallel for reduction(max : max_value)
which should be very handy for lots of programming problems.
Sergey Kostrov wrote:
>>I only want to use something like :
>>#pragma omp parallel for reduction(max : max_value)
This form is already defined by OpenMP 3.1, although I've seen it denied. OpenMP 4.0 RC2 also defines
#pragma omp parallel for simd reduction(max : max_value)
to specify explicitly that both simd and thread parallel optimizations are desired, as well as forms for simd without threaded parallelism.
I guess Intel compilers are waiting to implement reduction(max/min: ) until there is documented demand for the OpenMP 4 forms.
I've drafted a white paper on the omp simd forms already supported, as well as alternatives for those which aren't (e.g. C++ std::max(), std:max_element()....
gcc development branch accessed by e.g.
svn co svn://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch gcc-omp4
includes early support for OpenMP 3.1 and 4.0 max|min reductions. If it reaches sufficient maturity to be merged into gcc-4.9, this would indicate support for these features well before they appear in Intel C/C++. I had to use the configure --disable-werror option in order to build this gcc.
As indicated elsewhere, the libiomp5 and open source Intel OpenMP libraries already should include support for omp parallel reduction(min|max: ). It is not expected to appear in the icc release this week, although there would be several OpenMP 4.0 features. It should be possible to use linux clang as well as the gcc branch to test min|max reductions with the Intel and gomp libraries.
I didn't find any max|min reduction tests in gcc testsuite. There are some gfortran max|min reduction unit tests, but the gomp-4_0-branch doesn't appear to add any gfortran OpenMP 4 features.