#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--
Ticket URL: https://bitbucket.org/einsteintoolkit/tickets/issues/2734/consider-adding-if-statement-functionality