[Rd] using a "third party" DLL in my package

Liaw, Andy andy_liaw at merck.com
Wed May 27 14:58:42 CEST 2009


I don't know if this applies to Seija's case, but one instance that I've ran into when problem arose only with -O3 is uninitialized variables/arrays.  Adding the initialization fixed the problem.  Just one thing to check, I guess.

Best,
Andy

From: Prof Brian Ripley
> 
> It is likely that this is related to using higher-precision FPU 
> registers, in which case there is a portable solution: look up 
> SAFE_FFLAGS in 'Writing R Extensions'.
> 
> But if that is the cause, the real solution is to write the 
> code using 
> proper convergence tests.
> 
> On Sat, 23 May 2009, Kasper Daniel Hansen wrote:
> 
> >
> > On May 20, 2009, at 4:32 , Seija Sirkiä wrote:
> >
> >> Hello again,
> >> 
> >> thank you for the comments, especially this one:
> >> 
> >> Prof Brian Ripley wrote:
> >> 
> >>> My concern would be that there are different cases that fail under
> >>> Fortran compiler X and you are just sweeping the problem under the
> >>> carpet.
> >> 
> >> It inspired us to go back to search the cause, and we've made some 
> >> progress: it's not the compiler, it's the compiler 
> options. Simple, but it 
> >> took a while to figure that out since my experience in 
> these things is 
> >> limited. When I build the package with default options 
> using INSTALL 
> >> --build the dll is built with option -O3 as per R's 
> Makeconfig file. If I 
> >> build the dll by hand, using gfortran with no additional 
> options and 
> >> dyn.load it, everything works, and also with -O and -Os. 
> (No, I don't fully 
> >> understand what the differences between all these are, but 
> that's another 
> >> question).
> >> 
> >> I'm looking at chapter 5.5 in Writing R Extensions and 
> also 6.3.3 in R 
> >> Installation and Administration but I can't figure out how 
> to tell "inside" 
> >> my package that it is not to be built -O3 but with, say, 
> -O. I can see how 
> >> to add flags in the package (and as far as I can tell, if 
> there are several 
> >> optimization level flags the last in line is used and 
> that's the wrong one 
> >> from my point of view), and also how to override flags but 
> only on my 
> >> computer. Am I blind or am I again attempting something I 
> shouldn't?
> >
> >
> > This is not trivial, and how you do it is compiler 
> dependent. A quick fix was 
> > provided by Simon Urbanek a while back and it is _not_ 
> portable, it assumes 
> > you are using GCC. It would be nice to have a configure 
> file that detects the 
> > compiler and optimization setting and then re-sets the 
> optimization level. I 
> > have thought about writing one, but have never got around to do it.
> >
> > Anyway, the fix is in the Makevars file from affxparser 
> from Bioconductor. 
> > Essentially, you use a Makevars file placed in the src 
> directory, containing
> >
> > MYCXXFLAGS=-O0 -Wall
> >
> > %.o: %.cpp
> >       $(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) $(MYCXXFLAGS) 
> -c $< -o $@
> >
> > Essentially this makes sure that -O0 (indicating no 
> optimization) is placed 
> > at the _end_ of the call to the compiler (this is for C++ 
> files btw), using 
> > the fact that if you have two -O* settings, the last one 
> overrides the first.
> >
> > This ought to be easily adaptable to FORTRAN.
> >
> > Kasper
> >
> > ______________________________________________
> > R-devel at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-devel
> 
> -- 
> Brian D. Ripley,                  ripley at stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272866 (PA)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
> 
Notice:  This e-mail message, together with any attachme...{{dropped:12}}



More information about the R-devel mailing list