-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
world counter problem calling Julia functions from inside cfunctions (since pull #17057) #19790
Comments
duplicate of #19774 ? |
Yes, this is a duplicate. For now, the workaround is to use |
Note that for this usecase, you should not cache the cfunction yourself. |
Sorry, yuyichao, I don't understand your comment (but I want to understand it):
Are there better ways to do this? |
Yichao is suggesting that it is unnecessary to cache the cfunction in a global |
Right. I've just realized that typeinf is not handling that correctly so I'm trying to fix that. |
See JuliaMath/Cubature.jl#23 for what I think packages with a similar usage should do. The integrands function in that PR should be compiled to returning one of 8 constant pointers and it should be automatically recompiled when new functions are defined. |
I think I've understood your idea now and the impact (now julia knows at compile-time what to do for Thank you very much |
I cooked up a minimal example (a modified example from the julia docs) in order to show my problem:
One gets the output:
Yes in the (constructed) example above, one can use the workaround to define
mycompare
beforemycustomsort_c
. But in real world examples this is not always possible.Real world example: I'm the author of the ODEInterface package (available for Julia v0.4, v0.5, and trunk before 23.12.2016). There the idea is, that the user can write julia functions (e.g. the right-hand side of an ODE) and give this julia-functions to the ODEInterface. Inside the ODEInterface Fortran codes are called. These Fortran-Codes call Callback-functions that (in my case) are cfunctions of the ODEInterface that in turn try to call the user-given Julia function. Since Pull #17057 this is not possible anymore, because the ODEInterface (and hence the cfunctions) are typically loaded/compiled before the user defines the problems he/she wants to solve.
Any idea how I can solve this problem?
The text was updated successfully, but these errors were encountered: