commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: eb
Subject: [Commit-gnuradio] r7254 - in gnuradio/branches/developers/eb/gcell/src: apps include lib/spu
Date: Sun, 23 Dec 2007 23:23:21 -0700 (MST)

Author: eb
Date: 2007-12-23 23:23:21 -0700 (Sun, 23 Dec 2007)
New Revision: 7254

Added:
   gnuradio/branches/developers/eb/gcell/src/apps/gen_script.py
   gnuradio/branches/developers/eb/gcell/src/include/gc_methods.h
   gnuradio/branches/developers/eb/gcell/src/lib/spu/gc_delay.c
   gnuradio/branches/developers/eb/gcell/src/lib/spu/gc_delay.h
Modified:
   gnuradio/branches/developers/eb/gcell/src/apps/benchmark_nop.cc
   gnuradio/branches/developers/eb/gcell/src/lib/spu/Makefile.am
   gnuradio/branches/developers/eb/gcell/src/lib/spu/test_spu.c
Log:
improved benchmarking code

Modified: gnuradio/branches/developers/eb/gcell/src/apps/benchmark_nop.cc
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/apps/benchmark_nop.cc     
2007-12-24 03:01:11 UTC (rev 7253)
+++ gnuradio/branches/developers/eb/gcell/src/apps/benchmark_nop.cc     
2007-12-24 06:23:21 UTC (rev 7254)
@@ -20,22 +20,24 @@
  */
 
 #include "gc_job_manager.h"
+#include "gc_methods.h"
 #include "mb_time.h"
 #include <getopt.h>
 #include <stdlib.h>
 
 static void
-init_jd(gc_job_desc *jd, gc_method_t method)
+init_jd(gc_job_desc *jd, unsigned int usecs)
 {
-  jd->method = method;
-  jd->input.n_direct = 0;
+  jd->method = GCM_UDELAY;
+  jd->input.n_direct = 1;
+  jd->input.dir_val[0].u32 = usecs;
   jd->input.n_indirect = 0;
   jd->output.n_direct = 0;
   jd->output.n_indirect = 0;
 }
 
 static void
-run_test(int nspes)
+run_test(unsigned int nspes, unsigned int usecs)
 {
   static const int NJDS = 64;
   static const int njobs = static_cast<int>(1e6);
@@ -55,7 +57,7 @@
   // allocate and init all job descriptors
   for (int i = 0; i < NJDS; i++){
     all_jds[i] = mgr->alloc_job_desc();
-    init_jd(all_jds[i], 0);
+    init_jd(all_jds[i], usecs);
   }
 
   mb_time t_start = mb_time::time();
@@ -79,6 +81,7 @@
   while (ncompleted < njobs){
     njds[ci^1] = 0;
     int n = mgr->wait_jobs(njds[ci], jds[ci], done, GC_WAIT_ANY);
+    // printf("%2d\n", n);
     if (n < 0){
       fprintf(stderr, "mgr->wait_jobs failed\n");
       break;
@@ -107,7 +110,8 @@
   // stop timing
   mb_time t_stop = mb_time::time();
   double delta = (t_stop - t_start).double_time();
-  printf("elapsed time: %10.3f\n", delta);
+  printf("nspes: %2d  udelay: %4d  elapsed time: %7.3f  njobs: %g  us/job: 
%7.3f\n",
+        mgr->nspes(), usecs, delta, (double) njobs, delta/njobs*1e6);
 
   delete mgr;
 }
@@ -116,14 +120,19 @@
 main(int argc, char **argv)
 {
   unsigned int nspes = 0;
+  unsigned int usecs = 0;
   int ch;
 
-  while ((ch = getopt(argc, argv, "n:")) != EOF){
+  while ((ch = getopt(argc, argv, "n:u:")) != EOF){
     switch(ch){
     case 'n':
       nspes = strtol(optarg, 0, 0);
       break;
 
+    case 'u':
+      usecs = strtol(optarg, 0, 0);
+      break;
+
     case '?':
     default:
       fprintf(stderr, "usage: benchmark_nop [-n <nspes>]\n");
@@ -131,6 +140,6 @@
     }
   }
 
-  run_test(nspes);
+  run_test(nspes, usecs);
   return 0;
 }

Added: gnuradio/branches/developers/eb/gcell/src/apps/gen_script.py
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/apps/gen_script.py                
                (rev 0)
+++ gnuradio/branches/developers/eb/gcell/src/apps/gen_script.py        
2007-12-24 06:23:21 UTC (rev 7254)
@@ -0,0 +1,14 @@
+#!/usr/bin/env python
+
+import sys
+
+def main():
+    f = sys.stdout
+    for udelay in (1, 5, 10, 50, 100, 500):
+        for nspes in (1, 2, 3, 4, 5, 6):
+            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))
+
+if __name__ == '__main__':
+    main()


Property changes on: 
gnuradio/branches/developers/eb/gcell/src/apps/gen_script.py
___________________________________________________________________
Name: svn:executable
   + *

Added: gnuradio/branches/developers/eb/gcell/src/include/gc_methods.h
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/include/gc_methods.h              
                (rev 0)
+++ gnuradio/branches/developers/eb/gcell/src/include/gc_methods.h      
2007-12-24 06:23:21 UTC (rev 7254)
@@ -0,0 +1,29 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio 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.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_GC_METHODS_H
+#define INCLUDED_GC_METHODS_H
+
+// list of pre-defined methods
+
+#define GCM_NOP                0       // do nothing
+#define        GCM_UDELAY      1       // delay by dir_val[0] microseconds
+
+#endif /* INCLUDED_GC_METHODS_H */

Modified: gnuradio/branches/developers/eb/gcell/src/lib/spu/Makefile.am
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/spu/Makefile.am       
2007-12-24 03:01:11 UTC (rev 7253)
+++ gnuradio/branches/developers/eb/gcell/src/lib/spu/Makefile.am       
2007-12-24 06:23:21 UTC (rev 7254)
@@ -44,6 +44,7 @@
        libgcell_spu.a
 
 libgcell_spu_a_SOURCES = \
+       gc_delay.c \
        gc_spu_jd_queue.c \
        sys_tags.c
 

Added: gnuradio/branches/developers/eb/gcell/src/lib/spu/gc_delay.c
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/spu/gc_delay.c                
                (rev 0)
+++ gnuradio/branches/developers/eb/gcell/src/lib/spu/gc_delay.c        
2007-12-24 06:23:21 UTC (rev 7254)
@@ -0,0 +1,44 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio 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.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+#include "gc_delay.h"
+
+inline static void
+gc_udelay_1us(void)
+{
+  unsigned int i = 160;
+
+  do {  // 20 clocks per iteration of the loop
+    asm ("nop $127; nop $127; nop $127; nop $127; nop $127");
+    asm ("nop $127; nop $127; nop $127; nop $127; nop $127");
+    asm ("nop $127; nop $127; nop $127; nop $127; nop $127");
+    asm ("nop $127; nop $127; nop $127");
+  } while(--i != 0);
+}
+
+void
+gc_udelay(unsigned int usecs)
+{
+  unsigned int i;
+  for (i = 0; i < usecs; i++)
+    gc_udelay_1us();
+}
+

Added: gnuradio/branches/developers/eb/gcell/src/lib/spu/gc_delay.h
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/spu/gc_delay.h                
                (rev 0)
+++ gnuradio/branches/developers/eb/gcell/src/lib/spu/gc_delay.h        
2007-12-24 06:23:21 UTC (rev 7254)
@@ -0,0 +1,26 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007 Free Software Foundation, Inc.
+ * 
+ * This file is part of GNU Radio
+ * 
+ * GNU Radio is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3, or (at your option)
+ * any later version.
+ * 
+ * GNU Radio 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.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+#ifndef INCLUDED_GC_DELAY_H
+#define INCLUDED_GC_DELAY_H
+
+void gc_udelay(unsigned int usecs);
+
+#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        
2007-12-24 03:01:11 UTC (rev 7253)
+++ gnuradio/branches/developers/eb/gcell/src/lib/spu/test_spu.c        
2007-12-24 06:23:21 UTC (rev 7254)
@@ -27,6 +27,8 @@
 #include "gc_mbox.h"
 #include "sys_tags.h"
 #include "gc_jd_queue.h"
+#include "gc_methods.h"
+#include "gc_delay.h"
 
 gc_spu_args_t  spu_args;
 
@@ -39,7 +41,22 @@
     printf("spu[%d]: job_id = %3d  client_id = %3d\n",
           spu_args.spu_idx, jd->sys.job_id, jd->sys.client_id);
 
-  // FIXME lookup method
+  jd->status = JS_OK;  // assume success
+
+  switch(jd->method){  // FIXME lookup method
+
+  case GCM_NOP:
+    break;
+
+  case GCM_UDELAY:
+    gc_udelay(jd->input.dir_val[0].u32);
+    break;
+
+  default:
+    jd->status = JS_UNKNOWN_METHOD;
+    break;
+  }
+
   // FIXME copy indirect args in
   // FIXME invoke method
   // FIXME copy indirect args out





reply via email to

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