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
message.

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
SLOW_OPTIM?=false
# Compile with instrumentation support for timing
TIMINGS?=false
# 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)
endif
endif
ifeq ($(TIMINGS),true)
CFLAGS:=$(CFLAGS) -DTIMING_ENABLE
endif
INCLUDE_DIRS := -I../include $(MPI_INCDIR) $(LAPACK_INCDIR) $(BLITZ_INCDIR) $(FFTW_INCDIR) $(UMF_INCDIR)
CFLAGS := $(CFLAGS) $(INCLUDE_DIRS)
......@@ -88,4 +96,6 @@ cases/%.src.c: cases/%.cpp CaseFileSource.c
%.o: %.cpp *.hpp
$(MPICXX) $(CFLAGS) -o $@ -c $<
print-% : ; @echo $* = $($*)
.SECONDARY:
......@@ -4,6 +4,7 @@
#include <mpi.h>
#include <stdio.h>
#ifdef TIMING_ENABLE
// Structure for information related to a single timing invocation
struct timing_element;
......@@ -96,3 +97,11 @@ void timing_stack_report(){
timing_stack_recurse(root[i],0);
}
}
#else
void timing_stack_report() {
fprintf(stderr,"Timing was not enabled for this build of SPINS.\n");
}
#endif
......@@ -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()
#else
void timing_push(const char * name);
void timing_pop();
#endif
void timing_stack_report();
......
Markdown is supported
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