diff --git a/sumpy/__init__.py b/sumpy/__init__.py index a325e3d1a90a370f7f35883f3de62f6d90486f7c..8bece3a2dccde8dc6bf6a2b0d41eef20dfb3d1f2 100644 --- a/sumpy/__init__.py +++ b/sumpy/__init__.py @@ -40,6 +40,21 @@ __all__ = [ code_cache = WriteOncePersistentDict("sumpy-code-cache-v6-"+VERSION_TEXT) +# {{{ optimization control + +OPT_ENABLED = True + +OPT_ENABLED = "SUMPY_NO_OPT" not in os.environ + + +def set_optimization_enabled(flag): + """Set whether the :mod:`loopy` kernels should be optimized.""" + global OPT_ENABLED + OPT_ENABLED = flag + +# }}} + + # {{{ cache control CACHING_ENABLED = True diff --git a/sumpy/tools.py b/sumpy/tools.py index 428fa2a1ba54afc1151b7874aa89bc81c2bdec35..46fa9ee96c10b49a859871a91354e37c5cda28d9 100644 --- a/sumpy/tools.py +++ b/sumpy/tools.py @@ -365,7 +365,7 @@ class OrderedSet(collections.MutableSet): class KernelCacheWrapper(object): @memoize_method def get_cached_optimized_kernel(self, **kwargs): - from sumpy import code_cache, CACHING_ENABLED + from sumpy import code_cache, CACHING_ENABLED, OPT_ENABLED if CACHING_ENABLED: import loopy.version @@ -374,7 +374,8 @@ class KernelCacheWrapper(object): self.get_cache_key() + tuple(sorted(six.iteritems(kwargs))) + (loopy.version.DATA_MODEL_VERSION,) - + (KERNEL_VERSION,)) + + (KERNEL_VERSION,) + + (OPT_ENABLED,)) try: result = code_cache[cache_key] @@ -391,7 +392,10 @@ class KernelCacheWrapper(object): from pytools import MinRecursionLimit with MinRecursionLimit(3000): - knl = self.get_optimized_kernel(**kwargs) + if OPT_ENABLED: + knl = self.get_optimized_kernel(**kwargs) + else: + knl = self.get_kernel() if CACHING_ENABLED: code_cache.store_if_not_present(cache_key, knl)