how to set compilation options for stan?

Open
#457 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
15/100
Issue type
Documentation
Clarity
Needs clarification
Activity status
Stale
Tech stack
cpp, r
Domain
build-system

Research direction

The question is whether ~/.R/Makevars is read at all, or whether -O2 is added later by rstan or rethinking. The compile line in the payload comes from the R build of rstan, so start with how ulam in rethinking invokes rstan and whether it passes its own flags. Check R_MAKEVARS_USER and the Makevars lookup order in R's documentation. Done means a written answer on which file controls CXXFLAGS and how to override it, ideally with a docs note in rethinking.

Written by the indexing model from the issue text.

Description

I've got the following:

[nawal@heisenbug:~/data/software-exercises/R]$ cat ~/.R/Makevars 
CXXFLAGS=-O0 -march=native -mtune=native -arch x86_64 -ftemplate-depth-256
CXX11FLAGS=-O0 -march=native -mtune=native -arch x86_64 -ftemplate-depth-256
CXX12FLAGS=-O0 -march=native -mtune=native -arch x86_64 -ftemplate-depth-256
CXX13FLAGS=-O0 -march=native -mtune=native -arch x86_64 -ftemplate-depth-256
CXX14FLAGS=-O0 -march=native -mtune=native -arch x86_64 -ftemplate-depth-256

But when ulam runs, I see the following:

nawal    2095081 68.6  3.5 574808 285348 pts/2   R    16:21   0:02 /nix/store/fg7ass3a5m5pgl26qzfdniicbwbgzccy-gcc-13.2.0/libexec/gcc/x86_64-unknown-linux-gnu/13.2.0/cc1plus -quiet -I /nix/store/4kbfmgdfg0h6zjd0kjayhsm314s3bmjn-R-4.3.3/lib/R/include -I /nix/store/6cn0x7wci7wa6vhhz07pvh7ziqaqimlb-r-Rcpp-1.0.12/library/Rcpp/include/ -I /nix/store/qfh1qgk5h4x34cfingbgl83wqrrd3fl8-r-RcppEigen-0.3.4.0.0/library/RcppEigen/include/ -I /nix/store/qfh1qgk5h4x34cfingbgl83wqrrd3fl8-r-RcppEigen-0.3.4.0.0/library/RcppEigen/include/unsupported -I /nix/store/ix342nzw09l2iqyss22scqq9fl4v1dy6-r-BH-1.84.0-0/library/BH/include -I /nix/store/hyiz44s2rciwdid2h847acw82z294ccd-r-StanHeaders-2.32.6/library/StanHeaders/include/src/ -I /nix/store/hyiz44s2rciwdid2h847acw82z294ccd-r-StanHeaders-2.32.6/library/StanHeaders/include/ -I /nix/store/dhlx17iaf7rark4lc7m3i2hvasz86191-r-RcppParallel-5.1.7/library/RcppParallel/include/ -I /nix/store/5n9f14hwzlwbrsw0jij876zba42277k5-r-rstan-2.32.6/library/rstan/include -D_GNU_SOURCE -D NDEBUG -D EIGEN_NO_DEBUG -D BOOST_DISABLE_ASSERTS -D BOOST_PENDING_INTEGER_LOG2_HPP -D STAN_THREADS -D USE_STANC3 -D STRICT_R_HEADERS -D BOOST_PHOENIX_NO_VARIADIC_EXPRESSION -D _HAS_AUTO_PTR_ETC=0 -D _REENTRANT -D RCPP_PARALLEL_USE_TBB=1 -include /nix/store/hyiz44s2rciwdid2h847acw82z294ccd-r-StanHeaders-2.32.6/library/StanHeaders/include/stan/math/prim/fun/Eigen.hpp -idirafter /nix/store/rzs2mn1lv3dsiyilygfz9vv1p8r36jvn-glibc-2.39-52-dev/include -idirafter /nix/store/fg7ass3a5m5pgl26qzfdniicbwbgzccy-gcc-13.2.0/lib/gcc/x86_64-unknown-linux-gnu/13.2.0/include-fixed -idirafter /usr/include file1ff5872073811a.cpp -quiet -dumpbase file1ff5872073811a.cpp -dumpbase-ext .cpp -mtune=generic -march=x86-64 -g -O2 -std=gnu++17 -fpic -o /tmp/cc3A9Lgb.s

i.e. -O2 instead of -O0. Is this something set in rethinking? Or does it mean R can't find the ~/.R/Makevars for some reason?

Dominant language
R
Stars
2.4k
Forks
632
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rmcelreath/rethinking

All issues in rmcelreath/rethinking

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.