|
17 | 17 | from devito.exceptions import CompilationError |
18 | 18 | from devito.symbolics import IndexedPointer |
19 | 19 | from devito.ir.iet.nodes import (Node, Iteration, Expression, ExpressionBundle, |
20 | | - Call, Lambda, BlankLine, Section, ListMajor) |
| 20 | + Call, Lambda, BlankLine, Section, ListMajor, MetaCall) |
21 | 21 | from devito.ir.support.space import Backward |
22 | 22 | from devito.symbolics import (FieldFromComposite, FieldFromPointer, |
23 | 23 | ListInitializer, uxreplace) |
@@ -1509,7 +1509,8 @@ class Specializer(Uxreplace): |
1509 | 1509 | Note that the Operator is not re-optimized in response to this replacement - this |
1510 | 1510 | transformation could nominally result in expressions of the form `f + 0` in the |
1511 | 1511 | generated code. If one wants to construct an Operator where such expressions are |
1512 | | - considered, then use of `subs=...` is a better choice. |
| 1512 | + considered, then use of `subs=...` at construction time is a better choice. However, |
| 1513 | + it is likely that such expressions will be optimized away by the C-level compiler. |
1513 | 1514 | """ |
1514 | 1515 |
|
1515 | 1516 | def __init__(self, mapper, nested=False): |
@@ -1554,6 +1555,23 @@ def visit_Operator(self, o, **kwargs): |
1554 | 1555 | state['parameters'] = parameters |
1555 | 1556 | state['body'] = body |
1556 | 1557 |
|
| 1558 | + # TODO: Also rebuild the _func_table for the Operator |
| 1559 | + # TODO: This is somewhat incongruent with the visitor and should be refactored |
| 1560 | + |
| 1561 | + func_table = OrderedDict() |
| 1562 | + for k, v in o._func_table.items(): |
| 1563 | + root = v.root |
| 1564 | + local = v.local |
| 1565 | + |
| 1566 | + body = self._visit(root.body) |
| 1567 | + parameters = tuple(i for i in root.parameters if i not in self.mapper) |
| 1568 | + |
| 1569 | + new_root = root._rebuild(body=body, parameters=parameters) |
| 1570 | + |
| 1571 | + func_table[k] = MetaCall(root=new_root, local=local) |
| 1572 | + |
| 1573 | + state['_func_table'] = func_table |
| 1574 | + |
1557 | 1575 | try: |
1558 | 1576 | state.pop('ccode') |
1559 | 1577 | except KeyError: |
|
0 commit comments