The Intel Xeon Phi (so-called MIC) accelerator can be used in several modes ([Offload][1] and [Native][2]). The default mode on the cluster is the offload mode, but all modes described in this document are supported.
For more details, see the sections below.
## Intel Utilities for Xeon Phi
Continue [here][3].
## GCC With KNC Support
On Salomon, we have the `GCC/5.1.1-knc` module with cross-compiled (offload) support for [KNC][a]. (gcc, g++ and gfortran)
!!! warning
Available on Salomon only.
To compile a code using GCC compiler, run the following commands:
* Create `reduce_mul.c`:
```console
$vim reduce_mul.c
```
```c
#include<immintrin.h>
doublereduce(double*values)
{
__m512dval=_mm512_load_pd(values);
return_mm512_reduce_mul_pd(val);
}
```
* Create `main.c`:
```console
vim main.c
```
```c
#include<immintrin.h>
#include<stdio.h>
#include<stdlib.h>
doublereduce(double*values);
intmain(intargc,char*argv[])
{
// Generate random input vector of [-1, 1] values.
* To execute the code, run the following command on the host:
```console
$micnativeloadex ./reduce_mul
-0.004276 vs -0.004276
```
## Native Mode
In the native mode, a program is executed directly on Intel Xeon Phi without involvement of the host machine. Similarly to offload mode, the code is compiled on the host computer with Intel compilers.
To compile code, the user has to be connected to a compute node with MIC and load the Intel compilers module. To get an interactive session on a compute node with an Intel Xeon Phi and load the module, use following commands:
```console
$qsub -I-q qprod -lselect=1:ncpus=24:accelerator=True -A NONE-0-0
$ml intel/2017b
```
To produce a binary compatible with the Intel Xeon Phi architecture, the user has to specify the `-mmic` compiler flag. Two compilation examples are shown below. The first example shows how to compile the OpenMP parallel code `vect-add.c` for host only:
* The second example shows how to compile the same code for Intel Xeon Phi:
```console
$icc -mmic-fopenmp vect-add.c -o vect-add-mic
```
* Execution of the Program in Native Mode on Intel Xeon Phi:
The user access to the Intel Xeon Phi is through the SSH. Since user home directories are mounted using NFS on the accelerator, users do not have to copy binary files or libraries between the host and accelerator. Get the PATH of MIC enabled libraries for currently used Intel Compiler.
* To run this code on Intel Xeon Phi:
```console
$ssh mic0
$./vect-add-mic
./vect-add-mic: error while loading shared libraries: libiomp5.so: cannot open shared object file: No such file or directory
S: Module is Sticky, requires --force to unload or purge
```
After loading the `devel_environment` module, modules for the k1om-mpss-linux architecture become available and system software (GCC, CMake, Make, Git, htop, Vim...) can be used.
* Example
```console
r21u02n578-mic0:~$gcc --version
gcc (GCC) 5.1.1
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software;see the source for copying conditions. There is NO
warranty;not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
@r21u02n578-mic0:~$cmake --version
cmake version 2.8.7
r21u02n578-mic0:~$git --version
git version 1.7.7
r21u02n578-mic0:~$make --version
GNU Make 3.82
Built for k1om-mpss-linux-gnu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
r21u02n578-mic0:~$perl --version
This is perl 5, version 14, subversion 2 (v5.14.2) built for k1om-linux
Copyright 1987-2011, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl". If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
Modules `icc`, `ifort`, and `iccifort` are only libraries and headers, not compilers. To compile, use the procedure from the [Native Mode](#native-mode) chapter.
### Octave/3.8.2
Load the `devel_environment` and the `Octave/3.8.2` modules and run the test: