How does cache works in JuliaDiffEq?

Hi,

I am trying to understand the internal of JuliaDiffEq package. I have encountered many files names sth_cache.jl. Can anyone explain to me what do these files do and why we need it? I tried to find the explanations in the document but I came up with nothing.

It is documented very briefly here. The gist is that one can allocate all the cache arrays only once and put them into a mutable cache, so when the integrator performs the stepping, it won’t have any memory allocatation. For instance, the RK4 mutable cache has fsalfirst(k1), k2, k3, k4 and k for derivatives, tmp for temporary evaluations, and atmp for the error estimation.

However, sometimes users may not want to mutate the cache arrays (e.g. one might use SVector or a scalar in the out-of-place form of the derivative function u' = f(u,p,t)), hence the constant cache.

Hopefully, this clears some confusions that you have.

2 Likes