-
Notifications
You must be signed in to change notification settings - Fork 417
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
Consider "-inl.h" design pattern to reduce compile time for templated code #160
Comments
I like this idea! I've been looking for a way of reducing the compilation time after I experienced dramatically increased compilation time with #154. I proposed minimizing exposing API to users using One concern with this design pattern is that FCL wouldn't be a header-only project, which I was intended for the next work. But now I think reducing compilation time is more worth and don't have a compelling reason for making FCL header-only project. |
Yeah, I agree I think with this design pattern FCL could be used header-only, if people use the |
We could consider explicitly instantiating for |
Actually for explicit instantiations it wouldn't be unreasonable to simply instantiate for |
@jslee02, Jeremy Nimmer asserts that he used |
If it's an industry standard then I'm okay with it. I don't have a strong preference here. |
I don't like to argue over naming, but if it's an industry standard and used in open source software, then it should be easy to find examples that use this convention. |
Googling for "template inl.h instantiation" does pull up a lot of uses, including a mention in the Google Style Guide, basically to say "don't do this" (but they aren't talking about this specific problem). |
Searching the ubuntu packages database, I see it in nodejs, unity, gtest, and mongodb. So it is in use in some well-known projects. |
Interestingly I got 1,260 results for |
Anyways, I created a pull request for this. Feedback is welcome! |
I saw that too but then when I looked closer Google had apparently dropped the ".h" and matched lots of things containing the word "implementation"! |
I believe this is addressed by #165. |
After PR #154 lands, most FCL code is templatized by scalar type. In normal use it will almost always be instantiated with
double
(maybefloat
). The more elaborate instantiations needed for autodifferentiation will be rare, so most user code needs only declarations for theT=double
case and doesn't need to have access to the definitions of the templatized methods, which are expensive to compile.In Drake we use this design pattern to hide the definitions from compilation units that don't need them. Then we explicitly instantiate the most common
T=double
case in library code. So user code normally includesblah.h
; code that needs to make its own instantiation includesblah-inl.h
.We should consider this for FCL also to lighten the compilation load, reduce code bloat, and hide implementations when possible.
The text was updated successfully, but these errors were encountered: