Java Applications on Sniper

525 views
Skip to first unread message

Hesam

unread,
Aug 8, 2012, 9:13:32 PM8/8/12
to snip...@googlegroups.com
Hi,
I am new to this group and sniper!

You see, there is a output file after compiling C/C++ programs, however compiling Java programs will produce .class files.

I wanted to know is it possible to run Java Applications (multi-threaded) on sniper and how?

Thanks
Message has been deleted

Hesam

unread,
Aug 9, 2012, 9:15:27 AM8/9/12
to snip...@googlegroups.com
Hi again :)

I figured it out. I should run JVM and pass my jar file as argument to it. This is my example:

./run-sniper -n 2 /usr/lib/Java6u1/bin/java -jar /home/hesam/Desktop/Test.jar

Thanks


Wim Heirman

unread,
Aug 9, 2012, 9:28:24 AM8/9/12
to snip...@googlegroups.com
Hi Hesam,

Which JVM is it you're using? We have been running Jikes on Sniper,
but that required quite a few patches to work properly. I'd be
interested to hear how this is working out for you.

Regards,
Wim
> --
> --
> You received this message because you are subscribed to the Google
> Groups "Sniper simulator" group.
> To post to this group, send email to snip...@googlegroups.com
> To unsubscribe from this group, send email to
> snipersim+...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/snipersim?hl=en

Hesam

unread,
Aug 9, 2012, 9:37:40 AM8/9/12
to snip...@googlegroups.com, wim.h...@elis.ugent.be
Hi Wim,

I have sun JDK (JDK 1.6) on my Ubuntu. I am using that for JVM.

I have not tested it thoroughly, but as I saw in my few tests with simple programs, it was working some how fine.

Have you encountered to problems using sun Java?

Thanks

Wim Heirman

unread,
Aug 9, 2012, 9:43:46 AM8/9/12
to snip...@googlegroups.com
Hesam,

I haven't tried Sun Java yet, only Jikes. There, one of the problems
was that it spawned a lot of helper threads, but you can solve that by
increasing the number of simulated cores. Another problem was
self-modifying code once the JIT compiler decides to increase the
optimization level. We added the general/enable_smc_support=true
configuration flag to support this, it disables some optimizations
that were incompatible with self-modifying code. Finally, Jikes used
helper threads with timeout values -- but if you're running in
fast-forward or cache-only mode, simulated time is not advancing so
these threads never woke up. Here the solution was to just run the
whole thing in detailed mode (so don't use --roi).

Regards,
Wim

Hesam

unread,
Aug 10, 2012, 3:54:42 AM8/10/12
to snip...@googlegroups.com, wim.h...@elis.ugent.be
Wim,

The first thing that is happening is that when I run JVM, the sim.out and sim.stats.delta will be empty files.

Do you have any clue why it is happening? Is there any log file that can give me the clue?

Yours,
Hesam

Wim Heirman

unread,
Aug 10, 2012, 10:39:42 AM8/10/12
to snip...@googlegroups.com
Hesam,

Did you see any other output or error messages? You can enable more
detailed logging by setting the log/enabled=true configuration
variable.

Regards,
Wim

Hesam

unread,
Aug 10, 2012, 11:30:24 AM8/10/12
to snip...@googlegroups.com, wim.h...@elis.ugent.be
No errors messages on command line! :(
I had enabled the logging but I couldn't understand the problem.

These are the command line outputs:

[SNIPER] Start
Running ['bash', '-c', '/home/hesam/Desktop/sniper-3.06/pin_kit/ia32/bin/pinbin -mt -injection child -xyzzy -enable_vsm 0 -t /home/hesam/Desktop/sniper-3.06/lib/pin_sim -c /home/hesam/Desktop/sniper-3.06/config/base.cfg --general/total_cores=2 --general/output_dir=/home/hesam/Desktop/sniper-3.06/output_files/ --config=/home/hesam/Desktop/sniper-3.06/config/nehalem.cfg --config=/home/hesam/Desktop/sniper-3.06/config/gainestown.cfg -- /usr/lib/Java6u1/bin/java -jar /home/hesam/Desktop/Test.jar']
[SNIPER] Enabling performance models
[SNIPER] Setting instrumentation mode to DETAILED
[SNIPER] End
[SNIPER] Elapsed time: 8.12 seconds

I will see if I can find out what is the problem!

Trevor E. Carlson

unread,
Aug 10, 2012, 11:45:52 AM8/10/12
to snip...@googlegroups.com
Hesam,

    Did you enable self modifying code support with this line?
-g --general/enable_smc_support=true
    You can double-check the Sniper-generated sim.cfg file to make sure.

    Also, you can enable gdb with the '--gdb' flag and then run the application to see if there are any Pin tool faults occurring.

-Trevor

Hesam

unread,
Aug 10, 2012, 12:37:04 PM8/10/12
to snip...@googlegroups.com
Trevor,

Thank you for the points you made.
When I used --gdb flag following lines appeared on command line. I don't know whether it is an important error or not!

Traceback (most recent call last):
  File "/usr/lib/python2.7/site.py", line 562, in <module>
    main()
  File "/usr/lib/python2.7/site.py", line 544, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/site.py", line 271, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/site.py", line 246, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python2.7/site.py", line 236, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python2.7/sysconfig.py", line 558, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python2.7/sysconfig.py", line 457, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/usr/lib/python2.7/sysconfig.py", line 303, in _init_posix
    makefile = _get_makefile_filename()
  File "/usr/lib/python2.7/sysconfig.py", line 297, in _get_makefile_filename
    return os.path.join(get_path('platstdlib').replace("/usr/local","/usr",1), "config" + (sys.pydebug and "_d" or ""), "Makefile")
AttributeError: 'module' object has no attribute 'pydebug'

I had set the smc support by changing "config/base.cfg" file as Wim has mentioned this flag in previous posts!

Still it is the same as before. No sim.out and sim.stats.delta.

Trevor E. Carlson

unread,
Aug 10, 2012, 1:16:15 PM8/10/12
to snip...@googlegroups.com
Hesam,

    I have seen this error before. Last time it had to do with Sniper's python libraries interacting with gdb's python in a weird way. Which OS are you running? Are you running in 32-bits or 64-bits?

-Trevor

Hesam

unread,
Aug 10, 2012, 6:09:43 PM8/10/12
to snip...@googlegroups.com
I am running it on Ubuntu 11.04 (32 bit).

Although as it was mentioned in the Sniper's manual, it downloaded the python kit itself at the beginning of the make process (I mean I did not download or install any specific python before).

Hesam

unread,
Aug 11, 2012, 5:32:31 AM8/11/12
to snip...@googlegroups.com
Using --gdb flag will cause so many differences in my case. I didn't have any problem with running C programs.
When I run sniper with a C program, without --gdb the outputs were fine, but when I use --gdb, the sim.out file is empty!

This is the output when I used --gdb for a C program:

[SNIPER] Start
Running /home/hesam/Desktop/sniper-3.06/pin_kit/ia32/bin/pinbin -mt -injection child -xyzzy -enable_vsm 0 -pause_tool 1 -t /home/hesam/Desktop/sniper-3.06/lib/pin_sim -c /home/hesam/Desktop/sniper-3.06/config/base.cfg --general/total_cores=2 --general/output_dir=/home/hesam/Desktop/sniper-3.06/output_files/ --config=/home/hesam/Desktop/sniper-3.06/config/nehalem.cfg --config=/home/hesam/Desktop/sniper-3.06/config/gainestown.cfg -- /home/hesam/Desktop/a.out

Traceback (most recent call last):
  File "/usr/lib/python2.7/site.py", line 562, in <module>
    main()
  File "/usr/lib/python2.7/site.py", line 544, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/site.py", line 271, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/site.py", line 246, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python2.7/site.py", line 236, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python2.7/sysconfig.py", line 558, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python2.7/sysconfig.py", line 457, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/usr/lib/python2.7/sysconfig.py", line 303, in _init_posix
    makefile = _get_makefile_filename()
  File "/usr/lib/python2.7/sysconfig.py", line 297, in _get_makefile_filename
    return os.path.join(get_path('platstdlib').replace("/usr/local","/usr",1), "config" + (sys.pydebug and "_d" or ""), "Makefile")
AttributeError: 'module' object has no attribute 'pydebug'
[SNIPER] End
[SNIPER] Elapsed time: 0.18 seconds

Traceback (most recent call last):
  File "./run-sniper", line 447, in <module>
    gen_simout.generate_simout(resultsdir = outputdir, output = open(simoutfile, 'w'), silent = True)
  File "./tools/gen_simout.py", line 9, in generate_simout
    res = sniper_lib.get_results(jobid = jobid, resultsdir = resultsdir)
  File "./tools/sniper_lib.py", line 25, in get_results
    results = parse_results_from_dir(resultsdir, partial = partial)
  File "./tools/sniper_lib.py", line 252, in parse_results_from_dir
    return parse_results_from_fileobjs(files, partial = partial)
  File "./tools/sniper_lib.py", line 151, in parse_results_from_fileobjs
    simcfg = parse_config(simcfg.read())
AttributeError: 'NoneType' object has no attribute 'read'
Resuming

[SNIPER] Enabling performance models
[SNIPER] Setting instrumentation mode to DETAILED
[SNIPER] Disabling performance models
[SNIPER] Leaving ROI after 7.48 seconds
[SNIPER] Simulated 0.2M instructions @ 24.9 KIPS (12.4 KIPS / target core - 80391.7ns/instr)
[SNIPER] Setting instrumentation mode to FAST_FORWARD

As you see, the lines that I have highlighted in green, are the same as the lines in the output of my Java program, and you see the line which is highlighted in yellow is the same AttributeError which I posted yesterday.

The lines which were not among the command line outputs of Java program are highlighted in blue. And there you see an orange line indicating another AttributeError which may cause sim.out to be empty.

The strange thing is that, there didn't exist a line similar to Simulated 0.2M instructions @ 24.9 KIPS (12.4 KIPS / target core - 80391.7ns/instr) among Java program outputs. It seems to me that sniper simulator may have crashed or something or finished in an abnormal way.

Hesam

unread,
Aug 11, 2012, 8:35:04 AM8/11/12
to snip...@googlegroups.com
I turned on logging from config/base.cfg.

There are some clues that can show the sniper is terminating abnormally when I am trying to run it with Java programs (Sun Java VM).

I have tested to similar pieces of codes in Java and C to check if the log files are different.
This is the program in C:
#include <stdio.h>
void main() {
    int a = 10;
    int b = 10;
    int c = a + b;
    a = c;
}

And here is the code in Java:
public class Main {
    public static void main(String[] args) {
        int a = 10;
        int b = 10;
        int c = a + b;
        a = c;
    }
}

Finally, here is the system.log contents after running after running the codes (I have highlighted the lines that existed (and were similar) in log files of both Java and C programs, and the lines which were only in C program log files are in red):

0        [ 7777] [] [simulator.cc        :  77]  In Simulator ctor.
140      [ 7777] [] [core_manager.cc     :  24]  Starting CoreManager Constructor.
164      [ 7777] [] [core.cc             :  54]  Core ctor for: 0
183      [ 7777] [] [smtransport.cc      :  37]  Created node: 0x17b6c10 on id: 0
449      [ 7777] [] [network.cc          :  50]  Initialized.
1679     [ 7777] [] [core.cc             :  64]  instantiated memory manager model
28859    [ 7777] [] [core.cc             :  54]  Core ctor for: 1
28911    [ 7777] [] [smtransport.cc      :  37]  Created node: 0xb5d21868 on id: 1
29042    [ 7777] [] [network.cc          :  50]  Initialized.
29952    [ 7777] [] [core.cc             :  64]  instantiated memory manager model
32356    [ 7777] [] [core_manager.cc     :  31]  Finished CoreManager Constructor.
32610    [ 7777] [] [sim_thread_manager.c:  28]  Starting 2 threads.
32622    [ 7777] [] [sim_thread_manager.c:  37]  Starting thread 0
32697    [ 7777] [] [sim_thread_manager.c:  37]  Starting thread 1
32741    [ 7777] [] [sim_thread_manager.c:  48]  Threads started: 0.
141664   [ 7777] [] [pin_sim.cc          : 448]  Start of instrumentation.
141875   [ 7777] [] [pin_sim.cc          : 505]  Running program...
143327   [ 7778] [] [pin_tls.cc          :  33]  0x179e1c8->set(0xb5d50030)
143347   [ 7777] [] [thread_manager.cc   : 155]  (1) spawnThread with func: (nil) and arg: (nil)
143465   [ 7779] [] [pin_tls.cc          :  33]  0x179e1c8->set(0xb5d501a0)
143522   [ 7777] [] [scheduler_static.cc :  12]  Scheduler: thread 0 from application 0 now scheduled to core0
143534   [ 7777] [] [thread_manager.cc   : 163]  Done with (2)

143543   [ 7777] [] [thread_manager.cc   :  79]  onThreadStart(0)
143552   [ 7777] [] [pin_tls.cc          :  33]  0x179e1b8->set(0xb54986a0)
143562   [ 7777] [] [pin_tls.cc          :  33]  0x179e1c8->set(0xb5d50030)
20988805 [ 7777] [] [pin_sim.cc          : 327]  Application exit.
20991991 [ 7777] [] [simulator.cc        : 144]  Simulator dtor starting...
20992012 [ 7777] [] [sim_thread_manager.c:  53]  Sending quit messages.
20992029 [ 7777] [] [smtransport.cc      :  99]  sending msg -- size: 36, data: 0xafa2dda8, dest: 0x17b6c10
20992051 [ 7777] [] [smtransport.cc      :  99]  sending msg -- size: 36, data: 0xafa2ddd0, dest: 0xb5d21868
20992196 [ 7777] [] [sim_thread_manager.c:  75]  Waiting for local sim threads to exit.
20992213 [ 7777] [] [sim_thread_manager.c:  82]  All threads have exited.
21015157 [ 7777] [] [network.cc          :  63]  Destroyed.
21016043 [ 7777] [] [network.cc          :  63]  Destroyed.


As you can see, the Sniper has failed to finish the job for Java program (probably crashed in pin_sim.cc).

Hesam

unread,
Aug 11, 2012, 9:04:29 AM8/11/12
to snip...@googlegroups.com
And I forgot to mention that I have simulated the programs with 2 cores, although I tested running JVM with 8 cores (or even more) but nothing changed.

For that same set of programs, I checked sim_0.log and sim_1.log. For both programs sim_1.log were only a few lines (core 1 is not being used much).
But I thought maybe the finishing lines maybe helpful. This is the last lines in sim_0.log for both programs.

The color coding is similar to the last post (green lines were existed in both, red lines were only in sim_0.log of C program). :)

20928121 [7778] [0]* [network.cc    : 97] Entering netPullFromTransport
20928132 [7778] [0]* [smtransport.cc:109] attempting recv -- this: 0x17b6c10
20992066 [7778] [0]* [smtransport.cc:121] msg recv'd -- data: 0xafa2dda8, this: 0x17b6c10
20992100 [7778] [0]* [network.cc    :101] Pull packet : type 5, from 0, time 0
20992132 [7778] [0]* [network.cc    :132] Executing callback on packet : type 5, from 0, to 0, core_id 0, time0
20992153 [7778] [0]* [sim_thread.cc : 40]  Sim thread exiting

Trevor E. Carlson

unread,
Aug 12, 2012, 2:31:36 AM8/12/12
to snip...@googlegroups.com
Hesam,

    Well, it looks like we found some additional information into this problem. Sun/Oracle's java application is calling execv() which normally is not followed into the child process by Pin. Therefore, Sniper ends at the execv(), causing an empty sim.stats.delta to be produced (Sniper is not crashing). It is possible to follow the execv() with the -follow_execv Pin option, but the next failure occurs when Java tries to spawn many threads. A quick fix for your single-threaded program was to use 16 cores (-n16), but it might be possible to limit the number of threads that java is spawning.  To get Sniper working with Java programs with Sun/Oracle's JVM, all you need to do is modify this line in the run-sniper script:
pinoptions = '-mt -injection child'
and change it to:
pinoptions = '-mt -injection child -follow-execv'
Then run Sniper:
$ ./run-sniper -n 16 -g --general/enable_smc_support=true -- java Main
    The sim.out file was correctly produced, and it looks like 9 threads were being spawned in total (8 java threads, and 1 application thread possibly). Please tell us if you run into any additional issues.

-Trevor

Hesam

unread,
Aug 12, 2012, 7:45:15 AM8/12/12
to snip...@googlegroups.com
Trevor,

Thank you for the help. Finally it did work for me too! :)

However, 16 cores were not sufficient for me! It gave following error "*ERROR* No cores available for spawnThread request." and apparently it worked with at least 30 cores for me. Why there is this difference between my number of cores and the 16 cores you suggested? I mean is it because of the hardware differences in the host machine?

This simple application was just for the initial tests. The reason I am using sniper is that I want to measure the overhead that is caused by thread migration in Java multi-threaded applications. I was meaning to test this application on a machine with 8 cores, and since I did not have access to the suitable platform, I wanted to use Sniper as a simulator and count the number of cycles to check the overhead of migration. But in this situation, which Sniper needs at least 30 cores to run JVM, this test may become a little complicated. You see if I want to add another 8 cores to these 30 cores, I can not know whether JVM will assign the running threads of my application to that 30 cores!

I really appreciate it if you can give me a suggestion on this issue.

Once again, thank you for your time and your great helps.

-Hesam

Hesam

unread,
Aug 13, 2012, 6:47:23 PM8/13/12
to snip...@googlegroups.com
I don't know what has happened to my simulator or my machine, but sniper is not able to run the previous program either.

Firstly it needs an unusually large number of cores (such as 55 cores!!) and even then it gives this error:

E:Wait for stop after PTRACE_ME failed: No child processes

I am testing the first program which I could simulate them on sniper, even that program is giving the same error!

Now I have two questions:
1- When Sniper is simulating does it simulate the resources such as memory or it uses the actual available resources of the host machine?

2- Why does Sniper needs this much cores when I'm trying to simulate, but as You mentioned it should only need 16 cores? (BTW, my machine is a intel core 2 dou and my OS is Ubuntu 11.04 (32-bits))

I'm looking forward to hearing back from you,

-Hesam

Hesam

unread,
Aug 15, 2012, 8:28:12 PM8/15/12
to snip...@googlegroups.com
Trevor,

I am watching SchedulerStatic::threadCreate(), and it seems to me that JVM is spawning too much threads! (about 32 threads).

I wanted to ask you did you run Sun Java (Java 1.6)? Since, you told you are having 9  threads (8 JVM threads and 1 application thread) I don't get the source of the difference between my number of threads and yours.

Also, I am constantly getting this JVM error:

Error occurred during initialization of VM
Could not reserve enough space for object heap
Could not create the Java virtual machine.

When I'm running JVM on sniper which is the source of memory it is trying to use? is it the Memory of the host machine?
If yes, it seems that sniper is reserving too much memory from system, since JVM is able run this really simple program (without simulation).

I tried to use -Xmx128m for JVM but it made JVM to spawn even more threads!! even 64 cores is not enough in that case! (despite if I specify -n more than 50 I receive Pintool error:
E:Wait for stop after PTRACE_ME failed: No child processes, Which I could ot figure out what is the reason for that error)

-Hesam

Trevor Carlson

unread,
Aug 15, 2012, 9:20:59 PM8/15/12
to snip...@googlegroups.com
Hesam,

Unfortunately, I have very little experience with Java and how to control the amount of memory and number of threads that it uses. If you are able to limit the number of threads that it spawns, then you should be able to get it running on Sniper. Of course, as you increase the number of cores that Sniper uses, you also increase Sniper's memory footprint. I wouldn't be surprised if the kernel is killing the processes because your system is running out of memory.

See if you can find the Java reference manual to see if you can reduce the number of helper threads. When I ran Java earlier, it did it on a very simple virtual machine with only 512MB of RAM, so maybe that was the reason. If you find out more information about how to strict the spawning of threads in Java, definitely tell me.

Sorry that I couldn't be of more help,
Trevor

--
--
You received this message because you are subscribed to the Google
Groups "Sniper simulator" group.
To post to this group, send email to snip...@googlegroups.com
To unsubscribe from this group, send email to
snipersim+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/snipersim?hl=en

----------------------------------------------
Trevor E. Carlson
Computer Systems Laboratory, Ghent University
Electronics and Information Systems Department
mobile: +32 474 545 987

Wim Heirman

unread,
Aug 16, 2012, 4:18:31 AM8/16/12
to snip...@googlegroups.com
Hesam,

One more thing you can try is the osemu/nprocs option, this option
controls how much processors are made visible to the application (at
least, if it is using the get_nprocs() call). By default, the number
returned here equals the number of simulated cores, but if the
application always spawns two threads per core, you can never set -n
high enough.

Instead, try passing -g --osemu/nprocs=4 to run-sniper, in combination
with -n16 or -n32. This should make Java believe there are only 4
processors, but still simulate 16 or 32 cores.

Regards,
Wim
Reply all
Reply to author
Forward
0 new messages