Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
cosmetics in the ChangeLog
[simgrid.git] / doc / install.doc
1 /*! \page install Java Binding
2
3 \section bindings_binding_java_install How to install Simgrid-java
4
5 To use java with Simgrid you have to install some dependencies:
6  \li Simgrid (see <a href="http://simgrid.gforge.inria.fr/simgrid/3.7/doc/install.html">install
7      Simgrid</a>). You should set the SIMGRID_ROOT environment
8      variable to the path where you installed SimGrid.
9  \li Java JDK packages, such as sun-java6-jdk (with libgcj10-dev or
10 another version of gcj) or openjdk6. For maximal performance and
11 scalability, use a coroutine-enabled JVM (see
12 \ref bindings_binding_java_coroutines).
13  
14 Then Download and install package Simgrid-java:
15 \verbatim
16 git clone git://scm.gforge.inria.fr/simgrid/simgrid-java.git
17 cd simgrid-java
18 cmake -DCMAKE_INSTALL_PREFIX=$HOME/Install/simgrid-java/ .
19 make install
20 \endverbatim
21  
22 Cmake output
23 \verbatim
24 -- SITE        : Linux_2.6.38-8-generic_x86_64
25 -- BUILDNAME   : Simgrid-Java
26 -- Looking for lib SimGrid
27 -- Looking for lib SimGrid - found
28 -- Simgrid version : 3.6
29 -- Looking for gras.h
30 -- Looking for gras.h - found
31 -- Found Tesh: /home/user/Bureau/simgrid/git/bin/tesh
32 -- Found gras_stub_generator: /home/user/Bureau/simgrid/git/bin/gras_stub_generator
33 -- Java version 1.6.0.22 configured successfully!
34 -- Looking for jni.h
35 -- Looking for jni.h - found
36 -- Add flags -I/usr/lib/jvm/java-6-openjdk/include
37 -- Looking for jni_md.h
38 -- Looking for jni_md.h - found
39 -- Found javac: /usr/bin/javac
40 -- Found jar: /usr/bin/jar
41 -- Configuring done
42 -- Generating done
43 -- Build files have been written to: /home/user/workspace/simgrid-java/build
44 \endverbatim
45
46 \section bindings_binding_java_use How to use Simgrid-java
47
48 To execute the examples you need to add the path where you installed
49 the generated libSG_java library (<build_dir>/lib) and libsimgrid
50 ($SIMGRID_ROOT/lib) into the LD_LIBRARY_PATH.
51
52 Be careful on Mac, this variable is called DYLD_LIBRARY_PATH and not
53 LD_LIBRARY_PATH.
54
55 \verbatim
56 $ export SIMGRID_ROOT="$HOME/Install/simgrid/"
57 $ export SIMGRID_JAVA_ROOT="$HOME/Install/simgrid-java"
58 $ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$SIMGRID_ROOT/lib:$SIMGRID_JAVA_ROOT/java
59 $ cd examples
60 $ java -cp .:../simgrid.jar basic/BasicTest platform.xml basic/basicDeployment.xml
61 \endverbatim
62
63
64
65
66
67
68
69
70 \section bindings_binding_java_coroutines How to use the coroutines context factory
71
72 There is two main motivations to use the coroutine variant of SimGrid
73 Java bindings: it's about 5 times faster than the default thread-based
74 context factory, and the amount of runnable processes is then only
75 limited by the amount of RAM that you have. The drawbacks are that it
76 requires a specific and rather experimental JVM to run, and that this
77 context factory itself remains a bit experimental so far.
78
79 \subsection  bindings_java_coro_install Getting a mlvm JVM
80
81 You need to get a patched JVM from <a href="http://ssw.jku.at/General/Staff/LS/coro/">here</a>
82 (many thanks to Lukas Stadler for this work!). 
83
84 You can either get a prebuilt binary, or recompile your own JVM. Make
85 sure to get a coro-simple version, as we don't need to serialize nor
86 migrate stacks in SimGrid. You should be able to follow the README.txt
87 that you'll get in the repository, but here is how we did it, just in
88 case. The instructions are given for a debian or Ubuntu box, but I
89 think you should manage to convert it to your system quite easily.
90  
91  -# Install mercurial and some dependencies
92 \verbatim 
93 sudo apt-get install mercurial ksh libfreetype6-dev libcups2-dev libasound2-dev gawk openjdk-7-jdk libxext-dev libxrender-dev libxtst-dev
94 # Grab the forest extension: we need to source-install it
95 hg clone https://bitbucket.org/gxti/hgforest hgforest \endverbatim
96 \endverbatim
97  -# Configure the mercurial extensions: Edit ~/.hgrc and paste the
98     following lines. Don't forget to change the /path/to/forest.py to
99     point to where you just downloaded the source. 
100     
101     Forest extension is needed to download the openjdk source code and
102     patches while the mq line is needed to apply the patches. The
103     username is needed at the step "preparing the sources", not sure why.
104 \verbatim
105 [ui]
106 username = YouUserameWithoutSpaces
107 [extensions]
108 forest=/path/to/forest.py
109 mq=
110 \endverbatim
111  -# Prepare the source code
112 \verbatim 
113 # create a working directory, and enter it
114 mkdir davinci; cd davinci
115
116 # Grab the sources
117 hg fclone http://hg.openjdk.java.net/hsx/hotspot-comp sources
118 # Grab the patches
119 hg fclone http://hg.openjdk.java.net/mlvm/mlvm patches
120
121 # Link the patch directories into the sources
122 bash patches/make/link-patch-dirs.sh sources patches
123 # Test wether the previous command worked with
124 ls -i patches/hotspot/series sources/hotspot/.hg/patches/series
125 # It should display something like the following.
126 # (note that both file share the same inode number)
127 #  9707849 patches/hotspot/series  
128 #  9707849 sources/hotspot/.hg/patches/series
129
130
131 # Specify what to compile. 
132 export davinci=$(pwd) guards="buildable testable coro-simple"
133 # Apply the patches
134 sh patches/make/each-patch-repo.sh hg qselect --reapply $guards '$(sh $davinci/patches/make/current-release.sh)'
135 # Check that it understood that you want the patch applied:
136 grep GLOBAL_GUARDS patches/make/* -r
137 # this should display something like the following (maybe amonst other unrelated lines)
138 # GLOBAL_GUARDS=buildable testable coro-simple
139 # If this does not work, edit patches/make/Makefile,
140 #   manually coro-simple to GLOBAL_GUARDS and then 
141 #   rerun the patches/make/each-patch-repo.sh script as earlier
142
143
144 # Finish the setup
145 (cd patches/make; make setup && make force && make && make FORCE_VERSIONS=1 && echo "Sources are properly setup")
146 # If this last command failed, check your mercurial config within ~/.hgrc (see above)
147 \endverbatim           
148  -# Compile it all
149 \verbatim
150 unset LD_LIBRARY_PATH
151 export ALT_BOOTDIR=/usr/lib/jvm/java-7-openjdk-amd64/
152 cd sources
153 # Check that everything is fine
154 make sanity
155 # Go for it (it takes about half an hour on my machine)
156 make all
157
158 # Check that the coroutine library got compiled in
159 ls sources/build/linux-amd64/classes/java/dyn/
160 # This should display a bunch of class files. If not, something went wrong, you need to investigate further
161 \endverbatim
162
163 \subsection  bindings_java_coro_use Using coroutine contexts
164
165 SimGrid Java will automatically switch to the coroutine context
166 factory if your JVM support it, so you will just need to execute your
167 simulation with the correct JVM. The selected context factory gets
168 displayed automatically.
169 \verbatim
170 export LD_LIBRARY_PATH=/path/to/simgrid.so:/path/to/libSG_java.so
171 cd examples
172 $PATH_TO_COROUTINE_JVM/java -cp .:../simgrid.jar masterslave.Masterslave masterslave/ masterslaveDeployment.xml platform.xml
173 \endverbatim
174
175 Note that you may have to adjust the "coro.stacksPerThread"
176 configuration option to run large simulations. The default is 100 and
177 you want to increase it to run more processes.
178 \verbatim
179 $ $PATH_TO_COROUTINE_JVM/java -Dcoro.stacksPerThread=$STACKS_NUMBER -cp .:../simgrid.jar basic/BasicTest platform.xml basic/basicDeployment.xml
180 \endverbatim
181
182 If you feel limited in the amount of processes you can run, give a try
183 to this command:
184 \verbatim 
185 sysctl -w vm.max_map_count = 131072
186 \endverbatim
187  */