From 7d5603b175936a6d2eaf415568b003ada08dc132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20He=C3=9F?= <rene.hess@iwr.uni-heidelberg.de> Date: Thu, 7 Dec 2017 09:57:14 +0100 Subject: [PATCH] Option to store stack for chace objects --- python/dune/perftool/generation/cache.py | 7 ++++++- python/dune/perftool/options.py | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/python/dune/perftool/generation/cache.py b/python/dune/perftool/generation/cache.py index a14e5516..b26dc15b 100644 --- a/python/dune/perftool/generation/cache.py +++ b/python/dune/perftool/generation/cache.py @@ -1,10 +1,13 @@ """ This module provides the memoization infrastructure for code generating functions. """ +import inspect + from dune.perftool.generation.context import (get_global_context_value, global_context, ) from dune.perftool.generation.counter import get_counter +from dune.perftool.options import get_option # Store a global list of generator functions _generators = [] @@ -53,7 +56,9 @@ class _CacheObject(object): def __init__(self, value, count=None): self.value = value self.count = count - self.stackframe = None + self.stack = None + if get_option('debug_cache_with_stack'): + self.stack = inspect.stack() class _RegisteredFunction(object): diff --git a/python/dune/perftool/options.py b/python/dune/perftool/options.py index ffd4551d..2e01ae32 100644 --- a/python/dune/perftool/options.py +++ b/python/dune/perftool/options.py @@ -34,6 +34,7 @@ class PerftoolOptionsArray(ImmutableRecord): # Arguments that are to be set from the outside uflfile = PerftoolOption(helpstr="the UFL file to compile") + debug_cache_with_stack = PerftoolOption(default=False, helpstr="Store stack along with cache objects. Makes debugging caching issues easier.") driver_file = PerftoolOption(helpstr="The filename for the generated driver header") operator_file = PerftoolOption(helpstr="The filename for the generated local operator header") numerical_jacobian = PerftoolOption(default=False, helpstr="use numerical jacobians (only makes sense, if uflpdelab for some reason fails to generate analytic jacobians)") -- GitLab