SimGrid: Installing Simgrid

SimGrid 3.10 Versatile Simulation of Distributed Systems

- Home page
- Online documentation
- Dev's Corner

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Installing Simgrid

The easiest way to install SimGrid is to go for a binary package. Under Debian or Ubuntu, this is very easy as SimGrid is directly integrated to the official repositories. Under Windows, SimGrid can be installed in a few clicks once you downloaded the installer from gforge. If you just want to use Java, simply copy the jar file on your disk and you're set.

Recompiling an official archive is not much more complex, actually. SimGrid has very few dependencies and rely only on very standard tools. First, download the SimGrid-3.10.tar.gz archive from the download page. Then, recompiling the archive should be done in a few lines:

tar xf SimGrid-3.10.tar.gz
cd SimGrid-3.10
cmake -DCMAKE_INSTALL_PREFIX=/opt/simgrid .
make
make install

If you want to stay on the bleeding edge, you should get the latest git version, and recompile it as you would do for an official archive. Depending on the files you change in the source tree, some extra tools may be needed.

# Installing a binary package

## Binary packages for linux

Most of the developers use a Debian or Ubuntu system, and some of us happen to be Debian Maintainers, so the packages for these systems are well integrated with these systems and very uptodate. To install them, simply type:

    apt-get install simgrid

On other Linux variants, you probably want to go for a source install. Please contact us if you want to contribute the build scripts for your prefered distribution.

## Installation wizard for Windows

Before starting the installation, make sure that you have the following dependencies:

- cmake 2.8 (download page)
- MinGW (download page)
- perl (download page)
- git (download page)

Then download the package SimGrid Installer, execute it and follow instructions.

Step 1: Accept the license.
Step 2: Select packets to install.
Step 3: Choice where to install packets previously selected. Please don't use spaces in path.
Step 4: Add CLASSPATH to environment variables.
Step 5: Add PATH to environment variables.
Step 6: Restart your computer to take in consideration environment variables.

## Using the binary jar file

The easiest way to install the Java bindings of SimGrid is to grab the jar file from the Download page, and copy it in your classpath (typically, in the same directory than your source code). If you go for that version, there is no need to install the C library as it is bundled within the jar file. Actually, only a bunch of architectures are supported this way to keep the jarfile size under control and because we don't have access to every exotic architectures ourselves.

If the jarfile fails on you, complaining that your architecture is not supported, drop us an email: we may extend the jarfile for you, if we have access to your architecture to build SimGrid on it.

# Installing from source

## Resolving the dependencies

SimGrid only uses very standard tools:

- C compiler, C++ compiler, make and friends.
- perl (but you may try to go without it)
- We use cmake to configure our compilation (download page). You need cmake version 2.8 or higher. You may want to use ccmake for a graphical interface over cmake.

On MacOSX, it is advised to use the clang compiler (version 3.0 or higher), from either MacPort or XCode. If you insist on using gcc on this system, you still need a recent version of this compiler, so you need an unofficial gcc47 from MacPort because the version provided by Apple is ways to ancient to suffice. See also Cmake on Mac OSX.

On Windows, it is strongly advised to use the MinGW environment to build SimGrid. Any other compilers are not tests (and thus probably broken). We usually use the activestate version of Perl, and the msys version of git on this architecture, but YMMV. See also Cmake on Windows (with MinGW).

## Retrieving the source

If you just want to use SimGrid, you should probably grab the latest stable version available from the download page. We do our best to release soon and release often, but sometimes you need to install the developer version of SimGrid, directly from the git repository. Avoid the git version if you are not sure, as it may break on you, or even worse.

    git clone git://scm.gforge.inria.fr/simgrid/simgrid.git simgrid

## Configuring the build

Note that compile-time options are very different from run-time options.

### Setting compilation options

The default configuration should be ok for most usages, but if you need to change something, there is several ways to do so. First, you can use environment variable. For example, you can change the used compilers by issuing these commands before launching cmake:

    export CC=gcc-4.4
    export CXX=g++-4.4

Another way to do so is to use the -D argument of cmake as follows. Note that the terminating dot is mandatory (see Compiling into a separate directory to understand its meaning).

    cmake -DCC=clang -DCXX=clang++ .

Finally, you can use a graphical interface such as ccmake to change these settings. Simply follow the instructions after starting the interface.

    ccmake .

### SimGrid compilation options

In addition to the classical cmake configuration variables, SimGrid accepts several options, as listed below.

- CMAKE_INSTALL_PREFIX (path): Where to install SimGrid (e.g. /usr/local or /opt).

- enable_compile_optimizations (ON/OFF): request the compiler to produce efficient code. You want to activate it, unless you want to debug SimGrid itself (as efficient code may be appear mangled to the debugers).

- enable_debug (ON/OFF): disable this if simulation speed really matters to you. All log messages of gravity debug or below will be discarded at compilation time. Since there is quite a bunch of such log messages in SimGrid itself, this can reveal faster than discarding them at runtime as usually. But of course, it is then impossible to get any debug message from SimGrid if something goes wrong.

- enable_msg_deprecated (ON/OFF): enable this option if your code used a feature of Simgrid that was droped or modified in recent releases of SimGrid. You should update your code if possible, but with this option, SimGrid will try to emulate its old behavior.

- enable_model-checking (ON/OFF): Only enable this if you actually plan to use the model-checking aspect of SimGrid. This mode of execution is still under heavy work, but it should be rather usable now. Be warned that this option will hinder your simulation speed even if you simulate without activating the model-checker. We are working on improving this situation.

- enable_supernovae (ON/OFF): If you use an ancient compiler (such as gcc prior to 4.6), you want to enable this option to ensure that the whole SimGrid library is presented to the compiler as a unique compilation unit to allow cross-units optimizations. This is useless on modern compilers (and will soon be droped).

- enable_compile_warnings (ON/OFF): request the compiler to issue error message whenever the source code is not perfectly clean. If you develop SimGrid itself, you must activate it to ensure the code quality, but as a user, that option will only bring you issues.

- enable_lib_static (ON/OFF): enable this if you want to compile the static library (but you should consider enjoying this new century instead).

- enable_maintainer_mode (ON/OFF): you only need to set this option if you modify very specific parts of SimGrid itself (the XML parsers and other related elements). Adds an extra dependency on flex and flexml.

- enable_tracing (ON/OFF): disable this if you have issues with the tracing module. But this module is now very stable and you really should try to enjoy this beauty.

- enable_smpi (ON/OFF): disable this if you have issues with the module allowing to run MPI code on top of SimGrid. This module very stable, but if you really don't need it, you can disable it.

- enable_mallocators (ON/OFF): disable this when tracking memory issues within SimGrid, or the caching mechanism used internally will fool the debugers.

- enable_jedule (ON/OFF): enable this to get SimDag producing traces that can then be vizualized with the Jedule external tool.

- enable_lua (ON/OFF): enable this if you want to enjoy the lua bindings of SimGrid. Adds an extra dependency on lua library and developper header files.

- enable_gtnets (ON/OFF): whether you want to use gtnets. See section Using GTNetS.
- gtnets_path (path): GTNetS installation directory (eg /usr or /opt).
- enable_ns3 (ON/OFF): whether you want to use ns3. See section Using NS3.
- ns3_path (path): NS3 installation directory (eg /usr or /opt).
- enable_latency_bound_tracking (ON/OFF): enable it if you want to be warned when communications are limited by round trip time while doing packet-level simulation.

### Resetting the compilation configuration

If you need to empty the cache of values saved by cmake (either because you added a new library or because something seriously went wrong), you can simply delete the file CMakeCache.txt that is created at the root of the source tree. You may also want to edit this file directly in some circumstances.

### Compiling into a separate directory

By default, the files produced during the compilation are placed in the source directory. As the compilation generates a lot of files, it is advised to to put them all in a separate directory. It is then easier to cleanup, and this allows to compile several configurations out of the same source tree. For that, simply enter the directory where you want the produced files to land, and invoke cmake (or ccmake) with the full path to the simgrid source as last argument. This approach is called "compilation out of source tree".

    mkdir build
    cd build
    cmake [options] ..
    make

### Cmake on Windows (with MinGW)

Cmake can produce several kind of of makefiles. Under Windows, it has no way of determining what kind you want to use, so you have to hint it:

    cmake -G"MinGW Makefiles" (other options) .
    mingw32-make

### Cmake on Mac OSX

SimGrid compiles like a charm with clang on Mac OSX:

    cmake -DCMAKE_C_COMPILER=/path/to/clang -DCMAKE_CXX_COMPILER=/path/to/clang++ .
    make

With the XCode version of clang 4.1, you may get the following error message:

    CMake Error: Parse error in cache file build_dir/CMakeCache.txt. Offending entry: /SDKs/MacOSX10.8.sdk

In that case, edit the CMakeCache.txt file directly, so that the CMAKE_OSX_SYSROOT is similar to the following. Don't worry about the warning that the "-pthread" argument is not used, if it appears.

    CMAKE_OSX_SYSROOT:PATH=/Applications/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer

## Compiling SimGrid

In most cases, compiling and installing simgrid is enough:

    make
    make install # try "sudo make install" if you don't have the permission to write

In addition, several compilation targets are provided in SimGrid. If your system is well configured, the full list of targets is available for completion when using the Tab key. Note that some of the existing targets are not really for publc consumption so don't worry if some stuff don't work for you.

    make simgrid                    Builds only the simgrid library and not any example
    make masterslave                Builds only this example (and its dependencies)
    make clean                      Clean the results of a previous compilation
    make install                    Install the project (doc/ bin/ lib/ include/)
    make uninstall                  Uninstall the project (doc/ bin/ lib/ include/)
    make dist                       Cuild a distribution archive (tgz)
    make distcheck                  Check the dist (make + make dist + tests on the distribution)
    make simgrid_documentation      Create simgrid documentation

If you want to see what is really happening, try adding VERBOSE=1 to your compilation requests:

    make VERBOSE=1

## Testing SimGrid

Once everything is built, you may want to test the result. SimGrid comes with an extensive set of regression tests (see that page of the insider manual for more details). Running the tests is done using the ctest binary that comes with cmake. These tests are run every night and the result is publicly available.

    ctest                     # Launch all tests
    ctest -D Experimental     # Launch all tests and report the result to
                              # http://cdash.inria.fr/CDash/index.php?project=SimGrid
    ctest -R msg              # Launch only the tests which name match the string "msg"
    ctest -j4                 # Launch all tests in parallel, at most 4 at the same time
    ctest --verbose           # Display all details on what's going on
    ctest --output-on-failure # Only get verbose for the tests that fail

    ctest -R msg- -j5 --output-on-failure # You changed MSG and want to check that you didn't break anything, huh?
                                          # That's fine, I do so all the time myself.

# Setting up your own code

## MSG code on Unix (Linux or Mac OSX)

Do not build your simulator by modifying the SimGrid examples. Go outside the SimGrid source tree and create your own working directory (say `/home/joe/SimGrid/MyFirstScheduler/`).

Suppose your simulation has the following structure (remember it is just an example to illustrate a possible way to compile everything; feel free to organize it as you want).

- `sched.h`: a description of the core of the scheduler (i.e. which functions are can be used by the agents). For example we could find the following functions (master, forwarder, slave).
- `sched.c`: a C file including `sched.h` and implementing the core of the scheduler. Most of these functions use the MSG functions defined in section Task Actions.
- `masterslave.c`: a C file with the main function, i.e. the MSG initialization (MSG_init()), the platform creation (e.g. with MSG_create_environment()), the deployment phase (e.g. with MSG_function_register() and MSG_launch_application()) and the call to MSG_main()).

To compile such a program, we suggest to use the following Makefile. It is a generic Makefile that we have used many times with our students when we teach the C language.

    all: masterslave
    masterslave: masterslave.o sched.o

    INSTALL_PATH = $$HOME
    CC = gcc
    PEDANTIC_PARANOID_FREAK =       -O0 -Wshadow -Wcast-align \
                                    -Waggregate-return -Wmissing-prototypes -Wmissing-declarations \
                                    -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations \
                                    -Wmissing-noreturn -Wredundant-decls -Wnested-externs \
                                    -Wpointer-arith -Wwrite-strings -finline-functions
    REASONABLY_CAREFUL_DUDE =       -Wall
    NO_PRAYER_FOR_THE_WICKED =      -w -O2
    WARNINGS =                      $(REASONABLY_CAREFUL_DUDE)
    CFLAGS = -g $(WARNINGS)

    INCLUDES = -I$(INSTALL_PATH)/include
    DEFS = -L$(INSTALL_PATH)/lib/
    LDADD = -lm -lsimgrid
    LIBS =

    %: %.o
            $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS) $(LDADD) -o $@

    %.o: %.c
            $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) -c -o $@ $<

    clean:
            rm -f $(BIN_FILES) *.o *~
    .SUFFIXES:
    .PHONY: clean

The first two lines indicates what should be build when typing make (`masterslave`) and of which files it is to be made of (`masterslave.o` and `sched.o`). This makefile assumes that you have set up correctly your `LD_LIBRARY_PATH` variable (look, there is a `LDADD = -lm -lsimgrid`). If you prefer using the static version, remove the `-lsimgrid` and add a `/lib/libsimgrid.a` on the next line, right after the `LIBS =` .

More generally, if you have never written a Makefile by yourself, type in a terminal: `info make` and read the introduction. The previous example should be enough for a first try but you may want to perform some more complex compilations...

## Compile the "HelloWorld" project on Windows

In the SimGrid install directory you should have an HelloWorld project to explain you how to start compiling a source file. There are:

    - HelloWorld.c          The example source file.
    - CMakeLists.txt        It allows to configure the project.
    - README                This explaination.

Now let's compile this example:

- Run windows shell "cmd".
- Open HelloWorld Directory ('cd' command line).
- Create a build directory and change directory. (optional)
- Type 'cmake -G"MinGW Makefiles" <path_to_HelloWorld_project>'
- Run mingw32-make
- You should obtain a runnable example ("HelloWorld.exe").

For compiling your own code you can simply copy the HelloWorld project and rename source name. It will create a target with the same name of the source.

## Adding and Compiling a new example on Windows

- Put your source file into the helloWord directory.
- Edit CMakeLists.txt by removing the Find Targets section and add those two lines into this section

      ################
      # FIND TARGETS #
      ################
      #It creates a target called 'TARGET_NAME.exe' with the sources 'SOURCES'
      add_executable(TARGET_NAME SOURCES)
      #Links TARGET_NAME with simgrid
      target_link_libraries(TARGET_NAME simgrid)

- To initialize and build your project, you'll need to run

      cmake -G"MinGW Makefiles" <path_to_HelloWorld_project>

- Run "mingw32-make"
- You should obtain "TARGET_NAME.exe".

## Setup a virtualbox to use SimGrid-Ruby on windows

Allan Espinosa made these set of Vagrant rules available so that you can use the SimGrid Ruby bindings in a virtual machine using VirtualBox. Thanks to him for that. You can find his project here: https://github.com/aespinosa/simgrid-vagrant