Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add model Reno, NewReno and Tahoe with ns3
[simgrid.git] / doc / installSimgrid.doc
1 /*! \page installSimgrid Install Simgrid
2
3 \htmlinclude .installSimgrid.doc.toc
4
5 \section installSimgrid_cmake Installing the SimGrid library with Cmake (since V3.4)
6
7 \subsection installSimgrid_intro Some generalitty
8
9 \subsubsection installSimgrid_intro1 What is Cmake?
10
11 CMake is a family of tools designed to build, test and package software. CMake is used to control the software compilation process using simple platform and compiler independent configuration files. CMake generates native makefiles and workspaces that can be used in the compiler environment of your choice. For more information see official web site <a href="http://www.cmake.org/">here</a>.
12
13 \subsubsection installSimgrid_intro2 Why cmake?
14
15 CMake permits to developers to compil projects on different plateforms. Then many tools are embedded like ctest for making test, a link to cdash for vizualise results but also test coverage and bug reports. 
16
17 \subsubsection installSimgrid_intro3 What cmake need?
18
19 CMake needs some prerequists like :
20
21 For Unix and MacOS:
22   \li make
23   \li perl and libpcre
24   \li c and c++ compiler
25   \li ccmake for graphical used of CMake
26   \li cmake <a href="http://www.cmake.org/cmake/resources/software.html">(download page)</a>
27
28 For Windows :
29   \li cmake 2.8 <a href="http://www.cmake.org/cmake/resources/software.html">(download page)</a>
30   \li perl strawberry <a href="http://www.strawberryperl.com/download/5.12.2.0/strawberry-perl-5.12.2.0.msi">(download page)</a>
31   \li git <a href="http://msysgit.googlecode.com/files/Git-1.7.4-preview20110204.exe">(download page)</a>
32   \li SimGrid Installer <a href="https://gforge.inria.fr/frs/?group_id=12">(download page)</a>
33   
34 \subsubsection installSimgrid_cmakeoption1 Liste of options
35
36 \verbatim
37 "cmake -D[name]=[value] ... ./"
38
39 [name]  enable_gtnets           [value] ON/OFF or TRUE/FALSE or 1/0
40         enable_lua                      ON/OFF or TRUE/FALSE or 1/0
41         enable_compile_optimizations    ON/OFF or TRUE/FALSE or 1/0
42         enable_compile_warnings         ON/OFF or TRUE/FALSE or 1/0
43         enable_smpi                     ON/OFF or TRUE/FALSE or 1/0
44         enable_maintainer_mode          ON/OFF or TRUE/FALSE or 1/0
45         enable_supernovae               ON/OFF or TRUE/FALSE or 1/0
46         enable_tracing                  ON/OFF or TRUE/FALSE or 1/0
47         enable_coverage                 ON/OFF or TRUE/FALSE or 1/0
48         enable_memcheck                 ON/OFF or TRUE/FALSE or 1/0
49         enable_model-checking           ON/OFF or TRUE/FALSE or 1/0
50         enable_debug                    ON/OFF or TRUE/FALSE or 1/0
51         enable_jedule                   ON/OFF or TRUE/FALSE or 1/0
52         enable_latency_bound_tracking   ON/OFF or TRUE/FALSE or 1/0
53         enable_lib_static               ON/OFF or TRUE/FALSE or 1/0
54         enable_pcre                     ON/OFF or TRUE/FALSE or 1/0
55         custom_flags                    <flags>
56         gtnets_path                     <path_to_gtnets_directory>
57         CMAKE_INSTALL_PREFIX            <path_to_install_directory>
58         CMAKE_C_COMPILER                <path_to_compiler>
59         CMAKE_CXX_COMPILER              <path_to_compiler>
60         pipol_user                      <pipol_username>
61 \endverbatim
62                                                                                                                                                           
63 \subsubsection installSimgrid_cmakeoption2 Options explaination
64
65   \li enable_gtnets : set to true implie that user wants to use gtnets.
66
67   \li enable_lua : set to true implie that user wants to add lua langage into simgrid compilation.
68
69   \li enable_compile_optimizations : add flags "-O3 -finline-functions -funroll-loops -fno-strict-aliasing"
70
71   \li enable_compile_warnings : add flags "-Wall -Wunused -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wno-unused-function -Wno-unused-parameter -Wno-strict-aliasing -Wno-format-nonliteral -Werror"
72
73   \li enable_smpi : Set to true if you want to use smpi lib. Actually on simgrid v3.4.1 Mac doesn't support lib smpi.
74
75   \li enable_maintainer_mode : set to true it remakes some files. 
76
77   \li enable_supernovae : set to true make one file for each lib and compile with those generated files.
78
79   \li enable_tracing : To enable the generation of simulation traces for visualization.
80
81   \li enable_coverage : When set to true this option enable code coverage by setting -fprofile-arcs -ftest-coverage flags.
82
83   \li enable_memcheck : When set to true this option enable tests for memcheck.
84
85   \li enable_model-checking : Enable the model checking when set to true.
86
87   \li enable_debug : If enable_debug is set to 'off' Simgrid compil flag has '-DNDEBUG' option.
88   
89   \li enable_jedule : To enable jedule mode, which creates visualizations of task schedules with Simdag. 
90   
91   \li enable_latency_bound_tracking : Set to on if you want to be warned when communications are limited by round trip time.
92   
93   \li enable_lib_static : Enable generated Simgrid and smpi static libraries.
94   
95   \li enable_pcre : Use or not the pcre lib for memory optimization.    
96   
97   \li custom_flags : If user wants to use a specific flag during compilation, give here.
98
99   \li gtnets_path : Path to gtnets install directory (ex /usr)
100
101   \li CMAKE_INSTALL_PREFIX : Path where are installed lib/ doc/ and include/ directories (ex /usr/local)
102   
103   \li CMAKE_C_COMPILER : Change the c compiler.
104   
105   \li CMAKE_CXX_COMPILER : Change the c++ compiler. 
106   
107   \li pipol_user : specify your pipol username if you want to use the pipol-remote command.
108
109 \subsubsection installSimgrid_cmakeoption3 Initialisation
110
111 Those options are initialized the first time you launch "cmake ." whithout specified option.
112
113 \verbatim
114 enable_gtnets                   on
115 enable_lua                      on
116 enable_smpi                     on
117 enable_supernovae               on
118 enable_tracing                  on
119 enable_compile_optimizations    on
120 enable_debug                    on
121 enable_pcre                     on
122 enable_compile_warnings         off
123 enable_maintainer_mode          off
124 enable_coverage                 off
125 enable_memcheck                 off
126 enable_model-checking           off
127 enable_jedule                   off
128 enable_latency_bound_tracking   off 
129 enable_lib_static               off
130 CMAKE_INSTALL_PREFIX            /usr/local
131 custom_flags                    null
132 gtnets_path                     null
133 pipol_user                      null
134 \endverbatim
135
136 \subsubsection installSimgrid_cmakeoption4 Option's cache and how to reset?
137
138 When options have been set they are keep into a cache file named "CMakeCache.txt". So if you want 
139 reset values you just delete this file located to the project directory.
140
141 \subsection installSimgrid_cmakecompilation Cmake compilation
142
143 \subsubsection installSimgrid_cmakecompilation1 With command line.
144
145 On Unix or Mac platform:
146
147 \verbatim
148 cmake -D[name]=[value] ... ./
149 make
150 \endverbatim
151
152 On Windows platform:
153
154 \verbatim
155 cmake -G"Unix Makefiles" -D[name]=[value] ... ./
156 gmake
157 \endverbatim
158
159 \subsubsection installSimgrid_cmakecompilation2 With ccmake tool.
160
161 \verbatim
162 "ccmake ./"
163 \endverbatim
164 Then follow instructions.
165
166 \subsubsection installSimgrid_cmakecompilation2bis Build out of source.
167
168 As cmake generate many files used for compilation, we recommand to make a build directory.
169 For examples you can make :
170
171 \verbatim
172 "navarrop@caraja:~/Developments$ cd simgrid/"
173 "navarrop@caraja:~/Developments/simgrid$ mkdir build_directory"
174 "navarrop@caraja:~/Developments/simgrid$ cd build_directory/"
175 "navarrop@caraja:~/Developments/simgrid/build_directory$ cmake ../"
176 "navarrop@caraja:~/Developments/simgrid/build_directory$ make"
177 \endverbatim
178
179 Or complety out of sources :
180
181 \verbatim
182 "navarrop@caraja:~/Developments$ mkdir build_dir"
183 "navarrop@caraja:~/Developments$ cd build_dir/"
184 "navarrop@caraja:~/Developments/build_dir$ cmake ../simgrid/"
185 "navarrop@caraja:~/Developments/build_dir$ make"
186 \endverbatim
187
188 Those two kind of compilation permit to delete files created by compilation easier.
189
190 \subsubsection installSimgrid_cmakecompilation3 Resume of command line
191
192  \li CMake
193 \verbatim
194 cmake <path>                    configure the project for Unix and Mac
195 cmake -G"Unix Makefiles" <path> configure the project for Windows
196 make                            build all targets for Unix and Mac
197 gmake                           buill all targets for windows
198 (g)make VERBOSE=1               build all targets and print build command lines
199 make check                      test all targets and summarize
200 make dist                       make the distrib
201 make distcheck                  check the dist (make + make dist + make check) 
202 (g)make install                 install the project (doc/ bin/ lib/ include/)
203 (g)make uninstall               uninstall the project (doc/ bin/ lib/ include/)
204 (g)make clean                   clean all targets
205 make simgrid_documentation      Create simgrid documentation
206 \endverbatim
207
208 When the project have been succesfully compiling and build you can make tests.
209
210  \li CTest
211 \verbatim
212 ctest                   launch only tests
213 ctest -D Continuous
214 ctest -D Continuous(Start|Update|Configure|Build)
215 ctest -D Continuous(Test|Coverage|MemCheck|Submit)
216 ctest -D Experimental
217 ctest -D Experimental(Start|Update|Configure|Build)
218 ctest -D Experimental(Test|Coverage|MemCheck|Submit)
219 ctest -D Nightly                                
220 ctest -D Nightly(Start|Update|Configure|Build)
221 ctest -D Nightly(Test|Coverage|MemCheck|Submit)
222 ctest -D NightlyMemoryCheck
223 \endverbatim
224
225 If you want to test before make a commit you can simply make "ctest -D Experimental" and then you can visualize results submitted into Cdash. <a href="http://cdash.inria.fr/CDash/index.php?project=Simgrid">(Go to Cdash site)</a>.
226
227 \subsection installSimgrid_cmakeinstall How to install with cmake?
228
229 \subsubsection installSimgrid_cmakeinstall1 From svn. 
230
231 \verbatim
232 cmake -Denable_maintainer_mode=on -DCMAKE_INSTALL_PREFIX=/home/navarrop/Bureau/install_simgrid ./
233 make 
234 make install
235 \endverbatim
236
237 \subsubsection installSimgrid_cmakeinstall2 From a distrib
238
239 \verbatim
240 For version 3.4.1 and 3.4
241         cmake -Dprefix=/home/navarrop/Bureau/install_simgrid ./
242         make
243         make install-simgrid
244 Since version 3.5
245         cmake -DCMAKE_INSTALL_PREFIX=/home/navarrop/Bureau/install_simgrid ./
246         make
247         make install
248 \endverbatim
249
250
251 \subsection installSimgrid_cmakehowto How to modified sources files for developers
252
253 \subsubsection installSimgrid_cmakehowto1 Add an executable or examples.
254
255 If you want make an executable you have to create a CMakeList.txt to the src directory. 
256 You must specified where to create the executable, source list, dependencies and the name of the binary.
257
258 \verbatim
259 cmake_minimum_required(VERSION 2.6)
260
261 set(EXECUTABLE_OUTPUT_PATH "./")                        
262 set(LIBRARY_OUTPUT_PATH "${CMAKE_HOME_DIRECTORY}/lib")
263
264 add_executable(get_sender get_sender.c)                                 #add_executable(<name_of_target> <src list>)
265
266 ### Add definitions for compile
267 target_link_libraries(get_sender simgrid m pthread)     #target_link_libraries(<name_of_targe> <dependencies>)
268 \endverbatim
269
270 Then you have to modified <project/directory>/buildtools/Cmake/MakeExeLib.cmake and add 
271 this line :
272 \verbatim
273 add_subdirectory(${CMAKE_HOME_DIRECTORY}/<path_where_is_CMakeList.txt>)
274 \endverbatim
275
276 \subsubsection installSimgrid_cmakehowto2 Delete/add sources to lib.
277
278 If you want modified, add or delete source files from a library you have to edit <project/directory>/buildtools/Cmake/DefinePackages.cmake
279
280 \verbatim
281 set(JMSG_JAVA_SRC
282         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/MsgException.java
283         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/JniException.java
284         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/NativeException.java
285         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/HostNotFoundException.java
286         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/ProcessNotFoundException.java
287         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/Msg.java
288         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/Process.java
289         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/Host.java
290         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/Task.java
291         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/MsgNative.java
292         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/ApplicationHandler.java
293         ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/Sem.java
294 )
295 \endverbatim
296
297
298 \section installSimgrid_installation Installing the SimGrid library with Autotools (valid until V3.3.4)
299
300 Many people have been asking me questions on how to use SimGrid. Quite
301 often, the questions were not really about SimGrid but on the
302 installation process. This section is intended to help people that are
303 not familiar with compiling C files under UNIX. If you follow these
304 instructions and still have some troubles, drop an e-mail to
305 <simgrid-user@lists.gforge.inria.fr>.
306
307 \subsection installSimgrid_compiling Compiling SimGrid from a stable archive
308
309 First of all, you need to download the latest version of SimGrid from 
310 <a href="http://gforge.inria.fr/frs/?group_id=12">here</a>.
311 Suppose you have uncompressed SimGrid in some temporary location of
312 your home directory (say <tt>/home/joe/tmp/simgrid-3.0.1 </tt>). The
313 simplest way to use SimGrid is to install it in your home
314 directory. Change your directory to
315 <tt>/home/joe/tmp/simgrid-3.0.1</tt> and type
316
317 \verbatim
318 ./configure --prefix=$HOME
319 make
320 make install
321 \endverbatim
322
323 If at some point, something fails, check the <a href="http://simgrid.gforge.inria.fr/doc/faq.html#faq_trouble_compil">FAQ section</a>. .
324 If it does not help, you can report this problem to the
325 list but, please, avoid sending a laconic mail like "There is a problem. Is it
326 okay?". Send the config.log file which is automatically generated by
327 configure. Try to capture both the standard output and the error output of the
328 <tt>make</tt> command with <tt>script</tt>. There is no way for us to help you
329 without the relevant bits of information.
330
331 Now, the following directory should have been created : 
332
333       \li <tt>/home/joe/doc/simgrid/html/</tt>
334       \li <tt>/home/joe/lib/</tt>
335       \li <tt>/home/joe/include/</tt>
336
337 SimGrid is not a binary, it is a library. Both a static and a dynamic
338 version are available. Here is what you can find if you try a <tt>ls
339 /home/joe/lib</tt>:
340
341 \verbatim libsimgrid.a libsimgrid.la libsimgrid.so libsimgrid.so.0 libsimgrid.so.0.0.1
342 \endverbatim
343
344 Thus, there is two ways to link your program with SimGrid:
345       \li Either you use the static version, e.g 
346 \verbatim gcc libsimgrid.a -o MainProgram MainProgram.c
347 \endverbatim
348           In this case, all the SimGrid functions are directly
349           included in <tt>MainProgram</tt> (hence a bigger binary).
350       \li Either you use the dynamic version (the preferred method)
351 \verbatim gcc -lsimgrid -o MainProgram MainProgram.c
352 \endverbatim
353           In this case, the SimGrid functions are not included in
354           <tt>MainProgram</tt> and you need to set your environment
355           variable in such a way that <tt>libsimgrid.so</tt> will be
356           found at runtime. This can be done by adding the following
357           line in your .bashrc (if you use bash and if you have
358           installed the SimGrid libraries in your home directory):
359 \verbatim export LD_LIBRARY_PATH=$HOME/lib/:$LD_LIBRARY_PATH
360 \endverbatim
361
362 \subsection installSimgrid_compiling_snapshoot SimGrid development snapshots
363
364 We have very high standards on software quality, and we are reluctant releasing
365 a stable release as long as there is still some known bug in the code base. In
366 addition, we added quite an extensive test base, making sure that we correctly
367 test the most important parts of the tool. 
368
369 As an unfortunate conclusion, there may be some time between the stable
370 releases. If you want to benefit from the most recent features we introduced,
371 but don't want to take the risk of an untested version from the SVN, then
372 development snapshots are done for you. 
373
374 These are pre-releases of SimGrid that still fail some tests about features
375 that almost nobody use, or on platforms not being in our core target (which is
376 Linux, Mac, other Unixes and Windows, from the most important to the less
377 one). That means that using this development releases should be safe for most
378 users. 
379
380 These archives can be found on 
381 <a href="http://www.loria.fr/~quinson/Research/SimGrid/">this web page</a>. Once you 
382 got the lastest archive, you can compile it just like any archive (see above).
383
384 \subsection installSimgrid_compiling_svn Compiling SimGrid from the SVN
385
386 The project development takes place in the SVN, where all changes are
387 committed when they happen. Then every once in a while, we make sure that the
388 code quality meets our standard and release an archive from the code in the
389 SVN. We afterward go back to the development in the SVN. So, if you need a
390 recently added feature and can afford some little problem with the stability
391 of the lastest features, you may want to use the SVN version instead of a
392 released one.
393
394 For that, you first need to get the "simgrid" module from
395 <a href="http://gforge.inria.fr/scm/?group_id=12">here</a>. 
396
397 You won't find any <tt>configure</tt> and a few other things
398 (<tt>Makefile.in</tt>'s, documentation, ...) will be missing as well. The
399 reason for that is that all these files have to be regenerated using the
400 latest versions of <tt>autoconf</tt>, <tt>libtool</tt>, <tt>automake</tt>
401 (>1.9) and <tt>doxygen</tt> (>1.4). To generate the <tt>configure</tt> and
402 the <tt>Makefile.in</tt>'s, you just have to launch the <tt>bootstrap</tt>
403 command that resides in the top of the source tree. Then just follow the
404 instructions of Section \ref installSimgrid_compiling.
405
406 We insist on the fact that you really need the latest versions of
407 autoconf, automake and libtool. Doing this step on exotic architectures/systems
408 (i.e. anything different from a recent linux distribution) may be
409 ... uncertain. If you need to compile the SVN version on a machine where all these
410 dependencies are not met, the easiest is to do <tt>make dist</tt> in the SVN
411 directory of another machine where all dependencies are met. It will create an
412 archive you may deploy on other sites just as a regular stable release.
413
414 In summary, the following commands will checkout the SVN, regenerate the
415 configure script and friends, configure SimGrid and build it.
416
417 \verbatim svn checkout svn://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk simgrid
418 cd simgrid
419 ./bootstrap
420 ./configure --enable-maintainer-mode --prefix=<where to install SimGrid>
421 make \endverbatim
422
423 Then, if you want to install SimGrid on the current box, just do:
424 \verbatim make install \endverbatim
425
426 If you want to build an snapshot of the SVN to deploy it on another box (for
427 example because the other machine don't have the autotools), do:
428 \verbatim make dist \endverbatim
429
430 Moreover, you should never call the autotools manually since you must run
431 them in a specific order with specific arguments. Most of the times, the
432 makefiles will automatically call the tools for you. When it's not possible
433 (such as the first time you checkout the SVN), use the ./bootstrap command
434 to call them explicitly.
435
436 \subsection installSimgrid_setting_MSG Setting up your own MSG code
437
438 Do not build your simulator by modifying the SimGrid examples.  Go
439 outside the SimGrid source tree and create your own working directory
440 (say <tt>/home/joe/SimGrid/MyFirstScheduler/</tt>).
441
442 Suppose your simulation has the following structure (remember it is
443 just an example to illustrate a possible way to compile everything;
444 feel free to organize it as you want).
445
446       \li <tt>sched.h</tt>: a description of the core of the
447           scheduler (i.e. which functions are can be used by the
448           agents). For example we could find the following functions
449           (master, forwarder, slave).
450
451       \li <tt>sched.c</tt>: a C file including <tt>sched.h</tt> and
452           implementing the core of the scheduler. Most of these
453           functions use the MSG functions defined in section \ref
454           msg_gos_functions.
455
456       \li <tt>masterslave.c</tt>: a C file with the main function, i.e.
457           the MSG initialization (MSG_global_init()), the platform
458           creation (e.g. with MSG_create_environment()), the
459           deployment phase (e.g. with MSG_function_register() and
460           MSG_launch_application()) and the call to
461           MSG_main()).
462
463 To compile such a program, we suggest to use the following
464 Makefile. It is a generic Makefile that we have used many times with
465 our students when we teach the C language.
466
467 \verbatim
468 all: masterslave 
469 masterslave: masterslave.o sched.o
470
471 INSTALL_PATH = $$HOME
472 CC = gcc
473 PEDANTIC_PARANOID_FREAK =       -O0 -Wshadow -Wcast-align \
474                                 -Waggregate-return -Wmissing-prototypes -Wmissing-declarations \
475                                 -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations \
476                                 -Wmissing-noreturn -Wredundant-decls -Wnested-externs \
477                                 -Wpointer-arith -Wwrite-strings -finline-functions
478 REASONABLY_CAREFUL_DUDE =       -Wall
479 NO_PRAYER_FOR_THE_WICKED =      -w -O2 
480 WARNINGS =                      $(REASONABLY_CAREFUL_DUDE)
481 CFLAGS = -g $(WARNINGS)
482
483 INCLUDES = -I$(INSTALL_PATH)/include
484 DEFS = -L$(INSTALL_PATH)/lib/
485 LDADD = -lm -lsimgrid 
486 LIBS = 
487
488 %: %.o
489         $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS) $(LDADD) -o $@ 
490
491 %.o: %.c
492         $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) -c -o $@ $<
493
494 clean:
495         rm -f $(BIN_FILES) *.o *~
496 .SUFFIXES:
497 .PHONY : clean
498
499 \endverbatim
500
501 The first two lines indicates what should be build when typing make
502 (<tt>masterslave</tt>) and of which files it is to be made of
503 (<tt>masterslave.o</tt> and <tt>sched.o</tt>). This makefile assumes
504 that you have set up correctly your <tt>LD_LIBRARY_PATH</tt> variable
505 (look, there is a <tt>LDADD = -lm -lsimgrid</tt>). If you prefer using
506 the static version, remove the <tt>-lsimgrid</tt> and add a
507 <tt>$(INSTALL_PATH)/lib/libsimgrid.a</tt> on the next line, right
508 after the <tt>LIBS = </tt>.
509
510 More generally, if you have never written a Makefile by yourself, type
511 in a terminal : <tt>info make</tt> and read the introduction. The
512 previous example should be enough for a first try but you may want to
513 perform some more complex compilations...
514
515 \subsection installSimgrid_setting_GRAS Setting up your own GRAS code
516
517 If you use the GRAS interface instead of the MSG one, then previous section
518 is not the better source of information. Instead, you should check the GRAS
519 tutorial in general, and the \ref GRAS_tut_tour_setup in particular.
520
521
522
523 */