Difference between revisions of "Adding requirements to the Cactus scheduler"

From Einstein Toolkit Documentation
Jump to: navigation, search
(Adding requirements to the Cactus scheduler)
(Suggested Solution)
Line 15: Line 15:
 
* Each scheduled routine declares which grid variables it reads and which grid variables it writes
 
* Each scheduled routine declares which grid variables it reads and which grid variables it writes
 
* Since most routine write only parts of grid variables, the routine would also specify which part it reads/writes, e.g. the interior, outer boundary, symmetry boundary, etc.
 
* Since most routine write only parts of grid variables, the routine would also specify which part it reads/writes, e.g. the interior, outer boundary, symmetry boundary, etc.
 +
* This allows the Cactus scheduler in a first step to validate the schedule and detect cases where a required variable has not been defined, or where a variable is calculated multiple times or synchronized multiple times
 +
* In a second step this will also allow the Cactus scheduler to completely derive the schedule from these declarations. This may even make it possible to execute routines in parallel if they are independent. Even SYNC statements can be automatically derived.
 +
 +
One particular issue arises with routines which modify a variable, e.g. imposing the constraint that <math>\tilde A^i_i=0</math>. These routines read and write the same variable, and it is thus not immediately clear why they should be executed or in which order they should be executed. To resolve this, I suggest to add a tag to variables, declaring that this routine "reads Aij:original" and writes "Aij:constraints-enforces". Each other routine accessing this variables would then also need to declare whether it reads or writes the original Aij or the Aij with constraints enforced.
 +
 +
Another issue arises with loops in the schedule. This is currently mostly used by MoL for the sub-timesteps. I have currently no good idea for handling this, and I suggest to punt and implement a special case for this.

Revision as of 19:48, 15 January 2011

Problem Outline

One of the currently most complex aspects of programming with Cactus is writing schedule.ccl files for new routines, in particular if mesh refinement is used. The basic problem is that it is very difficult to ensure that routines are executed in the correct order, i.e. that all grid variables which are required for a routine are actually calculated beforehand. It is also difficult to ensure that boundary conditions (and synchronisation and symmetry boundaries) are applied when needed, in particular after regridding.

The Cactus schedule consists of several independent "parts": There are schedule bins defined by the flesh, there are schedule groups defined by infrastructure thorns (e.g. MoL or HydroBase), and there is the recursive Berger-Oliger algorithm traversing the bins implemented in Carpet. It is for the end-user difficult to see which groups are executed when and on what refinement level, and in which order this occurs.

The Cactus schedule offers "before" and "after" clauses to ensure a partial ordering between routines. Unfortunately, this ordering applies only to routines within the same schedule group and the same schedule bin and refinement level. It is not possible to ensure a particular order between routines in different schedule groups or schedule bins, and it is very complex to ensure that a routine is executed e.g. after another routine has been executed on all refinement levels.

There is one example setup that illustrates this problem. When setting up initial conditions for a hydrodynamics evolution, one may e.g. want to first set up a neutron star, then calculate its maximum density, and then set up the atmosphere to a value depending on this maximum density. Making this possible in Cactus required introducing a new schedule bin "postpostinitial" to the flesh, and requires careful arrangement of schedule groups defined by ADMBase and HydroBase. Even now that this is possible, it is probably not possible to ensure at run time that these actions occur in a correct order.

Suggested Solution

To resolve this issue, and to generally simplify the way in which schedule.ccl files are designed and written, I suggest the following:

  • Each scheduled routine declares which grid variables it reads and which grid variables it writes
  • Since most routine write only parts of grid variables, the routine would also specify which part it reads/writes, e.g. the interior, outer boundary, symmetry boundary, etc.
  • This allows the Cactus scheduler in a first step to validate the schedule and detect cases where a required variable has not been defined, or where a variable is calculated multiple times or synchronized multiple times
  • In a second step this will also allow the Cactus scheduler to completely derive the schedule from these declarations. This may even make it possible to execute routines in parallel if they are independent. Even SYNC statements can be automatically derived.

One particular issue arises with routines which modify a variable, e.g. imposing the constraint that <math>\tilde A^i_i=0</math>. These routines read and write the same variable, and it is thus not immediately clear why they should be executed or in which order they should be executed. To resolve this, I suggest to add a tag to variables, declaring that this routine "reads Aij:original" and writes "Aij:constraints-enforces". Each other routine accessing this variables would then also need to declare whether it reads or writes the original Aij or the Aij with constraints enforced.

Another issue arises with loops in the schedule. This is currently mostly used by MoL for the sub-timesteps. I have currently no good idea for handling this, and I suggest to punt and implement a special case for this.