Skip to content

Commit d910f40

Browse files
committed
get_loopy_evaluator -> loopy_evaluator_and_optimizations
1 parent ba9dc9a commit d910f40

File tree

4 files changed

+20
-14
lines changed

4 files changed

+20
-14
lines changed

sumpy/e2p.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ def default_name(self):
8585
pass
8686

8787
@memoize_method
88-
def get_cached_loopy_knl_and_optimizations(self):
89-
return self.expansion.loopy_evaluator(self.kernels)
88+
def get_loopy_evaluator_and_optimizations(self):
89+
return self.expansion.loopy_evaluator_and_optimizations(self.kernels)
9090

9191
def get_cache_key(self):
9292
return (type(self).__name__, self.expansion, tuple(self.kernels))
9393

9494
def add_loopy_eval_callable(
9595
self, loopy_knl: lp.TranslationUnit) -> lp.TranslationUnit:
96-
inner_knl, _ = self.get_cached_loopy_knl_and_optimizations()
96+
inner_knl, _ = self.get_loopy_evaluator_and_optimizations()
9797
loopy_knl = lp.merge([loopy_knl, inner_knl])
9898
loopy_knl = lp.inline_callable_kernel(loopy_knl, "e2p")
9999
for kernel in self.kernels:
@@ -208,7 +208,7 @@ def get_kernel(self, max_ntargets_in_one_box):
208208
return loopy_knl
209209

210210
def get_optimized_kernel(self, max_ntargets_in_one_box):
211-
inner_knl, optimizations = self.get_cached_loopy_knl_and_optimizations()
211+
inner_knl, optimizations = self.get_loopy_evaluator_and_optimizations()
212212
knl = self.get_kernel(max_ntargets_in_one_box=max_ntargets_in_one_box)
213213
knl = lp.tag_inames(knl, {"itgt_box": "g.0"})
214214
knl = lp.split_iname(knl, "itgt_offset", 256, inner_tag="l.0")
@@ -378,7 +378,7 @@ def get_kernel(self, max_ntargets_in_one_box):
378378
return loopy_knl
379379

380380
def get_optimized_kernel(self, max_ntargets_in_one_box):
381-
_, optimizations = self.get_cached_loopy_knl_and_optimizations()
381+
_, optimizations = self.get_loopy_evaluator_and_optimizations()
382382
knl = self.get_kernel(max_ntargets_in_one_box=max_ntargets_in_one_box)
383383
knl = lp.tag_inames(knl, {"itgt_box": "g.0", "dummy": "l.0"})
384384
knl = lp.unprivatize_temporaries_with_inames(knl,

sumpy/expansion/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222

2323
from abc import ABC, abstractmethod
2424
from typing import (
25-
Any, ClassVar, Dict, Hashable, List, Optional, Sequence, Tuple, Type)
25+
Any, ClassVar, Dict, Hashable, List, Optional, Sequence, Tuple, Type,
26+
Callable)
2627

2728
from pytools import memoize_method
2829
import loopy as lp
@@ -66,9 +67,9 @@ class ExpansionBase(ABC):
6667
.. automethod:: get_coefficient_identifiers
6768
.. automethod:: coefficients_from_source
6869
.. automethod:: coefficients_from_source_vec
69-
.. automethod:: loopy_expansion_formation
7070
.. automethod:: evaluate
71-
.. automethod:: loopy_evaluator
71+
.. automethod:: loopy_expansion_formation
72+
.. automethod:: loopy_evaluator_and_optimizations
7273
7374
.. automethod:: with_kernel
7475
.. automethod:: copy
@@ -183,7 +184,9 @@ def evaluate(self, kernel, coeffs, bvec, rscale, sac=None):
183184
in *coeffs*.
184185
"""
185186

186-
def loopy_evaluator(self, kernels: Sequence[Kernel]) -> lp.TranslationUnit:
187+
def loopy_evaluator_and_optimizations(self, kernels: Sequence[Kernel]) \
188+
-> Tuple[lp.TranslationUnit, Sequence[
189+
Callable[[lp.TranslationUnit], lp.TranslationUnit]]]:
187190
"""
188191
:returns: a :mod:`loopy` kernel that returns the evaluated
189192
target transforms of the potential given by *kernels*.

sumpy/expansion/local.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
import loopy as lp
3838

39-
from typing import Sequence
39+
from typing import Sequence, Callable, Tuple
4040

4141
import logging
4242
logger = logging.getLogger(__name__)
@@ -410,7 +410,9 @@ def loopy_translate_from(self, src_expansion):
410410
f"A direct loopy kernel for translation from "
411411
f"{src_expansion} to {self} is not implemented.")
412412

413-
def get_loopy_evaluator(self, kernels: Sequence[Kernel]) -> lp.TranslationUnit:
413+
def loopy_evaluator_and_optimizations(self, kernels: Sequence[Kernel]) \
414+
-> Tuple[lp.TranslationUnit, Sequence[
415+
Callable[[lp.TranslationUnit], lp.TranslationUnit]]]:
414416
from sumpy.expansion.loopy import (make_l2p_loopy_kernel_for_volume_taylor,
415417
make_e2p_loopy_kernel)
416418
try:

sumpy/expansion/loopy.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
THE SOFTWARE.
2121
"""
2222

23-
from typing import Sequence
23+
from typing import Sequence, Callable, Tuple
2424
import pymbolic
2525
import pymbolic.primitives as prim
2626
import loopy as lp
@@ -36,8 +36,9 @@
3636
logger = logging.getLogger(__name__)
3737

3838

39-
def make_e2p_loopy_kernel(
40-
expansion: ExpansionBase, kernels: Sequence[Kernel]) -> lp.TranslationUnit:
39+
def make_e2p_loopy_kernel(expansion: ExpansionBase, kernels: Sequence[Kernel]) \
40+
-> Tuple[lp.TranslationUnit, Sequence[
41+
Callable[[lp.TranslationUnit], lp.TranslationUnit]]]:
4142
"""
4243
This is a helper function to create a loopy kernel for multipole/local
4344
evaluation. This function uses symbolic expressions given by the expansion class,

0 commit comments

Comments
 (0)