Hi guys,
I’m learning Julia, and I’m trying to get things done “as Julian as possible”. My case scenario is HPC, so things have to be fast.
I’d like to preallocate work arrays that need to be used inside a function, e.g. f(u, wk1, wk2). Because this buffers are going to be allocated once and are only to be used internally by the function, i would like to keep them away from the final call and use “f” as f(u).
I thought of one ways, please let me know which are the advantages or disadvantages of using it, and/or if there are better ones
Currently I’m using a higher order function:
function GetF(N)
wk = zeros(N)
wk2 = zeros(N)
function F!(u)
# some amazing stuff that produces 0 allocations
end
return F!
end
F! = GetF(64) #F! Can be used
Thanks in advance!