From 478f6c705ee2e32d4afac3eb11f3a5be7489dd90 Mon Sep 17 00:00:00 2001 From: Ellis Hoag Date: Mon, 23 Apr 2018 13:59:21 -0500 Subject: [PATCH] Working --- grudge/execution.py | 5 +++-- grudge/symbolic/compiler.py | 7 ++++++- test/test_mpi_communication.py | 13 +++++++++++-- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/grudge/execution.py b/grudge/execution.py index 5be80e9f..fae28410 100644 --- a/grudge/execution.py +++ b/grudge/execution.py @@ -483,7 +483,7 @@ class BoundOperator(object): + sep + str(self.eval_code)) - def __call__(self, queue, profile_data=None, **context): + def __call__(self, queue, profile_data=None, log_quantities=None, **context): import pyopencl.array as cl_array def replace_queue(a): @@ -512,7 +512,8 @@ class BoundOperator(object): new_context[name] = with_object_array_or_scalar(replace_queue, var) return self.eval_code.execute( - ExecutionMapper(queue, new_context, self), profile_data=profile_data) + ExecutionMapper(queue, new_context, self), profile_data=profile_data, + log_quantities=log_quantities) # }}} diff --git a/grudge/symbolic/compiler.py b/grudge/symbolic/compiler.py index a85c8926..439731f6 100644 --- a/grudge/symbolic/compiler.py +++ b/grudge/symbolic/compiler.py @@ -477,7 +477,7 @@ class Code(object): return argmax2(available_insns), discardable_vars - def execute(self, exec_mapper, pre_assign_check=None, profile_data=None): + def execute(self, exec_mapper, pre_assign_check=None, profile_data=None, log_quantities=None): if profile_data is not None: from time import time start_time = time() @@ -505,6 +505,11 @@ class Code(object): del context[name] mapper_method = getattr(exec_mapper, insn.mapper_method) + if log_quantities is not None: + from pytools.log import time_and_count_function + mapper_method = time_and_count_function(mapper_method, + log_quantities["timer"], + log_quantities["counter"]) assignments, new_futures = mapper_method(insn) for target, value in assignments: diff --git a/test/test_mpi_communication.py b/test/test_mpi_communication.py index 7777d14d..70883b5b 100644 --- a/test/test_mpi_communication.py +++ b/test/test_mpi_communication.py @@ -170,11 +170,19 @@ def mpi_communication_entrypoint(): from pytools.log import LogManager, \ add_general_quantities, \ - add_run_info - log_filename = None + add_run_info, \ + IntervalTimer, EventCounter + # log_filename = None + log_filename = 'grudge_log.dat' logmgr = LogManager(log_filename, "w", comm) add_run_info(logmgr) add_general_quantities(logmgr) + log_quantities = {"timer": IntervalTimer("insn_timer", + "Time spent evaluating instructions"), + "counter": EventCounter("insn_counter", + "Number of instructions evaluated")} + for quantity in log_quantities.values(): + logmgr.add_quantity(quantity) # print(sym.pretty(op.sym_operator())) bound_op = bind(vol_discr, op.sym_operator()) @@ -183,6 +191,7 @@ def mpi_communication_entrypoint(): def rhs(t, w): val, rhs.profile_data = bound_op(queue, profile_data=rhs.profile_data, + log_quantities=log_quantities, t=t, w=w) return val rhs.profile_data = {} -- GitLab