[MPICH] A Question about MPI - Use the "-map" option in mpiexec

Jayesh Krishna jayesh at mcs.anl.gov
Fri Sep 21 11:52:48 CDT 2007


Hi,
 I am providing below a simple code (In production code be careful of what/how much you read and the newlines. This code is *only* for demonstrating the usage of the "-map" option of mpiexec command.) used to open/read/close a file in windows,
 
/****************** Sample Code *****************/
#include <stdio.h>

#include "mpi.h"

#define MAX_BUF_LEN 100

int main(int argc, char *argv[]){

MPI_File fh;

MPI_Status st;

char buf[MAX_BUF_LEN];

MPI_Init(&argc, &argv);

MPI_File_open(MPI_COMM_SELF, "J:\\testfolder\\testfile", MPI_MODE_RDONLY, MPI_INFO_NULL, &fh);

MPI_File_read(fh, buf, sizeof(buf), MPI_CHAR, &st);

printf("Read %s\n", buf);

MPI_File_close(&fh);

MPI_Finalize();

}

/****************** Sample Code *****************/
 
 You can run the above program as follows,
 
Assumptions
---------------
# The executable of the above program is named "testpgm.exe"
# The machine with machine name "machineA" has a folder "mappedFolder" which is shared. The folder "mappedFolder" contains a folder "testfolder" with a file "testfile"
# The user running the program (running mpiexec) has permissions to map the folder "mappedFolder" and has access to read the file "testfile" (You can test this by mapping "mappedFolder" from the windows explorer and trying to read the file testfile)
 
Executing the program
------------------------
 
mpiexec -n 1 -map j:\\machineA\mappedFolder testpgm.exe
 
 
  Let us know if you need any further assistance. I would recommend that you go through the windows developer's guide to get a better understanding of the options provided with the mpiexec command.
 
 
Regards,
Jayesh

  _____  

From: menglige [mailto:menglige at gmail.com] 
Sent: Friday, September 21, 2007 1:22 AM
To: Jayesh Krishna
Subject: Re: RE: [MPICH] A Question about MPI - Use the "-map" option in mpiexec


Thank you  very much!!!!!!!!!!!!!
could you give me an example. 
i want to operate a file named"remotefile" which  in folder "E:\test" of remote host "node1".
1, mpiexec -map ????
2,in my code .
MPI_File_Open(????????????)
 
 
  _____  

menglige
2007-09-21
  _____  

发件人: Jayesh Krishna
发送时间: 2007-09-21 02:22:06
收件人: 'menglige'
抄送: 'mpich-discuss'; 'Robert Latham'
主题: RE: [MPICH] A Question about MPI - Use the "-map" option in mpiexec
 
 Hi,
  If you would like to access use a remote machine's file system you will
have to share the file system using the "-map" option of the mpiexec command
in MPICH2 on windows (i.e., You cannot access the network shares from within
the MPI program if you do not use the "-map" option of mpiexec command). You
can find the details in the window's developer's guide available at
http://www-unix.mcs.anl.gov/mpi/mpich/ <http://www-unix.mcs.anl.gov/mpi/mpich/ . Once you map the shared drive, to>  . Once you map the shared drive, to
say X:, you can access the file in the network share as
"X:\\folder1\\folder2\\filename" (without the quotes. Also make sure that
the string containing the filename has a '\0' at the end) from within your
MPI program.
  Let us know if you need any futher help in this regard.
 
Regards,
Jayesh
 
-----Original Message-----
From: owner-mpich-discuss at mcs.anl.gov
[mailto:owner-mpich-discuss at mcs.anl.gov] On Behalf Of Robert Latham
Sent: Thursday, September 20, 2007 12:34 PM
To: menglige
Cc: mpich-discuss
Subject: Re: [MPICH] A Question about MPI
 
On Thu, Sep 20, 2007 at 05:18:00PM +0800, menglige wrote:
> 
> int MPI_File_open(MPI_Comm comm, char * filename, int amode, MPI_Info 
> info, ??MPI_File * fh)
> 
> I want to open a file on the remote host.the host name is "node1" and file
name is "remotefile" in folder "E:\test" .
> How can i write the parameter "filename"?
 
Simce most MPI implementations are based on ROMIO, I'll tell you what ROMIO
can do about that, and it will likely work for you.
 
The NTFS driver for ROMIO doesn't go out and access remote machines.
Maybe Jayesh knows a trick or two, but you'll have to first export that
remote machine's file system to your client code (maybe a network shared
drive or shared folder.  
 
Once you've done that, specify the path like you would in windows Explorer.
I don't regularly use windows, so the following is
untested:
 
If you used a shared drive, something like char * filename = "y:\test" ;
 
or if you used a network folder then maybe char * filename =
\\remote_machine\test;
 
==rob
 
--
Rob Latham
Mathematics and Computer Science Division    A215 0178 EA2D B059 8CDF
Argonne National Lab, IL USA                 B29D F333 664A 4280 315B
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/mpich-discuss/attachments/20070921/3cc7e22a/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/gif
Size: 1237 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/mpich-discuss/attachments/20070921/3cc7e22a/attachment.gif>


More information about the mpich-discuss mailing list