[Rcpp-devel] Rcpp function results are different on different systems

Iñaki Ucar iucar at fedoraproject.org
Thu Aug 19 11:56:42 CEST 2021


On Thu, 19 Aug 2021 at 04:53, Dirk Eddelbuettel <edd at debian.org> wrote:
>
>
> Naeem,
>
> I would simplify, simplify, simplify -- as 'Rcpp FAQ 7.31' reminds us all,
> testing _equality_ of doubles is challenging anyway.
>
> Besides, it may make sense to would ascertain first you get what you want in
> _purely serial modes_ and then move to OpenMP.

Exactly. Serial execution should be fine. I.e., if you set the number
of threads to 1, then all platforms will return the same result.
However, you have defined a number of variables outside the parallel
region, and then you modify them inside the parallel region. OpenMP
takes those variables as shared by default, which leads to the
unexpected results you are getting. You need to tell OpenMP that those
variables are threadprivate. Or you could just define them inside the
parallel region, so that OpenMP knows that they are private without
additional hints.

-- 
Iñaki Úcar


More information about the Rcpp-devel mailing list