Flow123d  release_3.0.0-1120-g2970c33
Classes | Namespaces | Macros
sys_profiler.hh File Reference
#include "global_defs.h"
#include <mpi.h>
#include <ostream>
#include <boost/functional/hash/hash.hpp>
#include <boost/property_tree/ptree_fwd.hpp>
#include <boost/ref.hpp>
#include <boost/tuple/detail/tuple_basic.hpp>
#include <boost/unordered/unordered_map.hpp>
#include "time_point.hh"
#include "petscsys.h"
#include "simple_allocator.hh"

Go to the source code of this file.

Classes

struct  boost::hash< T >
 
class  MPI_Functions
 
class  Profiler
 

Namespaces

 boost
 

Macros

#define CONSTEXPR_   constexpr
 
#define _PASTE(a, b)   a ## b
 
#define PASTE(a, b)   _PASTE(a, b)
 
#define START_TIMER(tag)
 Starts a timer with specified tag. More...
 
#define START_TIMER_EXT(tag, subtag)
 Starts a timer with specified tag and subtag. More...
 
#define END_TIMER(tag)
 Ends a timer with specified tag. More...
 
#define END_START_TIMER(tag)
 
#define ADD_CALLS(n_calls)
 Increase number of calls in actual timer. More...
 

Detailed Description

 * Copyright (C) 2015 Technical University of Liberec. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 3 as published by the Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Todo:
  • START_GLOBAL_TIMER(tag) - this calls the start_timer, which creates local timer on the correct place in the hierarchy, further this timer is added to the list of global timers, this contains groups of timers with same tag, and collect/sum data from these timers in the report.
!!! Unfortunately using constexpr is worse (without optimization).
This is probably due to use of static variable for
CodePoint, the access could be slow, and computation of hash is done only once. Actually timing results
are:

OPTIONS     OVERHEAD (compared to call 2x clock())
-g, no c++11 : 18%
-g,    c++11 : 60%
-O3,no c++11 : 6%
-O3,   c++11 : 6%

Definition in file sys_profiler.hh.

Macro Definition Documentation

#define _PASTE (   a,
 
)    a ## b

Definition at line 94 of file sys_profiler.hh.

#define ADD_CALLS (   n_calls)

Increase number of calls in actual timer.

Some time you want to measure a performance of a cycle with body that is below resolution of the Timer implementation. If you know number of cycles, you can use this macro in following way:

1 START_TIMER("cycle");
2 unsigned int i;
3 for(i =0; i<1000000; i++) i*i*i;
4 ADD_CALLS(i);
5 END_TIMER("cycle");

In the profiler report you get the total time spent in the cycle, and time per one call which will be average time spent in the body of the cycle.

Definition at line 188 of file sys_profiler.hh.

#define CONSTEXPR_   constexpr

Definition at line 88 of file sys_profiler.hh.

#define END_START_TIMER (   tag)

Ends current timer and starts the new one with given tag. Again this expands into two lines, see ATTENTION in previous macro.

Definition at line 162 of file sys_profiler.hh.

#define END_TIMER (   tag)

Ends a timer with specified tag.

Use only if you want to end timer before the end of block. Again this expands into two lines, see ATTENTION in previous macro.

Definition at line 151 of file sys_profiler.hh.

#define PASTE (   a,
 
)    _PASTE(a, b)

Definition at line 95 of file sys_profiler.hh.

#define START_TIMER (   tag)

Starts a timer with specified tag.

In fact it creates an static constant expression that identifies the point in the code and contains tag of the involved timer and its hash. Then it creates local variable that calls Profiler::start_timer() in constructor and Profiler::stop_timer() in destructor. This way the timer is automatically closed at the end of current block.

ATTENTION: This macro expands to two statements so following code is illegal:

1 if (some_condition) START_TIMER(tag);

Definition at line 117 of file sys_profiler.hh.

#define START_TIMER_EXT (   tag,
  subtag 
)

Starts a timer with specified tag and subtag.

In fact it creates an static constant expression that identifies the point in the code and contains tag and subtag of the involved timer and its hash. Then it creates local variable that calls Profiler::start_timer() in constructor and Profiler::stop_timer() in destructor. This way the timer is automatically closed at the end of current block.

ATTENTION: This macro expands to two statements so following code is illegal:

1 if (some_condition) START_TIMER_EXT(tag, subtag);

Definition at line 138 of file sys_profiler.hh.