Skip to content
Snippets Groups Projects
intel-xeon-phi.md 30.9 KiB
Newer Older
  • Learn to ignore specific revisions
  • David Hrbáč's avatar
    David Hrbáč committed
    # Intel Xeon Phi
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ## Guide to Intel Xeon Phi Usage
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    Intel Xeon Phi can be programmed in several modes. The default mode on Anselm is offload mode, but all modes described in this document are supported.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ## Intel Utilities for Xeon Phi
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    To get access to a compute node with Intel Xeon Phi accelerator, use the PBS interactive session
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    David Hrbáč's avatar
    David Hrbáč committed
    $ qsub -I -q qmic -A NONE-0-0
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    To set up the environment module "Intel" has to be loaded
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    David Hrbáč's avatar
    David Hrbáč committed
    $ module load intel/13.5.192
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    Information about the hardware can be obtained by running the micinfo program on the host.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    David Hrbáč's avatar
    David Hrbáč committed
    $ /usr/bin/micinfo
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    The output of the "micinfo" utility executed on one of the Anselm node is as follows. (note: to get PCIe related details the command has to be run with root privileges)
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        MicInfo Utility Log
    
        Created Mon Jul 22 00:23:50 2013
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
                System Info
                        HOST OS                 : Linux
                        OS Version              : 2.6.32-279.5.2.bl6.Bull.33.x86_64
                        Driver Version          : 6720-15
                        MPSS Version            : 2.1.6720-15
                        Host Physical Memory    : 98843 MB
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
        Device No: 0, Device Name: mic0
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
                Version
                        Flash Version            : 2.1.03.0386
                        SMC Firmware Version     : 1.15.4830
                        SMC Boot Loader Version  : 1.8.4326
                        uOS Version              : 2.6.38.8-g2593b11
                        Device Serial Number     : ADKC30102482
    
                Board
                        Vendor ID                : 0x8086
                        Device ID                : 0x2250
                        Subsystem ID             : 0x2500
                        Coprocessor Stepping ID  : 3
                        PCIe Width               : x16
                        PCIe Speed               : 5 GT/s
                        PCIe Max payload size    : 256 bytes
                        PCIe Max read req size   : 512 bytes
                        Coprocessor Model        : 0x01
                        Coprocessor Model Ext    : 0x00
                        Coprocessor Type         : 0x00
                        Coprocessor Family       : 0x0b
                        Coprocessor Family Ext   : 0x00
                        Coprocessor Stepping     : B1
                        Board SKU                : B1PRQ-5110P/5120D
                        ECC Mode                 : Enabled
                        SMC HW Revision          : Product 225W Passive CS
    
                Cores
                        Total No of Active Cores : 60
                        Voltage                  : 1032000 uV
                        Frequency                : 1052631 kHz
    
                Thermal
                        Fan Speed Control        : N/A
                        Fan RPM                  : N/A
                        Fan PWM                  : N/A
                        Die Temp                 : 49 C
    
                GDDR
                        GDDR Vendor              : Elpida
                        GDDR Version             : 0x1
                        GDDR Density             : 2048 Mb
                        GDDR Size                : 7936 MB
                        GDDR Technology          : GDDR5
                        GDDR Speed               : 5.000000 GT/s
                        GDDR Frequency           : 2500000 kHz
                        GDDR Voltage             : 1501000 uV
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ## Offload Mode
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    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.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    David Hrbáč's avatar
    David Hrbáč committed
    $ qsub -I -q qmic -A NONE-0-0
    $ module load intel/13.5.192
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    For debugging purposes it is also recommended to set environment variable "OFFLOAD_REPORT". Value can be set from 0 to 3, where higher number means more debugging information.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    David Hrbáč's avatar
    David Hrbáč committed
    export OFFLOAD_REPORT=3
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    A very basic example of code that employs offload programming technique is shown in the next listing.
    
    !!! Note
        This code is sequential and utilizes only single core of the accelerator.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ vim source-offload.cpp
    
        #include <iostream>
    
        int main(int argc, char* argv[])
        {
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
            const int niter = 100000;
            double result = 0;
    
         #pragma offload target(mic)
            for (int i = 0; i < niter; ++i) {
                const double t = (i + 0.5) / niter;
                result += 4.0 / (t * t + 1.0);
            }
            result /= niter;
            std::cout << "Pi ~ " << result << 'n';
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        }
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    To compile a code using Intel compiler run
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ icc source-offload.cpp -o bin-offload
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    To execute the code, run the following command on the host
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        ./bin-offload
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    ### Parallelization in Offload Mode Using OpenMP
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    One way of paralelization a code for Xeon Phi is using OpenMP directives. The following example shows code for parallel vector addition.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
        $ vim ./vect-add
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
        #include <stdio.h>
    
        typedef int T;
    
        #define SIZE 1000
    
        #pragma offload_attribute(push, target(mic))
        T in1[SIZE];
        T in2[SIZE];
        T res[SIZE];
        #pragma offload_attribute(pop)
    
        // MIC function to add two vectors
        __attribute__((target(mic))) add_mic(T *a, T *b, T *c, int size) {
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
          int i = 0;
          #pragma omp parallel for
            for (i = 0; i < size; i++)
              c[i] = a[i] + b[i];
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        }
    
        // CPU function to add two vectors
        void add_cpu (T *a, T *b, T *c, int size) {
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
          int i;
          for (i = 0; i < size; i++)
            c[i] = a[i] + b[i];
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        }
    
        // CPU function to generate a vector of random numbers
        void random_T (T *a, int size) {
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
          int i;
          for (i = 0; i < size; i++)
            a[i] = rand() % 10000; // random number between 0 and 9999
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        }
    
        // CPU function to compare two vectors
        int compare(T *a, T *b, T size ){
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
          int pass = 0;
          int i;
          for (i = 0; i < size; i++){
            if (a[i] != b[i]) {
              printf("Value mismatch at location %d, values %d and %dn",i, a[i], b[i]);
              pass = 1;
            }
          }
          if (pass == 0) printf ("Test passedn"); else printf ("Test Failedn");
          return pass;
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        }
    
        int main()
        {
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
          int i;
          random_T(in1, SIZE);
          random_T(in2, SIZE);
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
          #pragma offload target(mic) in(in1,in2)  inout(res)
          {
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
            // Parallel loop from main function
            #pragma omp parallel for
            for (i=0; i<SIZE; i++)
              res[i] = in1[i] + in2[i];
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
            // or parallel loop is called inside the function
            add_mic(in1, in2, res, SIZE);
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
          }
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
          //Check the results with CPU implementation
          T res_cpu[SIZE];
          add_cpu(in1, in2, res_cpu, SIZE);
          compare(res, res_cpu, SIZE);
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    During the compilation Intel compiler shows which loops have been vectorized in both host and accelerator. This can be enabled with compiler option "-vec-report2". To compile and execute the code run
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ icc vect-add.c -openmp_report2 -vec-report2 -o vect-add
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ ./vect-add
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    Some interesting compiler flags useful not only for code debugging are:
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    !!! Note
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        Debugging
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        openmp_report[0|1|2] - controls the compiler based vectorization diagnostic level
        vec-report[0|1|2] - controls the OpenMP parallelizer diagnostic level
    
    
        Performance ooptimization
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        xhost - FOR HOST ONLY - to generate AVX (Advanced Vector Extensions) instructions.
    
    David Hrbáč's avatar
    David Hrbáč committed
    ## Automatic Offload Using Intel MKL Library
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    Intel MKL includes an Automatic Offload (AO) feature that enables computationally intensive MKL functions called in user code to benefit from attached Intel Xeon Phi coprocessors automatically and transparently.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Behavioral of automatic offload mode is controlled by functions called within the program or by environmental variables. Complete list of controls is listed [ here](http://software.intel.com/sites/products/documentation/doclib/mkl_sa/11/mkl_userguide_lnx/GUID-3DC4FC7D-A1E4-423D-9C0C-06AB265FFA86.htm).
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    The Automatic Offload may be enabled by either an MKL function call within the code:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```cpp
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        mkl_mic_enable();
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    or by setting environment variable
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ export MKL_MIC_ENABLE=1
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    To get more information about automatic offload please refer to "[Using Intel® MKL Automatic Offload on Intel ® Xeon Phi™ Coprocessors](http://software.intel.com/sites/default/files/11MIC42_How_to_Use_MKL_Automatic_Offload_0.pdf)" white paper or [ Intel MKL documentation](https://software.intel.com/en-us/articles/intel-math-kernel-library-documentation).
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ### Automatic Offload Example
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    At first get an interactive PBS session on a node with MIC accelerator and load "intel" module that automatically loads "mkl" module as well.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ qsub -I -q qmic -A OPEN-0-0 -l select=1:ncpus=16
        $ module load intel
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    Following example show how to automatically offload an SGEMM (single precision - g dir="auto">eneral matrix multiply) function to MIC coprocessor. The code can be copied to a file and compiled without any necessary modification.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ vim sgemm-ao-short.c
    
        #include <stdio.h>
        #include <stdlib.h>
        #include <malloc.h>
        #include <stdint.h>
    
        #include "mkl.h"
    
        int main(int argc, char **argv)
        {
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
                float *A, *B, *C; /* Matrices */
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
                MKL_INT N = 2560; /* Matrix dimensions */
                MKL_INT LD = N; /* Leading dimension */
                int matrix_bytes; /* Matrix size in bytes */
                int matrix_elements; /* Matrix size in elements */
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
                float alpha = 1.0, beta = 1.0; /* Scaling factors */
                char transa = 'N', transb = 'N'; /* Transposition options */
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
                int i, j; /* Counters */
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
                matrix_elements = N * N;
                matrix_bytes = sizeof(float) * matrix_elements;
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
                /* Allocate the matrices */
                A = malloc(matrix_bytes); B = malloc(matrix_bytes); C = malloc(matrix_bytes);
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
                /* Initialize the matrices */
                for (i = 0; i < matrix_elements; i++) {
                        A[i] = 1.0; B[i] = 2.0; C[i] = 0.0;
                }
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
                printf("Computing SGEMM on the hostn");
                sgemm(&transa, &transb, &N, &N, &N, &alpha, A, &N, B, &N, &beta, C, &N);
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
                printf("Enabling Automatic Offloadn");
                /* Alternatively, set environment variable MKL_MIC_ENABLE=1 */
                mkl_mic_enable();
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
                int ndevices = mkl_mic_get_device_count(); /* Number of MIC devices */
                printf("Automatic Offload enabled: %d MIC devices presentn",   ndevices);
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
                printf("Computing SGEMM with automatic workdivisionn");
                sgemm(&transa, &transb, &N, &N, &N, &alpha, A, &N, B, &N, &beta, C, &N);
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
                /* Free the matrix memory */
                free(A); free(B); free(C);
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
                printf("Donen");
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
            return 0;
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        }
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    !!! Note
    
        This example is simplified version of an example from MKL. The expanded version can be found here: `$MKL_EXAMPLES/mic_ao/blasc/source/sgemm.c`.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    To compile a code using Intel compiler use:
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ icc -mkl sgemm-ao-short.c -o sgemm
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    For debugging purposes enable the offload report to see more information about automatic offloading.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ export OFFLOAD_REPORT=2
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    The output of a code should look similar to following listing, where lines starting with [MKL] are generated by offload reporting:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        Computing SGEMM on the host
        Enabling Automatic Offload
        Automatic Offload enabled: 1 MIC devices present
        Computing SGEMM with automatic workdivision
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        [MKL] [MIC --] [AO Function]    SGEMM
        [MKL] [MIC --] [AO SGEMM Workdivision]  0.00 1.00
        [MKL] [MIC 00] [AO SGEMM CPU Time]      0.463351 seconds
        [MKL] [MIC 00] [AO SGEMM MIC Time]      0.179608 seconds
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        [MKL] [MIC 00] [AO SGEMM CPU->MIC Data] 52428800 bytes
        [MKL] [MIC 00] [AO SGEMM MIC->CPU Data] 26214400 bytes
        Done
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ## Native Mode
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    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.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    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:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ qsub -I -q qmic -A NONE-0-0
    
        $ module load intel/13.5.192
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    !!! Note
    
        Particular version of the Intel module is specified. This information is used later to specify the correct library paths.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    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:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ icc -xhost -no-offload -fopenmp vect-add.c -o vect-add-host
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    To run this code on host, use:
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ ./vect-add-host
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    The second example shows how to compile the same code for Intel Xeon Phi:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ icc -mmic -fopenmp vect-add.c -o vect-add-mic
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    ### Execution of the Program in Native Mode on Intel Xeon Phi
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    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.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    To connect to the accelerator run:
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ ssh mic0
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    If the code is sequential, it can be executed directly:
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        mic0 $ ~/path_to_binary/vect-add-seq-mic
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    If the code is parallelized using OpenMP a set of additional libraries is required for execution. To locate these libraries new path has to be added to the LD_LIBRARY_PATH environment variable prior to the execution:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        mic0 $ export LD_LIBRARY_PATH=/apps/intel/composer_xe_2013.5.192/compiler/lib/mic:$LD_LIBRARY_PATH
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    !!! Note
    
        The path exported in the previous example contains path to a specific compiler (here the version is 5.192). This version number has to match with the version number of the Intel compiler module that was used to compile the code on the host computer.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    For your information the list of libraries and their location required for execution of an OpenMP parallel code on Intel Xeon Phi is:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    !!! Note
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        /apps/intel/composer_xe_2013.5.192/compiler/lib/mic
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        - libiomp5.so
        - libimf.so
        - libsvml.so
        - libirng.so
        - libintlc.so.5
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    Finally, to run the compiled code use:
    
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ ~/path_to_binary/vect-add-mic
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ## OpenCL
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    OpenCL (Open Computing Language) is an open standard for general-purpose parallel programming for diverse mix of multi-core CPUs, GPU coprocessors, and other parallel processors. OpenCL provides a flexible execution model and uniform programming environment for software developers to write portable code for systems running on both the CPU and graphics processors or accelerators like the Intel® Xeon Phi.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    On Anselm OpenCL is installed only on compute nodes with MIC accelerator, therefore OpenCL code can be compiled only on these nodes.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        module load opencl-sdk opencl-rt
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    Always load "opencl-sdk" (providing devel files like headers) and "opencl-rt" (providing dynamic library libOpenCL.so) modules to compile and link OpenCL code. Load "opencl-rt" for running your compiled code.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    There are two basic examples of OpenCL code in the following directory:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        /apps/intel/opencl-examples/
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    First example "CapsBasic" detects OpenCL compatible hardware, here CPU and MIC, and prints basic information about the capabilities of it.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        /apps/intel/opencl-examples/CapsBasic/capsbasic
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    To compile and run the example copy it to your home directory, get a PBS interactive session on of the nodes with MIC and run make for compilation. Make files are very basic and shows how the OpenCL code can be compiled on Anselm.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ cp /apps/intel/opencl-examples/CapsBasic/* .
        $ qsub -I -q qmic -A NONE-0-0
        $ make
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    The compilation command for this example is:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ g++ capsbasic.cpp -lOpenCL -o capsbasic -I/apps/intel/opencl/include/
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    After executing the complied binary file, following output should be displayed.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        ./capsbasic
    
        Number of available platforms: 1
        Platform names:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
            [0] Intel(R) OpenCL [Selected]
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        Number of devices available for each type:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
            CL_DEVICE_TYPE_CPU: 1
            CL_DEVICE_TYPE_GPU: 0
            CL_DEVICE_TYPE_ACCELERATOR: 1
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
        ** Detailed information for each device ***
    
        CL_DEVICE_TYPE_CPU[0]
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
            CL_DEVICE_NAME:        Intel(R) Xeon(R) CPU E5-2470 0 @ 2.30GHz
            CL_DEVICE_AVAILABLE: 1
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
        ...
    
        CL_DEVICE_TYPE_ACCELERATOR[0]
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
            CL_DEVICE_NAME: Intel(R) Many Integrated Core Acceleration Card
            CL_DEVICE_AVAILABLE: 1
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
        ...
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    !!! Note
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        More information about this example can be found on Intel website: <http://software.intel.com/en-us/vcsource/samples/caps-basic/>
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    The second example that can be found in "/apps/intel/opencl-examples" directory is General Matrix Multiply. You can follow the the same procedure to download the example to your directory and compile it.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ cp -r /apps/intel/opencl-examples/* .
        $ qsub -I -q qmic -A NONE-0-0
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ cd GEMM
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ make
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    The compilation command for this example is:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ g++ cmdoptions.cpp gemm.cpp ../common/basic.cpp ../common/cmdparser.cpp ../common/oclobject.cpp -I../common -lOpenCL -o gemm -I/apps/intel/opencl/include/
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    To see the performance of Intel Xeon Phi performing the DGEMM run the example as follows:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        ./gemm -d 1
        Platforms (1):
         [0] Intel(R) OpenCL [Selected]
        Devices (2):
         [0] Intel(R) Xeon(R) CPU E5-2470 0 @ 2.30GHz
         [1] Intel(R) Many Integrated Core Acceleration Card [Selected]
        Build program options: "-DT=float -DTILE_SIZE_M=1 -DTILE_GROUP_M=16 -DTILE_SIZE_N=128 -DTILE_GROUP_N=1 -DTILE_SIZE_K=8"
        Running gemm_nn kernel with matrix size: 3968x3968
        Memory row stride to ensure necessary alignment: 15872 bytes
        Size of memory region for one matrix: 62980096 bytes
        Using alpha = 0.57599 and beta = 0.872412
        ...
        Host time: 0.292953 sec.
        Host perf: 426.635 GFLOPS
        Host time: 0.293334 sec.
        Host perf: 426.081 GFLOPS
        ...
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    !!! Warning
        GNU compiler is used to compile the OpenCL codes for Intel MIC. You do not need to load Intel compiler module.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ## MPI
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ### Environment Setup and Compilation
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    Again an MPI code for Intel Xeon Phi has to be compiled on a compute node with accelerator and MPSS software stack installed. To get to a compute node with accelerator use:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ qsub -I -q qmic -A NONE-0-0
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    The only supported implementation of MPI standard for Intel Xeon Phi is Intel MPI. To setup a fully functional development environment a combination of Intel compiler and Intel MPI has to be used. On a host load following modules before compilation:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
        $ module load intel/13.5.192 impi/4.1.1.036
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    To compile an MPI code for host use:
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ````bash
            $ mpiicc -xhost -o mpi-test mpi-test.c
        ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
        To compile the same code for Intel Xeon Phi architecture use:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
        ```bash
            $ mpiicc -mmic -o mpi-test-mic mpi-test.c
    ````
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    An example of basic MPI version of "hello-world" example in C language, that can be executed on both host and Xeon Phi is (can be directly copy and pasted to a .c file)
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```cpp
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        #include <stdio.h>
        #include <mpi.h>
    
        int main (argc, argv)
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
             int argc;
             char *argv[];
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        {
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
          int rank, size;
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
          int len;
          char node[MPI_MAX_PROCESSOR_NAME];
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
          MPI_Init (&argc, &argv);      /* starts MPI */
          MPI_Comm_rank (MPI_COMM_WORLD, &rank);        /* get current process id */
          MPI_Comm_size (MPI_COMM_WORLD, &size);        /* get number of processes */
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
          MPI_Get_processor_name(node,&len);
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
          printf( "Hello world from process %d of %d on host %s n", rank, size, node );
          MPI_Finalize();
          return 0;
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        }
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ### MPI Programming Models
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    Intel MPI for the Xeon Phi coprocessors offers different MPI programming models:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    !!! Note
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        **Host-only model** - all MPI ranks reside on the host. The coprocessors can be used by using offload pragmas. (Using MPI calls inside offloaded code is not supported.)
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        **Coprocessor-only model** - all MPI ranks reside only on the coprocessors.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        **Symmetric model** - the MPI ranks reside on both the host and the coprocessor. Most general MPI case.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ### Host-Only Model
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    In this case all environment variables are set by modules, so to execute the compiled MPI program on a single node, use:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ mpirun -np 4 ./mpi-test
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    The output should be similar to:
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        Hello world from process 1 of 4 on host cn207
        Hello world from process 3 of 4 on host cn207
        Hello world from process 2 of 4 on host cn207
        Hello world from process 0 of 4 on host cn207
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ### Coprocessor-Only Model
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    There are two ways how to execute an MPI code on a single coprocessor: 1.) lunch the program using "**mpirun**" from the
    coprocessor; or 2.) lunch the task using "**mpiexec.hydra**" from a host.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    **Execution on coprocessor**
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    Similarly to execution of OpenMP programs in native mode, since the environmental module are not supported on MIC, user has to setup paths to Intel MPI libraries and binaries manually. One time setup can be done by creating a "**.profile**" file in user's home directory. This file sets up the environment on the MIC automatically once user access to the accelerator through the SSH.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
        $ vim ~/.profile
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
        PS1='[u@h W]$ '
        export PATH=/usr/bin:/usr/sbin:/bin:/sbin
    
        #OpenMP
        export LD_LIBRARY_PATH=/apps/intel/composer_xe_2013.5.192/compiler/lib/mic:$LD_LIBRARY_PATH
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        #Intel MPI
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        export LD_LIBRARY_PATH=/apps/intel/impi/4.1.1.036/mic/lib/:$LD_LIBRARY_PATH
        export PATH=/apps/intel/impi/4.1.1.036/mic/bin/:$PATH
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    !!! Note
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        - this file sets up both environmental variable for both MPI and OpenMP libraries.
        - this file sets up the paths to a particular version of Intel MPI library and particular version of an Intel compiler. These versions have to match with loaded modules.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    To access a MIC accelerator located on a node that user is currently connected to, use:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ ssh mic0
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    or in case you need specify a MIC accelerator on a particular node, use:
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ ssh cn207-mic0
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    To run the MPI code in parallel on multiple core of the accelerator, use:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ mpirun -np 4 ./mpi-test-mic
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    The output should be similar to:
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        Hello world from process 1 of 4 on host cn207-mic0
        Hello world from process 2 of 4 on host cn207-mic0
        Hello world from process 3 of 4 on host cn207-mic0
        Hello world from process 0 of 4 on host cn207-mic0
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    **Execution on host**
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    If the MPI program is launched from host instead of the coprocessor, the environmental variables are not set using the ".profile" file. Therefore user has to specify library paths from the command line when calling "mpiexec".
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    First step is to tell mpiexec that the MPI should be executed on a local accelerator by setting up the environmental variable "I_MPI_MIC"
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ export I_MPI_MIC=1
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    Now the MPI program can be executed as:
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ mpiexec.hydra -genv LD_LIBRARY_PATH /apps/intel/impi/4.1.1.036/mic/lib/ -host mic0 -n 4 ~/mpi-test-mic
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    or using mpirun
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ mpirun -genv LD_LIBRARY_PATH /apps/intel/impi/4.1.1.036/mic/lib/ -host mic0 -n 4 ~/mpi-test-mic
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    !!! Note
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        - the full path to the binary has to specified (here: `>~/mpi-test-mic`)
        - the `LD_LIBRARY_PATH` has to match with Intel MPI module used to compile the MPI code
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    The output should be again similar to:
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        Hello world from process 1 of 4 on host cn207-mic0
        Hello world from process 2 of 4 on host cn207-mic0
        Hello world from process 3 of 4 on host cn207-mic0
        Hello world from process 0 of 4 on host cn207-mic0
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    !!! Note
    
        `mpiexec.hydra` requires a file the MIC filesystem. If the file is missing please contact the system administrators.
    
    A simple test to see if the file is present is to execute:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
          $ ssh mic0 ls /bin/pmi_proxy
          /bin/pmi_proxy
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    **Execution on host - MPI processes distributed over multiple accelerators on multiple nodes**
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    To get access to multiple nodes with MIC accelerator, user has to use PBS to allocate the resources. To start interactive session, that allocates 2 compute nodes = 2 MIC accelerators run qsub command with following parameters:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ qsub -I -q qmic -A NONE-0-0 -l select=2:ncpus=16
    
        $ module load intel/13.5.192 impi/4.1.1.036
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    This command connects user through ssh to one of the nodes immediately. To see the other nodes that have been allocated use:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ cat $PBS_NODEFILE
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    For example:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        cn204.bullx
        cn205.bullx
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    This output means that the PBS allocated nodes cn204 and cn205, which means that user has direct access to "**cn204-mic0**" and "**cn-205-mic0**" accelerators.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    !!! Note
    
        At this point user can connect to any of the allocated nodes or any of the allocated MIC accelerators using ssh:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        - to connect to the second node : `$ ssh cn205`
        - to connect to the accelerator on the first node from the first node: `$ ssh cn204-mic0` or `$ ssh mic0`
        - to connect to the accelerator on the second node from the first node: `$ ssh cn205-mic0`
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    At this point we expect that correct modules are loaded and binary is compiled. For parallel execution the mpiexec.hydra is used. Again the first step is to tell mpiexec that the MPI can be executed on MIC accelerators by setting up the environmental variable "I_MPI_MIC"
    
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ export I_MPI_MIC=1
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    The launch the MPI program use:
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
        $ mpiexec.hydra -genv LD_LIBRARY_PATH /apps/intel/impi/4.1.1.036/mic/lib/
         -genv I_MPI_FABRICS_LIST tcp
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
         -genv I_MPI_FABRICS shm:tcp
         -genv I_MPI_TCP_NETMASK=10.1.0.0/16
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
         -host cn204-mic0 -n 4 ~/mpi-test-mic
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        : -host cn205-mic0 -n 6 ~/mpi-test-mic
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    or using mpirun:
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
        $ mpirun -genv LD_LIBRARY_PATH /apps/intel/impi/4.1.1.036/mic/lib/
         -genv I_MPI_FABRICS_LIST tcp
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
         -genv I_MPI_FABRICS shm:tcp
         -genv I_MPI_TCP_NETMASK=10.1.0.0/16
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
         -host cn204-mic0 -n 4 ~/mpi-test-mic
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        : -host cn205-mic0 -n 6 ~/mpi-test-mic
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    In this case four MPI processes are executed on accelerator cn204-mic and six processes are executed on accelerator cn205-mic0. The sample output (sorted after execution) is:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        Hello world from process 0 of 10 on host cn204-mic0
        Hello world from process 1 of 10 on host cn204-mic0
        Hello world from process 2 of 10 on host cn204-mic0
        Hello world from process 3 of 10 on host cn204-mic0
        Hello world from process 4 of 10 on host cn205-mic0
        Hello world from process 5 of 10 on host cn205-mic0
        Hello world from process 6 of 10 on host cn205-mic0
        Hello world from process 7 of 10 on host cn205-mic0
        Hello world from process 8 of 10 on host cn205-mic0
        Hello world from process 9 of 10 on host cn205-mic0
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    The same way MPI program can be executed on multiple hosts:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
        $ mpiexec.hydra -genv LD_LIBRARY_PATH /apps/intel/impi/4.1.1.036/mic/lib/
         -genv I_MPI_FABRICS_LIST tcp
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
         -genv I_MPI_FABRICS shm:tcp
         -genv I_MPI_TCP_NETMASK=10.1.0.0/16
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
         -host cn204 -n 4 ~/mpi-test
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        : -host cn205 -n 6 ~/mpi-test
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ### Symmetric Model
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    In a symmetric mode MPI programs are executed on both host computer(s) and MIC accelerator(s). Since MIC has a different
    architecture and requires different binary file produced by the Intel compiler two different files has to be compiled before MPI program is executed.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    In the previous section we have compiled two binary files, one for hosts "**mpi-test**" and one for MIC accelerators "**mpi-test-mic**". These two binaries can be executed at once using mpiexec.hydra:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
        $ mpiexec.hydra
         -genv I_MPI_FABRICS_LIST tcp
         -genv I_MPI_FABRICS shm:tcp
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
         -genv I_MPI_TCP_NETMASK=10.1.0.0/16
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
         -genv LD_LIBRARY_PATH /apps/intel/impi/4.1.1.036/mic/lib/
         -host cn205 -n 2 ~/mpi-test
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        : -host cn205-mic0 -n 2 ~/mpi-test-mic
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    In this example the first two parameters (line 2 and 3) sets up required environment variables for execution. The third line specifies binary that is executed on host (here cn205) and the last line specifies the binary that is execute on the accelerator (here cn205-mic0).
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    The output of the program is:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        Hello world from process 0 of 4 on host cn205
        Hello world from process 1 of 4 on host cn205
        Hello world from process 2 of 4 on host cn205-mic0
        Hello world from process 3 of 4 on host cn205-mic0
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    The execution procedure can be simplified by using the mpirun command with the machine file a a parameter. Machine file contains list of all nodes and accelerators that should used to execute MPI processes.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    An example of a machine file that uses 2 >hosts (**cn205** and **cn206**) and 2 accelerators **(cn205-mic0** and **cn206-mic0**) to run 2 MPI processes on each of them:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ cat hosts_file_mix
        cn205:2
        cn205-mic0:2
        cn206:2
        cn206-mic0:2
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    In addition if a naming convention is set in a way that the name of the binary for host is **"bin_name"**  and the name of the binary for the accelerator is **"bin_name-mic"** then by setting up the environment variable **I_MPI_MIC_POSTFIX** to **"-mic"** user do not have to specify the names of booth binaries. In this case mpirun needs just the name of the host binary file (i.e. "mpi-test") and uses the suffix to get a name of the binary for accelerator (i..e. "mpi-test-mic").
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ export I_MPI_MIC_POSTFIX=-mic
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    To run the MPI code using mpirun and the machine file "hosts_file_mix" use:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
        $ mpirun
         -genv I_MPI_FABRICS shm:tcp
         -genv LD_LIBRARY_PATH /apps/intel/impi/4.1.1.036/mic/lib/
         -genv I_MPI_FABRICS_LIST tcp
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
         -genv I_MPI_FABRICS shm:tcp
         -genv I_MPI_TCP_NETMASK=10.1.0.0/16
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
         -machinefile hosts_file_mix
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
         ~/mpi-test
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    A possible output of the MPI "hello-world" example executed on two hosts and two accelerators is:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        Hello world from process 0 of 8 on host cn204
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        Hello world from process 1 of 8 on host cn204
        Hello world from process 2 of 8 on host cn204-mic0
        Hello world from process 3 of 8 on host cn204-mic0
        Hello world from process 4 of 8 on host cn205
        Hello world from process 5 of 8 on host cn205
        Hello world from process 6 of 8 on host cn205-mic0
        Hello world from process 7 of 8 on host cn205-mic0
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    !!! Note
    
        At this point the MPI communication between MIC accelerators on different nodes uses 1Gb Ethernet only.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    **Using the PBS automatically generated node-files**
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    PBS also generates a set of node-files that can be used instead of manually creating a new one every time. Three node-files are genereated:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    !!! Note
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        **Host only node-file:**
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
         - /lscratch/${PBS_JOBID}/nodefile-cn MIC only node-file:
         - /lscratch/${PBS_JOBID}/nodefile-mic Host and MIC node-file:
         - /lscratch/${PBS_JOBID}/nodefile-mix
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Each host or accelerator is listed only per files. User has to specify how many jobs should be executed per node using `-n` parameter of the mpirun command.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ## Optimization
    
    For more details about optimization techniques please read Intel document [Optimization and Performance Tuning for Intel® Xeon Phi™ Coprocessors](http://software.intel.com/en-us/articles/optimization-and-performance-tuning-for-intel-xeon-phi-coprocessors-part-1-optimization "http&#x3A;//software.intel.com/en-us/articles/optimization-and-performance-tuning-for-intel-xeon-phi-coprocessors-part-1-optimization")