New Compilers

This note covers important topics with respect to compilers on all our platforms.

Why is this important. Two reasons...

For C++ programers this gives us support for C++11 which is needed for many newer packages.

For Mc2 users we are seeing relatively good performance for codes compiled using these new gcc/g++/gfrotran compilers. So if you have previously not been able to run on Mc2 because your programs did not work with the IBM compilers the new versions of gcc/g++/gfrotran provide a viable option.

******** We will start with C++11 support. ********

The example is from

Our example:

[joeuser@mio001 ~]$ cat eleven.C 
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
bool is_greater_than_5(int value)
    return (value > 5);
int main()
    vector<int> numbers { 1, 2, 3, 4, 5, 10, 15, 20, 25, 35, 45, 50 };
    auto greater_than_5_count = count_if(numbers.begin(), numbers.end(), is_greater_than_5);
    cout << "The number of elements greater than 5 is: "
        << greater_than_5_count << "." << endl;

To invoke C++11 you need to add the option -std=c++11 on the command line.

With the "default" compilers your get:

[joeuser@mio001 ~]$ g++ -std=c++11  eleven.C
cc1plus: error: unrecognized command line option "-std=c++11"
[joeuser@mio001 ~]$ 

For version 13 of the Intel compilers you also get build errors.

We can load the new gnu compilers using the command:

[joeuser@mio001 ~]$ module load PrgEnv/devtoolset-3 

This gives:

[joeuser@mio001 ~]$ g++ -v
gcc version 4.9.2 20150212 (Red Hat 4.9.2-6) (GCC) 

Then we do a build and run:

[joeuser@mio001 ~]$ icpc -std=c++11 eleven.C [joeuser@mio001 ~]$ ./a.out The number of elements greater than 5 is: 7.

Limited support is offered in the Intel compilers starting with version 14.x but full support is offered in 16.x. So we will want to load the module for Intel/16. ALONG WITH module load PrgEnv/devtoolset-3. Intel recommends having newer version of gnu compilers loaded.

[joeuser@aun001 ~]$ module purge
[joeuser@aun001 ~]$ module load PrgEnv/devtoolset-3 
[joeuser@aun001 ~]$  module load PrgEnv/intel/16.0 
[joeuser@aun001 ~]$ icpc -v
icpc version 16.0.1 (gcc version 4.9.2 compatibility)
[joeuser@aun001 ~]$ 

Finally we see we have support in g++ and icpc...

[joeuser@mio001 ~]$ g++ -std=c++11  eleven.C
[joeuser@mio001 ~]$ ./a.out
The number of elements greater than 5 is: 7.

[joeuser@mio001 ~]$ icpc -std=c++11  eleven.C
[joeuser@mio001 ~]$ ./a.out
The number of elements greater than 5 is: 7.
[joeuser@mio001 ~]$ 

On Mc2 the module we want to load is

module load PrgEnv/gcc/gcc-4.7.2.bgq 

[joeuser@mc2 ~]$ module load PrgEnv/gcc/gcc-4.7.2.bgq 
[joeuser@mc2 ~]$ 
[joeuser@mc2 ~]$ g++ -std=c++11 eleven.C 
[joeuser@mc2 ~]$ srun -n 1 ./a.out
The number of elements greater than 5 is: 7.
[joeuser@mc2 ~]$ 

There are some funny things happening with the libraries that ship with the new Mc2 gnu compilers. We are still sorting things out but we know that you DO NOT want to put the paths to these libraries as part fo your default library path. However, you MAY need to pass the path to the srun command. You WILL need to do this if you you do a dynamic link (this is not the default). The way to do this is:

srun --export="LD_LIBRARY_PATH=/bgsys/drivers/ppcfloor/gnu-linux-4.7.2/powerpc64-bgq-linux/lib:$LD_LIBRARY_PATH" -n 1 ./a.out

******** Mc2 compilers instead of IBM compilers. ********

We have not done extensive testing. But we are seeing reasonable performance with these new compilers. If you have program that you were not able to build using the IBM compilers the Gnu compilers might be a viable option.

******** MPI compilers ********

To use these new compilers along with MPI on AuN or Mio you can do the following:

module purge
module load PrgEnv/devtoolset-3
module load openmpi/gcc/1.6.5

For Mc2 do the following:

module purge
module load PrgEnv/gcc/gcc-4.7.2.bgq 
module load PrgEnv/MPI/gcc/default
export MPICH_CC=`which gcc`
export MPICH_F90=`which gfortran`
export MPICH_F77=`which gfortran`
export MPICH_CXX=`which g++`

Know issues on Mc2:

  1. The Fortran subroutine system_clock does not return useful results
    and timing results based on it will not be valid.
  2. The Fortran module mpi is not compatible with the new compiler.

If either of these become an issue for you let us know. We might be able to help.

December 2016 update
New Gnu compilers for Mio and AuN.

As stated above the gnu compilers for Mio and Aun are gcc, g++, gfortran version 4.4.7.

We now have versions 4.9.2, 5.3.1, and 6.2.1 available on both platforms. These versions are available after loading the modules

PrgEnv/devtoolset-3 for 4.9.2
PrgEnv/devtoolset-4 for 5.3.1
PrgEnv/devtoolset-6 for 6.2.1

For example, after running the command

module load PrgEnv/devtoolset-6

the which command shows that gcc, g++, gfortran are found at:


And the version returned by using the -v option on the compiler command line is:

gcc version 6.2.1 20160916 (Red Hat 6.2.1-3) (GCC) 

For additional information on the newer compilers see: