libgeodecomp icon indicating copy to clipboard operation
libgeodecomp copied to clipboard

Feature request: additional hook for Initializer after Initialization

Open klreuther opened this issue 5 years ago • 2 comments

The initializer is not only responsible for the creation of the grid, it also stores some information needed during the entire calculation run (e.g., the total number of steps). The initializer object is therefore persistent throughout the calculation.

If the initializer requires significant amounts memory for grid creation, an additional hook Initializer::gridInitializationDone() can signal it to free the initialization memory.

Exemplary call in libgeodecomp/parallelization/hiparsimulator.h:

231a232,233
>
>       initializer->gridInitializationDone();

Change to /libgeodecomp/io/initializer.h:

111a112,113
>     virtual void gridInitializationDone() = 0;
>

klreuther avatar Oct 16 '19 15:10 klreuther

As far as I see, the persistently needed methods of the initializer are only

  1. startStep()
  2. maxSteps()
  3. gridBox()
  4. gridDimensions().

IMHO these could just as well be parameters to the simulator itself which in turn passes it to the initializer. I am aware that this minor structural change requires adaptations of all codes using LGD, but a person can dream, no?

klreuther avatar Oct 16 '19 15:10 klreuther

In porting a code to use LibGeoDecomp I've found the need to enable resetting of maxSteps of an Initializer, and have implemented this by passing a new value from a Simulator to an Initializer in the following way: https://github.com/aproeme/libgeodecomp/commit/a81ed60085a4ac1e8f8af43262a13729b8168d60

I may not permanently rely on the ability to change these parameters via an existing Simulator, but could not see a better solution for the moment. It seems useful to be able to stage simulations by changing parameters via the Simulator, regardless of whether the parameters themselves are moved to live in the Simulators they initialise or whether they stay inside the original Initializer and are modified by passing new values through the Simulator, as I did for maxSteps and as suggested by klreuther.

aproeme avatar Jan 15 '20 20:01 aproeme