From zhengda1936 at gmail.com  Sun Feb  1 03:27:22 2015
From: zhengda1936 at gmail.com (Zheng Da)
Date: Sat, 31 Jan 2015 21:27:22 -0500
Subject: [Rd] invoking R function in C++ in parallel
In-Reply-To: <21709.33317.869936.212965@max.nulle.part>
References: <CAFLer83nzRs1cV7Cpu7VWUEDrqaSC7kjrUBbMUHzaFAp97DQGA@mail.gmail.com>
	<21709.28119.188963.170738@max.nulle.part>
	<CABtg=K=oxOB_w8-baCvS5SN+OkMR0k0KHGjwLT5HeTnDZqhrNw@mail.gmail.com>
	<21709.33317.869936.212965@max.nulle.part>
Message-ID: <CAFLer83PE1wSfsygS6dY2UXDv+X0DwiPV42ifQ=v6FA0F0EzHw@mail.gmail.com>

Thank you both.
I think I have got the answer I need.
I'll need to turn to another direction to search for my solution.

Best,
Da

On Sat, Jan 31, 2015 at 8:32 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
>
> On 31 January 2015 at 19:29, G?bor Cs?rdi wrote:
> | On Sat, Jan 31, 2015 at 7:05 PM, Dirk Eddelbuettel <edd at debian.org> wrote:
> | [...]
> |
> |     - either work in something like OpenMP and run in multiple threads that
> |        remain /completely/ shielded from R, ie no R calls, and not even R data
> |        types as you cannot trigger gc() calls from different threads
> |
> |
> | I think you can use R objects, as long as you don't call R functions on them
> | (not even from R's C api, although some of them are currently fine) and
> | consider them as read-only. E.g. if you have a numeric vector, you can do
> | double *cvec = REAL(vec);
> | and then use cvec in your thread(s).
>
> You and I are saying the same thing here: you call it read-only access; I
> called ot "do not use R types". We recommend the same approach in other
> places: instantiate std::vector<double> from RcppVector, don't use R calls.
>
> My recommendation is to make it pretty plain: do not call R functions. Use
> other types. There are equivalent read-only constructors for some relevant
> data types.
>
> Recall that OP, in the parts you chose not to quote, asked to call back to R
> in a multithreaded way. And we both say 'nope' here.
>
> All this has come up before on rcpp-devel and SO.
>
> Dirk
>
> --
> http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org



[Rd] invoking R function in C++ in parallel
Zheng Da