-
-
Notifications
You must be signed in to change notification settings - Fork 79
Improve wrappers, add handles and NVector #67
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
Conversation
Thanks! This sounds like a big step forward. I can't have a look at it On Wed, 20 Jul 2016 at 16:30, Alexey Stukalov [email protected]
|
@alyst : Thanks again for pushing this! The CIs fail because it seems that you have removed |
@acroy I don't know actually why CI complains, because autogenerated |
The CI error is indeed strange. Does it run locally for you? I guess you could check if the old code runs as it is by trying the examples? How about putting the underscored functions into a (sub)module? |
@acroy I can put low-level functions to a submodule (then the underscores would not be necessary), but the downside is that then you would have to look at two different places in case there's any problem. |
I tried it locally and get the same error. The problem is that you renamed
True, but I think it would be cleaner. If the old code is not broken I don't have a strong preference though. Maybe we should check if there is some sort of convention ... |
@acroy Thanks, indeed
I'm not sure it would be cleaner. There would be issues with type definitions ( |
Great. Let's see what Travis CI has to say (the AppVeyor failure seems unrelated). Have you tried if the examples are still working? |
@acroy I've just added more examples to the |
@alyst : Thanks! I agree that sorting out all the wrapper issues is beyond the scope of this PR (maybe you could open an issue once this is merged). The important thing is that the example code works. I am a bit puzzled by the failure of the CIs - although it seems to be unrelated? |
Bump. I've just fixed a few 0.5 issues (the same way that #72 does it), so now all CI configurations are green. |
Could you rebase once more? If CIs pass I am +1 for merging, but maybe someone else could have a look as well as the changes are quite substantial. |
- update wrapper generator script to replace Ptr{Void} with the typed pointer (e.g. CVODEMemPtr) in the cfunction declaration - correct constants (e.g. CV_SUCCESS) type (should be Cint) - the result of the wrapper script doesn't need further manual editing - rename sundials_h.jl to types_and_consts.jl, remove constants.jl - don't wrap _impl.h headers
Rebased. The tests pass except for coverage noise. I have to say, I will give up rebasing it soon. But when I just have rebased today after being asked by @acroy , I have found that I have to do it again, because of the c4f46b2 appearing out of the blue. I have introduced substantial changes taking into account that recently the rate of commits was rather low. I'm afraid I would not be able to keep up with the master, if that would change. |
644d698
to
00e5979
Compare
creates NVector that doesn't own N_Vector
this should prevent N_Vector being destroyed before/during Sundials call also auto-convert Cint arguments
It could be that the segfault was triggered by GC running immediately before the low-level Sundials call or during the call (in a user function). At that time the intermediate At least Travis doesn't fail for 2 times in a row. |
@alyst : Great job! Everything seems to work now. Looking at the examples I realized that they need some cleanup, but this should be done separately. I would suggest that someone tags the current master, merges this and we see how it goes. |
* don't use nvector() as it's dangerous * use convert(Vector, ) * use @checkflag * transpose result matrix for memory efficiency * misc code cleanups
* add comments and status messages * don't cd() to the directory where the headers are generated * don't require JULIAHOME env variable
I don't really have the bandwidth to review all of this. It looks reasonable at a glance, but is definitely worth at least a new minor version on the first tag that includes it. |
So to move on the current master should be tagged (as it contains 0.5 compatibility fixes). Then this PR gets in (fingers crossed). Then the new minor version is tagged. |
I would tag e3cbb09 rather than master, since that last commit is a bit of a change. |
I would be a good idea to tag a new version on METADATA. I just got bit by the memory leak this PR fixed. |
We want to do #75 first to clean up the API, and I got caught up for a little bit. |
This is a "loose" rebase of #29 to the master. So it has the same goal (avoid memory leaks by enabling some automatic memory management on the Julia side) but does it a little bit differently.
NVector
code (theN_Vector
wrapper that manages the memory) is mostly taken from WIP: Add types to facilitate release of memory via finalizers. #29Handle
concept (CVODEMem, IDAMem, KINMem wrapper that calls appropriateXXXFree()
methods upon finalization) generalizes similar idea from WIP: Add types to facilitate release of memory via finalizers. #29 by using type parametersHandle
andNVector
and provide more Julia-friendly methodsN_Vector
, the generator automatically adds higher-levels wrappers that provide automatic conversion of Julia objects (Handle
,NVector
,Vector
) into appropriate low-level typesuser_data
is of typeAny
to facilitate passing Julia objects directlyxxx_impl.h
headers) are not wrappedN_Vector
is wrapped (parallel one is not)With these changes I was able to fix the
N_Vector
memory leaks in my Sundials-using code.But there must be a lot of issues with the current state of the PR (e.g. lifetime of
NVector
s that are implicitly generated by "higher-level" wrapper functions), so any comments and suggestions are welcome.cc @acroy @stevengj