A lot of files were missing copyright field in the header and
the Blender Foundation contributed to them in a sense of bug
fixing and general maintenance.
This change makes it explicit that those files are at least
partially copyrighted by the Blender Foundation.
Note that this does not make it so the Blender Foundation is
the only holder of the copyright in those files, and developers
who do not have a signed contract with the foundation still
hold the copyright as well.
Another aspect of this change is using SPDX format for the
header. We already used it for the license specification,
and now we state it for the copyright as well, following the
FAQ:
https://reuse.software/faq/
50 lines
2.5 KiB
C++
50 lines
2.5 KiB
C++
/* SPDX-FileCopyrightText: 2023 Blender Foundation
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
|
|
#pragma once
|
|
|
|
/** \file
|
|
* \ingroup fn
|
|
*
|
|
* A #Procedure optimization pass takes an existing procedure and changes it in a way that
|
|
* improves its performance when executed.
|
|
*
|
|
* Oftentimes it would also be possible to implement a specific optimization directly during
|
|
* construction of the initial #Procedure. There is a trade-off between doing that or just
|
|
* building a "simple" procedure and then optimizing it uses separate optimization passes.
|
|
* - Doing optimizations directly during construction is typically faster than doing it as a
|
|
* separate pass. However, it would be much harder to turn the optimization off when it is not
|
|
* necessary, making the construction potentially slower in those cases.
|
|
* - Doing optimizations directly would also make code more complex, because it mixes the logic
|
|
* that generates the procedure from some other data with optimization decisions.
|
|
* - Having a separate pass allows us to use it in different places when necessary.
|
|
* - Having a separate pass allows us to enable and disable it easily to better understand its
|
|
* impact on performance.
|
|
*/
|
|
|
|
#include "FN_multi_function_procedure.hh"
|
|
|
|
namespace blender::fn::multi_function::procedure_optimization {
|
|
|
|
/**
|
|
* When generating a procedure, destruct instructions (#DestructInstruction) have to be inserted
|
|
* for all variables that are not outputs. Often the simplest approach is to add these instructions
|
|
* at the very end. However, when the procedure is executed this is not optimal, because many more
|
|
* variables are initialized at the same time than necessary. This inhibits the reuse of memory
|
|
* buffers which decreases performance and increases memory use.
|
|
*
|
|
* This optimization pass moves destruct instructions up in the procedure. The goal is to destruct
|
|
* each variable right after its last use.
|
|
*
|
|
* For simplicity, and because this is the most common use case, this optimization currently only
|
|
* works on a single chain of instructions. Destruct instructions are not moved across branches.
|
|
*
|
|
* \param procedure: The procedure that should be optimized.
|
|
* \param block_end_instr: The instruction that points to the last instruction within a linear
|
|
* chain of instructions. The algorithm moves instructions backward starting at this instruction.
|
|
*/
|
|
void move_destructs_up(Procedure &procedure, Instruction &block_end_instr);
|
|
|
|
} // namespace blender::fn::multi_function::procedure_optimization
|