Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rewrite evaluable loops using Loop base class
Currently there are 2.5 implementations for evaluable loops: `LoopSum`, `LoopConcatenate` and `LoopConcatenateCombined`. The first loop is the most common one (before sparsification). The second appears after sparsification. The last loop is created only during the 'optimize for numpy' stage and is a combination of several concatenates in a single loop for performance reasons. This patch introduces a base class for evaluable loops and rewrites `LoopSum` and `LoopConcatenate` as implementations of the base class. The base class requires two methods to be implemented: one for initializing the output value and one for updating the output value for each iteration. Due to the generic nature of the base class, the method for updating the output value is guarded with a multiprocessing lock if the loop is evaluated in parallel, even when this is not necessary, e.g. for `LoopConcatenate`. To minimize the impact of locking, the lock used to increment the loop index is reused for updating the the output value. In addition this patch replaces `LoopConcatenateCombined` with `LoopTuple`, which supports any combination of loop evaluables, not just `LoopConcatenate`.
- Loading branch information