<div>Maybe I did not describe my question/problem clearly,</div><div><br></div><div>I've seen the examples and you would call </div><div><br></div><div> RInside R(int argc, int argv); after int main and mpi_init, and all nodes should have an embedded R instance.</div>
<div><br></div><div>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. </div><div><br></div><div>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.</div>
<div><br></div><div>do_work(.......){</div><div><br></div><div><div>R["data"] = data;</div><div>R.parseEvalQ();</div><div>R.parseEvalQ(garch);</div></div><div><br></div><div>}</div><div><br></div><div><div>test.cpp: In function ‘void do_work(std::string, int&)’:</div>
<div>test.cpp:278:4: error: expected primary-expression before ‘[’ token</div><div>test.cpp:279:4: error: expected primary-expression before ‘.’ token</div><div>test.cpp:280:4: error: expected primary-expression before ‘.’ token</div>
</div><div><br></div><div>The error is because the function doesn't have access to the the R object</div><div><br></div><div><br><div class="gmail_quote">On Sat, Jan 19, 2013 at 5:14 PM, Dirk Eddelbuettel <span dir="ltr"><<a href="mailto:edd@debian.org" target="_blank">edd@debian.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im"><br>
On 19 January 2013 at 16:29, Nicholas Pezolano wrote:<br>
| Hi I'm using Rinside with MPI and testing out a simple master slave model.<br>
|<br>
| heres a basic example of what i'm trying to do.<br>
| <a href="http://www.lam-mpi.org/tutorials/one-step/ezstart.php" target="_blank">http://www.lam-mpi.org/tutorials/one-step/ezstart.php</a><br>
|<br>
| The function do_work(unit_of_work_t work){ ..... gets run across all the<br>
| N nodes until the M units of work are done. <br>
| I am calling many R functions from C++, as well as loading R libraries,<br>
| in the do_work function.<br>
|<br>
| Is there a way to load R once on each of the slaves and have the do_work<br>
| function have access to RInside for every iteration of the master-slave model?<br>
|<br>
| Do I have to run RInside R(argc, argv); for every-time<br>
| the function do_work is called by the master?<br>
|<br>
| Is there a way to free the R instance or is this handled automatically? or is<br>
| there a better approach?<br>
<br>
</div>Do you know that there is a working example, contributed in the early days by<br>
Jianping Hua?<br>
<br>
All this assumes that you are a tad familiar with basic MPI. The model used<br>
here uses straight MPI from C (or C++), and each (worker/slave) node just<br>
happens to do its work with R.<br>
<br>
There are other models, notably Rmpi and you are not forced to use RInside in<br>
order to deploy MPI with R. If you have basic questions, r-sig-hpc may be a<br>
better place.<br>
<span class="HOEnZb"><font color="#888888"><br>
Dirk<br>
<br>
<br>
<br>
--<br>
Dirk Eddelbuettel | <a href="mailto:edd@debian.org">edd@debian.org</a> | <a href="http://dirk.eddelbuettel.com" target="_blank">http://dirk.eddelbuettel.com</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br><div>Nicholas Pezolano</div><div>Department of Applied Math & Statistics</div><div>State University of New York at Stony Brook</div><div><br>
</div>
</div>