CliMA / ClimaCore.jl

CliMA model dycore
https://clima.github.io/ClimaCore.jl/dev
Apache License 2.0
79 stars 7 forks source link

Redefining operators in the same scope ressults in allocations #346

Open charleskawczynski opened 2 years ago

charleskawczynski commented 2 years ago

See this comment.

jakebolewski commented 2 years ago

I think the issue is that what you linked to is an alias for an abstract type (unionall vector for any FT) so it needs to be boxed, if it was a concrete bitstype the allocation should not happen I'm guessing.

This is why it is probably good to be wary of non-concrete aliases like this

charleskawczynski commented 2 years ago

Ah, whoops, well, I think this test doesn't use the union all type

jakebolewski commented 2 years ago

I guess i can see why one would potentially need to re-define operators with boundary conditions, but ones like these might be better to define once as a module const and use the same operator throughout the code.

My point is maybe we should prioritize where re-defining the operator is not possible.

charleskawczynski commented 2 years ago

I completely agree, I don't think this is a long-term issue for TurbulenceConvection.jl-- we should be able to easily fix anywhere that we hit this. I figure it's just helpful to keep the issue open for now so that people are aware.