[ET Trac] #2734: Consider adding if statement functionality to read/write declarations

Samuel Cupp trac-noreply at einsteintoolkit.org
Wed May 31 14:56:34 CDT 2023


#2734: Consider adding if statement functionality to read/write declarations

 Reporter: Samuel Cupp
   Status: new
Milestone: 
  Version: 
     Type: enhancement
 Priority: minor
Component: Cactus

Currently, the read/write declarations are a compile-time setting. This is usually fine. For a function that is scheduled in multiple places with different rd/wr, Cactus takes a union of all declarations for generating the function-specific macros. However, one case can lead to additional complications in scheduling. If a function has many different _if_ statements inside it controlling behavior at runtime \(see e.g. GRHydro for the worst case scenario of this type of runtime-dependent scheduling\), then properly setting the rd/wr declarations will require either ignoring the actual behavior of the code and hoping for the best **or** having all of those _if_ statements reproduced inside the schedule.ccl. The former can bypass some safety checks and enforcement of good code behavior, while the latter causes excessive bloat in the schedule.ccl.

‌

A preferable alternative would be to allow rd/wr declarations to have runtime tags/conditionals/something that can turn them on/off depending on parameters. An easy example is `IllinoisGRMHD`'s conserv\_to\_prims function, which writes the primitives, conservatives, and \(if update\_Tmunu\) the stress-energy tensor. Right now, the only way to explicitly give this data dependency would be \(focusing on the WRITES declarations\)

```
if (update_Tmunu)
{
  schedule IllinoisGRMHD_conserv_to_prims
  {
    LANG: C
    READS: stuff
    WRITES: prims, cons, Tmunu
  } ""
} else {
  schedule IllinoisGRMHD_conserv_to_prims
  {
    LANG: C
    READS: stuff
    WRITES: prims, cons
  } ""
}
```

Instead, it would be convenient to say

```
schedule IllinoisGRMHD_conserv_to_prims
{
  LANG: C
  READS: stuff
  WRITES: prims, cons
  WRITES: Tmunu if update_Tmunu
} ""
```

or something equivalent. This not only gives the ability to more accurately state the data dependencies, it also allows for more compact scheduling of complicated functions while still allowing for them to be controlled using runtime parameters.

--
Ticket URL: https://bitbucket.org/einsteintoolkit/tickets/issues/2734/consider-adding-if-statement-functionality
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.einsteintoolkit.org/pipermail/trac/attachments/20230531/2f379d78/attachment.htm>


More information about the Trac mailing list