MPI: the example of R

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

MPI: the example of R

Andy Jacobson-2-2
Howdy,

        The folks over at R (http://www.r-project.org) have put
        together an MPI package that doesn't require any changes to
        the R executable.  Everything is done with dynamically-loaded
        code.  For instance, the MPI_Init call is in this external
        function:


SEXP mpi_initialize(){
        int flag;
        MPI_Initialized(&flag);
        if (flag)
                return AsInt(1);
        else {
          fprintf(stdout,"About to call MPI_Init()");fflush(stdout);
                MPI_Init((void *)0,(void *)0);
          fprintf(stdout,"About to call MPI_Errhandler_set()");fflush(stdout);
                MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
          fprintf(stdout,"About to call MPI_Errhandler_set()");fflush(stdout);
                MPI_Errhandler_set(MPI_COMM_SELF, MPI_ERRORS_RETURN);
                comm=(MPI_Comm *)Calloc(COMM_MAXSIZE, MPI_Comm);
                status=(MPI_Status *)Calloc(1, MPI_Status);
                datatype=(MPI_Datatype *)Calloc(1, MPI_Datatype);
                info=(MPI_Info *)Calloc(1, MPI_Info);
                comm[0]=MPI_COMM_WORLD;

                return AsInt(1);
        }
}


        So while we octavites are concerned with adhering to the
        letter of the MPI standard, the author here has instead chosen
        to get on with business by explicitly passing NULL pointers to
        MPI_Init.  Note that disclaimers in the code suggest that this
        "Rmpi" package is only likely to have full functionality with
        LAM/MPI.  The implication is that LAM may not check or use
        these args (recall that this is implementation dependent).  

        Information on Rmpi is at
        http://www.stats.uwo.ca/faculty/yu/Rmpi/ 


        Cheers,

                Andy
--
Andy Jacobson

[hidden email]

Program in Atmospheric and Oceanic Sciences
Sayre Hall, Forrestal Campus
Princeton University
PO Box CN710 Princeton, NJ 08544-0710 USA

Tel: 609/258-5260  Fax: 609/258-2850


Reply | Threaded
Open this post in threaded view
|

Re: MPI: the example of R

JD Cole-2
How about this,
   I am currently working on a more generalized interface for parallel
computation in Octave. Along the way I have implemented a dynamically
linked library, which I coined PIL (Parallel Interface Library) which
allows anyone to implement their favorite parallel library (be it MPI or
PVM) as a PIL external to Octave. Which parallel library to use is
specified on the command line with the --parallel path/to/library.pil
(This concept was mentioned before
here:http://www.octave.org/mailing-lists/octave-maintainers/2003/75 ).
With the addition of a small class in the main Octave source, MPI_Init
can get its needed arguments. (As can any other parallel implementation.)

I have separated my PIL code from my other work and attached it to the
message.

JD

Andy Jacobson wrote:

>Howdy,
>
>        The folks over at R (http://www.r-project.org) have put
>        together an MPI package that doesn't require any changes to
>        the R executable.  Everything is done with dynamically-loaded
>        code.  For instance, the MPI_Init call is in this external
>        function:
>
>
>SEXP mpi_initialize(){
> int flag;
> MPI_Initialized(&flag);
> if (flag)
> return AsInt(1);
> else {
>  fprintf(stdout,"About to call MPI_Init()");fflush(stdout);
> MPI_Init((void *)0,(void *)0);
>  fprintf(stdout,"About to call MPI_Errhandler_set()");fflush(stdout);
> MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
>  fprintf(stdout,"About to call MPI_Errhandler_set()");fflush(stdout);
> MPI_Errhandler_set(MPI_COMM_SELF, MPI_ERRORS_RETURN);
> comm=(MPI_Comm *)Calloc(COMM_MAXSIZE, MPI_Comm);
> status=(MPI_Status *)Calloc(1, MPI_Status);
> datatype=(MPI_Datatype *)Calloc(1, MPI_Datatype);
> info=(MPI_Info *)Calloc(1, MPI_Info);
> comm[0]=MPI_COMM_WORLD;
>
> return AsInt(1);
> }
>}
>
>
>        So while we octavites are concerned with adhering to the
>        letter of the MPI standard, the author here has instead chosen
>        to get on with business by explicitly passing NULL pointers to
>        MPI_Init.  Note that disclaimers in the code suggest that this
>        "Rmpi" package is only likely to have full functionality with
>        LAM/MPI.  The implication is that LAM may not check or use
>        these args (recall that this is implementation dependent).  
>
>        Information on Rmpi is at
>        http://www.stats.uwo.ca/faculty/yu/Rmpi/ 
>
>
>        Cheers,
>
>                Andy
>


PIL-pil_pre_release.tar.gz (9K) Download Attachment