Newsgroups: comp.parallel.pvm
From: Antonio Scotti <scotti@centauro.upc.es>
Subject: Re: How to introduce parallel subroutines to PVM programs?
Organization: Universitat Politecnica de Catalunya
Date: 9 Nov 1995 09:13:13 GMT
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <47sgn9$mp7@diable.upc.es>

minyard@pollux.cs.uga.edu (james minyard) wrote:
>Antonio Scotti (scotti@centauro.upc.es) wrote:
>: But what if one needs a specific operation to be executed several times
>: during program execution ?
>: For example one may need to implement a matrix multiplication operation
>: ( I mean a  parallel version ) and use it all the times that it is needed
>: throughout the program. In  sequencial, traditional, programming one would then
>: write either a function or a procedure and put the function/procedure call at
>: the place where the operation is needed.
>: How can this be done with pvm programs, if at all?
>
>after spawning a slave process, the process that spawned it can 
>communicate with it all it wants.  if you use different types of message 
>tags in your message passing, you can have your slave process sit there 
>and wait for a message, and do something depending on the message tag.
>
>for example (in slave):
>  int bufid,bytes,sendertid,msgtag; 
>  bufid=pvm_mkbuf(PvmDataDefault);
>  pvm_setrbuf(bufid);  /* don't forget to free the old rbuf */
>  pvm_recv(pvm_parent(),-1);
>  pvm_bufinfo(bufid,&bytes,&sendertid,&msgtag);
>  while (msgtag!=EXIT_TAG) {
>    switch msgtag {
>      case MATRIX_MULT_TAG:
>        do_whatever();
>        break;
>      case DO_SOMETHING_ELSE_TAG:
>        do_something_else();
>        break;
>    }
>    pvm_recv(pvm_parent(),-1);
>    pvm_bufinfo(bufid,&bytes,&sendertid,&msgtag);
>  }
>  /* clean up */
>  pvm_exit();
>  exit(0);
>
>that's just an aproximation off the top of my head.  it's probably not
>correct, but it gets the idea across, and you can use it however you want. 

Hello James,
and thanks for your ideas. But this is not quite what I wanted to know,
though rereading the text of my original posting I realize that according to it
your answer in correct. 

What I actually ment (and the title of my posting, at least, points at it) is,
how can I create parallel procedures on their own right such as the
"do_whatever()" and "do_something_else()" procedures of your example?

Put it on another way, how can I tell my pvm program "Just do this in parallel"
without resorting to the master/slave or spmd paradigms?
I thing goes along with the idea of building parallel functions' libraries,
(perhaps using PVM)
such as parallel routines to perform say, sorting, matrix multiply or whatever
one may need to stuff into one's program.
Or one might even think to write a sequencial program that does "certain
things"
in parallel, in a way that is transparent to the user/programmer, by adding for
example at some stage, a  routine that does its job in parallel.

I am looking forward for your answers.
Cheers,
-- Antonio



=============================================================
= Antonio Scotti                                            =
= CIMNE                                                     =     
= International Centre for Numerical Methods in Engineering =
= Universitat Politecnica de Catalunya, Campus Norte        =
= s/n Gran Capita`, Edificio C1                             =
= Barcelona, Spain                                          =
=                                                           =
= phone: ++ 34 3 401.74.03                                  =
= E-mail: scotti@centauro.upc.es                            =
= 							    =
=           "The mind leads, the body follows"              =
=                                     KOICHI TOHEI          =       
=============================================================


