Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Problems with Runtime.getRuntime().exec

88 views
Skip to first unread message

Tania

unread,
Nov 27, 2001, 6:46:09 AM11/27/01
to
Hi everybody,

I am having the following problem:
I create a process and I tell it to execute a MPI application. It
works well and gives me the right result when the application is
small.
The application is a matrix multiplication and when I put a 10x10
(for instance) matrix, it goes right. But, when the matrix is big,
there lives the problem. When I put a 500x500 matrix, it doesn't work.
I verify with the command top (UNIX) if the process mpirun was
created, it is... but, it doesn't call the program matrix.
Is there any kind of constraint of the method exec related to the
granularity of the application that is going to be executed??
The source is:

Process p =null;
p=Runtime.getRuntime().exec("/mpich-1.2.2.3/bin/mpirun -machinefile
/mpich-1.2.2.3/examples/jota/maquinas.dat -np 2 mmatrix" );

Can it be related to the available memory to the JVM??
This command works well if I put it directly in the console.
I am using jdk-1.3.0 and Linux 6.0.

Thanks a lot,
Tania Ramos
UnB-University of Brasilia-Brasil

Gordon Beaton

unread,
Nov 27, 2001, 6:52:36 AM11/27/01
to
On 27 Nov 2001 03:46:09 -0800, Tania wrote:
> I create a process and I tell it to execute a MPI application. It
> works well and gives me the right result when the application is
> small.
>
> The application is a matrix multiplication and when I put a 10x10
> (for instance) matrix, it goes right. But, when the matrix is big,
> there lives the problem. When I put a 500x500 matrix, it doesn't
> work. I verify with the command top (UNIX) if the process mpirun was
> created, it is... but, it doesn't call the program matrix.
>
> Is there any kind of constraint of the method exec related to
> the granularity of the application that is going to be executed??
> The source is:

Does "mpirun" produce a lot of output, perhaps related to the size of
the matrix?

If so, you need to deal with it somehow, by either reading from
p.getInputStream(), closing p.getInputStream(), or redirecting the
output of the external process to /dev/null.

The reason for this is that the output stream of the external process
has only limited space. If nobody reads from the stream, the process
will write until it fills, then block until there is once again space
available.

/gordon

--
[ do not send me private copies of your followups ]
g o r d o n . b e a t o n @ e r i c s s o n . c o m

Tania

unread,
Nov 27, 2001, 11:13:41 AM11/27/01
to
Hi,

Thanks for answering me. But, mmatrix is a programa that generates
an output that goes to an archive. Do you think that even with the
output going to an archive, this is still the problem? The output is
very big...

Thanks,
Tania Ramos

n...@for.email (Gordon Beaton) wrote in message news:<9tvuq4$otu$1...@news.du.uab.ericsson.se>...

Gordon Beaton

unread,
Nov 27, 2001, 11:27:30 AM11/27/01
to
On 27 Nov 2001 08:13:41 -0800, Tania wrote:
> Thanks for answering me. But, mmatrix is a programa that generates
> an output that goes to an archive. Do you think that even with the
> output going to an archive, this is still the problem? The output is
> very big...

So, it doesn't print anything at all while it works?

If all of the outout is going to a file I can't see how that should
affect anything, as long as there is room for the file in the
filesystem.

Now I am starting to understand that "mpirun" runs "mmatrix" - is that
correct? Perhaps there is a PATH or similar environment problem when
you run it from java, so that mpirun works but not mmatrix?

What happens if you do this:

Process p = Runtime.getRuntime().exec("mpirun... ");
p.getInputStream().close();
BufferedReader br = new
BufferedReader(new
InputStreamReader(p.getErrorStream());

String line;
while ((line = br.readLine()) != null) {
System.out.println(line);
}

br.close();
System.out.println("exit value: " + p.exitValue());

Tania

unread,
Nov 28, 2001, 7:38:23 AM11/28/01
to
You are right. Mpirun runs mmatrix, and mpirun works but no mmatrix. I
did you've told me to do and I had the following as a result:

/mpich1.2.2.3/bin/mpirun :line 1: 8131 Segmentation fault (core dumped)/
/mpich1.2.2.3/examples/jota/mmatrix -p4pg /home/tania/PI8049 -p4wd
/home/tania

exit value: -117

I've already had this kind of problem when I used to call mpirun without
being from java and it was related to available memory( the mmatrix was
too big). I was wondering if it could be the same, do you think it can
be related to the available memory to the JVM??? Can I increase this
amount of memory??? Because, when I run the same command without being
from java, it doesn't occur.


Thanks a lot,
Tania Ramos
UnB- University of Brasilia- Brasil


n...@for.email (Gordon Beaton) wrote in message news:<9u0eti$de$1...@news.du.uab.ericsson.se>...

0 new messages