Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Difficulties with isfinite() on Windows machines #347

Open
cschwarz-stat-sfu-ca opened this issue May 21, 2021 · 1 comment
Open

Difficulties with isfinite() on Windows machines #347

cschwarz-stat-sfu-ca opened this issue May 21, 2021 · 1 comment

Comments

@cschwarz-stat-sfu-ca
Copy link

Description:

Using the isfinite() function in TMB cases compiler error on Windows but not on Macintosh when using compile() in R

Reproducible Steps:

Here is my simple.cpp file>


#include <TMB.hpp>

template
Type objective_function::operator() ()
{

DATA_VECTOR( left ); // left and right values
PARAMETER( log_shape );

Type test;
Type test2;

test = pow(left(1)-log_shape,2);

test2 = isfinite(test);

ADREPORT (test);
REPORT(test);
return test2;
};

Here is my R code

library(TMB)
compile( "simple.cpp" ) # compile() is a function within the TMB library

dyn.load(dynlib("simple"))

simple.model <- MakeADFun(
data= list(left=10.1),
parameters=list(log_shape=3.1 ),
DLL="simple"
)

simple.model$fn(simple.model$par)

Current Output:

When running the R code on Macintosh

library(TMB)
compile( "simple.cpp" ) # compile() is a function within the TMB library
Note: Using Makevars in /Users/cschwarz/.R/Makevars
clang++ -I"/Library/Frameworks/R.framework/Resources/include" -DNDEBUG -I"/Users/cschwarz/Rlibs/TMB/include" -I"/Users/cschwarz/Rlibs/RcppEigen/include" -DTMB_SAFEBOUNDS -DLIB_UNLOAD=R_unload_simple -DTMB_LIB_INIT=R_init_simple -I/usr/local/include -fPIC -Wall -g -O2 -c simple.cpp -o simple.o
....
clang++ -dynamiclib -Wl,-headerpad_max_install_names -undefined dynamic_lookup -single_module -multiply_defined suppress -L/Library/Frameworks/R.framework/Resources/lib -L/usr/local/lib -o simple.so simple.o -F/Library/Frameworks/R.framework/.. -framework R -Wl,-framework -Wl,CoreFoundation
[1] 0

i.e. a successful compilation

When running the R code on Windows it terminates with
C:/Rlibs/RCPPEI1/include/Eigen/src/Core/CoreEvaluators.h:960:8: warning: ignoring attributes on template argument 'Eigen::internal::packet_traits::type' {aka '__vector(2) double'} [-Wignored-attributes]
enum {
^
make: *** [C:/PROGRA
1/R/R-41~1.0/etc/x64/Makeconf:245: simple.o] Error 1
Error in compile("simple.cpp") : Compilation failed

If you comment out the isfinite() statement it compiles fine.

TMB Version:

Mac: > packageVersion("TMB")
[1] ‘1.7.20’

Windows

packageVersion("TMB")
[1] ‘1.7.20’

R Version:

Mac: "R version 4.0.5 (2021-03-31)"

Windows: "R version 4.1.0 (2021-05-18)"

Operating System:

Mac: OS 11.3.1

Windows: Windows 8.1 Pro

Thanks
Carl Schwarz

@cschwarz-stat-sfu-ca
Copy link
Author

cschwarz-stat-sfu-ca commented May 24, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant