diff --git a/python/dune/codegen/options.py b/python/dune/codegen/options.py index 257da40169f578a4b64a367f6aaa4cd55729253d..100cb0b78433620a2037955da74c482598ea5ca0 100644 --- a/python/dune/codegen/options.py +++ b/python/dune/codegen/options.py @@ -56,6 +56,7 @@ class CodegenGlobalOptionsArray(ImmutableRecord): operator_to_build = CodegenOption(default=None, helpstr="The operators from the list that is about to be build now. CMake sets this one!!!") debug_interpolate_input = CodegenOption(default=False, helpstr="Should the input for printresidual and printmatix be interpolated (instead of random input).") use_likwid = CodegenOption(default=False, helpstr="Use likwid instead of own performance measurements.") + use_sde = CodegenOption(default=False, helpstr="Use sde instead of own performance measurements.") autotune_google_benchmark = CodegenOption(default=False, helpstr="Use google-benchmark library for autotuning (when autotuning is activated).") # Arguments that are mainly to be set by logic depending on other options diff --git a/python/dune/codegen/pdelab/driver/timings.py b/python/dune/codegen/pdelab/driver/timings.py index aeca64d46c73f2327b48c22f07dca7a85a044104..70705a40a06b1bb31accfceeae32b7fb78b697b4 100644 --- a/python/dune/codegen/pdelab/driver/timings.py +++ b/python/dune/codegen/pdelab/driver/timings.py @@ -4,7 +4,7 @@ from dune.codegen.generation import (cached, include_file, pre_include, preamble, - ) + post_include) from dune.codegen.options import get_option from dune.codegen.pdelab.driver import (get_form_ident, is_linear, @@ -24,6 +24,9 @@ from dune.codegen.pdelab.driver.solve import (name_vector, ) +_sde_marks = {} + + @preamble(section="timings") def define_timing_identifier(name): ini = name_initree() @@ -138,6 +141,10 @@ def setup_timer(): logger.warning("timings: using instrumentation level >= 3 with likwid will slow down your code considerably") local_operator_likwid() finalize_likwid() + elif get_option("use_sde"): + post_include('#define __SSC_MARK(x) do{ __asm__ volatile' + + '("movl $" #x ", %%ebx\\n\\t.byte 100\\n\\t.byte 103\\n\\t.byte 144" : : : "%ebx"); } while(0)', + filetag='driver') else: from dune.codegen.loopy.target import type_floatingpoint pre_include("#define HP_TIMER_OPCOUNTER {}".format(type_floatingpoint()), filetag="driver") @@ -156,6 +163,8 @@ def init_region_timer(region): setup_timer() if get_option("use_likwid"): init_likwid_timer(region) + elif get_option("use_sde"): + pass else: from dune.codegen.generation import post_include post_include("HP_DECLARE_TIMER({});".format(region), filetag="driver") @@ -164,6 +173,9 @@ def init_region_timer(region): def start_region_timer(region): if get_option("use_likwid"): return ["LIKWID_MARKER_START(\"{}\");".format(region)] + elif get_option("use_sde"): + _sde_marks[region + '_start'] = len(_sde_marks) + return ["__SSC_MARK(0x{});".format(_sde_marks[region + '_start'])] else: return ["HP_TIMER_START({});".format(region)] @@ -171,6 +183,9 @@ def start_region_timer(region): def stop_region_timer(region): if get_option("use_likwid"): return ["LIKWID_MARKER_STOP(\"{}\");".format(region)] + elif get_option("use_sde"): + _sde_marks[region + '_stop'] = len(_sde_marks) + return ["__SSC_MARK(0x{});".format(_sde_marks[region + '_stop'])] else: timestream = name_timing_stream() return ["HP_TIMER_STOP({});".format(region), @@ -207,7 +222,7 @@ def timed_region(region, actions): init_region_timer(region) - if get_option('instrumentation_level') >= 3 and not get_option('use_likwid'): + if get_option('instrumentation_level') >= 3 and not (get_option('use_likwid') or get_option("use_sde")): timestream = name_timing_stream() lop_name = name_localoperator(get_form_ident()) print_times.append("{}.dump_timers({}, {}, true);".format(lop_name, timestream, name_timing_identifier()))