Skip to main content

Problem: mpirun / mpiexec calls from Java Runtime.exec() Fails on Large MPI Problems

This is a follow-up to my earlier post:

Question: How to Launch an MPI Parallel Program Programmatically

An Iceberg Problem

I've been stuck on my MPI-Java integration experiment for more than a week and so far haven't found a way out of this problem. My problem is quite similar to this posting on the comp.parallel.mpi newsgroup. Unfortunately, the thread was first posted in the year 2001 and, almost five years later, no one has answered the question.

Let me explain my situation: I want to convert my parallel code, which is written in C and is based on the MPICH and PETSc parallel-computing libraries, into a Web service. From my point of view, three solutions are available: The first one is to use Apache Axis C++ Web Services library to extend the existing code into a Web service. The second one is to leave the parallel code as is and then develop a Java Web service that acts a proxy to execute the parallel code via a Java Runtime.exec() method call. The third one is to use the parallel code in the same way the old-fashioned Web applications were developed, thru some Common Gateway Interface (CGI) mechanisms.

On my first attempt, I went the Java Runtime.exec() plus mpiexec way. It worked well for small Hello World code with simple matrix computation and MPI function calls but it doesn't work when I told Runtime.exec() to launch my parallel structural analysis code. An excerpt of the error is attached at the end of this post.

I also looked at the Axis C++ way, which, for me, is the most direct (but painful) way to create a Web service from existing C code. From preliminary study, if I choose to avoid mpiexec to make a self-contained Web service, it seems like I will have to use the MPI_Comm_spawn function to initialize the master and the worker nodes. Looking at the sample codes, my feeling is that this is a bit much for me as I will have to learn how to use another toolkit -- the Axis C++ -- and to invest considerable time to be familiar enough to master it. I still remember how I spent almost one month in 2004 learning undocumented features of Apache Axis to create a custom serializer-deserializer module for my Java codes.

I also had a glance at CGI and again don't feel like investing my time in learning yet another technology.

I think I will have to stick with the "Java Runtime.exec() plus mpiexec" way. I will post further development about this on this blog.


References:

Question: How to Launch an MPI Parallel Program Programmatically
Google Groups : comp.parallel.mpi
Problems with Runtime.getRuntime().exec


Keywords: , , ,


Update: Jan 18, 06

The poster of the comp.parallel.mpi thread also cross-posted to comp.lang.java.programmer and there are 5 messages on this thread. Here is the link: Problems with Runtime.getRuntime().exec. Unfortunately, this thread leads to no solution.


Update: Jan 18, 06

A friend of mine suggested another solution: using socket communication -- by letting the Java proxy Web service communicate with the master of the cluster, which is implemented in C, thru socket communication. He also introduced me the class ProcessBuilder, which is a new Java class introduced in JDK 5.0, as an alternative to the Runtime.exec() solution.


Attachment:

Error from Java Runtime.exec() plus mpiexec:

Executing: mpiexec -n 2 /home/shared/thitiv/parefg-20060107_1451/parefg /home/shared/thitiv/parefg-20060107_1451/tension.in /home/shared/thitiv/parefg-20060107_1451/tension.out
OUTPUT>Petsc Release Version 2.3.0, Patch 43, April, 26, 2005
OUTPUT>See docs/changes/index.html for recent updates.
OUTPUT>See docs/faq.html for hints about trouble shooting.
OUTPUT>See docs/index.html for manual pages.
OUTPUT>-----------------------------------------------------------------------
OUTPUT>/home/shared/thitiv/parefg-20060107_1451/parefg on a linux-gnu named ubuntu by thitiv Wed Jan 18 14:50:13 2006
OUTPUT>Libraries linked from /usr/local/lib/petsc-2.3.0/lib/linux-gnu
OUTPUT>Configure run at Tue Jan 3 09:36:34 2006
OUTPUT>Configure options --with-mpi-dir=/usr/local/bin/mpich2 --with-shared=0
OUTPUT>-----------------------------------------------------------------------
OUTPUT>[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
OUTPUT>[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
OUTPUT>[0]PETSC ERROR: likely location of problem given in stack below
OUTPUT>[0]PETSC ERROR: --------------- Stack Frames ---------------
OUTPUT>[0]PETSC ERROR: Note: The EXACT line numbers in the stack are not available,
OUTPUT>[0]PETSC ERROR: INSTEAD the line number of the start of the function
OUTPUT>[0]PETSC ERROR: is given.
OUTPUT>[0]PETSC ERROR: --------------------------------------------
OUTPUT>[0]PETSC ERROR: User provided function() line 0 in unknown directory unknown file
OUTPUT>[0]PETSC ERROR: Signal received!
OUTPUT>[0]PETSC ERROR: !
ERROR>[cli_0]: aborting job:
ERROR>application called MPI_Abort(MPI_COMM_WORLD, 59) - process 0
OUTPUT>rank 0 in job 3 ubuntu_32773 caused collective abort of all ranks
OUTPUT> exit status of rank 0: killed by signal 9
ExitValue: 137


Comments

Popular posts from this blog

Padonc's "Bought from Mae Hong Son" T-shirts -- Interesting Souvenir from Mae Hong Son

Padonc's "Bought from Mae Hong Son" T-shirts -- Interesting Souvenir from Mae Hong Son The "I love New York" t-shirt and the series of souvenir was one of my impressive memory from my previous trips to New York City. I got this same kind of impression when I was browsing by the shops by the Jong Kam Walking Street in the city of Mae Hong Son in the second night of the trip. I didn't look at the seller when I caught the sight of these T-shirts. The seller greeted me and, surprisingly, she was P'Kwan, my senior alumni from Chulalongkorn University, who lives in Mae Hong Son and gave me a warm welcome when my family and I went for a dinner at Fern Restaurant in Mae Hong Son town the other night. Note: Pi or P' (its abbreviation) is a Thai word to call an elder sister or brother. Here are the pictures: P'Kwan and Her Shop The T-shirts P'Kwan and the Shop P'Kay, P'Kwan's Husband, at Another Shop Keywords: trips , mae-hong-son , thai

Tip: Converting a CSV File into XML by Excel

I came across a problem to convert a historical data in comma-separated format (CSV) into a modern & more useful XML format. There are many ways to do such conversion. The most obvious one is to do it programmatically by writing a program to read CSV data and exporting it to an XML file by means of the Simple API for XML (SAX) or the Document Object Model (DOM) libraries. But I was too lazy to do it. I knew that Microsoft Excel 2003 supports exporting worksheets into XML data. I tried it out but found that it is not that simple -- we have to define an XML schema and bind each element to each column of the worksheet. So I went on researching. Finally, I found a very useful tool on MSDN: Excel 2003 XML Tools Add-in Version 1.1 ( download ). The Excel Add-in's "XML Tools -> Convert a Range to an XML List" menu command allows us to simply select a range in a worksheet (with or without first row as column names) -- with the advanced options to specify the XML root

It’s been eight years and here comes COVID-19 in early 2020

This blog was last posted in 2008 before Facebook and LinkedIn went mainstream. I have since then socialized and posted a lot on Facebook and LinkedIn. During the global COVID-19 crisis in early 2020 people dramatically change the way they live and work since they day I last posted on this blog. They stay a lot at home during the great lockdown to prevent the spreading of the coronavirus. Here is a summary of my online presence: Facebook: http://fb.com/drthitiv LinkedIn: http://linkedin.com/in/thitiv LINE: http://line.thiti.it Bangkok, THAILAND April 22, 2020