6 merge requests!368Update prace.md to document the change from qprace to qprod as the default...,!367Update prace.md to document the change from qprace to qprod as the default...,!366Update prace.md to document the change from qprace to qprod as the default...,!323extended-acls-storage-section,!196Master,!174MIC
Intel Xeon Phi accelerator can be programmed in several modes. The default mode on the cluster is offload mode, but all modes described in this document are supported.
## Intel Utilities for Xeon Phi
To get access to a compute node with Intel Xeon Phi accelerator, use the PBS interactive session
```console
$qsub -I-q qprod -lselect=1:ncpus=24:accelerator=True -A NONE-0-0
```
To set up the environment module "intel" has to be loaded, without specifying the version, default version is loaded (at time of writing this, it's 2017b)
```console
$ml intel/2017b
```
Information about the hardware can be obtained by running the micinfo program on the host.
```console
$/usr/bin/micinfo
```
The output of the "micinfo" utility executed on one of the cluster node is as follows. (note: to get PCIe related details the command has to be run with root privileges)
```console
MicInfo Utility Log
Created Thu Dec 7 09:19:43 2017
System Info
HOST OS : Linux
OS Version : 2.6.32-696.10.3.el6.x86_64
Driver Version : 3.8.2-1
MPSS Version : 3.8.2
Host Physical Memory : 128838 MB
Device No: 0, Device Name: mic0
Version
Flash Version : 2.1.02.0391
SMC Firmware Version : 1.17.6900
...
```
## Offload Mode
To compile a code for Intel Xeon Phi a MPSS stack has to be installed on the machine where compilation is executed. Currently the MPSS stack is only installed on compute nodes equipped with accelerators.
```console
$qsub -I-q qprod -lselect=1:ncpus=24:accelerator=True -A NONE-0-0
```
A very basic example of code that employs offload programming technique is shown in the next listing. Please note that this code is sequential and utilizes only single core of the accelerator.
```cpp
#include<iostream>
intmain(intargc,char*argv[])
{
constintniter=100000;
doubleresult=0;
#pragma offload target(mic)
for(inti=0;i<niter;++i){
constdoublet=(i+0.5)/niter;
result+=4.0/(t*t+1.0);
}
result/=niter;
std::cout<<"Pi ~ "<<result<<'\n';
}
```
### Intel
To compile a code using Intel compiler run.
* Create source-offload.cpp
```console
$vim source-offload.cpp
```
```cpp
#include<iostream>
intmain(intargc,char*argv[])
{
constintniter=100000;
doubleresult=0;
#pragma offload target(mic)
for(inti=0;i<niter;++i){
constdoublet=(i+0.5)/niter;
result+=4.0/(t*t+1.0);
}
result/=niter;
std::cout<<"Pi ~ "<<result<<'\n';
}
```
* Compile
```console
$ml intel/2017b
$icc source-offload.cpp -o bin-offload
```
* To execute the code, run the following command on the host
```console
$./bin-offload
Pi ~ 3.14159
```
### GCC with knc support
On Salomon cluster we have module `GCC/5.1.1-knc` with cross-compiled support. (gcc, g++ and gfortran)
To compile a code using GCC compiler run.
* 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);
}
```
* A 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.
## qprod,qexp
To compile a code user has to be connected to a compute with MIC and load 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 Intel Xeon Phi architecture user has to specify "-mmic" compiler flag. Two compilation examples are shown below. The first example shows how to compile 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 load module `devel_environment` are available modules for architecture k10m-mpss-linux and now exists systems software (gcc, cmake, make, git, htop, vim, ...).
* 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.