Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Peter_C_
Beginner
68 Views

OpenMP array reductions in templated functions

Hello,

     I was getting syntax errors when trying to use OpenMP array reductions in icpc 17.0.4. After reducing the problem, it seems that array reductions might not be supported inside templated functions. Here's an example of what I'm seeing:

// This is OK.
void test1(int n) {
    double *a;

    #pragma omp parallel for reduction(+: a[:n])
    for (int i = 0; i < n; ++i) { }
}


// This fails to compile -- "error: syntax error in omp clause"
template <typename T>
void test2(int n, T /*unused*/) {
    T *a;

    #pragma omp parallel for reduction(+: a[:n])
    for (int i = 0; i < n; ++i) { }
}

template void test2(int, double);


// This also fails to compile, with the same error
template <typename T>
void test3(int n, T) {
    double *a;

    #pragma omp parallel for reduction(+: a[:n])
    for (int i = 0; i < n; ++i) { }
}

template void test3(int,double);

 

 

Is this a known issue, or did I make a mistake somewhere? Thanks!

Peter

0 Kudos
2 Replies
Viet_H_Intel
Moderator
68 Views

 

Hi Peter,

This seems to be a bug. Can you submit a bug report at https://supporttickets.intel.com.

Your test case compiled with g++

vahoang@orcsle100:/tmp$ g++ -fopenmp t2.cpp -c
vahoang@orcsle100:/tmp$ cat t2.cpp
#include"omp.h"

template <typename T>
void test2(int n, T /*unused*/) {
    T *a;

    #pragma omp parallel for reduction(+: a[:n])
    for (int i = 0; i < n; ++i) { }
}

template void test2(int, double);
vahoang@orcsle100:/tmp$ g++ -fopenmp t2.cpp -c
vahoang@orcsle100:/tmp$ icpc -qopenmp t2.cpp -c
t2.cpp(7): error: syntax error in omp clause
      #pragma omp parallel for reduction(+: a[:n])
                                             ^

compilation aborted for t2.cpp (code 2)
vahoang@orcsle100:/tmp$

Anthony_L_1
Beginner
68 Views

Hello,

This is also an issue in ICC 18.0.0

Was there any response to the bug report? And any indication of whether this may be fixed in the next few updates?

Anthony

 

Reply