[Rd] error code 1 from Lapack routine 'dsyevr'
Hi, I got an error message in my program saying "Error in eigen(gene_intersection.kernel) : error code 1 from Lapack routine 'dsyevr' Execution halted". As you see, I was trying to compute the eigenvalues of a matrix but got this error. Is there anyone who knows what this error means and how I can fix it? Theoretically the eigenvalues should be nonnegative, if it helps. Thank you! -- View this message in context: http://r.789695.n4.nabble.com/error-code-1-from-Lapack-routine-dsyevr-tp4702571.html Sent from the R devel mailing list archive at Nabble.com. __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
[Rd] invoking R function in C++ in parallel
Hello, I'm writing an R extension in C++. In the extension, I want to invoke an R function directly and it works when I use Rcpp in the serial code. But what I really want is to invoke the R function in parallel with openmp. When I do so, I got segmentation fault. I remember someone said that R isn't thread-safe. I think it's also understandable because an R function also has environment variables. My question is: Can we make a copy of an R function (including its environment variables) for each thread? Are there any ways to invoke an R function in C/C++ in multiple threads safely? Thanks, Da __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] invoking R function in C++ in parallel
On 31 January 2015 at 18:30, Zheng Da wrote: | I'm writing an R extension in C++. In the extension, I want to invoke | an R function directly and it works when I use Rcpp in the serial | code. But what I really want is to invoke the R function in parallel | with openmp. When I do so, I got segmentation fault. | | I remember someone said that R isn't thread-safe. I think it's also | understandable because an R function also has environment variables. | | My question is: | Can we make a copy of an R function (including its environment | variables) for each thread? Nope. And you pretty much just explained why. You can - 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 - or work via, say, the parallel or Rmpi packages in multiple _processes_ each of which could call its corresponding R interpreter (but that is still slower). There are some examples for OpenMP at the Rcpp Gallery: http://gallery.rcpp.org. You may also enjoy the RcppParallel package. But none of this overcomes your main hurdle: no, you cannot call R from different threads. | Are there any ways to invoke an R function in C/C++ in multiple threads safely? No. It is a design constraint. Dirk -- http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] invoking R function in C++ in parallel
On Sat, Jan 31, 2015 at 7:05 PM, Dirk Eddelbuettel 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). This is pretty restrictive, but could be enough in some cases. Gabor [...] [[alternative HTML version deleted]] __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] invoking R function in C++ in parallel
On 31 January 2015 at 19:29, Gábor Csárdi wrote: | On Sat, Jan 31, 2015 at 7:05 PM, Dirk Eddelbuettel 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 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 | e...@debian.org __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] invoking R function in C++ in parallel
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 wrote: > > On 31 January 2015 at 19:29, Gábor Csárdi wrote: > | On Sat, Jan 31, 2015 at 7:05 PM, Dirk Eddelbuettel 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 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 | e...@debian.org __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel
Re: [Rd] error code 1 from Lapack routine 'dsyevr'
On 31/01/2015 14:15, eigen wrote: Hi, I got an error message in my program saying "Error in eigen(gene_intersection.kernel) : error code 1 from Lapack routine 'dsyevr' Execution halted". As you see, I was trying to compute the eigenvalues of a matrix but got this error. Is there anyone who knows what this error means and how I can fix it? The help page for eigen says Source: By default ‘eigen’ uses the LAPACK routines ‘DSYEVR’, ‘DGEEV’, ‘ZHEEV’ and ‘ZGEEV’ LAPACK is from http://www.netlib.org/lapack> and its guide is listed in the references. You need to consult that guide and/or the source code: all I saw at a cursory look was *> \param[out] INFO *> \verbatim *> INFO is INTEGER *> = 0: successful exit *> < 0: if INFO = -i, the i-th argument had an illegal value *> > 0: Internal error *> \endverbatim so it means 'internal error'. Theoretically the eigenvalues should be nonnegative, if it helps. Thank you! -- Brian D. Ripley, rip...@stats.ox.ac.uk Emeritus Professor of Applied Statistics, University of Oxford 1 South Parks Road, Oxford OX1 3TG, UK __ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel