Skip to content
Snippets Groups Projects
compilers.md 3.67 KiB
Newer Older
  • Learn to ignore specific revisions
  • David Hrbáč's avatar
    David Hrbáč committed
    # Compilers
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ## Available Compilers, Including GNU, INTEL, and UPC Compilers
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    Currently there are several compilers for different programming languages available on the Anselm cluster:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    * C/C++
    * Fortran 77/90/95
    * Unified Parallel C
    * Java
    * NVIDIA CUDA
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    The C/C++ and Fortran compilers are divided into two main groups GNU and Intel.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ## Intel Compilers
    
    
    For information about the usage of Intel Compilers and other Intel products, please read the [Intel Parallel studio](intel-suite/) page.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ## GNU C/C++ and Fortran Compilers
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    For compatibility reasons there are still available the original (old 4.4.6-4) versions of GNU compilers as part of the OS. These are accessible in the search path by default.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    It is strongly recommended to use the up to date version (4.8.1) which comes with the module gcc:
    
    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 gcc
        $ gcc -v
        $ g++ -v
        $ gfortran -v
    
    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
    With the module loaded two environment variables are predefined. One for maximum optimizations on the Anselm cluster architecture, and the other for debugging purposes:
    
    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
        $ echo $OPTFLAGS
        -O3 -march=corei7-avx
    
        $ echo $DEBUGFLAGS
        -O0 -g
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    For more information about the possibilities of the compilers, please see the man pages.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ## Unified Parallel C
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
     UPC is supported by two compiler/runtime implementations:
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    * GNU - SMP/multi-threading support only
    * Berkley - multi-node support as well as SMP/multi-threading support
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    ### GNU UPC Compiler
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    To use the GNU UPC compiler and run the compiled binaries use the module gupc
    
    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 add gupc
        $ gupc -v
        $ g++ -v
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    Simple program to test the compiler
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
        $ cat count.upc
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        /* hello.upc - a simple UPC example */
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        #include <upc.h>
        #include <stdio.h>
    
        int main() {
    
    David Hrbáč's avatar
    David Hrbáč committed
          if (MYTHREAD == 0) {
            printf("Welcome to GNU UPC!!!n");
          }
          upc_barrier;
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
          printf(" - Hello from thread %in", MYTHREAD);
    
    David Hrbáč's avatar
    David Hrbáč committed
          return 0;
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        }
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    To compile the example use
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ gupc -o count.upc.x count.upc
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    To run the example with 5 threads issue
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ ./count.upc.x -fupc-threads-5
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    For more information see the man pages.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    ### Berkley UPC Compiler
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    To use the Berkley UPC compiler and runtime environment to run the binaries use the module bupc
    
    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 add bupc
        $ upcc -version
    
    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
    As default UPC network the "smp" is used. This is very quick and easy way for testing/debugging, but limited to one node only.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    For production runs, it is recommended to use the native Infiband implementation of UPC network "ibv". For testing/debugging using multiple nodes, the "mpi" UPC network is recommended.
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    !!! warning
    
        Selection of the network is done at the compile time and not at runtime (as expected)!
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    Example UPC code:
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
        $ cat hello.upc
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        /* hello.upc - a simple UPC example */
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        #include <upc.h>
        #include <stdio.h>
    
        int main() {
    
    David Hrbáč's avatar
    David Hrbáč committed
          if (MYTHREAD == 0) {
            printf("Welcome to Berkeley UPC!!!n");
          }
          upc_barrier;
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
          printf(" - Hello from thread %in", MYTHREAD);
    
    David Hrbáč's avatar
    David Hrbáč committed
          return 0;
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        }
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    To compile the example with the "ibv" UPC network use
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
        $ upcc -network=ibv -o hello.upc.x hello.upc
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    To run the example with 5 threads issue
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ upcrun -n 5 ./hello.upc.x
    
    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 example on two compute nodes using all 32 cores, with 32 threads, issue
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```bash
        $ qsub -I -q qprod -A PROJECT_ID -l select=2:ncpus=16
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
        $ module add bupc
        $ upcrun -n 32 ./hello.upc.x
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    ```
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    For more information see the man pages.
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ## Java
    
    
    For information how to use Java (runtime and/or compiler), please read the [Java page](java/).
    
    Lukáš Krupčík's avatar
    Lukáš Krupčík committed
    
    
    David Hrbáč's avatar
    David Hrbáč committed
    ## NVIDIA CUDA
    
    
    Lubomir Prda's avatar
    Lubomir Prda committed
    For information on how to work with NVIDIA CUDA, please read the [NVIDIA CUDA page](nvidia-cuda/).