Skip to content

[Rcpp-devel] parallelization in Rcpp

2 messages · Zhao Yang, Tim Triche, Jr.

#
Hello,

Firstly, I would like to thank the develops of Rcpp for this tool.

Then, here is the function:
-----------------------------
code<-'
NumericVector my_id(id);
NumericMatrix my_link(link);
NumericVector lst(1000);

for (int i=0;i<1000;i++){
for (int j=0;j<1000;j++){
if (my_link(my_id[i],my_id[j])==1){
lst[i]+=1;}}}
return lst;
'
fun<-cxxfunction(signature(id="numeric",link="numeric"),body=code,plugin="Rcpp")
------------------------------

And my question is: How to use multicores to calculate the loop and output the final result? 

Thank you.

Best,
Zhao
#
there is an example of using OpenMP for this:

http://dirk.eddelbuettel.com/code/rcpp/html/OpenMP_2OpenMPandInline_8r-example.html

thanks Dirk :-)
On Thu, Feb 14, 2013 at 3:43 AM, Zhao Yang <kikyoyangz at gmail.com> wrote: