<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Thanks a loot for the first reaction on my question.<br>
<br>
I do not perform any terminal input on slaves. Terminal input is
restricted to the root process without any exception. The basic idea is
to use two threads for the root-process: one for user-I/O and one for
handling the slaves.<br>
I hoped that this is possible ... ?<br>
<br>
Cheers<br>
Wilfried<br>
<br>
<br>
Am 31.08.2012 09:23, schrieb Titianingrum -:
<blockquote
cite="mid:CALq83yvme0QG-oEjLWp=hkqoY=OC4PYckXfkhQNqnXRggro9tA@mail.gmail.com"
type="cite">mpi program run hiden on slave side, so how to input there?<br>
that's I know that mpi program not run well while need input.<br>
<br>
<br>
<div class="gmail_quote">On Mon, Aug 27, 2012 at 3:07 PM, Dr.
Wilfried Jakob (IAI) <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:wilfried.jakob@kit.edu" target="_blank">wilfried.jakob@kit.edu</a>></span>
wrote:<br>
<blockquote class="gmail_quote"
style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div bgcolor="#ffffff" text="#000000">Hi,<br>
as I did not receive any reply to my email from 31.7.2012 I post it
again and really hope that somebody can help me.<br>
<br>
I want to have a communication on the root process (rank=0) in such a
way that single characters are read from the terminal.<br>
This is achieved in plain C by using termios.h and the functions
tcgetattr() and tcsetattr() as shown in the attached test program. With
gcc and Debian Linux this works fine.<br>
<br>
I translated the program with mpicc without any problems and started it
directly from the command line: it worked well.<br>
Then I started it with<br>
<big><tt> mpiexec -f nodes -n 2 tioTestMPI <br>
</tt></big>and received the following:<br>
<br>
<big><tt>Waiting for input ...<br>
error with cbreak<br>
Waiting for input ...<br>
error with cbreak<br>
</tt></big><br>
A more detailed analysis shows that the call to "tcgetattr" yields the
error "Invalid argument". This was obtained by a subsequent call to
perror.<br>
<br>
A version including prior calls to <br>
<big><tt> MPI_Init(&argc, &argv);<br>
MPI_Comm_rank(MPI_COMM_WORLD, &rank);<br>
MPI_Comm_size(MPI_COMM_WORLD, &size);<br>
</tt></big>is given by the second program. It yields the same
results:<br>
<big><tt>Waiting for input ...<br>
error with cbreak<br>
lazy slave<br>
</tt></big><br>
Thanks in advance<br>
Wilfried Jakob<br>
<br>
<br>
Here is the source code of the test program 1:<br>
=================================================<br>
#include <stdio.h><br>
#include <stdlib.h><br>
#include <termios.h><br>
#include <unistd.h><br>
<br>
static struct termios new_io;<br>
static struct termios old_io;<br>
<br>
int cbreak(int fd) {<br>
/* save old terminal settings */<br>
if((tcgetattr(fd, &old_io)) == -1)<br>
return -1;<br>
new_io = old_io;<br>
/* change terminal settings */<br>
new_io.c_lflag = new_io.c_lflag & ~(ECHO|ICANON);<br>
new_io.c_cc[VMIN] = 1;<br>
new_io.c_cc[VTIME]= 0;<br>
<br>
/* set new settings */<br>
if((tcsetattr(fd, TCSAFLUSH, &new_io)) == -1)<br>
return -1;<br>
return 1;<br>
}<br>
<br>
<br>
int getch(void) {<br>
int c;<br>
<br>
if(cbreak(STDIN_FILENO) == -1) {<br>
printf(" error with cbreak \n");<br>
exit(EXIT_FAILURE);<br>
}<br>
c = getchar();<br>
/* restore old terminal settings */<br>
tcsetattr(STDIN_FILENO, TCSANOW, &old_io);<br>
return c;<br>
}<br>
<br>
<br>
int main (int argc, char** argv)<br>
{<br>
int ii;<br>
<br>
printf ("Waiting for input ...\n");<br>
ii = getch ();<br>
printf (" read: \"%c\" = %d\n", (char)ii, ii);<br>
<br>
printf ("Waiting for input ...\n");<br>
ii = getch ();<br>
printf (" read: \"%c\" = %d\n", (char)ii, ii);<br>
<br>
printf ("\nfinished!\n");<br>
return 0;<br>
}<br>
=================================================<br>
<br>
Here is the source code of the test program 2:<br>
=================================================<br>
#include <stdio.h><br>
#include <stdlib.h><br>
#include <termios.h><br>
#include <unistd.h><br>
<br>
#include "mpi.h"<br>
<br>
static struct termios new_io;<br>
static struct termios old_io;<br>
<br>
<br>
int cbreak(int fd) {<br>
/* save old terminal settings */<br>
if((tcgetattr(fd, &old_io)) == -1)<br>
return -1;<br>
new_io = old_io;<br>
/* change terminal settings */<br>
new_io.c_lflag = new_io.c_lflag & ~(ECHO|ICANON);<br>
new_io.c_cc[VMIN] = 1;<br>
new_io.c_cc[VTIME]= 0;<br>
<br>
/* set new settings */<br>
if((tcsetattr(fd, TCSAFLUSH, &new_io)) == -1)<br>
return -1;<br>
return 1;<br>
}<br>
<br>
<br>
int getch(void) {<br>
int c;<br>
<br>
if(cbreak(STDIN_FILENO) == -1) {<br>
printf(" error with cbreak\n");<br>
exit(EXIT_FAILURE);<br>
}<br>
c = getchar();<br>
/* restore old terminal settings */<br>
tcsetattr(STDIN_FILENO, TCSANOW, &old_io);<br>
return c;<br>
}<br>
<br>
<br>
int main (int argc, char** argv)<br>
{<br>
int ii, rank, size;<br>
<br>
MPI_Init(&argc, &argv);<br>
MPI_Comm_rank(MPI_COMM_WORLD, &rank);<br>
MPI_Comm_size(MPI_COMM_WORLD, &size);<br>
<br>
if (rank == 0) { /* master */<br>
printf ("Waiting for input ...\n");<br>
ii = getch ();<br>
printf (" read: \"%c\" = %d\n", (char)ii, ii);<br>
<br>
printf ("Waiting for input ...\n");<br>
ii = getch ();<br>
printf (" read: \"%c\" = %d\n", (char)ii, ii);<br>
<br>
printf ("\nfinished!\n");<br>
} /* master */<br>
else<br>
printf ("lazy slave\n");<br>
<br>
MPI_Finalize();<br>
return 0;<br>
}<br>
=================================================<br>
<br>
</div>
<br>
_______________________________________________<br>
mpich-discuss mailing list <a moz-do-not-send="true"
href="mailto:mpich-discuss@mcs.anl.gov">mpich-discuss@mcs.anl.gov</a><br>
To manage subscription options or unsubscribe:<br>
<a moz-do-not-send="true"
href="https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss"
target="_blank">https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss</a><br>
<br>
</blockquote>
</div>
<br>
<br clear="all">
<br>
-- <br>
titia<br>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
mpich-discuss mailing list <a class="moz-txt-link-abbreviated" href="mailto:mpich-discuss@mcs.anl.gov">mpich-discuss@mcs.anl.gov</a>
To manage subscription options or unsubscribe:
<a class="moz-txt-link-freetext" href="https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss">https://lists.mcs.anl.gov/mailman/listinfo/mpich-discuss</a>
</pre>
</blockquote>
</body>
</html>