Difference between revisions of "CmakeBlueGene"

From KitwarePublic
Jump to navigationJump to search
(New page: = How to build software for IBM/BlueGene= BlueGene consists of two different types of nodes, the service node, which are more or less regular PowerPC Linux machines, and the actual comput...)
 
Line 48: Line 48:
as additional libraries you have built for this platform.
as additional libraries you have built for this platform.


== Build the software for Windows ==
== Build the software for BlueGene/L ==


Let's say you have the classical hello world software with a CMake based buildsystem and want to build this for Windows
Let's say you have the classical hello world software with a CMake based buildsystem and want to build this for now for your super computer.
using mingw32.
main.c:
main.c:
<pre>
<pre>
Line 72: Line 71:
~/src/helloworld/ $ mkdir build
~/src/helloworld/ $ mkdir build
~/src/helloworld/ $ cd build
~/src/helloworld/ $ cd build
~/src/helloworld/build/ $ cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-mingw32.cmake -DCMAKE_INSTALL_PREFIX=/home/alex/mingw-install ..  
~/src/helloworld/build/ $ cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-BlueGeneL.cmake -DCMAKE_INSTALL_PREFIX=/home/alex/bgl-install ..  
-- Configuring done
-- Configuring done
-- Generating done
-- Generating done
Line 79: Line 78:
Scanning dependencies of target hello
Scanning dependencies of target hello
[100%] Building C object CMakeFiles/hello.dir/main.o
[100%] Building C object CMakeFiles/hello.dir/main.o
Linking C executable hello.exe
Linking C executable hello
[100%] Built target hello
[100%] Built target hello
</pre>
</pre>


So that's all. It actually doesn't matter whether it's just a "hello world" or some complex piece of software,
So that's all. It actually doesn't matter whether it's just a "hello world" or some complex piece of software,
the only difference is the usage of the toolchain file. If the software has all required configure checks, it should just
the only difference is the usage of the toolchain file. If the software has all required configure checks, it should just build also with this toolchain.
build also with this toolchain.

Revision as of 15:36, 26 July 2007

How to build software for IBM/BlueGene

BlueGene consists of two different types of nodes, the service node, which are more or less regular PowerPC Linux machines, and the actual compute nodes, which have the same processors, but run the "Compute Node Kernel" as operating system. Building software for the service nodes is not different than building software on any other Linux system. But to build software for the actual compute nodes, you need to cross compile. For C/C++ there are typically two toolchains you can use for the compute nodes:

  • the GNU gcc toolchain (powerpc-bgl-blrts-gnu-gcc)
  • the IBM XL toolchain (blrts_xlc)

In order to use them with CMake you have to write a toolchain file, more on that below.

Write a CMake toolchain file

For CMake to be able to crosscompile software, it requires you to write a toolchain file, which tells CMake some information about the toolchain.

For the GNU toolchain on BlueGene it could look like like the following:

# the name of the target operating system
SET(CMAKE_SYSTEM_NAME BlueGeneL)

# set the compiler
set(CMAKE_C_COMPILER /bgl/BlueLight/ppcfloor/blrts-gnu/bin/powerpc-bgl-blrts-gnu-gcc )
set(CMAKE_CXX_COMPILER /bgl/BlueLight/ppcfloor/blrts-gnu/bin/powerpc-bgl-blrts-gnu-g++ )

# set the search path for the environment coming with the compiler
# and a directory where you can install your own compiled software
set(CMAKE_FIND_ROOT_PATH
    /bgl/BlueLight/ppcfloor/
    /bgl/BlueLight/V1R3M2_140_2007-070424/ppc/blrts-gnu/powerpc-bgl-blrts-gnu/
    /bgl/BlueLight/V1R3M2_140_2007-070424/ppc/bglsys
    /home/alex/bgl-install
)

# adjust the default behaviour of the FIND_XXX() commands:
# search headers and libraries in the target environment, search 
# programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

Save this file as Toolchain-BlueGeneL.cmake to some location where you will put all your toolchain files, e.g. $HOME. As you can see CMAKE_FIND_ROOT_PATH is set to three directories coming with the toolchain, which contain the headers and libraries installed with the toolchain, and /home/alex/bgl-install/. This last directory is intended to hold other libraries you will compile for the compute nodes, they should be installed under this install prefix. This way the FIND_XXX() commands in CMake will find both the headers and libraries coming with the toolchain as well as additional libraries you have built for this platform.

Build the software for BlueGene/L

Let's say you have the classical hello world software with a CMake based buildsystem and want to build this for now for your super computer. main.c:

#include <stdio.h>

int main()
{
   printf("Hello world\n");
   return 0;
}

CMakeLists.txt:

ADD_EXECUTABLE(hello main.c)

Then run CMake on it to generate the buildfiles, the important point is that you tell it to use the toochain file you just wrote:

~/src/helloworld/ $ mkdir build
~/src/helloworld/ $ cd build
~/src/helloworld/build/ $ cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-BlueGeneL.cmake -DCMAKE_INSTALL_PREFIX=/home/alex/bgl-install .. 
-- Configuring done
-- Generating done
-- Build files have been written to: /home/alex/src/helloworld/build
~/src/helloworld/build/ $ make
Scanning dependencies of target hello
[100%] Building C object CMakeFiles/hello.dir/main.o
Linking C executable hello
[100%] Built target hello

So that's all. It actually doesn't matter whether it's just a "hello world" or some complex piece of software, the only difference is the usage of the toolchain file. If the software has all required configure checks, it should just build also with this toolchain.