commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r7540 - in gnuradio/branches/developers/eb/gcell/src:


From: eb
Subject: [Commit-gnuradio] r7540 - in gnuradio/branches/developers/eb/gcell/src: apps lib/spu
Date: Fri, 1 Feb 2008 20:42:43 -0700 (MST)

Author: eb
Date: 2008-02-01 20:42:42 -0700 (Fri, 01 Feb 2008)
New Revision: 7540

Modified:
   gnuradio/branches/developers/eb/gcell/src/apps/benchmark_nop.cc
   gnuradio/branches/developers/eb/gcell/src/apps/gen_script.py
   gnuradio/branches/developers/eb/gcell/src/lib/spu/gc_delay.c
   gnuradio/branches/developers/eb/gcell/src/lib/spu/gc_delay.h
   gnuradio/branches/developers/eb/gcell/src/lib/spu/test_spu.c
Log:
added exponential backoff to try to avoid livelock

Modified: gnuradio/branches/developers/eb/gcell/src/apps/benchmark_nop.cc
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/apps/benchmark_nop.cc     
2008-02-01 19:45:27 UTC (rev 7539)
+++ gnuradio/branches/developers/eb/gcell/src/apps/benchmark_nop.cc     
2008-02-02 03:42:42 UTC (rev 7540)
@@ -135,7 +135,7 @@
 
     case '?':
     default:
-      fprintf(stderr, "usage: benchmark_nop [-n <nspes>]\n");
+      fprintf(stderr, "usage: benchmark_nop [-n <nspes>] [-u <udelay>]\n");
       return 1;
     }
   }

Modified: gnuradio/branches/developers/eb/gcell/src/apps/gen_script.py
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/apps/gen_script.py        
2008-02-01 19:45:27 UTC (rev 7539)
+++ gnuradio/branches/developers/eb/gcell/src/apps/gen_script.py        
2008-02-02 03:42:42 UTC (rev 7540)
@@ -1,11 +1,21 @@
 #!/usr/bin/env python
 
 import sys
+from optparse import OptionParser
 
+
 def main():
+    parser = OptionParser()
+    parser.add_option("-m", "--max-spes", type="int", default=6,
+                      help="set maximum number of SPEs to use 
[default=%default]")
+    (options, args) = parser.parse_args()
+    if len(args) != 0:
+        parser.print_help()
+        sys.exit(1)
+
     f = sys.stdout
-    for udelay in (1, 5, 10, 50, 100, 200, 300, 500):
-        for nspes in (1, 2, 3, 4, 5, 6):
+    for udelay in (1, 10, 50, 100, 200, 300, 500):
+        for nspes in range(1, options.max_spes+1):
             f.write("./benchmark_nop -n %d -u %d\n" % (nspes, udelay))
             f.write("./benchmark_nop -n %d -u %d\n" % (nspes, udelay))
             f.write("./benchmark_nop -n %d -u %d\n" % (nspes, udelay))

Modified: gnuradio/branches/developers/eb/gcell/src/lib/spu/gc_delay.c
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/spu/gc_delay.c        
2008-02-01 19:45:27 UTC (rev 7539)
+++ gnuradio/branches/developers/eb/gcell/src/lib/spu/gc_delay.c        
2008-02-02 03:42:42 UTC (rev 7540)
@@ -20,6 +20,7 @@
  */
 
 #include "gc_delay.h"
+#include <compiler.h>
 
 inline static void
 gc_udelay_1us(void)
@@ -42,3 +43,16 @@
     gc_udelay_1us();
 }
 
+void
+gc_cdelay(unsigned int cpu_cycles)
+{
+  if (cpu_cycles < 40) // roughly the amount of overhead
+    return;
+  
+  cpu_cycles >>= 2;    // about 4 cycles / loop
+
+  while (cpu_cycles-- != 0){
+    asm ("");          // keeps compiler from removing the loop
+  }
+}
+

Modified: gnuradio/branches/developers/eb/gcell/src/lib/spu/gc_delay.h
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/spu/gc_delay.h        
2008-02-01 19:45:27 UTC (rev 7539)
+++ gnuradio/branches/developers/eb/gcell/src/lib/spu/gc_delay.h        
2008-02-02 03:42:42 UTC (rev 7540)
@@ -1,6 +1,6 @@
 /* -*- c++ -*- */
 /*
- * Copyright 2007 Free Software Foundation, Inc.
+ * Copyright 2007,2008 Free Software Foundation, Inc.
  * 
  * This file is part of GNU Radio
  * 
@@ -22,5 +22,6 @@
 #define INCLUDED_GC_DELAY_H
 
 void gc_udelay(unsigned int usecs);
+void gc_cdelay(unsigned int cpu_cycles);
 
 #endif /* INCLUDED_GC_DELAY_H */

Modified: gnuradio/branches/developers/eb/gcell/src/lib/spu/test_spu.c
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/spu/test_spu.c        
2008-02-01 19:45:27 UTC (rev 7539)
+++ gnuradio/branches/developers/eb/gcell/src/lib/spu/test_spu.c        
2008-02-02 03:42:42 UTC (rev 7540)
@@ -32,7 +32,24 @@
 
 gc_spu_args_t  spu_args;
 
+
+#define BACKOFF_CAP ((1 << 12) - 1)    // 4095 cycles, about 1.3 us
+static unsigned int backoff;           // current backoff value in clock cycles
+
+void 
+backoff_reset(void)
+{
+  backoff = ((1 << (spu_args.spu_idx & 0x3)) + 1) & BACKOFF_CAP;
+}
+
 void
+backoff_delay(void)
+{
+  gc_cdelay(backoff);
+  backoff = ((backoff << 1) + 1) & BACKOFF_CAP;        // capped exponential 
backoff
+}
+
+void
 process_job(gc_eaddr_t jd_ea, gc_job_desc_t *jd)
 {
   // FIXME do something useful ;)
@@ -88,7 +105,10 @@
     // try to get a job from the job queue
     if (gc_jd_queue_dequeue(spu_args.queue, &jd_ea, &jd)){
       process_job(jd_ea, &jd);
+      backoff_reset();
     }
+    else
+      backoff_delay();
   }
 }
 
@@ -107,7 +127,8 @@
 
   // printf("spu[%d] queue = 0x%llx\n", spu_args.spu_idx, spu_args.queue);
 
+  backoff_reset();             // initialize our backoff counter
+
   main_loop();
-
   return 0;
 }





reply via email to

[Prev in Thread] Current Thread [Next in Thread]