[mpich-discuss] windows console functions using mpich2

Jayesh Krishna jayesh at mcs.anl.gov
Thu Jan 27 10:12:05 CST 2011


Hi,
 You are seeing this behavior because when you launch your code with mpiexec, mpiexec gathers the stdout from the various MPI processes and prints it out. Although you are setting the cursor position in the MPI process, it does not get reflected in mpiexec (which is the process that actually prints your output).
 I am not sure if there is an easy way to set/control the cursor position of mpiexec other than modifying mpiexec itself (The easiest way would be to add an command line option or an environment variable for setting the cursor position).
 Alternately, you can launch the mpiexec from another Windows process (CreateProcess()) and control the stdout from the launching Windows process.

Regards,
Jayesh

----- Original Message -----
From: "S.Banen" <s.banen at kabelfoon.nl>
To: mpich2-maint at mcs.anl.gov
Sent: Thursday, January 27, 2011 9:27:46 AM
Subject: [mpich2-maint] windows console functions using mpich2

Hi,

I have a problem that has been bugging me for several days now, and I can't
find a solution or a clue in any forum, so I hope that you can help me.

I am using windows console functions (SetConsoleCursorPosition, etc.) in a
c++ win32 console application to control the location of the cursor in the
console window.
One example for using this is that I print every five seconds to screen the
updated remaining time for all nodes participating in the computation:
Node 0 timeleft:   1 day(s), 06:25:43
Node 1 timeleft:   1 day(s), 06:24:21
Etc.

I don't want to use a new line each time, so the remaining time is printed
at the same window position every time. 

Executing the application without MPI works fine.
Executing the application from the development IDE (Visual Studio 2005)
using the "MPI Cluster Debugger"  also works fine.
But when executing the application from the command line using mpiexec, it
seems as if the code for controlling the cursor is simply ignored; the
output is not printed at the desired location, but at the current position
of the cursor.

Below code that points out the problem:

In stdafx.h:

#include "mpi.h"
#include <stdio.h>
#include <iostream>
Using namespace std; 
#include "windows.h" 


In MPITest.cpp:

#include "stdafx.h" 
int main(int argc,char *argv [])
{
	int numtasks, rank, rc, wait; 
	rc = MPI_Init(&argc,&argv);
	MPI_Comm_size(MPI_COMM_WORLD,&numtasks);
	MPI_Comm_rank(MPI_COMM_WORLD,&rank);
	printf ("Number of tasks= %d My rank= %d\n", numtasks,rank);
	HANDLE hStdout = GetStdHandle(STD_ERROR_HANDLE);
	COORD pos = {7, 7};
	int val = SetConsoleCursorPosition( hStdout, pos);
	cerr<<"This text should appear at console window location of
pos"<<endl;
	MPI_Finalize();
}

My questions are:

- Is it possible to control the cursor location using mpich2 together with
the windows console functions?

	- If the answer is yes, what am I doing wrong (or, what do I have to
do to get it right)?

	- If the answer is no, is there any way to work around this problem?

Thank you for your time.

Regards, Steven Banen




_______________________________________________
mpich2-maint mailing list
mpich2-maint at lists.mcs.anl.gov
https://lists.mcs.anl.gov/mailman/listinfo/mpich2-maint


More information about the mpich-discuss mailing list