Open kurt-o-sys opened 4 years ago
Hello,
thank you for reaching to us. The list of unimplemented built-ins is not up to date (and we should fix that). However, we only use it to check if we cannot find given built-in implementation in FastR: then we need to report either "unimplemented builtin" or "wrong builtin" and we use this list to distinguish the two. If the builtin is implemented, we do not even reach that point.
That being said, there are unimplemented built-ins in FastR, like the one you've come across. We are implementing them on per needed basis. I cannot give you concrete ETA for individual builtins. The La_xyz
built-ins usually down-call to native code from blas/lapack, e.g.: La_svd
in https://github.com/oracle/fastr/blob/master/com.oracle.truffle.r.nodes.builtin/src/com/oracle/truffle/r/nodes/builtin/base/LaFunctions.java#L817
So, in short, La_dlange
is really not implemented yet?
I cannot find an inner class annotated with @RBuiltin(name = "La_dlange" ...)
, but there are calls to @Child private LapackRFFI.DlangeNode dlangeNode = LapackRFFI.DlangeNode.create();
. Does that mean that it about writing a kind of wrapper class around that LapackRFFI.DlangeNode?
Does that mean that it about writing a kind of wrapper class around that LapackRFFI.DlangeNode?
Yes. DlangeNode
calls into the Lapack routine, which is piece of code unaware of the rest of R and operates only on primitive C arrays. The built-in La_dlange
works on R objects: it validates its arguments, converts the R vectors to primitive arrays, calls the Lapack routine and converts the results back to R objects. This is what most of the RBuiltin
annotated classes in LaFunctions.java
do.
The built-in in GNU-R is here: https://github.com/wch/r-source/blob/R-3-6-branch/src/modules/lapack/Lapack.c#L333. Basically we need to check if the first argument is matrix and coerce it to a real matrix and that the second one is a character vector and then pass the right arguments to DlangeNode#execute
.
Note that we use our own thin wrappers around the C/Fortran routines: https://github.com/oracle/fastr/blob/master/com.oracle.truffle.r.native/fficall/src/truffle_common/lapack_rffi.c#L123, so DlangeNode
interface is not exactly the same as the dlange
native routine.
The classes annotated with @RBuiltin
are registered in BasePackage
.
Allright, thx for the info. I guess I'll just have to wait and hope someone makes this work.
After installing the
quadprog
andNlcOptim
package, and trying to run a solver:It seems some internal calculation, used to calculate the
norm
of a matrix, is not implemented (which somehow seems pretty weird to me). InNlcOptim::solnl
, there are a few calls to the Rnorm
function, e.g. https://github.com/cran/NlcOptim/blob/master/R/NlcOptim.R#L506 (this is where fastr seems to fail, but there are other paths as well that use thenorm
function):If I check the sources of
norm
:== EDIT: added more info
so, checking the source
https://github.com/oracle/fastr/blob/3e4189b7fe018edd4e8f7ec15ae70059f34710c1/com.oracle.truffle.r.nodes/src/com/oracle/truffle/r/nodes/builtin/InternalNode.java#L442
, it seems many symbols seem not implemented. Is there any particular reason or eta for many of them (excluding things like the distribution functions, since they are used in a different way and it actually doesn't matter for these):