Re: [Rcpp-devel] When calling same Rcpp function several times different results are returned

2015-07-15 Thread JJ Allaire
It's because several instances of your object will be created (via the splitting constructor) and then joined together using the join method. If all instances share an output variable then they will overwrite each others' output, giving them their own allows the split/join logic to work correctly.

Re: [Rcpp-devel] When calling same Rcpp function several times different results are returned

2015-07-14 Thread Dirk Eddelbuettel
On 14 July 2015 at 09:25, Danas Zuokas wrote: | I have written parallel implementation of sums in groups using RcppParallel. Isn't this the same question as http://stackoverflow.com/questions/31318419/when-calling-same-rcpp-function-several-times-different-results-are-returned You got some

Re: [Rcpp-devel] When calling same Rcpp function several times different results are returned

2015-07-14 Thread JJ Allaire
Would that still solve the problem if there are overlapping indexes in gi ? (i.e. if the same index appeared more than one time and was utilized from more than one thread at a time) On Tue, Jul 14, 2015 at 7:21 AM, JJ Allaire jj.alla...@gmail.com wrote: The examples in the RcppParallel

Re: [Rcpp-devel] When calling same Rcpp function several times different results are returned

2015-07-14 Thread Danas Zuokas
I have tried this with no luck. 2015-07-14 14:34 GMT+03:00 Romain Francois rom...@r-enthusiasts.com: Or just use a std::vectordouble for sg. That should do it. Romain Envoyé de mon iPhone Le 14 juil. 2015 à 13:21, JJ Allaire jj.alla...@gmail.com a écrit : The examples in the

Re: [Rcpp-devel] When calling same Rcpp function several times different results are returned

2015-07-14 Thread Romain Francois
Or just use a std::vectordouble for sg. That should do it. Romain Envoyé de mon iPhone Le 14 juil. 2015 à 13:21, JJ Allaire jj.alla...@gmail.com a écrit : The examples in the RcppParallel documentation assume that access to vectors and matrixes are *aligned* (i.e. fall into neat buckets

Re: [Rcpp-devel] When calling same Rcpp function several times different results are returned

2015-07-14 Thread JJ Allaire
The examples in the RcppParallel documentation assume that access to vectors and matrixes are *aligned* (i.e. fall into neat buckets whereby reading and writing doesn't overlap between worker instances). Your example appears to access arbitrary elements of sg (depending on what's passed in gi)