-
-
Notifications
You must be signed in to change notification settings - Fork 183
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
Untangles all of our includes! #254
Conversation
@bob-carpenter, I need to talk to you about how I allocated memory for the I'll leave a note on the particular line so you can see what I'm talking about. |
!is_constant_struct<T4>::value * length(x4) + | ||
!is_constant_struct<T5>::value * length(x5) + | ||
!is_constant_struct<T6>::value * length(x6)), | ||
all_partials(new T_partials_return[n_partials]), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bob-carpenter, this used to look like this:
all_partials(static_cast<T_partials_return*>
(vari::operator new
(sizeof(T_partials_return) * n_partials)))
Should I have left it alone? I was trying to trace back to a way to allocate on the right managed stack without having to touch anything in reverse mode (stan::vari::operator new
is in reverse mode).
Yes, that's bad news. For every Instead, how about just declaring (note the final
and then in the ctor, all you'd need is this:
That leaves the allocation up to Now if you want to write a mixed case, that could do the allocation back on vari, which should be more efficient. |
Ack, as I was closing that file I saw that you did the delete. That should be OK the way you have it. It might be more efficient than using a
At least that way, there's only one erroneous debug. So it really depends how safe you feel managing your own memory! |
Sorry, I should have made it clear that I deleted the memory in the destructor. I thought we would have been able to add things to another stack that we controlled without having to go through the reverse chainable, but I'm not realizing that we didn't expose anything like that. We'll talk tomorrow about it, but if you think it's ok, there shouldn't be anything else on this pull request that's questionable. Just a lot of rearranging the deck chairs. |
We could create another memory arena, but you'd have
|
That's what I assumed. I think the old code was error prone if it was allocating on the rev memory arena in forward mode if we never recover memory. Of course, we've never used forward mode in any of the production code, so it's a moot point.
|
Jenkins, retest this please. |
I just took another sweep of this changes and I think it's accomplished what I was shooting for. Could someone else take a look and not take my word for it? I've reworked code for |
I checked everything out and looked at it and grepped to make sure there weren't any cross-includes and that looks good. It looks like Even in scope, it's potentially volatile because further use of a It also doesn't look like you could do We already went through the OperandsAndPartials so that OK (at least by me). I made the doc changes and pushed so if it still passes it's ready to go as far as I'm concerned. |
I’ve always thought of the VectorViews as static, at least in how On Mar 16, 2016, at 2:53 AM, Bob Carpenter notifications@github.com wrote:
|
VectorView has const correctness (it had a template specialization for it before this pull request). But, it's functionality was extended at some point for use in OperandsAndPartials. (It could have been me) if we were to redesign it, which I would support, I would prefer simpler classes rather than a generic template implementation that covers many separate use cases.
|
Thanks for the updated doc, Bob. |
Fixes #246. Untangles all of our includes!
Summary:
This pull request untangles all of our includes.
For prim vs rev vs fwd:
For scal vs arr vs mat:
Most of this was just shifting code around. There were two major pieces that I had to rewrite in order to get this to work:
All tests still pass. This might reduce compile times a bit.
Intended Effect:
Detangle all our headers! Makes the math library easier to use. We can now maintain this going forward.
How to Verify:
Run tests. See VectorView and OperandsAndPartials to see if that makes sense. I added some more doc for those.
Side Effects:
Compile times might be slightly shorter!
Documentation:
Included.
Reviewer Suggestions:
Anyone.
P.S. Sorry for the really large number of files.