Quantcast
Channel: Intel® C++ Compiler
Viewing all articles
Browse latest Browse all 1616

icpc fails to compile simple openMP code

$
0
0

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[i];

    }

    return sum;

}

int main()

{

    int inarray[SIZE], sum, validSum;

    validSum=0;

    for(int i=0; i<SIZE; i++){

        inarray[i]=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...


Viewing all articles
Browse latest Browse all 1616

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>