Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add a link to Jonathan's version of the coro JVM
[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 Finally, if you're really stuck, you can get the version compiled by
91 Jonathan Rouzaud-Cornabas from his web page. This version is known to
92 work with SimGrid for sure!
93 http://graal.ens-lyon.fr/~jrouzaud/files/corosimple-linux-amd64-20120914.tgz
94  
95  -# Install mercurial and some dependencies
96 \verbatim 
97 sudo apt-get install mercurial ksh libfreetype6-dev libcups2-dev libasound2-dev gawk openjdk-7-jdk libxext-dev libxrender-dev libxtst-dev
98 # Grab the forest extension: we need to source-install it
99 hg clone https://bitbucket.org/gxti/hgforest hgforest \endverbatim
100 \endverbatim
101  -# Configure the mercurial extensions: Edit ~/.hgrc and paste the
102     following lines. Don't forget to change the /path/to/forest.py to
103     point to where you just downloaded the source. 
104     
105     Forest extension is needed to download the openjdk source code and
106     patches while the mq line is needed to apply the patches. The
107     username is needed at the step "preparing the sources", not sure why.
108 \verbatim
109 [ui]
110 username = YouUserameWithoutSpaces
111 [extensions]
112 forest=/path/to/forest.py
113 mq=
114 \endverbatim
115  -# Prepare the source code
116 \verbatim 
117 # create a working directory, and enter it
118 mkdir davinci; cd davinci
119
120 # Grab the sources
121 hg fclone http://hg.openjdk.java.net/hsx/hotspot-comp sources
122 # Grab the patches
123 hg fclone http://hg.openjdk.java.net/mlvm/mlvm patches
124
125 # Link the patch directories into the sources
126 bash patches/make/link-patch-dirs.sh sources patches
127 # Test wether the previous command worked with
128 ls -i patches/hotspot/series sources/hotspot/.hg/patches/series
129 # It should display something like the following.
130 # (note that both file share the same inode number)
131 #  9707849 patches/hotspot/series  
132 #  9707849 sources/hotspot/.hg/patches/series
133
134
135 # Specify what to compile. 
136 export davinci=$(pwd) guards="buildable testable coro-simple"
137 # Apply the patches
138 sh patches/make/each-patch-repo.sh hg qselect --reapply $guards '$(sh $davinci/patches/make/current-release.sh)'
139 # Check that it understood that you want the patch applied:
140 grep GLOBAL_GUARDS patches/make/* -r
141 # this should display something like the following (maybe amonst other unrelated lines)
142 # GLOBAL_GUARDS=buildable testable coro-simple
143 # If this does not work, edit patches/make/Makefile,
144 #   manually coro-simple to GLOBAL_GUARDS and then 
145 #   rerun the patches/make/each-patch-repo.sh script as earlier
146
147
148 # Finish the setup
149 (cd patches/make; make setup && make force && make && make FORCE_VERSIONS=1 && echo "Sources are properly setup")
150 # If this last command failed, check your mercurial config within ~/.hgrc (see above)
151 \endverbatim           
152  -# Compile it all
153 \verbatim
154 unset LD_LIBRARY_PATH
155 export ALT_BOOTDIR=/usr/lib/jvm/java-7-openjdk-amd64/
156 cd sources
157 # Check that everything is fine
158 make sanity
159 # Go for it (it takes about half an hour on my machine)
160 make all
161
162 # Check that the coroutine library got compiled in
163 ls sources/build/linux-amd64/classes/java/dyn/
164 # This should display a bunch of class files. If not, something went wrong, you need to investigate further
165 \endverbatim
166
167 \subsection  bindings_java_coro_use Using coroutine contexts
168
169 SimGrid Java will automatically switch to the coroutine context
170 factory if your JVM support it, so you will just need to execute your
171 simulation with the correct JVM. The selected context factory gets
172 displayed automatically.
173 \verbatim
174 export LD_LIBRARY_PATH=/path/to/simgrid.so:/path/to/libSG_java.so
175 cd examples
176 $PATH_TO_COROUTINE_JVM/java -cp .:../simgrid.jar masterslave.Masterslave masterslave/ masterslaveDeployment.xml platform.xml
177 \endverbatim
178
179 Note that you may have to adjust the "coro.stacksPerThread"
180 configuration option to run large simulations. The default is 100 and
181 you want to increase it to run more processes.
182 \verbatim
183 $ $PATH_TO_COROUTINE_JVM/java -Dcoro.stacksPerThread=$STACKS_NUMBER -cp .:../simgrid.jar basic/BasicTest platform.xml basic/basicDeployment.xml
184 \endverbatim
185
186 If you feel limited in the amount of processes you can run, give a try
187 to this command:
188 \verbatim 
189 sysctl -w vm.max_map_count = 131072
190 \endverbatim
191  */