From: Alyssa Rosenzweig Date: Tue, 12 May 2020 00:05:24 +0000 (-0400) Subject: pan/mdg: Explain helper invocations dataflow theory X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0da03c68ae3e16a339e41b967fcb689666f02296;p=mesa.git pan/mdg: Explain helper invocations dataflow theory Signed-off-by: Alyssa Rosenzweig Part-of: --- diff --git a/src/panfrost/midgard/midgard_helper_invocations.c b/src/panfrost/midgard/midgard_helper_invocations.c new file mode 100644 index 00000000000..32bcbd4d823 --- /dev/null +++ b/src/panfrost/midgard/midgard_helper_invocations.c @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2019 Collabora, Ltd. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Authors (Collabora): + * Alyssa Rosenzweig + */ + +#include "compiler.h" + +/* Midgard texture/derivative operations have a pair of bits controlling the + * behaviour of helper invocations: + * + * - Should a helper invocation terminate after executing this instruction? + * - Should a helper invocation actually execute this instruction? + * + * The terminate bit should be set on the last instruction requiring helper + * invocations. Without control flow, that's literally the last instruction; + * with control flow, there may be multiple such instructions (with ifs) or no + * such instruction (with loops). + * + * The execute bit should be set if the value of this instruction is required + * by a future instruction requiring helper invocations. Consider: + * + * 0 = texture ... + * 1 = fmul 0, #10 + * 2 = dfdx 1 + * store 2 + * + * Since the derivative calculation 2 requires helper invocations, the value 1 + * must be calculated by helper invocations, and since it depends on 0, 0 must + * be calculated by helpers. Hence the texture op has the execute bit set, and + * the derivative op has the terminate bit set. + * + * Calculating the terminate bit occurs by forward dataflow analysis to + * determine which blocks require helper invocations. A block requires + * invocations in if any of its instructions use helper invocations, or if it + * depends on a block that requires invocation. With that analysis, the + * terminate bit is set on the last instruction using invocations within any + * block that does *not* require invocations out. + * + * Likewise, calculating the execute bit requires backward dataflow analysis + * with union as the join operation and the generating set being the union of + * sources of instructions writing executed values. + */