unifhy-org / unifhy

A Unified Framework for Hydrology
https://unifhy-org.github.io/unifhy
BSD 3-Clause "New" or "Revised" License
12 stars 5 forks source link

Minimise number of regridding operations #47

Open ThibHlln opened 3 years ago

ThibHlln commented 3 years ago

At the moment in the Exchanger, the regridding is happening in get_transfer regardless of the temporal resolutions of the source and destination components.

When timestep of source < timestep of destination, it makes sense to regrid in get_transfer, but when timestep of source > timestep of destination, it would be better to regrid in set_transfer to avoid repeatedly regridding the same source value.

Here, by regridding, I mean the multiplication of the interpolation weights to go from one spatial resolution to another (not the calculation of the interpolation weights themselves, which is done only once per run in the framework since #43). So this is not the most expensive task to carry out, but still there is room for performance improvement by limiting the number of regridding operations.

ThibHlln commented 3 years ago

There is a memory tradeoff in implementing this.

At the moment, the transfers are stored at the source's spatial resolution, which means they only need to be stored once no matter how many destinations there are. If we are to do the remapping in set_transfer when timestep of source > timestep of destination, we will need to duplicate the information coming from source to be stored at the potentially different destinations' spatial resolutions.

So not sure whether it is worth it?