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

stanheaders seems to rely on outdated tbb header file task_scheduler_init.h #1101

Open
tillea opened this issue Oct 25, 2023 · 7 comments
Open

Comments

@tillea
Copy link

tillea commented Oct 25, 2023

Summary:

This report is about stanheaders. Actually the issue occures on the Debian packaged source that is available at CRAN. It is using a header file that was available in the Debian packaged TBB library of version 2020.3 but droped in 2021.4.0 (together with the rename to onetbb which has broken the old tbb interface).

My attempt to build rstanarm ended up in

/usr/lib/R/site-library/StanHeaders/include/stan/math/prim/core/init_threadpool_tbb.hpp:12:10: fatal error: tbb/task_scheduler_init.h: No such file or directory
  12 | #include <tbb/task_scheduler_init.h>
     |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
 compilation terminated.

since the header file task_scheduler_init.h does not exist any more in onetbb since 2021.

Description:

The issue becomes visible in different ways when StanHeaders is used. There is a complete build log when trying to build rstanarm (which reproduces the code cited above). You can also have a look at the complete build log od rstan in the CI of the rstan Debian package.

The following bug reports in Debian seems to be closely related to the outdated tbb interface:

Reproducible Steps:

You should be able to reproduce the issue when creating a Debian unstable (== sid) container / chroot and build the packages r-cran-rstan or r-cran-rstanarm.

RStan Version:

  • StanHeaders: Version: 2.26.28
  • rstanarm: 2.21.4 (This has built before for whatever reason. For the moment I can't build it due to the requirement of higher version of rstan which does not build)
  • rstan: 2.32.3

R Version:

Debian package of version 4.3.1

Operating System:

Debian unstable

@WardBrian
Copy link
Member

Stan can be compiled against oneTBB by defining TBB_INTERFACE_NEW during compilation (I am not 100% certain that this is available in the current stanheaders, but it was starting in version 2.26 other places)

@tillea
Copy link
Author

tillea commented Oct 25, 2023

Well, to "compile" StanHeaders we have added -DTBB_INTERFACE_NEW. However, when using those headers for instance to build rstan I guess this has to be set as well. To test what I'm guessing I did a new build by setting -DTBB_INTERFACE_NEW also when building the r-cran-rstan package. Please have a look at the log when trying to build rstan. It reproduces the two related bugs I've mentioned above:

g++ -std=gnu++17 -I"/usr/share/R/include" -DNDEBUG -DTBB_INTERFACE_NEW -I"../inst/include" -I"../inst/include/boost_not_in_BH" -I"/usr/lib/R/site-library/StanHeaders/include/src" - DBOOST_DISABLE_ASSERTS -DBOOST_PHOENIX_NO_VARIADIC_EXPRESSION -D_REENTRANT -DSTAN_THREADS -DUSE_STANC3 -DSTRICT_R_HEADERS -D_HAS_AUTO_PTR_ETC=0 -I'/usr/lib/R/site-library/Rcpp/         include' -I'/usr/lib/R/site-library/RcppEigen/include' -I'/usr/lib/R/site-library/BH/include' -I'/usr/lib/R/site-library/StanHeaders/include' -I'/usr/lib/R/site-library/RcppParallel/   include'    -DSTRICT_R_HEADERS -fpic  -g -O2 -ffile-prefix-map=/build/reproducible-path/r-base-4.3.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -           D_FORTIFY_SOURCE=2   -c Module.cpp -o Module.o
In file included from /usr/lib/R/site-library/StanHeaders/include/stan/math/prim/core.hpp:4,
                 from /usr/lib/R/site-library/StanHeaders/include/stan/math/rev/core/Eigen_NumTraits.hpp:5,
                 from /usr/lib/R/site-library/StanHeaders/include/stan/math/rev/core/typedefs.hpp:7,
                 from /usr/lib/R/site-library/StanHeaders/include/stan/math/rev/core/chainable_object.hpp:6,
                 from /usr/lib/R/site-library/StanHeaders/include/stan/math/rev/core.hpp:10,
                 from /usr/lib/R/site-library/StanHeaders/include/src/stan/model/model_base.hpp:5,
                 from Module.cpp:2:
/usr/lib/R/site-library/StanHeaders/include/stan/math/prim/core/init_threadpool_tbb.hpp:1: error: unterminated #ifndef
    1 | #ifndef STAN_MATH_PRIM_CORE_INIT_THREADPOOL_TBB_HPP
      |

Any idea what might be wrong here?

Kind regards, Andreas.

@tillea
Copy link
Author

tillea commented Oct 26, 2023

Thanks to Nilesh Patra this was solved in this patch

@SteveBronder
Copy link
Contributor

Thanks @tillea I think we should add that patch to stan math I'll open up a PR for that

@WardBrian
Copy link
Member

It’s already in Stan math, it was a backport

@tillea
Copy link
Author

tillea commented Oct 26, 2023 via email

@WardBrian
Copy link
Member

My understanding is that the next version of stanheaders uploaded to cran is intended to be 2.32, which would include this fix

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

3 participants