Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
7d268678effb70bcb626d4838f5d1a0d62e8175e
[simgrid.git] / docs / source / Installing_SimGrid.rst
1 .. Copyright 2005-2023
2
3 .. _install:
4
5 Installing SimGrid
6 ==================
7
8
9 SimGrid should work out of the box on Linux, macOS, FreeBSD, and
10 Windows (with WSL).
11
12 Pre-compiled Packages
13 ---------------------
14
15 Binaries for Linux
16 ^^^^^^^^^^^^^^^^^^
17
18 To get all of SimGrid on Debian or Ubuntu, simply type one of the
19 following lines, or several lines if you need several languages.
20
21 .. code-block:: console
22
23    $ apt install libsimgrid-dev  # if you want to develop in C or C++
24    $ apt install python3-simgrid # if you want to develop in Python
25
26 If you use the Nix_ package manager, the latest SimGrid release is packaged as ``simgrid`` in Nixpkgs_.
27 Previous SimGrid versions are maintained in `NUR-Kapack`_ and are available
28 pre-compiled in release and debug modes on the `capack cachix binary cache`_
29 — refer to `NUR-Kapack's documentation`_ for usage instructions.
30
31 If you use a pacman-based system (*e.g.*, Arch Linux and derived distributions),
32 the latest SimGrid is available in the `simgrid AUR package`_
33 — refer to `AUR official documentation`_ for installation instructions.
34
35 If you build pre-compiled packages for other distributions, drop us an
36 email.
37
38 .. _Nix: https://nixos.org/
39 .. _Nixpkgs: https://github.com/NixOS/nixpkgs
40 .. _NUR-Kapack: https://github.com/oar-team/nur-kapack
41 .. _capack cachix binary cache: https://app.cachix.org/cache/capack
42 .. _NUR-Kapack's documentation: https://github.com/oar-team/nur-kapack
43 .. _simgrid AUR package: https://aur.archlinux.org/packages/simgrid/
44 .. _AUR official documentation: https://wiki.archlinux.org/title/Arch_User_Repository
45
46 .. _deprecation_policy:
47
48 Version numbering and deprecation
49 ---------------------------------
50
51 SimGrid tries to be both a research instrument that you can trust, and
52 a vivid project targeting the future issues. We have 4 stable versions
53 per year, numbered 3.24 or 3.25. Backward compatibility is ensured for
54 one year: Code compiling without warning on 3.24 will still compile
55 with 3.28, but maybe with some deprecation warnings. You should update
56 your SimGrid installation at least once a year and fix those
57 deprecation warnings: the compatibility wrappers are usually removed
58 after 4 versions. Another approach is to never update your SimGrid
59 installation, but we don't provide any support to old versions.
60
61 Interim versions (also called pre-versions) may be released between
62 stable releases. They are numbered 3.X.Y, with even Y (for example,
63 3.23.2 was released on July 8. 2019 as a pre-version of 3.24). These
64 versions should be as usable as regular stable releases, even if they
65 may be somewhat less tested and documented. They play no role in our
66 deprecation handling, and they are not really announced to not spam
67 our users.
68
69 Version numbered 3.X.Y with odd Y are git versions. They often work,
70 but no guarantee is given whatsoever (all releases are given "as is",
71 but that's even more so for these unreleased versions).
72
73 .. _install_src:
74
75 Installing from the Source
76 --------------------------
77
78 .. _install_src_deps:
79
80 Getting the Dependencies
81 ^^^^^^^^^^^^^^^^^^^^^^^^
82
83 C++ compiler (either g++, clang, or icc).
84   We use the C++17 standard, and older compilers tend to fail on
85   us. It seems that g++ 7.0 or higher is required nowadays (because of
86   boost).  SimGrid compiles well with `clang` or `icc` too.
87 Python 3.
88   SimGrid should build without Python. That is only needed by our regression test suite.
89 cmake (v3.5).
90   ``ccmake`` provides a nicer graphical interface compared to ``cmake``.
91   Press ``t`` in ``ccmake`` if you need to see absolutely all
92   configuration options (e.g., if your Python installation is not standard).
93 boost mandatory components (at least v1.48, v1.59 recommended)
94   - On Debian / Ubuntu: ``apt install libboost-dev``
95   - On CentOS / Fedora: ``dnf install boost-devel``
96   - On macOS with homebrew: ``brew install boost``
97 boost recommended components (optional).
98   - boost-context may be used instead of our own fast context switching code which only works on amd64.
99   - boost-stacktrace is used to get nice stacktraces on errors in SimGrid.
100   - On Debian / Ubuntu: ``apt install libboost-context-dev libboost-stacktrace-dev``
101 python bindings (optional):
102   - On Debian / Ubuntu: ``apt install pybind11-dev python3-dev``
103 Model-checking mandatory dependencies
104   - On Debian / Ubuntu: ``apt install libevent-dev``
105 Model-checking optional dependencies
106   - On Debian / Ubuntu: ``apt install libunwind-dev libdw-dev libelf-dev``
107 Eigen3 (optional)
108   - On Debian / Ubuntu: ``apt install libeigen3-dev``
109   - On CentOS / Fedora: ``dnf install eigen3-devel``
110   - On macOS with homebrew: ``brew install eigen``
111   - Use EIGEN3_HINT to specify where it's installed if cmake doesn't find it automatically. Set EIGEN3_HINT=OFF to disable detection even if it could be found.
112 JSON (optional, for the DAG wfcommons loader)
113   - On Debian / Ubuntu: ``apt install nlohmann-json3-dev``
114   - Use nlohmann_json_HINT to specify where it's installed if cmake doesn't find it automatically.
115
116 For platform-specific details, please see below.
117
118 Getting the Sources
119 ^^^^^^^^^^^^^^^^^^^
120
121 Grab the last **stable release** from `FramaGit
122 <https://framagit.org/simgrid/simgrid/-/releases>`_, and compile it as follows:
123
124 .. code-block:: console
125
126    $ tar xf simgrid-3-XX.tar.gz
127    $ cd simgrid-*
128    $ cmake -DCMAKE_INSTALL_PREFIX=/opt/simgrid -GNinja .
129    $ make
130    $ make install
131
132 If you want to stay on the **bleeding edge**, get the current git version,
133 and recompile it as with stable archives. You may need some extra
134 dependencies.
135
136 .. code-block:: console
137
138    $ git clone https://framagit.org/simgrid/simgrid.git
139    $ cd simgrid
140    $ cmake -DCMAKE_INSTALL_PREFIX=/opt/simgrid .
141    $ make
142    $ make install
143
144 .. _install_src_config:
145
146 Build Configuration
147 ^^^^^^^^^^^^^^^^^^^
148
149 This section is about **compile-time options**, which are very
150 different from :ref:`run-time options <options>`. Compile-time options
151 fall into two categories. **SimGrid-specific options** define which part
152 of the framework to compile while **Generic options** are provided by
153 cmake itself.
154
155 .. warning::
156
157    Our build system often gets mixed up if you change something on
158    your machine after the build configuration.  For example, if
159    SimGrid fails to detect your fortran compiler, it is not enough to
160    install a fortran compiler. You also need to delete all Cmake
161    files, such as ``CMakeCache.txt``. Since Cmake also generates some
162    files in the tree, you may need to wipe out your complete tree and
163    start with a fresh one when you install new dependencies.
164
165    A better solution is to :ref:`build out of the source tree <install_cmake_outsrc>`.
166
167 Generic build-time options
168 """"""""""""""""""""""""""
169
170 These options specify, for example, the path to various system elements (Python
171 path, compiler to use, etc). In most case, CMake automatically discovers the
172 right value for these elements, but you can set them manually as needed.
173 Notably, such variables include ``CC`` and ``CXX``, defining the paths to the C
174 and C++ compilers; ``CFLAGS`` and ``CXXFLAGS`` specifying extra options to pass
175 to the C and C++ compilers; and ``PYTHON_EXECUTABLE`` specifying the path to the
176 Python executable.
177
178 The best way to discover the exact name of the option that you need to
179 change is to press ``t`` in the ``ccmake`` graphical interface, as all
180 options are shown (and documented) in the advanced mode.
181
182 Once you know their name, there are several ways to change the values of
183 build-time options. You can naturally use the ccmake graphical
184 interface for that, or you can use environment variables, or you can
185 prefer the ``-D`` flag of ``cmake``.
186
187 For example, you can change the compilers by issuing these commands to set some
188 environment variables before launching cmake:
189
190 .. code-block:: console
191
192    $ export CC=gcc-5.1
193    $ export CXX=g++-5.1
194
195 The same can be done by passing ``-D`` parameters to cmake, as follows.
196 Note that the dot at the end is mandatory (see :ref:`install_cmake_outsrc`).
197
198 .. code-block:: console
199
200    $ cmake -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ .
201
202 SimGrid compilation options
203 """""""""""""""""""""""""""
204
205 Here is the list of all SimGrid-specific compile-time options (the
206 default choice is in upper case).
207
208 CMAKE_INSTALL_PREFIX (path)
209   Where to install SimGrid (/opt/simgrid, /usr/local, or elsewhere).
210
211 enable_compile_optimizations (ON/off)
212   Ask the compiler to produce efficient code. You probably want to
213   leave this option activated, unless you plan to modify SimGrid itself:
214   efficient code takes more time to compile, and appears mangled to some debuggers.
215
216 enable_compile_warnings (on/OFF)
217   Ask the compiler to issue error messages whenever the source
218   code is not perfectly clean. If you are a SimGrid developer, you
219   have to activate this option to enforce the code quality. As a
220   regular user, this option is of little use.
221
222 enable_debug (ON/off)
223   Disabling this option discards all log messages of severity
224   debug or below at compile time (see :ref:`outcome_logs`). The resulting
225   code is marginaly faster than if you discard these messages at
226   runtime, but it obviously becomes impossible to get any debug
227   info from SimGrid when things go wrong.
228
229 enable_documentation (on/OFF)
230   Generates the documentation pages. Building the documentation is not
231   as easy as it used to be, and you should probably use the online
232   version for now.
233
234 enable_lto (ON/off)
235   Enables the *Link Time Optimization* in the C++ compiler.
236   This feature really speeds up the code produced, but it is fragile
237   with older gcc versions.
238
239 enable_maintainer_mode (on/OFF)
240   (dev only) Regenerates the XML parsers whenever the DTD is modified (requires flex and flexml).
241
242 enable_mallocators (ON/off)
243   Activates our internal memory caching mechanism. This produces faster
244   code, but it may fool the debuggers.
245
246 enable_model-checking (on/OFF)
247   Activates the liveness verification mode. This will hinder simulation speed even when the model checker is not activated at run
248   time, because some optimizations such as LTO must be disabled at compile time. You need to have the :ref:`required
249   build-dependencies <install_src_deps>` to activate this option.
250
251 enable_ns3 (on/OFF)
252   Activates the ns-3 bindings. See section :ref:`models_ns3`.
253
254 enable_smpi (ON/off)
255   Allows one to run MPI code on top of SimGrid.
256
257 enable_smpi_MBI_testsuite (on/OFF)
258   Adds many extra tests for the model checker module.
259
260 enable_smpi_MPICH3_testsuite (on/OFF)
261   Adds many extra tests for the MPI module.
262
263 minimal-bindings (on/OFF)
264   Take as few optional dependencies as possible, to get minimal
265   library bindings in Python.
266
267 NS3_HINT (empty by default)
268   Alternative path into which ns-3 should be searched for.
269
270 EIGEN3_HINT (empty by default)
271   Alternative path into which Eigen3 should be searched for.
272   Providing the value OFF as an hint will disable the detection alltogether.
273
274 SIMGRID_PYTHON_LIBDIR (auto-detected)
275   Where to install the Python module library. By default, it is set to the cmake Python3_SITEARCH variable if installing to /usr,
276   and a modified version of that variable if installing to another path. Just force another value if the auto-detected default
277   does not fit your setup.
278
279 SMPI_C_FLAGS, SMPI_CXX_FLAGS, SMPI_Fortran_FLAGS (string)
280   Default compiler options to use in smpicc, smpicxx, or smpiff.
281   This can be useful to set options like "-m32" or "-m64".
282
283 Reset the build configuration
284 """""""""""""""""""""""""""""
285
286 To empty the CMake cache (either when you add a new library or when
287 things go seriously wrong), simply delete your ``CMakeCache.txt``. You
288 may also want to directly edit this file in some circumstances.
289
290 .. _install_cmake_outsrc:
291
292 Out of Tree Compilation
293 ^^^^^^^^^^^^^^^^^^^^^^^
294
295 By default, the files produced during the compilation are placed in
296 the source directory. It is however often better to put them all in a
297 separate directory: cleaning the tree becomes as easy as removing this
298 directory, and you can have several such directories to test several
299 parameter sets or architectures.
300
301 For that, go to the directory where the files should be produced, and
302 invoke cmake (or ccmake) with the full path to the SimGrid source as
303 last argument.
304
305 .. code-block:: console
306
307   $ mkdir build
308   $ cd build
309   $ cmake [options] ..
310   $ make
311
312 Existing Compilation Targets
313 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
314
315 In most cases, compiling and installing SimGrid is enough:
316
317 .. code-block:: console
318
319   $ make
320   $ make install # try "sudo make install" if you don't have the permission to write
321
322 In addition, several compilation targets are provided in SimGrid. If
323 your system is well configured, the full list of targets is available
324 for completion when using the ``Tab`` key. Note that some of the
325 existing targets are not really for public consumption so don't worry
326 if some do not work for you.
327
328 - **make**: Build the core of SimGrid that gets installed, but not any example.
329 - **make examples**: Build the examples, which are needed by the tests.
330 - **make simgrid**: Build only the SimGrid library. Not any example nor the helper tools.
331 - **make s4u-comm-pingpong**: Build only this example (works for any example)
332 - **make python-bindings**: Build the Python bindings
333 - **make clean**: Clean the results of a previous compilation
334 - **make install**: Install the project (doc/ bin/ lib/ include/)
335 - **make dist**: Build a distribution archive (tar.gz)
336 - **make distcheck**: Check the dist (make + make dist + tests on the distribution)
337 - **make documentation**: Create SimGrid documentation
338
339 If you want to see what is really happening, try adding ``VERBOSE=1`` to
340 your compilation requests:
341
342 .. code-block:: console
343
344   $ make VERBOSE=1
345
346 .. _install_src_test:
347
348 Testing your build
349 ^^^^^^^^^^^^^^^^^^
350
351 Once everything is built, you may want to test the result. SimGrid
352 comes with an extensive set of regression tests (as described in the
353 @ref inside_tests "insider manual"). The tests are not built by
354 default, so you first have to build them with ``make tests``. You can
355 then run them with ``ctest``, that comes with CMake.  We run them
356 every commit and the results are on `our Jenkins <https://ci.inria.fr/simgrid/>`_.
357
358 .. code-block:: console
359
360   $ make tests                # Build the tests
361   $ ctest                     # Launch all tests
362   $ ctest -R s4u              # Launch only the tests whose names match the string "s4u"
363   $ ctest -j4                 # Launch all tests in parallel, at most 4 concurrent jobs
364   $ ctest --verbose           # Display all details on what's going on
365   $ ctest --output-on-failure # Only get verbose for the tests that fail
366
367   $ ctest -R s4u -j4 --output-on-failure # You changed S4U and want to check that you  \
368                                          # didn't break anything, huh?                 \
369                                          # That's fine, I do so all the time myself.
370
371 .. _install_cmake_mac:
372
373 macOS-specific instructions
374 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
375
376 SimGrid compiles like a charm with clang (version 3.0 or higher) on macOS:
377
378 .. code-block:: console
379
380   $ cmake -DCMAKE_C_COMPILER=/path/to/clang -DCMAKE_CXX_COMPILER=/path/to/clang++ .
381   $ make
382
383
384 Troubleshooting your macOS build.
385
386 CMake Error: Parse error in cache file build_dir/CMakeCache.txt. Offending entry: /SDKs/MacOSX10.8.sdk
387   This was reported with the XCode version of clang 4.1. The work
388   around is to edit the ``CMakeCache.txt`` file directly, to change
389   the following entry:
390
391   ``CMAKE_OSX_SYSROOT:PATH=/Applications/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer``
392
393   You can safely ignore the warning about "-pthread" not being used, if it appears.
394
395 /usr/include does not seem to exist
396   This directory does not exist by default on modern macOS versions,
397   and you may need to create it with ``xcode-select -install``
398
399 .. _install_cmake_windows:
400
401 Windows-specific instructions
402 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
403
404 The best solution to get SimGrid working on windows is to install the
405 Ubuntu subsystem of Windows 10. All of SimGrid (but the liveness model checker)
406 works in this setting. Native builds never really worked, and they are
407 disabled starting with SimGrid v3.33.
408
409 Python-specific instructions
410 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
411
412 Once you have the Python development headers installed as well as a
413 recent version of the `pybind11 <https://pybind11.readthedocs.io/en/stable/>`_
414 module (version at least 2.4), recompiling the Python bindings from
415 the source should be as easy as:
416
417 .. code-block:: console
418
419   # cd simgrid-source-tree
420   $ python setup.py build install
421
422 Starting with SimGrid 3.13, it should even be possible to install
423 simgrid without downloading the source with pip:
424
425 .. code-block:: console
426
427   $ pip install simgrid
428
429 If you installed SimGrid to a non-standard directory (such as ``/opt/simgrid`` as advised earlier), you should tell python where
430 to find the libraries as follows (notice the elements suffixed to the configured prefix).
431
432 .. code-block:: console
433
434   $ PYTHONPATH="/opt/simgrid/lib/python3/dist-packages" LD_LIBRARY_PATH="/opt/simgrid/lib" python your_script.py
435
436 You can add those variables to your bash profile to not specify it each time by adding these lines to your ``~/.profile``:
437
438 .. code-block:: console
439
440   export PYTHONPATH="$PYTHONPATH:/opt/simgrid/lib/python3/dist-packages"
441   export LD_LIBRARY_PATH="$PYTHONPATH:/opt/simgrid/lib"