Commit d68f6d2b authored by Christopher Subich's avatar Christopher Subich
Browse files

Make timing code compile-time optional (TIMINGS=true)

This changeset adds a compile-time option on whether to include the
timing code.  If SPINS is compiled without TIMINGS=true, the timing code
is #defined to a no-op and should not otherwise affect the performance
of the software; timing_stack_report will instead print a short error

Because this affects #defines in header files, changing from
TIMINGS=true to false (or vice versa) should only be done with a 'make
clean'.  Not doing so could leave the timing code in an inconsistent
state and result in either link-time errors (if older code calls timing
code that is #defined away) or a corrupted/growing timing stack (if for
example a timing_push() is compiled in but the corresponding
timing_pop() is removed.)
parent 3581d1c1
......@@ -14,6 +14,9 @@ OPTIM?=true
# longer for compilation
# Compile with instrumentation support for timing
# If MPICXX isn't separately defined, then set it to be the same
# as CXX
ifeq ($(strip $(MPICXX)),)
......@@ -36,6 +39,11 @@ ifeq ($(OPTIM),true)
ifeq ($(TIMINGS),true)
......@@ -88,4 +96,6 @@ cases/%.src.c: cases/%.cpp CaseFileSource.c
%.o: %.cpp *.hpp
$(MPICXX) $(CFLAGS) -o $@ -c $<
print-% : ; @echo $* = $($*)
......@@ -4,6 +4,7 @@
#include <mpi.h>
#include <stdio.h>
// Structure for information related to a single timing invocation
struct timing_element;
......@@ -96,3 +97,11 @@ void timing_stack_report(){
void timing_stack_report() {
fprintf(stderr,"Timing was not enabled for this build of SPINS.\n");
......@@ -14,9 +14,15 @@
This model does require that timing be called in a predictable way, such
that timing_pop is called before any possible exit from the code path.*/
void timing_push(const char * name);
#ifndef TIMING_ENABLE // If timing code is not enabled, define the respective functions as no-ops
#define timing_push(x)
#define timing_pop()
void timing_push(const char * name);
void timing_pop();
void timing_stack_report();
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment