Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
7698 Discussions

icpc fails to compile simple openMP code

Jinsu_P_
Beginner
164 Views

I started learning Intel Xeon Phi Coprocessor.
I tested some simple codes on the book but failed to compile.

////// This is simple offload example on the book.
////// reduction.cpp
#include <stdio.h>
#define SIZE 1000
#pragma omp declare target
int reduce(int *inarray)
{
    int sum=0;
    #pragma omp target map(inarray[0:SIZE]) map(sum)
    {
        for(int i=0;i<SIZE;i++)
            sum += inarray;
    }
    return sum;
}

int main()
{
    int inarray[SIZE], sum, validSum;
    validSum=0;
    for(int i=0; i<SIZE; i++){
        inarray=i;
        validSum+=i;
    }
    sum=0;
    sum = reduce(inarray);
    printf("sum reduction = %d, validSum=%d\n",sum, validSum);
}
///////////////////////////////////////////////////////////////////////////////////

When I complied it, however, I met an error like this

$ icpc -openmp reduction.cpp -o test3.out
reduction.cpp(5): error: unrecognized #pragma
  #pragma omp declare target
                ^
reduction.cpp(9): error: unrecognized #pragma
      #pragma omp target map(inarray[0:SIZE]) map(sum)
                    ^
compilation aborted for reduction.cpp (code 2)

-----------------------------------------------------------------------------

The Linux server with Xeon Phi uses icpc version 13.0.1
I tried the same code on my desktop and succeeded in compiling without error.
(but can't execute because my desktop don't have Xeon Phi coprocessor)
My desktop uses icpc version 14.0.3

Is it a version problem? But as I know, version 13.0 also supports Xeon Phi...

0 Kudos
1 Reply
MalReddy_Y_Intel
Employee
164 Views

 

Hi,

The openmp directives used in the above code are openmp4.0 features which are not supported in Intel compiler 13.0 ,May be you have to use "offload" pragma to execute on MIC.

Thanks,

Reddy

Reply