[R] DLL Advice

Jason Fisher stormplot at hotmail.com
Wed Feb 26 20:58:03 CET 2003


Hi All...

A few questions concerning the use of DLLs in R.  Before you get scared off 
and don’t read any further (I’ve seen a lot of talk within the help pages 
concerning loading DLLs in R) realize that communication between R and my 
DLLs is solid.  The problem arises when comparing the computational 
performance between calling a *.dll file, compiled using g77 under MinGW 
version 2.0.0 with package upgrades, and calling an *.exe file, compiled 
with Compaq Visual FORTRAN Professional Edition 6.6.A.  Both calls (.Fortran 
and system) are made from the R - Tcl/Tk GUI environment.  After comparing 
identical code, compiled as a DLL and EXE, I’ve come to the disappointing 
realization that the DLL calls take about five times the computational time 
of the EXE calls.  I tried the experiment using a number of different 
FORTRAN codes with the same results.

My first thought was that I was compiling the code incorrectly.  The 
following command is what I typically use to generate the DLL.

g77 –shared –o temp.dll temp.f

After a short search over the net, I discovered a number of g77 optimization 
options (e.g. –O, –O2) for compiling.  These options had little to no impact 
on the computational times.  Next, I went back to “Writing R Extensions” and 
started working with the Rcmd SHLIB.  This again had little to no impact on 
computational time.

Any ideas, I’m a novice at working with DLLs and know there must be 
something I’m missing.  One option is to just call the EXE, however, it just 
seems crummy to generate an input file in R, run the EXE which produces an 
output file, read the EXE output file in R, and finally delete the input  
and output files.

Thanks in advance for any insightful knowledge you bring my way.

Regards,
Jason

R 1.6.2

***************************************
Jason C. Fisher
UCLA Graduate Student
Civil & Environmental Engineering Dept.
5731 Boelter Hall
Box 951593
Los Angeles, CA 90095-1593
Phone Number: (310) 825-2292
Email: stormplot at hotmail.com




More information about the R-help mailing list