Skip to content

Commit

Permalink
Adding namespace in timing macros
Browse files Browse the repository at this point in the history
Sometime those macros are used under different namespaces. We need to use namespace ::paddle
to make it compile correctly.

Change-Id: I57a6d6ec8cd0d680b584aab62d72a35c226a24a4
  • Loading branch information
xuwei06 committed Dec 21, 2016
1 parent dadd48a commit 84ad724
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
3 changes: 3 additions & 0 deletions paddle/utils/Stat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ void StatSet::printSegTimerStatus() {

void StatSet::printBarrierTimerStatus() {
ReadLockGuard guard(lock_);
if (barrierStatSet_.empty()) {
return;
}
// control barrierAbstact in runtime, so enable compliation
LOG(INFO) << std::setiosflags(std::ios::left) << std::setfill(' ')
<< "======= BarrierStatSet status ======" << std::endl;
Expand Down
49 changes: 31 additions & 18 deletions paddle/utils/Stat.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,28 +258,41 @@ inline StatSet& registerTimerArg2(uint64_t threshold = -1,
// The default arguments are shown in the following line:
// REGISTER_TIMER(statName, threshold = -1, statSet = globalStat)
// TODO(yuyang18,wangyanfei01): if UNIQUE_NAME is needed
#define REGISTER_TIMER(statName, ...) \
static StatPtr __stat = registerTimerArg2(__VA_ARGS__).getStat(statName); \
TimerOnce __timerOnce(__stat.get(), "", registerTimerArg1(__VA_ARGS__));
#define REGISTER_TIMER(statName, ...) \
static ::paddle::StatPtr __stat = \
::paddle::registerTimerArg2(__VA_ARGS__).getStat(statName); \
::paddle::TimerOnce __timerOnce( \
__stat.get(), "", ::paddle::registerTimerArg1(__VA_ARGS__));

#define REGISTER_TIMER_SET(statName, start, ...) \
static StatPtr __stat = registerTimerArg2(__VA_ARGS__).getStat(statName); \
TimerOnce __timerOnce( \
__stat.get(), "", registerTimerArg1(__VA_ARGS__), false, start);
static ::paddle::StatPtr __stat = \
::paddle::registerTimerArg2(__VA_ARGS__).getStat(statName); \
::paddle::TimerOnce __timerOnce(__stat.get(), \
"", \
::paddle::registerTimerArg1(__VA_ARGS__), \
false, \
start);

// dynmaic timer, support to discriminate runtime entity, used in pserver
#define REGISTER_TIMER_DYNAMIC(statName, ...) \
StatPtr __stat = registerTimerArg2(__VA_ARGS__).getStat(statName); \
TimerOnce __timerOnce(__stat.get(), "", registerTimerArg1(__VA_ARGS__));

#define REGISTER_TIMER_DYNAMIC_SET(statName, start, ...) \
StatPtr __stat = registerTimerArg2(__VA_ARGS__).getStat(statName); \
TimerOnce __timerOnce( \
__stat.get(), "", registerTimerArg1(__VA_ARGS__), false, start);

#define REGISTER_TIMER_INFO(statName, info) \
static StatPtr __stat = globalStat.getStat(statName); \
TimerOnce __timerOnce(__stat.get(), info, 10 * 1000000LU /*threshold*/);
#define REGISTER_TIMER_DYNAMIC(statName, ...) \
::paddle::StatPtr __stat = \
::paddle::registerTimerArg2(__VA_ARGS__).getStat(statName); \
::paddle::TimerOnce __timerOnce( \
__stat.get(), "", ::paddle::registerTimerArg1(__VA_ARGS__));

#define REGISTER_TIMER_DYNAMIC_SET(statName, start, ...) \
::paddle::StatPtr __stat = \
::paddle::registerTimerArg2(__VA_ARGS__).getStat(statName); \
::paddle::TimerOnce __timerOnce(__stat.get(), \
"", \
::paddle::registerTimerArg1(__VA_ARGS__), \
false, \
start);

#define REGISTER_TIMER_INFO(statName, info) \
static ::paddle::StatPtr __stat = ::paddle::globalStat.getStat(statName); \
::paddle::TimerOnce __timerOnce( \
__stat.get(), info, 10 * 1000000LU /*threshold*/);

#endif // DISABLE_TIMER

Expand Down

0 comments on commit 84ad724

Please sign in to comment.