Metaprograms are properly flattened for prim and the same script should work for fwd, rev and mix. Here’s a hacked script, that’s much uglier than Ed’s: flatten_prim_meta.sh
All that’s left to do before I open the prim PR is write tests for the rest of meta (I think there are 4).
There’s also files that weren’t moved by Ed’s script for whatever reason (probably about 20, I have a list compiled), that I’ll either write a bash script to flatten them or do it manually, whatever’s faster.
~~
I’m very, very afraid of destroying Stan. After I get prim working I’m going to do Stan-dev/Stan’s compile model tests to make sure no compilation breaks.
Can anyone with more experience suggest anything else to test at a higher level before the PR goes through? The math tests can compile and the language @ all devs who touch stan-dev/math and stan-dev/stan.
Should I do any testing for the stanc3 ocaml compiler? @seantalts
This won’t be done this week. I’m still weeding through 100’s (or more) of compiler errors after “flattening” prim. They can take anywhere from a few seconds to hours for me to figure out. I’m just going through one at a time, fixing it in one case, and then writing a script that fixes it everywhere else in the library.
I’ve been ignoring this because it was frustrating. I’m introducing more “tangles” by trying to do prim separately. I was trying to be nice and easy to work with, but this has the unfortunate consequence of wasting time.
I’m going back to using Roualdes’ script (because stuff was actually compiling and tests passing when we did everything at once), and then I’ll do the Seam for meta after.
If anyone has time and wants to take a look, for whatever reason ./runTests.py test/unit/math/rev/vectorize/apply_scalar_unary.hpp isn’t finding Eigen::Internal. I’ve tried explicitly including some stuff directly from Eigen, but no luck. I’ll come back to it. Probably something like re-ordering includes may help.
I think the first, apply_scalar_unary.hpp, shouldn’t include <Eigen/Dense> directly – it should be including our headers.
The third, acosh.hpp, that shouldn’t be including prim.hpp. It should only include the headers for these things: check_greater_or_equal, apply_scalar_unary, and <cmath>.
That’s huge! Thank you so much @anon79882417, @roualdes, and @syclik. I’m so excited - this is going to make development and developer onboarding so much simpler going forward. I owe you all a tasty beverage!
Yeah, tomorrow/this weekend I’m looking at editing @roualdes script to include some missing ifdefs then avoid the meta areas, and only act on prim. If we’re lucky, after some manual editing were good to go. But most likely not that lucky
@anon79882417 I merged PR #1234 that cleans up the metaprograms a bit. I will pause my meta PRs that I have been doing under issue #1122 until the meta flattening refactor happens. This last one was open before the flattening refactor started and I wanted to close it before it happens.
I’m giving it another shot today. Yesterday I tried naively combining some of the meta files, but when I remove the mat/scal or arr from the pathway of a single include in meta.hpp, there are “over includes” (some of the same files being included more than once) and the compiler flips.
So today, I’m aiming to reduce dependencies by doing some of the following, in no particular order: 1. Remove meta.hpp includes from mat.hpp, scal.hpp, arr.hpp; 2. only include arr.hpp in all files (so we’re not over including, and this should be fine because arr.hpp includes mat.hpp includes scal.hpp), etc, etc… things like that. just generally try to untangle dependency structure.