-
Notifications
You must be signed in to change notification settings - Fork 2
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
Making use of state to accelerate calls like energy_forces
or calculate((Energy(), Forces()), ...)
in default implementation
#27
Comments
The default implementation of calculate should already transfer state for following call function calculate(properties::Tuple, sys, calc, params=nothing, state=nothing; kwargs...)
out = Dict{Symbol, Any}()
out[:state] = state
for property in properties
tmp = calculate(property, sys, calc, params, out[:state]; kwargs...)
for (k,v) in pairs(tmp)
out[k] = v
end
end
return NamedTuple(out)
end If that does not happen in practice, it is a bug. The combination call For I currently don't know how to solve this "nicely". One option would be to have the macro cover this also, but I am not sure can it be done. In any case, I know this is an issue and I have been thinking about it, but I don't have solution to it yet. So, at this moment, if you implemet calls that optimise combination calls, it is up to you to implement them. |
Indeed it does work in the current version, sorry. I think I looked at old code. Regarding what you mention with the high versus low level issue. Would it not work to have a macro to generate appropriate fallback functions for the low-level implementation pattern and one macro for the high-level implementation pattern. What I'm thinking is that instead of a |
The default implementation of calls like
energy_forces
orcalculate((Energy(), Forces())
do not allow us to make use of astate
in DFTK to reduce the computational burden on the second call (force computation). This should be done in the default implementation automatically. Essentially I suggest:energy_forces
should dispatch to the low-level interface (calculate((Energy(), Forces())
)calculate(::Tuple )
should transfer the state when dealing with one tuple element to thecalculate
call when dealing with the next.The text was updated successfully, but these errors were encountered: