EasyManuals Logo
Home>Intel>Computer Hardware>Xeon Phi

Intel Xeon Phi User Manual

Intel Xeon Phi
32 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #23 background imageLoading...
Page #23 background image
Intel® Xeon Phi Coprocessor DEVELOPERS QUICK START GUIDE
23
The code shown below is an example of a single host CPU thread attempting to offload the reduction code to
the Intel® Xeon Phi™ Coprocessor using OpenMP in the offload construct.
float OMP_reduction(float *data, int size)
{
float ret = 0;
#pragma offload target(mic) in(size) in(data:length(size))
{
#pragma omp parallel for reduction(+:ret)
for (int i=0; i<size; ++i)
{
ret += data[i];
}
}
return ret;
}
Code Example 5: C/C++: Using OpenMP in Offloaded Reduction Code
real function FTNReductionOMP(data, size)
implicit none
integer :: size
real, dimension(size) :: data
real :: ret = 0.0
!dir$ omp offload target(mic) in(size) in(data:length(size))
!$omp parallel do reduction(+:ret)
do i=1,size
ret = ret + data(i)
enddo
!$omp end parallel do
FTNReductionOMP = ret
return
end function FTNReductionOMP
Code Example 6: Fortran: Using OpenMP* in Offloaded Reduction Code
Parallel Programming on the Intel® Xeon Phi™ Coprocessor: OpenMP* + Intel® Cilk™ Plus
Extended Array Notation
The following code sample further extends the OpenMP example to use Intel Cilk Plus Extended Array
Notation. In the following code sample, each thread uses the Intel Cilk Plus Extended Array Notation
__sec_reduce_add() built-in reduction function to use all 32 of the Intel® MIC Architecture’s 512-bit vector
registers to reduce the elements in the array.
float OMPnthreads_CilkPlusEAN_reduction(float *data, int size)
{
float ret=0;
#pragma offload target(mic) in(data:length(size))
{

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Intel Xeon Phi and is the answer not in the manual?

Intel Xeon Phi Specifications

General IconGeneral
BrandIntel
ModelXeon Phi
CategoryComputer Hardware
LanguageEnglish

Related product manuals