From Documentation
Revision as of 14:15, 26 March 2015 by Preney (Talk | contribs)

Jump to: navigation, search
BOOST
Description: free peer-reviewed portable C++ source libraries
SHARCNET Package information: see BOOST software page in web portal
Full list of SHARCNET supported software


Which Versions of Boost are Available?

SHARCNET has a number of Boost versions available as special modules. The available versions can be viewed by running:

module avail boost

and/or by viewing the BOOST software page in the web portal.

At the present time, when you look up the available boost modules you will see output such as:

$ module avail boost

------------------------------------ /opt/sharcnet/modules -------------------------------------
boost/gcc482-openmpi183/1.50.0  boost/intel12-openmpi162/1.50.0
boost/gcc482-openmpi183/1.53.0  boost/intel12-openmpi162/1.53.0
boost/gcc482-openmpi183/1.55.0  boost/intel12-openmpi162/1.55.0
boost/gcc482-openmpi183/1.57.0  boost/intel12-openmpi162/1.57.0
boost/intel/1.55.0              boost/intel15-noopenmpi/1.57.0

------------------------------------ /opt/sharcnet/modules -------------------------------------
boost/gcc482-openmpi183/1.50.0  boost/intel12-openmpi162/1.50.0
boost/gcc482-openmpi183/1.53.0  boost/intel12-openmpi162/1.50.0
boost/gcc482-openmpi183/1.55.0  boost/intel12-openmpi162/1.50.0
boost/gcc482-openmpi183/1.57.0  boost/intel12-openmpi162/1.57.0
boost/intel/1.55.0              boost/intel15-noopenmpi/1.57.0
$

i.e., the following versions of Boost are available:

  1. Boost versions 1.50, 1.53, 1.55, and 1.57 for GCC v4.8.2 and OpenMPI v1.8.3
    • i.e., boost/gcc482-openmpi183/1.50.0, boost/gcc482-openmpi183/1.53.0, boost/gcc482-openmpi183/1.55.0, boost/gcc482-openmpi183/1.57.0
  2. Boost versions 1.50, 1.53, 1.55, and 1.57 for Intel v12 and OpenMPI v1.6.2
    • i.e., boost/intel12-openmpi162/1.50.0, boost/intel12-openmpi162/1.53.0, boost/intel12-openmpi162/1.55.0, boost/intel12-openmpi162/1.57.0
    • NOTE: You may experience problems compiling Boost codes with the Intel v12 compiler (e.g., some incompatible headers). If you do, try the GCC compiler to see if that works.
  3. Boost version 1.57 for Intel v15 without OpenMPI features (i.e., the "noopenmpi" item).
    • i.e., boost/intel15-noopenmpi/1.57.0

NOTE: The boost/intel/1.55.0 module should not be used --it is older and will be removed in the near future. Use one of the other Boost modules instead.

All of the aforementioned versions of Boost have been built with the operating system's installed Python. You can see which version of Python it will use by running:

rpm -qi python

NOTE: If you need a specific version of Boost compiled for a specific C++ compiler, version of OpenMPI, and/or a specific version of Python, then submit a ticket requesting such. Be sure to mention all required software packages and which versions are needed.

Using a Specific Version of Boost

To use a specific version of Boost, do the following:

  • Unload any loaded OpenMPI modules that will conflict.
  • Unload any loaded C++ compiler modules that will conflict.
  • Load any required C++ and OpenMPI modules.
  • Load the required version of Boost.

e.g.,

$ module list                                 # View which modules are currently loaded
$ module unload openmpi/intel/1.6.2           # Unload the OpenMPI (for Intel)
$ module unload intel/12.1.3                  # Unload the Intel C++ compiler
$ module load gcc/4.8.2                       # Load GCC v4.8.2
$ module load openmpi/gcc/1.8.3               # Load OpenMPI (for GCC)
$ module load boost/gcc482-openmpi183/1.57.0  # Load Boost v1.57 for GCC 4.8.2 and OpenMPI v1.8.3

Once this is done, you may use Boost (e.g., write #include <boost/filesystem.hpp> in your code, etc.). No special compiler options will be required.

If Special Compiler Options are Required

If you are not having success building your code using Boost (e.g., in a Makefile), you might need to manually specify the INCLUDE and LIB directories. You can get these paths by running the following command (replacing the full Boost module name with the one you've loaded), e.g.,

$ module show boost/gcc482-openmpi183/1.57.0
-------------------------------------------------------------------
/opt/sharcnet/modules/boost/gcc482-openmpi183/1.57.0:

module-whatis    Provides boost 1.57.0 (flavor gcc482-openmpi183) built using gcc/4.8.2, openmpi/gcc/1.8.3 on centos64.
conflict         intel
conflict         pgi
conflict         python
prereq   gcc/4.8.2
prereq   openmpi/gcc/1.8.3
prepend-path     --delim   CPPFLAGS -I/opt/sharcnet/boost/1.57.0/gcc482-openmpi183/include
prepend-path     --delim   LDFLAGS -L/opt/sharcnet/boost/1.57.0/gcc482-openmpi183/lib
prepend-path     LD_RUN_PATH /opt/sharcnet/boost/1.57.0/gcc482-openmpi183/lib
-------------------------------------------------------------------
$

i.e., for Boost 1.57.0 (flavour gcc482-openmpi183) you could explicitly invoke the compiler with:

g++ $CPPFLAGS $CXXFLAGS $LDFLAGS yoursourcecode.cxx

Also be aware that you must specify any Boost-required libraries for linking purposes using the -l option. You can see the actual available library names for any given Boost installation by running:

$ for a in `ls $BLIBS` ; do basename $a ; done

where $BLIBS is the directory you see with LDFLAGS in the module show output, thus, to see all libraries available with the gcc482-openmpi183/lib module, you would write:

$ for a in `ls /opt/sharcnet/boost/1.57.0/gcc482-openmpi183/lib/libboost_*` ; do basename $a ; done

NOTE: Using the -l option is important when using any non-header-only Boost library, e.g., MPI, serialization, program_options, etc.


Building an Example Boost Program

First create/write/copy your program somewhere suitable (this example is from the Boost.MPI documentation):

$ cd
$ mkdir boost-test
$ cat >boost-mpi-eg.cxx
#include <iostream>
#include <string>
#include <boost/mpi.hpp>
#include <boost/serialization/string.hpp>

namespace mpi = boost::mpi;

int main(int argc, char *argv[])
{
  mpi::environment env(argc, argv);
  mpi::communicator world;

  if (world.rank() == 0) {
    world.send(1, 0, std::string("Hello"));
    std::string msg;
    world.recv(1, 1, msg);
    std::cout << msg << "!" << std::endl;
  } else {
    std::string msg;
    world.recv(0, 0, msg);
    std::cout << msg << ", ";
    std::cout.flush();
    world.send(0, 1, std::string("world"));
  }

  return 0;
}
$

compile it:

$ mpic++ $CPPFLAGS $CXXFLAGS $LDFLAGS -lboost_mpi -lboost_serialization boost-mpi-eg.cxx

and run it (as it is very fast and short, sqsub is not used here):

$ mpirun -np 2 ./a.out

Operating System Installed Boost

If you don't load any SHARCNET-provided Boost module, you will be using the operating system's installed version of Boost. To determine which version(s) of boost and boost-devel are installed run the following commands:

rpm -qi boost
rpm -qi boost-devel

NOTE: These versions may be very old, they won't be upgraded or maintained by SHARCNET staff unless something in the operating system requires it to be upgraded. You are therefore strongly encouraged to use the SHARCNET-provided Boost modules discussed earlier on this page.


References

o Boost Homepage
http://www.boost.org/