Difference between revisions of "HPC:Boost"

From HPC wiki
Line 10: Line 10:
 
Code below has been adapted from the Boost [http://www.boost.org/doc/libs/1_57_0/doc/html/mpi/getting_started.html documentation]
 
Code below has been adapted from the Boost [http://www.boost.org/doc/libs/1_57_0/doc/html/mpi/getting_started.html documentation]
 
<pre>
 
<pre>
 +
#include <iostream>
 +
#include <mpi.h>
  
 +
int main( int argc, char* argv[])
 +
{
 +
  MPI_Init(&argc, &argv);
 +
 +
  int rank;
 +
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
 +
  if (rank == 0) {
 +
    int value = 17;
 +
    int result = MPI_Send(&value, 1, MPI_INT, 1, 0, MPI_COMM_WORLD);
 +
    if (result == MPI_SUCCESS)
 +
  std::cout << "Rank 0 OK!" << std::endl;
 +
  } else if (rank == 1) {
 +
    int value;
 +
    int result = MPI_Recv(&value, 1, MPI_INT, 0, 0, MPI_COMM_WORLD,
 +
  MPI_STATUS_IGNORE);
 +
    if (result == MPI_SUCCESS && value == 17)
 +
  std::cout << "Rank 1 OK!" << std::endl;
 +
  }
 +
  MPI_Finalize();
 +
  return 0;
 +
} 0;
 +
}
 
</pre>
 
</pre>
  
Line 16: Line 40:
  
 
===== Boost v1.55.0 =====  
 
===== Boost v1.55.0 =====  
The above code snippet is intended to verify Boost.MPI library functionality. Follow the steps below in an interactive node:
+
The above code snippet is intended to verify Boost.MPI library functionality. Follow the steps below in an interactive node. Launch an interactive session with -n 2 to ensure that the number of processors used in this Boost.MPI test are accounted for
  
 
Load the appropriate Boost version module:
 
Load the appropriate Boost version module:
 
<pre>
 
<pre>
[asrini@consign ~]$ bsub -Is bash
+
[asrini@consign ~]$ bsub -n 2 -Is bash
  
 
[asrini@node062 ~]$ ls boost_test.cpp
 
[asrini@node062 ~]$ ls boost_test.cpp
Line 34: Line 58:
 
<pre>
 
<pre>
  
[asrini@node062 ~]$ mpic++ -W -Wall -L/opt/software/boost/1.55.0/lib/ -lboost_mpi -lboost_serialization -lboost_system -lboost_filesystem -lboost_graph_parallel -lboost_iostreams boost_test.cpp -o Boost
+
[asrini@node062 ~]$ mpic++ -W -Wall -I/opt/software/boost/1.55.0/include/ -L/opt/software/boost/1.55.0/lib/ -lboost_mpi -lboost_serialization boost_test.cpp -o Boost
  
 
</pre>
 
</pre>
Line 43: Line 67:
  
 
[asrini@node062 ~]$ $ ldd Boost
 
[asrini@node062 ~]$ $ ldd Boost
linux-vdso.so.1 =>  (0x00007fffebbff000)
+
linux-vdso.so.1 =>  (0x00007fff3271e000)
libboost_mpi.so.1.55.0 => /opt/software/boost/1.55.0/lib/libboost_mpi.so.1.55.0 (0x00002b69ecb97000)
+
libboost_mpi.so.1.55.0 => /opt/software/boost/1.55.0/lib/libboost_mpi.so.1.55.0 (0x00002b7325636000)
libboost_serialization.so.1.55.0 => /opt/software/boost/1.55.0/lib/libboost_serialization.so.1.55.0 (0x00002b69ecdc7000)
+
libboost_serialization.so.1.55.0 => /opt/software/boost/1.55.0/lib/libboost_serialization.so.1.55.0 (0x00002b7325866000)
libboost_system.so.1.55.0 => /opt/software/boost/1.55.0/lib/libboost_system.so.1.55.0 (0x00002b69ed041000)
+
libmpi_cxx.so.1 => /usr/lib64/openmpi/lib/libmpi_cxx.so.1 (0x00002b7325ae0000)
libboost_filesystem.so.1.55.0 => /opt/software/boost/1.55.0/lib/libboost_filesystem.so.1.55.0 (0x00002b69ed244000)
+
libmpi.so.1 => /usr/lib64/openmpi/lib/libmpi.so.1 (0x00000031d0e00000)
libboost_graph_parallel.so.1.55.0 => /opt/software/boost/1.55.0/lib/libboost_graph_parallel.so.1.55.0 (0x00002b69ed45b000)
+
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00000031cfe00000)
libboost_iostreams.so.1.55.0 => /opt/software/boost/1.55.0/lib/libboost_iostreams.so.1.55.0 (0x00002b69ed6a3000)
+
libm.so.6 => /lib64/libm.so.6 (0x00000031ce200000)
libmpi_cxx.so.1 => /usr/lib64/openmpi/lib/libmpi_cxx.so.1 (0x00002b69ed8bc000)
+
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00000031d0600000)
libmpi.so.1 => /usr/lib64/openmpi/lib/libmpi.so.1 (0x00000030d6800000)
+
libpthread.so.0 => /lib64/libpthread.so.0 (0x00000031cea00000)
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00000030d5400000)
+
libc.so.6 => /lib64/libc.so.6 (0x00000031ce600000)
libm.so.6 => /lib64/libm.so.6 (0x00000030d3800000)
+
librt.so.1 => /lib64/librt.so.1 (0x00000031cf600000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00000030d5c00000)
+
libopen-rte.so.7 => /usr/lib64/openmpi/lib/libopen-rte.so.7 (0x00000031d0a00000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00000030d4000000)
+
libopen-pal.so.6 => /usr/lib64/openmpi/lib/libopen-pal.so.6 (0x00000031d0200000)
libc.so.6 => /lib64/libc.so.6 (0x00000030d3c00000)
+
libdl.so.2 => /lib64/libdl.so.2 (0x00000031cee00000)
librt.so.1 => /lib64/librt.so.1 (0x00000030d4c00000)
+
libnsl.so.1 => /lib64/libnsl.so.1 (0x00000031d1600000)
libz.so.1 => /lib64/libz.so.1 (0x00000030d4800000)
+
libutil.so.1 => /lib64/libutil.so.1 (0x00000031d2200000)
libbz2.so.1 => /lib64/libbz2.so.1 (0x00000030d8c00000)
+
libltdl.so.7 => /usr/lib64/libltdl.so.7 (0x00000031cfa00000)
libopen-rte.so.7 => /usr/lib64/openmpi/lib/libopen-rte.so.7 (0x00000030d6000000)
+
/lib64/ld-linux-x86-64.so.2 (0x00000031cde00000)
libopen-pal.so.6 => /usr/lib64/openmpi/lib/libopen-pal.so.6 (0x00000030d6400000)
+
 
libdl.so.2 => /lib64/libdl.so.2 (0x00000030d4400000)
 
libnsl.so.1 => /lib64/libnsl.so.1 (0x00000030d6c00000)
 
libutil.so.1 => /lib64/libutil.so.1 (0x00000030d7800000)
 
libltdl.so.7 => /usr/lib64/libltdl.so.7 (0x00000030d5000000)
 
/lib64/ld-linux-x86-64.so.2 (0x00000030d3400000)
 
 
</pre>
 
</pre>
  
Line 72: Line 91:
  
 
<pre>
 
<pre>
[asrini@node062 ~]$ /Boost
+
 
Processor name: node062.hpc.local
+
[asrini@node062 ~]$ mpirun -np 2 ./Boost
Master (0/1)
+
Rank 0 OK!
 +
Rank 1 OK!
 +
 
 
</pre>
 
</pre>
  
 
===== Boost v1.57.0 =====  
 
===== Boost v1.57.0 =====  
The above code snippet is intended to verify Boost.MPI library functionality. Follow the steps below in an interactive node:
+
The above code snippet is intended to verify Boost.MPI library functionality. Follow the steps below in an interactive node. Launch an interactive session with -n 2 to ensure that the number of processors used in this Boost.MPI test are accounted for
  
 
Load the appropriate Boost version module:
 
Load the appropriate Boost version module:
 
<pre>
 
<pre>
[asrini@consign ~]$ bsub -Is bash
+
[asrini@consign ~]$ bsub -n 2 -Is bash
  
 
[asrini@node062 ~]$ ls boost_test.cpp
 
[asrini@node062 ~]$ ls boost_test.cpp
Line 97: Line 118:
 
<pre>
 
<pre>
  
[asrini@node062 ~]$ mpic++ -W -Wall -L/opt/software/boost/1.57.0/lib/ -lboost_mpi -lboost_serialization -lboost_system -lboost_filesystem -lboost_graph_parallel -lboost_iostreams boost_test.cpp -o Boost
+
[asrini@node062 ~]$ mpic++ -W -Wall -I/opt/software/boost/1.57.0/include/ -L/opt/software/boost/1.57.0/lib/ -lboost_mpi -lboost_serialization boost_test.cpp -o Boost
  
 
</pre>
 
</pre>
  
Verify that the executable created was indeed compiled against this version of Boost. Notice the path to libboost_mpi.so.1.55.0 in the output below:
+
Verify that the executable created was indeed compiled against this version of Boost. Notice the path to libboost_mpi.so.1.57.0 in the output below:
  
 
<pre>
 
<pre>
  
 
[asrini@node062 ~]$ ldd Boost
 
[asrini@node062 ~]$ ldd Boost
linux-vdso.so.1 =>  (0x00007fff0c9d3000)
+
linux-vdso.so.1 =>  (0x00007fff9b7ff000)
libboost_mpi.so.1.57.0 => /opt/software/boost/1.57.0/lib/libboost_mpi.so.1.57.0 (0x00002af8847f0000)
+
libboost_mpi.so.1.57.0 => /opt/software/boost/1.57.0/lib/libboost_mpi.so.1.57.0 (0x00002b83ef4fe000)
libboost_serialization.so.1.57.0 => /opt/software/boost/1.57.0/lib/libboost_serialization.so.1.57.0 (0x00002af884a20000)
+
libboost_serialization.so.1.57.0 => /opt/software/boost/1.57.0/lib/libboost_serialization.so.1.57.0 (0x00002b83ef72e000)
libboost_system.so.1.57.0 => /opt/software/boost/1.57.0/lib/libboost_system.so.1.57.0 (0x00002af884c8a000)
+
libmpi_cxx.so.1 => /usr/lib64/openmpi/lib/libmpi_cxx.so.1 (0x00002b83ef998000)
libboost_filesystem.so.1.57.0 => /opt/software/boost/1.57.0/lib/libboost_filesystem.so.1.57.0 (0x00002af884e8d000)
 
libboost_graph_parallel.so.1.57.0 => /opt/software/boost/1.57.0/lib/libboost_graph_parallel.so.1.57.0 (0x00002af8850a4000)
 
libboost_iostreams.so.1.57.0 => /opt/software/boost/1.57.0/lib/libboost_iostreams.so.1.57.0 (0x00002af8852ec000)
 
libmpi_cxx.so.1 => /usr/lib64/openmpi/lib/libmpi_cxx.so.1 (0x00002af885505000)
 
 
libmpi.so.1 => /usr/lib64/openmpi/lib/libmpi.so.1 (0x00000031d0e00000)
 
libmpi.so.1 => /usr/lib64/openmpi/lib/libmpi.so.1 (0x00000031d0e00000)
 
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00000031cfe00000)
 
libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00000031cfe00000)
Line 121: Line 138:
 
libc.so.6 => /lib64/libc.so.6 (0x00000031ce600000)
 
libc.so.6 => /lib64/libc.so.6 (0x00000031ce600000)
 
librt.so.1 => /lib64/librt.so.1 (0x00000031cf600000)
 
librt.so.1 => /lib64/librt.so.1 (0x00000031cf600000)
libz.so.1 => /lib64/libz.so.1 (0x00000031cf200000)
 
libbz2.so.1 => /lib64/libbz2.so.1 (0x0000003daea00000)
 
 
libopen-rte.so.7 => /usr/lib64/openmpi/lib/libopen-rte.so.7 (0x00000031d0a00000)
 
libopen-rte.so.7 => /usr/lib64/openmpi/lib/libopen-rte.so.7 (0x00000031d0a00000)
 
libopen-pal.so.6 => /usr/lib64/openmpi/lib/libopen-pal.so.6 (0x00000031d0200000)
 
libopen-pal.so.6 => /usr/lib64/openmpi/lib/libopen-pal.so.6 (0x00000031d0200000)
Line 130: Line 145:
 
libltdl.so.7 => /usr/lib64/libltdl.so.7 (0x00000031cfa00000)
 
libltdl.so.7 => /usr/lib64/libltdl.so.7 (0x00000031cfa00000)
 
/lib64/ld-linux-x86-64.so.2 (0x00000031cde00000)
 
/lib64/ld-linux-x86-64.so.2 (0x00000031cde00000)
 
 
</pre>
 
</pre>
  
Line 137: Line 151:
 
<pre>  
 
<pre>  
  
[asrini@node062 ~]$ ./Boost
+
[asrini@node062 ~]$ mpirun -np 2 ./Boost
Processor name: node061.hpc.local
+
Rank 0 OK!
Master (0/1)
+
Rank 1 OK!
  
 
</pre>
 
</pre>

Revision as of 15:27, 19 March 2015

Boost

There are currently three different versions of Boost C++ Libraries installed on all the PMACS cluster nodes.

Boost v1.41.0 is the system default version and can be linked to programs without any additional work.
Note : The default version of Boost may not include all the desired libraries. For example MPI library bindings may not work as expected.

Additional versions of Boost

Boost v1.55.0 and v1.57.0 are both available as modules. The example C++ code below can be used to test Boost v1.55.0 and v1.57.0 functionality on the PMACS cluster but not the system default version.

Code below has been adapted from the Boost documentation

#include <iostream>
#include <mpi.h>

int main( int argc, char* argv[])
{
  MPI_Init(&argc, &argv);

  int rank;
  MPI_Comm_rank(MPI_COMM_WORLD, &rank);
  if (rank == 0) {
    int value = 17;
    int result = MPI_Send(&value, 1, MPI_INT, 1, 0, MPI_COMM_WORLD);
    if (result == MPI_SUCCESS)
	  std::cout << "Rank 0 OK!" << std::endl;
  } else if (rank == 1) {
    int value;
    int result = MPI_Recv(&value, 1, MPI_INT, 0, 0, MPI_COMM_WORLD,
						  MPI_STATUS_IGNORE);
    if (result == MPI_SUCCESS && value == 17)
	  std::cout << "Rank 1 OK!" << std::endl;
  }
  MPI_Finalize();
  return 0;
} 0;
}

Copy the code above into a file called boost_test.cpp

Boost v1.55.0

The above code snippet is intended to verify Boost.MPI library functionality. Follow the steps below in an interactive node. Launch an interactive session with -n 2 to ensure that the number of processors used in this Boost.MPI test are accounted for

Load the appropriate Boost version module:

[asrini@consign ~]$ bsub -n 2 -Is bash

[asrini@node062 ~]$ ls boost_test.cpp
boost_test.cpp

[asrini@node062 ~]$ module load openmpi-1.5.4-x86_64

[asrini@node062 ~]$ module load boost-1.55.0

Now compile the code against the version of Boost you are testing.


[asrini@node062 ~]$ mpic++ -W -Wall -I/opt/software/boost/1.55.0/include/ -L/opt/software/boost/1.55.0/lib/ -lboost_mpi -lboost_serialization boost_test.cpp -o Boost

Verify that the executable created was indeed compiled against this version of Boost. Notice the path to libboost_mpi.so.1.55.0 in the output below:


[asrini@node062 ~]$ $ ldd Boost
	linux-vdso.so.1 =>  (0x00007fff3271e000)
	libboost_mpi.so.1.55.0 => /opt/software/boost/1.55.0/lib/libboost_mpi.so.1.55.0 (0x00002b7325636000)
	libboost_serialization.so.1.55.0 => /opt/software/boost/1.55.0/lib/libboost_serialization.so.1.55.0 (0x00002b7325866000)
	libmpi_cxx.so.1 => /usr/lib64/openmpi/lib/libmpi_cxx.so.1 (0x00002b7325ae0000)
	libmpi.so.1 => /usr/lib64/openmpi/lib/libmpi.so.1 (0x00000031d0e00000)
	libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00000031cfe00000)
	libm.so.6 => /lib64/libm.so.6 (0x00000031ce200000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00000031d0600000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00000031cea00000)
	libc.so.6 => /lib64/libc.so.6 (0x00000031ce600000)
	librt.so.1 => /lib64/librt.so.1 (0x00000031cf600000)
	libopen-rte.so.7 => /usr/lib64/openmpi/lib/libopen-rte.so.7 (0x00000031d0a00000)
	libopen-pal.so.6 => /usr/lib64/openmpi/lib/libopen-pal.so.6 (0x00000031d0200000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00000031cee00000)
	libnsl.so.1 => /lib64/libnsl.so.1 (0x00000031d1600000)
	libutil.so.1 => /lib64/libutil.so.1 (0x00000031d2200000)
	libltdl.so.7 => /usr/lib64/libltdl.so.7 (0x00000031cfa00000)
	/lib64/ld-linux-x86-64.so.2 (0x00000031cde00000)

Test run this program:


[asrini@node062 ~]$ mpirun -np 2 ./Boost
Rank 0 OK!
Rank 1 OK!

Boost v1.57.0

The above code snippet is intended to verify Boost.MPI library functionality. Follow the steps below in an interactive node. Launch an interactive session with -n 2 to ensure that the number of processors used in this Boost.MPI test are accounted for

Load the appropriate Boost version module:

[asrini@consign ~]$ bsub -n 2 -Is bash

[asrini@node062 ~]$ ls boost_test.cpp
boost_test.cpp

[asrini@node061 ~]$ module load openmpi-1.5.4-x86_64

[asrini@node061 ~]$ module load boost-1.57.0

Now compile the code against the version of Boost you are testing.


[asrini@node062 ~]$ mpic++ -W -Wall -I/opt/software/boost/1.57.0/include/ -L/opt/software/boost/1.57.0/lib/ -lboost_mpi -lboost_serialization boost_test.cpp -o Boost

Verify that the executable created was indeed compiled against this version of Boost. Notice the path to libboost_mpi.so.1.57.0 in the output below:


[asrini@node062 ~]$ ldd Boost
	linux-vdso.so.1 =>  (0x00007fff9b7ff000)
	libboost_mpi.so.1.57.0 => /opt/software/boost/1.57.0/lib/libboost_mpi.so.1.57.0 (0x00002b83ef4fe000)
	libboost_serialization.so.1.57.0 => /opt/software/boost/1.57.0/lib/libboost_serialization.so.1.57.0 (0x00002b83ef72e000)
	libmpi_cxx.so.1 => /usr/lib64/openmpi/lib/libmpi_cxx.so.1 (0x00002b83ef998000)
	libmpi.so.1 => /usr/lib64/openmpi/lib/libmpi.so.1 (0x00000031d0e00000)
	libstdc++.so.6 => /usr/lib64/libstdc++.so.6 (0x00000031cfe00000)
	libm.so.6 => /lib64/libm.so.6 (0x00000031ce200000)
	libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00000031d0600000)
	libpthread.so.0 => /lib64/libpthread.so.0 (0x00000031cea00000)
	libc.so.6 => /lib64/libc.so.6 (0x00000031ce600000)
	librt.so.1 => /lib64/librt.so.1 (0x00000031cf600000)
	libopen-rte.so.7 => /usr/lib64/openmpi/lib/libopen-rte.so.7 (0x00000031d0a00000)
	libopen-pal.so.6 => /usr/lib64/openmpi/lib/libopen-pal.so.6 (0x00000031d0200000)
	libdl.so.2 => /lib64/libdl.so.2 (0x00000031cee00000)
	libnsl.so.1 => /lib64/libnsl.so.1 (0x00000031d1600000)
	libutil.so.1 => /lib64/libutil.so.1 (0x00000031d2200000)
	libltdl.so.7 => /usr/lib64/libltdl.so.7 (0x00000031cfa00000)
	/lib64/ld-linux-x86-64.so.2 (0x00000031cde00000)

Test run this program:

 

[asrini@node062 ~]$ mpirun -np 2 ./Boost
Rank 0 OK!
Rank 1 OK!

Other Pages