[Rcpp-devel] RInside and MPI master slave model proper usage

Nicholas Pezolano npezolano at gmail.com
Sun Jan 20 00:50:10 CET 2013


I posted a example code with the problem here http://pastebin.com/SCrqcp83

The example makefile from the /mpi folder compiles the code with out issue
and runs when the line 153  R.parseEvalQ(R_libs); is commented out.

http://pastebin.com/SCrqcp83

On Sat, Jan 19, 2013 at 5:52 PM, Dirk Eddelbuettel <edd at debian.org> wrote:

>
> On 19 January 2013 at 17:44, Nicholas Pezolano wrote:
> | Maybe I did not describe my question/problem clearly,
> |
> | I've seen the examples and you would call
> |
> |  RInside R(int argc, int argv);  after int main and mpi_init, and all
> nodes
> | should have an embedded R instance.
>
> It works with MPI, and hence works the other way around.
>
> A controller/master node lauches all the worker nodes.  Then __each worker
> node launches its own R instance via RInside__.
>
> How you get data and programs there is up for you. I like packages for many
> reasons, they work here too.
>
> And sorry, I am in the middle of a few other things and cannot debug what
> you
> have described in what is after all incomplete (or I missed it) and not
> reproducible.
>
> Dirk
>
>
> | However the problem with using MPI and RInside in the above master slave
> model
> | is the RInside objects/R instance will not be callable from the do_work
> | function.
> |
> | for instance the following code snippet works in the examples with mpi
> but
> | produces an error when used in a function or with the master slave model.
> |
> | do_work(.......){
> |
> | R["data"] = data;
> | R.parseEvalQ();
> | R.parseEvalQ(garch);
> |
> | }
> |
> | test.cpp: In function ‘void do_work(std::string, int&)’:
> | test.cpp:278:4: error: expected primary-expression before ‘[’ token
> | test.cpp:279:4: error: expected primary-expression before ‘.’ token
> | test.cpp:280:4: error: expected primary-expression before ‘.’ token
> |
> | The error is because the function doesn't have access to the the R object
> |
> |
> | On Sat, Jan 19, 2013 at 5:14 PM, Dirk Eddelbuettel <edd at debian.org>
> wrote:
> |
> |
> |     On 19 January 2013 at 16:29, Nicholas Pezolano wrote:
> |     | Hi I'm using Rinside with MPI and testing out a simple master slave
> |     model.
> |     |
> |     | heres a basic example of what i'm trying to do.
> |     | http://www.lam-mpi.org/tutorials/one-step/ezstart.php
> |     |
> |     | The function  do_work(unit_of_work_t work){ .....   gets run
> across all
> |     the
> |     |  N nodes until the M units of work are done.
> |     |     I am calling many R functions from C++, as well as loading R
> |     libraries,
> |     |  in the do_work function.
> |     |
> |     | Is there a way to load R once on each of the slaves and have the
> do_work
> |     | function have access to RInside for every iteration of the
> master-slave
> |     model?
> |     |
> |     | Do I have to run           RInside R(argc, argv);      for
> |     every-time
> |     | the function do_work is called by the master?
> |     |
> |     | Is there a way to free the R instance or is this handled
> automatically?
> |     or is
> |     | there a better approach?
> |
> |     Do you know that there is a working example, contributed in the
> early days
> |     by
> |     Jianping Hua?
> |
> |     All this assumes that you are a tad familiar with basic MPI. The
> model used
> |     here uses straight MPI from C (or C++), and each (worker/slave) node
> just
> |     happens to do its work with R.
> |
> |     There are other models, notably Rmpi and you are not forced to use
> RInside
> |     in
> |     order to deploy MPI with R.  If you have basic questions, r-sig-hpc
> may be
> |     a
> |     better place.
> |
> |     Dirk
> |
> |
> |
> |     --
> |     Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
> |
> |
> |
> |
> | --
> | Nicholas Pezolano
> | Department of Applied Math & Statistics
> | State University of New York at Stony Brook
> |
>
> --
> Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
>



-- 
Nicholas Pezolano
Cell - 1-516-815-6024
Department of Applied Math & Statistics
State University of New York at Stony Brook
ISC'12 Super Computing Competition Stony Brook
Team<http://hpcadvisorycouncil.com/events/2012/ISC12-Student-Cluster-Competition/team_stony_brook.php>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/rcpp-devel/attachments/20130119/065f941d/attachment.html>


More information about the Rcpp-devel mailing list