From f0522d5dc93a6a24e0b2181de230fe9e461aa2fe Mon Sep 17 00:00:00 2001
From: Pedro Gonnet <pedro.gonnet@durham.ac.uk>
Date: Tue, 2 Jul 2013 10:53:30 +0000
Subject: [PATCH] add timer for queue_gettask.

Former-commit-id: 93f0f1db6c4ef03efea154db17171346bc7ff1c3
---
 src/queue.c     | 30 +++---------------------------
 src/queue.h     | 10 ----------
 src/runner.c    |  2 +-
 src/scheduler.c |  2 +-
 src/timers.h    |  4 ++--
 5 files changed, 7 insertions(+), 41 deletions(-)

diff --git a/src/queue.c b/src/queue.c
index 66429a4c56..dba27a663e 100644
--- a/src/queue.c
+++ b/src/queue.c
@@ -29,33 +29,12 @@
 #include "cycle.h"
 #include "lock.h"
 #include "task.h"
+#include "timers.h"
 #include "cell.h"
 #include "queue.h"
 #include "error.h"
 #include "inline.h"
 
-/* Define the timer macros. */
-#ifdef TIMER_VERBOSE
-    #ifndef TIMER
-        #define TIMER
-    #endif
-#endif
-#ifdef TIMER
-    #define TIMER_TIC ticks tic = getticks();
-    #define TIMER_TOC(t) timer_toc( t , tic )
-    #define TIMER_TIC2 ticks tic2 = getticks();
-    #define TIMER_TOC2(t) timer_toc( t , tic2 )
-    INLINE static ticks timer_toc ( int t , ticks tic ) {
-        ticks d = (getticks() - tic);
-        __sync_add_and_fetch( &queue_timer[t] , d );
-        return d;
-        }
-#else
-    #define TIMER_TIC
-    #define TIMER_TOC(t)
-    #define TIMER_TIC2
-    #define TIMER_TOC2(t)
-#endif
 
 
 /* Counter macros. */
@@ -66,9 +45,6 @@
 #endif
 
 
-/* The timers. */
-ticks queue_timer[ queue_timer_count ];
-
 /* The counters. */
 int queue_counter[ queue_counter_count ];
 
@@ -174,7 +150,7 @@ struct task *queue_gettask ( struct queue *q , int qid , int blocking ) {
     
     /* If there are no tasks, leave immediately. */
     if ( q->count == 0 ) {
-        TIMER_TOC(queue_timer_gettask);
+        TIMER_TOC(timer_queue);
         return NULL;
         }
 
@@ -288,7 +264,7 @@ struct task *queue_gettask ( struct queue *q , int qid , int blocking ) {
         } /* while there are tasks. */
         
     /* Take the money and run. */
-    TIMER_TOC(queue_timer_gettask);
+    TIMER_TOC(timer_queue);
     return res;
 
     }
diff --git a/src/queue.h b/src/queue.h
index f15664be93..37aa20c4e8 100644
--- a/src/queue.h
+++ b/src/queue.h
@@ -24,16 +24,6 @@
 #define queue_sizegrow           2
 
 
-/* The queue timers themselves. */
-enum {
-    queue_timer_none = 0,
-    queue_timer_gettask,
-    queue_timer_bubble,
-    queue_timer_count,
-    };
-extern ticks queue_timer[ queue_timer_count ];
-
-
 /* Counters. */
 enum {
     queue_counter_swap = 0,
diff --git a/src/runner.c b/src/runner.c
index d6154f5c40..03c14350a8 100644
--- a/src/runner.c
+++ b/src/runner.c
@@ -792,7 +792,7 @@ void *runner_main ( void *data ) {
             /* Get a task, how and from where depends on the policy. */
             TIMER_TIC
             t = scheduler_gettask( sched , qid );
-            TIMER_TOC(timer_getpair);
+            TIMER_TOC(timer_gettask);
             
             /* Did I get anything? */
             if ( t == NULL )
diff --git a/src/scheduler.c b/src/scheduler.c
index 4ae16f2365..18515ff1da 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -741,7 +741,7 @@ struct task *scheduler_gettask ( struct scheduler *s , int qid ) {
 
     struct task *res = NULL;
     int k, nr_queues = s->nr_queues;
-
+    
     /* Loop as long as there are tasks... */
     while ( s->waiting > 0 && res == NULL ) {
         
diff --git a/src/timers.h b/src/timers.h
index eb83b6f43a..071ee6a722 100644
--- a/src/timers.h
+++ b/src/timers.h
@@ -34,8 +34,8 @@ enum {
     timer_dosub_force,
     timer_dopair_subset,
     timer_doghost,
-    timer_getpair,
-    timer_steal,
+    timer_gettask,
+    timer_queue,
     timer_stalled,
     timer_runners,
     timer_step,
-- 
GitLab