- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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...
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page