From edd at debian.org  Mon Nov 11 03:33:55 2013
From: edd at debian.org (Dirk Eddelbuettel)
Date: Sun, 10 Nov 2013 20:33:55 -0600
Subject: [Rd] Embedded R Fails When Run on LSF Queue System
In-Reply-To: <BAY404-EAS314A9EF4CC4090675818BF6E5FF0@phx.gbl>
References: <BAY176-W4686BF21116D18A83FEBE5E5FC0@phx.gbl>
	<21120.14264.657609.673673@max.nulle.part>
	<BAY404-EAS314A9EF4CC4090675818BF6E5FF0@phx.gbl>
Message-ID: <21120.16915.796106.939233@max.nulle.part>


On 10 November 2013 at 21:13, Nigel Delaney wrote:
| Thanks Dirk.  I'll confess I am mostly trying to follow the practices
| outlined in the writing R-extensions manual and books by Chambers and
| Gentleman, but  have found some conflicting advice on the internet in
| various places, and am also trying to build off a previously existing code
| base (that at least worked on some
| operating-systems/architectures/scenarios, but seems to break when I move
| the program around to any new type of environment).  Will definitely
| re-write that bit.

I had it easier :)   When we started littler, Jeff had already worked out all
embedding kinks via his rApache project.  RInside is a port / rewrite of the
same logic to C++ from the C used in littler.

| Sincere thanks again.  Out of curiosity, can I ask one more question since I
| gather you have much more expertise than myself?  The extension manual has a
| somewhat obscure, to me at least, section on threading issues (8.1.5).  My
| understanding is that because the R_CStackStart is a single value, if R is
| called from multiple threads (even if never simultaneously), it is
| essentially best to just disable the stack check rather than try to re-write
| this value each time, which I gather might need to be done (and simply
| increasing the stack size of the calling thread will not help).  Is this the
| approach you have taken in your projects?  Or do you think this is also a
| bad idea?

Yep. Just a set a big fat mutex before you start multithreading, never ever
call anything that could touch R, thne release the mutex when you're done and
continue single-threaded.  I know of no other sane way.

Dirk

-- 
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com



[Rd] Embedded R Fails When Run on LSF Queue System
Dirk Eddelbuettel