Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Running java on multiple processors on SuSE 10.1  RSS feed

 
Martin Fore
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've recently been working with java applications making use of multiple processors simultaneously. This works well on my dual core laptop (MS Windows); my applications utilise both processor cores.

Fueled by the success on my laptop,I decided to try the applications on a four-processor system running SuSE 10.1, hoping for even better performance. As it turned out, my applications were then only able to use one processor,even though four threads were spawned.

My applications extend the Thread-class, and I use java Sun 1.6.0_04, thus the spawned threads are of a native type. As far as I've gathered from discussion forums and other web-resources, this should be sufficient to obtain parallel processing, utilising all four processors. I've still not been able to resolve the problem. Does anyone out there have a suggestion as to what I should do?

Regards,
Martin
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using the smp kernel?
Here is a post that tells you how to tell.
 
Martin Fore
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Joe Ess:
Are you using the smp kernel?
Here is a post that tells you how to tell.


Yep, it's smp. Also,when i type in "grep processor /proc/cpuinfo", the system returns all four processors.

Martin
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you monitoring the processes?
Are you doing anything (writing to the console) that would cause the threads to block?
 
Martin Fore
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Joe Ess:
How are you monitoring the processes?
Are you doing anything (writing to the console) that would cause the threads to block?


I'm monitoring the threads via the command "top" showing the top CPU processes. When other users are running their parallel applications (using e.g. FLUENT) on the SuSE station, four processes with the same command name appear, each of them showing close to 100% at the CPU-column (indicating that all four processors are maxed out).
When I run my application, "top" displays only 1 such process. This is the only thing I do in addition to running the java application.

Martin
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Martin Fore:
This is the only thing I do in addition to running the java application.


Does the application do anything that would cause the threads to block?
 
Martin Fore
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Joe Ess:


Does the application do anything that would cause the threads to block?


I don't think it does. To investigate this, I implemented a very simple threading-example I found on the web:
<BEGIN>
public class MyThread extends Thread {

String word;

public MyThread(String rm){
word = rm;
}

public void run(){

for(; {
System.out.println(word);
int sum = 0;
for (int i = 0;i<10000;i++){
sum+=i;
}
}
}

public static void main(String[] args) {

Thread t1=new MyThread("First Thread");
Thread t2=new MyThread("Second Thread");
Thread t3=new MyThread("Third Thread");
Thread t4=new MyThread("Fourth Thread");
t1.start();
t2.start();
t3.start();
t4.start();
}
}
<END>
and I see the same thing here; works on both processors in Windows but only 1 in SuSE..

Thank you very much for your support,
Martin
 
Joe Ess
Bartender
Posts: 9406
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This line:

Can certainly block. Only one thread is allowed to access the console at a time. Your threads may simply be in "wait" states, blocked on the CPU. (see introduction to Java Stacktraces for how to check)
What kind hardware is your SUSE machine? "dual core" processors and multiple CPU hardware are not quite the same thing.
I haven't worked with SMP Linux, but I do manage a couple of multiple-CPU Solaris machines. I've noticed that Solaris is much more conservative with allocating CPU time than Windows XP. XP will let any application take over both cores on my desktop. I have a hard time getting 100% of any CPU on my Solaris boxes, even with code like yours above. Linux may also be on the conservative side.
Another note: top on Solaris doesn't appear to show individual threads. Maybe jconsole would be a better tool.
 
Martin Fore
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Joe Ess:
This line:

Can certainly block. Only one thread is allowed to access the console at a time. Your threads may simply be in "wait" states, blocked on the CPU. (see introduction to Java Stacktraces for how to check)
What kind hardware is your SUSE machine? "dual core" processors and multiple CPU hardware are not quite the same thing.
I haven't worked with SMP Linux, but I do manage a couple of multiple-CPU Solaris machines. I've noticed that Solaris is much more conservative with allocating CPU time than Windows XP. XP will let any application take over both cores on my desktop. I have a hard time getting 100% of any CPU on my Solaris boxes, even with code like yours above. Linux may also be on the conservative side.
Another note: top on Solaris doesn't appear to show individual threads. Maybe jconsole would be a better tool.


I've tried to run the code without the println() call, but the same thing happens. It could be that your point about Linux being more conservative in dealing out CPU time. I will investigate this further.
As for the hardware, it has four AMD Opteron Dual Core processors and 8 GB RAM.

Thank you very much for your help, Mr. Ess. I will use the tips you've given me in my search for a solutiuon to my problem.

Martin
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!