Moving from `Float64` to `Float32` not improving performance

If you do not run this on a GPU you will not gain anything much from Float32. See e.g. these discussion about it Why no Float type alias?

I just took a glance into your code and stumbled over:

  • Why is function get_mb(heights) local in function function glacier_evolution_optim. Why not just a global function with additional parameters ela_h and mb_grad ?

  • And I see those collect`s like

years = collect(0:(n_years+1))

Later you do

for (i, y) in enumerate(years)

but you don’t use i (perhaps I missed it?), so perhaps just a

years = 0:(n_years+1)
for y in years
...

will do.

  • The purpose of those let 's is not clear to me. Perhaps you developed those parts in the REPL where you needed them for scope issues. You don’t need them in the function body.

I don’t know if those issues help for performance, I didn’t try to run your code. But cleaning it up from not needed structures will help a lot to get people into the maximize-performance-game.

2 Likes