On Sat, 5 Jul 2003, Glauber Mariano Ferreira wrote:
> I would like to know if there is a way to print information on the
> client screen whem i send a message, from the server, to the client. I
> have this C program that runs in 4 stations (the server plus 3 clients)
> and whem i run my code in the server i would like to send a message to
> any client and print the information on the client screen. IS THAT
> POSSIBLE??? HOW DO I DO IT???
If all your send/receive code is not centralized such that it would not be
easy to add your own printf's any time you call MPI_Send/MPI_Recv (etc.),
then you might consider using the MPI profiling layer. See Chapter 8 of
the MPI-1 standard for details, but the gist of it is as follows:
- write your own MPI_Send function with exactly the same function
signature as the real one.
- in this replacement MPI_Send function, print out whatever message you
want, then invoke PMPI_Send to perform the actual send. Something along
the lines of the following (modify to suit your needs):
-----
int MPI_Send(void *buf, int count, MPI_Datatype dtype, int dest,
int tag, MPI_Comm comm) {
int rank, len;
char name[MPI_MAX_OBJECT_NAME];
MPI_Comm_rank(comm, &rank);
MPI_Comm_get_name(comm, name, &len);
printf("Comm %s, rank %d, calling MPI_Send to dest rank %d\n",
name, rank, dest);
return PMPI_Send(buf, count, dtype, dest, tag, comm);
}
-----
(forgive typos; this was typed straight into my mail client and I did
not try compiling it)
- repeat for all the MPI functions that you use.
- ensure that you link in your replacement MPI functions on the compile
line. For example, if all your MPI functions are in libmympi.a, you'd
use something along the lines of:
mpicc myapplication.c -Lpath/to/libmympi -lmympi -o myapplication
The neat thing about this is that your application source code does not
change at all. You can effectively insert and remove a whole bunch of
debugging code depending on how you link your final application (i.e.,
whether you link in libmympi.a or not).
Hope this helps.
--
{+} Jeff Squyres
{+} jsquyres_at_[hidden]
{+} http://www.lam-mpi.org/
|