<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7036.0">
<TITLE>[mpich-discuss] Running one MPI program from another</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->
<P><FONT SIZE=2>Hi,<BR>
Try launching "mpiexec -n 1 prog" instead of "prog" with CreateProcess(). Let us know if it works for you.<BR>
<BR>
Regards,<BR>
Jayesh<BR>
<BR>
--------------------------------------------------------------------------------<BR>
From: mpich-discuss-bounces@mcs.anl.gov [<A HREF="mailto:mpich-discuss-bounces@mcs.anl.gov">mailto:mpich-discuss-bounces@mcs.anl.gov</A>] On Behalf Of Rod Cook<BR>
Sent: Wednesday, April 22, 2009 10:12 AM<BR>
To: Jayesh Krishna<BR>
Cc: mpich-discuss@mcs.anl.gov<BR>
Subject: Re: [mpich-discuss] Running one MPI program from another<BR>
<BR>
<BR>
Jayesh,<BR>
<BR>
I can get my example code to work using MPI_Comm_spawn but it doesn't work for my actual application. The problem with using MPI_Comm_spawn is that I don't know how to tell that the spawned program has finished -- this is why I used CreateProcess because it is possible to wait for the program to terminate. The spawned program could be a non MPI executable or a standalone MPI executable which can't communicate with the program calling MPI_Comm_spawn.<BR>
<BR>
Cheers,<BR>
<BR>
Rod<BR>
----- Original Message -----<BR>
From: Jayesh Krishna<BR>
To: 'Rod Cook'<BR>
Cc: mpich-discuss@mcs.anl.gov<BR>
Sent: Wednesday, April 22, 2009 3:40 PM<BR>
Subject: RE: [mpich-discuss] Running one MPI program from another<BR>
<BR>
<BR>
Hi,<BR>
Did you try MPI_Comm_spawn() ?<BR>
<BR>
Regards,<BR>
Jayesh<BR>
<BR>
<BR>
<BR>
--------------------------------------------------------------------------------<BR>
From: mpich-discuss-bounces@mcs.anl.gov [<A HREF="mailto:mpich-discuss-bounces@mcs.anl.gov">mailto:mpich-discuss-bounces@mcs.anl.gov</A>] On Behalf Of Rod Cook<BR>
Sent: Wednesday, April 22, 2009 7:50 AM<BR>
To: mpich-discuss@mcs.anl.gov<BR>
Subject: [mpich-discuss] Running one MPI program from another<BR>
<BR>
<BR>
Hi,<BR>
<BR>
I am trying to run an MPI program (prog) from another MPI program (test) using CreateProcess under Windows XP. I am using MPICH2 v1.08.<BR>
<BR>
Source for test<BR>
#include "stdafx.h"<BR>
#include <afx.h><BR>
#include "mpi.h"<BR>
int run_program( char * program )<BR>
{<BR>
STARTUPINFO si;<BR>
PROCESS_INFORMATION pi;<BR>
ZeroMemory( &si, sizeof(si) );<BR>
si.cb = sizeof(si);<BR>
ZeroMemory( &pi, sizeof(pi) );<BR>
if( !CreateProcess( NULL, program, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ) )<BR>
{<BR>
return -1;<BR>
}<BR>
WaitForSingleObject( pi.hProcess, INFINITE );<BR>
CloseHandle( pi.hProcess );<BR>
CloseHandle( pi.hThread );<BR>
return 0;<BR>
}<BR>
int main(int argc, char* argv[])<BR>
{<BR>
MPI_Init(NULL,NULL);<BR>
run_program("prog");<BR>
MPI_Finalize();<BR>
return 0;<BR>
}<BR>
<BR>
Source for prog<BR>
#include "stdafx.h"<BR>
#include "mpi.h"<BR>
int main(int argc, char* argv[])<BR>
{<BR>
MPI_Init( NULL, NULL );<BR>
MPI_Finalize();<BR>
return 0;<BR>
}<BR>
<BR>
I get the following error when I run test:<BR>
<BR>
>mpiexec -n 1 test<BR>
MPIDU_Sock_post_connect failed.<BR>
[0] PMI_ConnectToHost failed: unable to post a connect to Yellowtail yellowtail<BR>
:2057, error: Unknown error class, error stack:<BR>
MPIDU_Sock_post_connect(1228): unable to connect to Yellowtail yellowtail<BR>
on port 2057, exhausted all endpoints (errno -1)<BR>
MPIDU_Sock_post_connect(1275): unable to connect to on port 2057,<BR>
No connection could be made because the target machine actively refused it. (er<BR>
rno 10061)<BR>
MPIDU_Sock_post_connect(1275): unable to connect to yellowtail on port 2057, No<BR>
connection could be made because the target machine actively refused it. (errno<BR>
10061)<BR>
MPIDU_Sock_post_connect(1275): unable to connect to Yellowtail on port 2057, No<BR>
connection could be made because the target machine actively refused it. (errno<BR>
10061)<BR>
uPMI_ConnectToHost returning PMI_FAIL<BR>
[0] PMI_Init failed.<BR>
Fatal error in MPI_Init: Other MPI error, error stack:<BR>
MPIR_Init_thread(294): Initialization failed<BR>
MPID_Init(83)........: channel initialization failed<BR>
MPID_Init(334).......: PMI_Init returned -1<BR>
><BR>
<BR>
In my actual application prog is either a standalone MPI program which I can't change or a non MPI program (in which case test works) .<BR>
<BR>
<BR>
I'd be gratefull for any help.<BR>
<BR>
<BR>
Thanks<BR>
<BR>
Rod Cook<BR>
</FONT>
</P>
</BODY>
</HTML>