Re: [julia-users] Performant methods for enclosing parameters?

2016-08-25 Thread Yichao Yu
On Thu, Aug 25, 2016 at 5:19 PM, Chris Rackauckas wrote: > Oh it's that same issue? Thanks for pointing it out. That means every one > of my performance problems are due to the same issue... that's both a good > thing and a bad thing I guess. So would your suggestion just be

Re: [julia-users] Performant methods for enclosing parameters?

2016-08-25 Thread Chris Rackauckas
Oh it's that same issue? Thanks for pointing it out. That means every one of my performance problems are due to the same issue... that's both a good thing and a bad thing I guess. So would your suggestion just be to move forward doing things like this, knowing that this issue will get fixed? If

Re: [julia-users] Performant methods for enclosing parameters?

2016-08-25 Thread Yichao Yu
On Thu, Aug 25, 2016 at 4:12 PM, Chris Rackauckas wrote: > It seems like a closure on a non bitstype still has issues, or is there > something wrong with doing this? > > immutable Params > α::Float64 > end > > function test() > h = (t,u,du,p) -> @inbounds begin >

Re: [julia-users] Performant methods for enclosing parameters?

2016-08-25 Thread Chris Rackauckas
It seems like a closure on a non bitstype still has issues, or is there something wrong with doing this? immutable Params α::Float64 end function test() h = (t,u,du,p) -> @inbounds begin du[1] = 1.01u[1] du[2] = p.α*u[2] end h2 = (t,u,du) -> @inbounds begin du[1] = 1.01u[1]

Re: [julia-users] Performant methods for enclosing parameters?

2016-08-23 Thread Erik Schnetter
`gelelementptr inbounds` takes as input a pointer to a C struct (or equivalent) as well as the offset to a field in that struct, and returns the pointer to that field. It's how LLVM accesses fields in a struct. This usually becomes a single add instruction, and can often be folded into other

Re: [julia-users] Performant methods for enclosing parameters?

2016-08-23 Thread Chris Rackauckas
Oh, I see what happened... in my example I did h(u,t,α) = α*u α = 1.01 g = (u,t) -> h(u,t,α) but since α was also defined in the global scope, this picked up that global α and resulted in the horrible output. Sorry for making such a fuss! Makes me feel better to know that closures actually

Re: [julia-users] Performant methods for enclosing parameters?

2016-08-23 Thread Andrew
I tried moving k outside. julia> outside_k(u::Float64,t::Float64,α) = α*u outside_k (generic function with 1 method) julia> function test(α, k) G = (u,t) -> k(u,t,1.01) G2 = (u,t)->k(u,t,α) const β = 1.01 G3 = (u,t)->k(u,t,β) @code_llvm G(1., 2.)

Re: [julia-users] Performant methods for enclosing parameters?

2016-08-23 Thread Chris Rackauckas
In my scenarios, the function k is given by the user. So this method won't work. If you move that definition of k outside of test() and pass it into your test, you'll see that the LLVM code explodes (at least it does for me). The issue is defining a closure on a function which was defined

Re: [julia-users] Performant methods for enclosing parameters?

2016-08-23 Thread Andrew
I'm pretty confused about what you're trying to accomplish beyond standard closures. What is your ParameterHolder type for? I rewrote your first example wrapping everything in a function. Is this doing what you want it to? The LLVM looks fine. function test(α) k(u::Float64,t::Float64,α) = α*u G

Re: [julia-users] Performant methods for enclosing parameters?

2016-08-23 Thread Chris Rackauckas
Yes, I am looking for a closure which has the least overhead possible (this was all in v0.5). For example, for re-ordering parameters: g = (du,u,t) -> f(t,u,du), or for enclosing parameter values as above. I'll give the Val method a try and see whether the compile time is significant (it will

Re: [julia-users] Performant methods for enclosing parameters?

2016-08-23 Thread Erik Schnetter
Chris I don't quite understand what you mean. Are you looking for a closure / lambda expression? ```Julia function myfunc(x0, x1, alpha) f(x) = alpha * x ODE.solve(f, x0, x1) end ``` Or is it important for your that your function `f` is optimized, i.e. you want to re-run the code

[julia-users] Performant methods for enclosing parameters?

2016-08-23 Thread Chris Rackauckas
Note: This looks long, but really just has a lot of LLVM IR! I have been digging into the issue recently of the best way to enclose parameters with a function . This is an issue that comes up a lot with scientific codes,