This article provides instructions to custom build the Boost library to run in native mode on Intel(R) Xeon Phi(tm) Coprocessor, as well as verify the build is working properly. The instructions are written assuming you have a copy of the Intel(R) C++ Compiler installed on your system.
The Boost library version used here is 1.49 (and has also been verified for version 1.48). The instructions are based on the “Getting Started on UNIX Variants” guide.Please refer to this guide for help on additional configuration options.
Boost.org provides free peer-reviewed portable C++ source libraries.
Steps to build Boost library for Intel(R) Xeon Phi(tm) Coprocessor:
- Download boost_1_49_0.tar.gz from Boost.org.
- In the directory where you want to put the Boost installation, uncompress the downloaded Boost distribution: tar zxvf boost_1_49_0.tar.gz
- Change your current directory to the Boost root directory (created by the above command):
- Setup the Intel compiler build environment to prepare for cross-compiling targeting Intel Xeon Phi Coprocessor: source /opt/intel/composerxe_mic/bin/iccvars.sh intel64
- Run the Boost bootstrap script :./bootstrap.sh
- Run bjam with Intel toolset selected: ./bjam toolset=intel --disable-icu --without-iostreams cflags="-mmic" cxxflags="-mmic" linkflags="-mmic"
Please refer to the Intel compiler reference manual for additional relevant compiler/linker flags that may be used.
The above steps will build static and shared non-debug multi-threaded variants of the libraries. To build all variants, pass the additional option, “--build-type=complete”.
Steps to verify the Boost build and run it on the MIC platform:
To verify the build process and demonstrate linking with the Boost library, the Boost.Regex based example from step #6 of the “Getting Started on UNIX Variants” guide is used. Note that this example does not provide comprehensive coverage on Boost usage but it is used here for sanity check only
- Copy the aforementioned example into a file called "boot_test.cpp"
- Build the test-program to run in native-mode on Intel Xeon Phi Coprocessor: icpc -mmic -vec-report2 -I . boost_test.cpp ./stage/lib/libboost_regex.a -o boost_test
- Copy the test program’s binary to the coprocesor: sudo scp boost_test 192.168.1.100:/tmp/.
- Log onto the coprocessor and change directory to /tmp: sudo ssh email@example.com
- cd /tmp
- Create an input file to be processed by the test program: (example): cat test.txt
To: George Shmidlap
From: Rita Marlowe
Subject: Will Success Spoil Rock Hunter?
Lastly, run the test program with the aforementioned input file: ./boost_test < test.txt
If this runs successfully, it should return: "Will Success Spoil Rock Hunter?"