<html>#2734: Consider adding if statement functionality to read/write declarations
<table style='border-spacing: 1ex 0pt; '>
<tr><td style='text-align:right'> Reporter:</td><td>Samuel Cupp</td></tr>
<tr><td style='text-align:right'>   Status:</td><td>new</td></tr>
<tr><td style='text-align:right'>Milestone:</td><td></td></tr>
<tr><td style='text-align:right'>  Version:</td><td></td></tr>
<tr><td style='text-align:right'>     Type:</td><td>enhancement</td></tr>
<tr><td style='text-align:right'> Priority:</td><td>minor</td></tr>
<tr><td style='text-align:right'>Component:</td><td>Cactus</td></tr>
</table>

<p>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 <em>if</em> 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 <strong>or</strong> having all of those <em>if</em> 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.</p>
<p>‌</p>
<p>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 <code>IllinoisGRMHD</code>'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)</p>
<div class="codehilite"><pre><span></span><span>if (update_Tmunu)</span>
<span>{</span>
<span>  schedule IllinoisGRMHD_conserv_to_prims</span>
<span>  {</span>
<span>    LANG: C</span>
<span>    READS: stuff</span>
<span>    WRITES: prims, cons, Tmunu</span>
<span>  } ""</span>
<span>} else {</span>
<span>  schedule IllinoisGRMHD_conserv_to_prims</span>
<span>  {</span>
<span>    LANG: C</span>
<span>    READS: stuff</span>
<span>    WRITES: prims, cons</span>
<span>  } ""</span>
<span>}</span>
</pre></div>


<p>Instead, it would be convenient to say</p>
<div class="codehilite"><pre><span></span><span>schedule IllinoisGRMHD_conserv_to_prims</span>
<span>{</span>
<span>  LANG: C</sp
<p>--<br/>
Ticket URL: <a href='https://bitbucket.org/einsteintoolkit/tickets/issues/2734/consider-adding-if-statement-functionality'>https://bitbucket.org/einsteintoolkit/tickets/issues/2734/consider-adding-if-statement-functionality</a></p>
</html>