1 /*! \page install Java Binding
3 \section bindings_binding_java_install How to install Simgrid-java
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).
14 Then Download and install package Simgrid-java:
16 git clone git://scm.gforge.inria.fr/simgrid/simgrid-java.git
18 cmake -DCMAKE_INSTALL_PREFIX=$HOME/Install/simgrid-java/ .
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
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!
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
43 -- Build files have been written to: /home/user/workspace/simgrid-java/build
46 \section bindings_binding_java_use How to use Simgrid-java
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.
52 Be careful on Mac, this variable is called DYLD_LIBRARY_PATH and not
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
60 $ java -cp .:../simgrid.jar basic/BasicTest platform.xml basic/basicDeployment.xml
70 \section bindings_binding_java_coroutines How to use the coroutines context factory
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.
79 \subsection bindings_java_coro_install Getting a mlvm JVM
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!).
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.
91 -# Install mercurial and some dependencies
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
97 -# Configure the Forest extension: Edit ~/.hgrc and paste the
98 following lines (beware of changing the /path/to/forest.py):
101 forest=/path/to/forest.py
103 -# Prepare the source code
105 # create a working directory, and enter it
106 mkdir davinci; cd davinci
109 hg fclone http://hg.openjdk.java.net/hsx/hotspot-comp sources
111 hg fclone http://hg.openjdk.java.net/mlvm/mlvm patches
113 # Link the patch directories into the sources
114 patches/make/link-patch-dirs.sh sources patches
115 # Check that it worked
116 ls -il patches/hotspot/series sources/hotspot/.hg/patches/series
118 # Fetches the guards (patches) to apply:
119 export davinci=$(pwd) guards="buildable testable coro-simple"
120 # (if a1 does not work) edit patches/make/Makefile and add coro-simple to GLOBAL_GUARDS
121 sh patches/make/each-patch-repo.sh hg qselect --reapply $guards '$(sh $davinci/patches/make/current-release.sh)'
125 # Prepare the sources
126 (cd patches/make; make setup && make force && make && make FORCE_VERSIONS=1)
128 unset LD_LIBRARY_PATH
129 export ALT_BOOTDIR=/usr/lib/jvm/java-7-openjdk-amd64/
130 # Check that everything is fine
136 \subsection bindings_java_coro_use Using coroutine contexts
138 SimGrid Java will automatically switch to the coroutine context
139 factory if your JVM support it, so you will just need to execute your
140 simulation with the correct JVM. The selected context factory gets
141 displayed when enabling the verbose logs of jmsg
142 (--log=jmsg.thres:verbose in the following).
144 $ $PATH_TO_COROUTINE_JVM/java -cp .:../simgrid.jar --log=jmsg.thres:verbose basic/BasicTest platform.xml basic/basicDeployment.xml
147 Note that you may have to adjust the "coro.stacksPerThread"
148 configuration option to run large simulations. The default is 100 and
149 you want to increase it to run more processes.
151 $ $PATH_TO_COROUTINE_JVM/java -Dcoro.stacksPerThread=$STACKS_NUMBER -cp .:../simgrid.jar basic/BasicTest platform.xml basic/basicDeployment.xml
154 If you feel limited in the amount of processes you can run, give a try
157 sysctl -w vm.max_map_count = 131072