[mpich-discuss] Running one MPI program from another

Jayesh Krishna jayesh at mcs.anl.gov
Fri Apr 24 08:57:06 CDT 2009


Hi,
 Great... Let us know if you need any help.
 
Regards,
Jayesh

  _____  

From: Rod Cook [mailto:rod at cookies.demon.co.uk] 
Sent: Friday, April 24, 2009 8:50 AM
To: Jayesh Krishna
Cc: mpich-discuss at mcs.anl.gov
Subject: Re: [mpich-discuss] Running one MPI program from another


Jayesh
 
The environment block was the problem. I've included a modified version of
the test program that works. I've also made the mod in my actual
application and works OK .
 
Thanks for your help, much appreciated.
 
Rod
 
 
#include "stdafx.h"
#include "Userenv.h"
#include <afx.h>
#include "mpi.h"
int run_program( char * program )
{
   STARTUPINFO si;
   PROCESS_INFORMATION pi;
   LPVOID env = NULL;
   CreateEnvironmentBlock(&env, NULL, FALSE);
   ZeroMemory( &si, sizeof(si) );
   si.cb = sizeof(si);
   ZeroMemory( &pi, sizeof(pi) );
   if( !CreateProcess( NULL,   // No module name (use command line)
      program,        // Command line
      NULL,           // Process handle not inheritable
      NULL,           // Thread handle not inheritable
      FALSE,          // Set handle inheritance to FALSE
      CREATE_UNICODE_ENVIRONMENT,              // Created environment
block contains unicode
      env,            // Use created environment block
      NULL,           // Use parent's starting directory 
      &si,            // Pointer to STARTUPINFO structure
      &pi )           // Pointer to PROCESS_INFORMATION structure
      ) 
   {
      return -1;
   }
   WaitForSingleObject( pi.hProcess, INFINITE );
   CloseHandle( pi.hProcess );
   CloseHandle( pi.hThread );
   return 0;
}
int main(int argc, char* argv[])
{
   MPI_Init(NULL,NULL);
   run_program("prog");
   MPI_Finalize();
 return 0;
}

 
 
 
 

----- Original Message ----- 
From: Jayesh  <mailto:jayesh at mcs.anl.gov> Krishna 
To: 'Rod Cook' <mailto:rod at cookies.demon.co.uk>  
Cc: mpich-discuss at mcs.anl.gov 
Sent: Thursday, April 23, 2009 3:53 PM
Subject: RE: [mpich-discuss] Running one MPI program from another

Hi,
 Since you are passing in a NULL value for the environment block the new
process created is inheriting the environment from the parent (since this
environment includes the runtime env for an MPI process it should not be
shared among two MPI processes). This could be your problem. Can you try
passing a dummy environment block instead of NULL in CreateProcess() ?
 
Regards,
Jayesh

  _____  

From: Rod Cook [mailto:rod at cookies.demon.co.uk] 
Sent: Thursday, April 23, 2009 3:42 AM
To: Jayesh Krishna
Cc: mpich-discuss at mcs.anl.gov
Subject: Re: [mpich-discuss] Running one MPI program from another


Jayesh
 
Using "mpiexec -n 1 prog" doesn't work.
 
Cheers
 
Rod
 

----- Original Message ----- 
From: Jayesh  <mailto:jayesh at mcs.anl.gov> Krishna 
To: 'Rod Cook' <mailto:rod at cookies.demon.co.uk>  
Cc: mpich-discuss at mcs.anl.gov 
Sent: Wednesday, April 22, 2009 8:38 PM
Subject: [mpich-discuss] Running one MPI program from another


Hi,
 Try launching "mpiexec -n 1 prog" instead of "prog" with CreateProcess().
Let us know if it works for you.

Regards,
Jayesh

--------------------------------------------------------------------------
------
From: mpich-discuss-bounces at mcs.anl.gov
[mailto:mpich-discuss-bounces at mcs.anl.gov] On Behalf Of Rod Cook
Sent: Wednesday, April 22, 2009 10:12 AM
To: Jayesh Krishna
Cc: mpich-discuss at mcs.anl.gov
Subject: Re: [mpich-discuss] Running one MPI program from another


Jayesh,

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.

Cheers,

Rod
----- Original Message -----
From: Jayesh Krishna
To: 'Rod Cook'
Cc: mpich-discuss at mcs.anl.gov
Sent: Wednesday, April 22, 2009 3:40 PM
Subject: RE: [mpich-discuss] Running one MPI program from another


Hi,
 Did you try MPI_Comm_spawn() ?

Regards,
Jayesh



--------------------------------------------------------------------------
------
From: mpich-discuss-bounces at mcs.anl.gov
[mailto:mpich-discuss-bounces at mcs.anl.gov] On Behalf Of Rod Cook
Sent: Wednesday, April 22, 2009 7:50 AM
To: mpich-discuss at mcs.anl.gov
Subject: [mpich-discuss] Running one MPI program from another


Hi,

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.

Source for test
#include "stdafx.h"
#include <afx.h>
#include "mpi.h"
int run_program( char * program )
{
   STARTUPINFO si;
   PROCESS_INFORMATION pi;
   ZeroMemory( &si, sizeof(si) );
   si.cb = sizeof(si);
   ZeroMemory( &pi, sizeof(pi) );
   if( !CreateProcess( NULL, program, NULL, NULL, FALSE, 0, NULL, NULL,
&si, &pi )  )
   {
      return -1;
   }
   WaitForSingleObject( pi.hProcess, INFINITE );
   CloseHandle( pi.hProcess );
   CloseHandle( pi.hThread );
   return 0;
}
int main(int argc, char* argv[])
{
   MPI_Init(NULL,NULL);
   run_program("prog");
   MPI_Finalize();
 return 0;
}

Source for prog
#include "stdafx.h"
#include "mpi.h"
int main(int argc, char* argv[])
{
   MPI_Init( NULL, NULL );
   MPI_Finalize();
   return 0;
}

I get the following error when I run test:

>mpiexec -n 1 test
MPIDU_Sock_post_connect failed.
[0] PMI_ConnectToHost failed: unable to post a connect to Yellowtail
yellowtail
                 :2057, error: Unknown error class, error stack:
MPIDU_Sock_post_connect(1228): unable to connect to Yellowtail yellowtail
 on port 2057, exhausted all endpoints (errno -1)
MPIDU_Sock_post_connect(1275): unable to connect to                  on
port 2057,
 No connection could be made because the target machine actively refused
it. (er
rno 10061)
MPIDU_Sock_post_connect(1275): unable to connect to yellowtail on port
2057, No
connection could be made because the target machine actively refused it.
(errno
10061)
MPIDU_Sock_post_connect(1275): unable to connect to Yellowtail on port
2057, No
connection could be made because the target machine actively refused it.
(errno
10061)
uPMI_ConnectToHost returning PMI_FAIL
[0] PMI_Init failed.
Fatal error in MPI_Init: Other MPI error, error stack:
MPIR_Init_thread(294): Initialization failed
MPID_Init(83)........: channel initialization failed
MPID_Init(334).......: PMI_Init returned -1
>

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) .


I'd be gratefull for any help.


Thanks

Rod Cook
  

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/mpich-discuss/attachments/20090424/76e15057/attachment.htm>


More information about the mpich-discuss mailing list