Hey all,
I tried to use the OpenMP declare reduction pragma for an implementation of an array reduction. The code compiles fine using g++ 4.9 and produces correct results. However, using icpc-16.0.038 gives an internal error 20000_0. I attached a small code example.
#include <iostream> #include <vector> #include <complex> template <const int n> struct complex_array { complex_array() : element( n, std::complex<float>(0.0f,0.0f) ) { } std::vector< std::complex<float> > element; }; template <const int n> static inline void add_complex_struct( complex_array<n> &x, complex_array<n> const &y ) { for ( int i = 0; i < n; ++i ) { x.element[i] += y.element[i]; } } #pragma omp declare reduction( complex_array_reduction : complex_array<10> : add_complex_struct<10>(omp_out, omp_in) ) int main() { complex_array<10> a_array, b_array; for ( int i = 0; i < 10; ++i ) { std::complex<float> cf( 1.0f+i, 1.5f+i ); a_array.element[i] = cf; } #pragma omp parallel for schedule(static) reduction( complex_array_reduction:b_array ) for ( int i = 0; i < 100; ++i ) { add_complex_struct<10>( b_array, a_array ); } for ( int i = 0; i < 10; ++i ) { std::cout << b_array.element[i] << std::endl; } }
I used g++ -fopenmp and icpc -qopenmp to compile the code.
Thanks,
Patrick