Skip to content

Refactor loopy methods #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sumpy/e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def get_kernel(self, result_dtype):
self.tgt_expansion, self.src_expansion)

translation_classes_data_knl = \
m2l_translation.translation_classes_dependent_data_loopy_knl(
m2l_translation.loopy_translation_classes_dependent_data(
self.tgt_expansion, self.src_expansion, result_dtype)

from sumpy.tools import gather_loopy_arguments
Expand Down Expand Up @@ -671,7 +671,7 @@ def default_name(self):
@memoize_method
def get_inner_knl_and_optimizations(self, result_dtype):
m2l_translation = self.tgt_expansion.m2l_translation
return m2l_translation.preprocess_multipole_loopy_knl(
return m2l_translation.loopy_preprocess_multipole(
self.tgt_expansion, self.src_expansion, result_dtype)

def get_kernel(self, result_dtype):
Expand Down Expand Up @@ -761,7 +761,7 @@ def default_name(self):
@memoize_method
def get_inner_knl_and_optimizations(self, result_dtype):
m2l_translation = self.tgt_expansion.m2l_translation
return m2l_translation.postprocess_local_loopy_knl(
return m2l_translation.loopy_postprocess_local(
self.tgt_expansion, self.src_expansion, result_dtype)

def get_kernel(self, result_dtype):
Expand Down
2 changes: 1 addition & 1 deletion sumpy/e2p.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def get_cache_key(self):

def add_loopy_eval_callable(
self, loopy_knl: lp.TranslationUnit) -> lp.TranslationUnit:
inner_knl = self.expansion.get_loopy_evaluator(self.kernels)
inner_knl = self.expansion.loopy_evaluator(self.kernels)
loopy_knl = lp.merge([loopy_knl, inner_knl])
loopy_knl = lp.inline_callable_kernel(loopy_knl, "e2p")
loopy_knl = lp.remove_unused_inames(loopy_knl)
Expand Down
8 changes: 4 additions & 4 deletions sumpy/expansion/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ class ExpansionBase(ABC):
.. automethod:: get_coefficient_identifiers
.. automethod:: coefficients_from_source
.. automethod:: coefficients_from_source_vec
.. automethod:: get_loopy_expansion_formation
.. automethod:: loopy_expansion_formation
.. automethod:: evaluate
.. automethod:: get_loopy_evaluator
.. automethod:: loopy_evaluator

.. automethod:: with_kernel
.. automethod:: copy
Expand Down Expand Up @@ -164,7 +164,7 @@ def coefficients_from_source_vec(self,
result[i] += weight * coeffs[i]
return result

def get_loopy_expansion_formation(
def loopy_expansion_formation(
self, kernels: Sequence[Kernel],
strength_usage: Sequence[int], nstrengths: int) -> lp.TranslationUnit:
"""
Expand All @@ -183,7 +183,7 @@ def evaluate(self, kernel, coeffs, bvec, rscale, sac=None):
in *coeffs*.
"""

def get_loopy_evaluator(self, kernels: Sequence[Kernel]) -> lp.TranslationUnit:
def loopy_evaluator(self, kernels: Sequence[Kernel]) -> lp.TranslationUnit:
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would get renamed to loopy_evaluator_and_optimizations in #158

"""
:returns: a :mod:`loopy` kernel that returns the evaluated
target transforms of the potential given by *kernels*.
Expand Down
14 changes: 7 additions & 7 deletions sumpy/expansion/m2l.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@ def translation_classes_dependent_ndata(self, tgt_expansion, src_expansion):
"""
return 0

def translation_classes_dependent_data_loopy_knl(self, tgt_expansion,
def loopy_translation_classes_dependent_data(self, tgt_expansion,
src_expansion, result_dtype):
"""Return a :mod:`loopy` kernel that calculates the data described by
:func:`~sumpy.expansion.m2l.M2LTranslationBase.translation_classes_dependent_data`.
:arg result_dtype: The :mod:`numpy` type of the result.
"""
return translation_classes_dependent_data_loopy_knl(tgt_expansion,
return loopy_translation_classes_dependent_data(tgt_expansion,
src_expansion, result_dtype)

@abstractmethod
Expand Down Expand Up @@ -437,7 +437,7 @@ def preprocess_multipole_nexprs(self, tgt_expansion, src_expansion):
src_expansion)
return len(circulant_matrix_mis)

def preprocess_multipole_loopy_knl(self, tgt_expansion, src_expansion,
def loopy_preprocess_multipole(self, tgt_expansion, src_expansion,
result_dtype):

circulant_matrix_mis, _, max_mi = \
Expand Down Expand Up @@ -553,7 +553,7 @@ def postprocess_local_nexprs(self, tgt_expansion, src_expansion):
return self.translation_classes_dependent_ndata(
tgt_expansion, src_expansion)

def postprocess_local_loopy_knl(self, tgt_expansion, src_expansion,
def loopy_postprocess_local(self, tgt_expansion, src_expansion,
result_dtype):
circulant_matrix_mis, needed_vector_terms, _ = \
self._translation_classes_dependent_data_mis(tgt_expansion,
Expand Down Expand Up @@ -1020,9 +1020,9 @@ def postprocess_local_exprs(self, tgt_expansion, src_expansion,
# }}} FourierBesselM2LWithFFT


# {{{ translation_classes_dependent_data_loopy_knl
# {{{ loopy_translation_classes_dependent_data

def translation_classes_dependent_data_loopy_knl(tgt_expansion, src_expansion,
def loopy_translation_classes_dependent_data(tgt_expansion, src_expansion,
result_dtype):
"""
This is a helper function to create a loopy kernel to generate translation
Expand Down Expand Up @@ -1086,6 +1086,6 @@ def translation_classes_dependent_data_loopy_knl(tgt_expansion, src_expansion,

return knl

# }}} translation_classes_dependent_data_loopy_knl
# }}} loopy_translation_classes_dependent_data

# vim: fdm=marker
2 changes: 1 addition & 1 deletion sumpy/p2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def __init__(self, ctx, expansion, kernels=None,

def add_loopy_form_callable(
self, loopy_knl: lp.TranslationUnit) -> lp.TranslationUnit:
inner_knl = self.expansion.get_loopy_expansion_formation(
inner_knl = self.expansion.loopy_expansion_formation(
self.source_kernels, self.strength_usage, self.strength_count)
loopy_knl = lp.merge([loopy_knl, inner_knl])
loopy_knl = lp.inline_callable_kernel(loopy_knl, "p2e")
Expand Down