commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r7248 - gnuradio/branches/developers/eb/gcell/src/apps


From: eb
Subject: [Commit-gnuradio] r7248 - gnuradio/branches/developers/eb/gcell/src/apps
Date: Sun, 23 Dec 2007 14:12:01 -0700 (MST)

Author: eb
Date: 2007-12-23 14:12:01 -0700 (Sun, 23 Dec 2007)
New Revision: 7248

Added:
   gnuradio/branches/developers/eb/gcell/src/apps/benchmark_nop.cc
Modified:
   gnuradio/branches/developers/eb/gcell/src/apps/
   gnuradio/branches/developers/eb/gcell/src/apps/Makefile.am
Log:
simple benchmarking code for job manager


Property changes on: gnuradio/branches/developers/eb/gcell/src/apps
___________________________________________________________________
Name: svn:ignore
   - Makefile
Makefile.in
.la
.lo
.deps
.libs
*.la
*.lo
test_all

   + Makefile
Makefile.in
.la
.lo
.deps
.libs
*.la
*.lo
test_all
benchmark_nop


Modified: gnuradio/branches/developers/eb/gcell/src/apps/Makefile.am
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/apps/Makefile.am  2007-12-23 
18:57:51 UTC (rev 7247)
+++ gnuradio/branches/developers/eb/gcell/src/apps/Makefile.am  2007-12-23 
21:12:01 UTC (rev 7248)
@@ -27,11 +27,16 @@
 TESTS = test_all
 
 noinst_PROGRAMS = \
-       test_all
+       test_all \
+       benchmark_nop
 
-
-LDADD = \
+STDLIBS = \
        $(top_builddir)/src/lib/libgcell-qa.la \
        $(top_builddir)/src/lib/libgcell.la
 
+LDADD = $(STDLIBS)
+
 test_all_SOURCES = test_all.cc
+
+benchmark_nop_SOURCES = benchmark_nop.cc
+benchmark_nop_LDADD = $(STDLIBS) -lmblock 

Added: gnuradio/branches/developers/eb/gcell/src/apps/benchmark_nop.cc
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/apps/benchmark_nop.cc             
                (rev 0)
+++ gnuradio/branches/developers/eb/gcell/src/apps/benchmark_nop.cc     
2007-12-23 21:12:01 UTC (rev 7248)
@@ -0,0 +1,136 @@
+/* -*- 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_job_manager.h"
+#include "mb_time.h"
+#include <getopt.h>
+#include <stdlib.h>
+
+static void
+init_jd(gc_job_desc *jd, gc_method_t method)
+{
+  jd->method = method;
+  jd->input.n_direct = 0;
+  jd->input.n_indirect = 0;
+  jd->output.n_direct = 0;
+  jd->output.n_indirect = 0;
+}
+
+static void
+run_test(int nspes)
+{
+  static const int NJDS = 64;
+  static const int njobs = static_cast<int>(1e6);
+  int nsubmitted = 0;
+  int ncompleted = 0;
+  gc_job_desc *all_jds[NJDS];
+  gc_job_desc *jds[2][NJDS];
+  unsigned int njds[2];
+  unsigned int ci;             // current index
+  bool done[NJDS];
+  
+  gc_jm_options opts;
+  opts.nspes = nspes;
+  // opts.gang_schedule = true;
+  gc_job_manager *mgr = gc_make_job_manager(&opts);
+
+  // 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);
+  }
+
+  mb_time t_start = mb_time::time();
+
+  ci = 0;
+  njds[0] = 0;
+  njds[1] = 0;
+  
+  // submit the first batch
+  for (int i = 0; i < NJDS; i++){
+    if (mgr->submit_job(all_jds[i])){
+      jds[ci][njds[ci]++] = all_jds[i];
+      nsubmitted++;
+    }
+    else {
+      printf("submit_job(jds[%d]) failed, status = %d\n",
+            i, all_jds[i]->status);
+    }
+  }
+  
+  while (ncompleted < njobs){
+    njds[ci^1] = 0;
+    int n = mgr->wait_jobs(njds[ci], jds[ci], done, GC_WAIT_ANY);
+    if (n < 0){
+      fprintf(stderr, "mgr->wait_jobs failed\n");
+      break;
+    }
+    for (unsigned int i = 0; i < njds[ci]; i++){
+      if (!done[i]){   // remember for next iteration
+       jds[ci^1][njds[ci^1]++] = jds[ci][i];
+      }
+      else {
+       ncompleted++;
+       if (nsubmitted < njobs){                    // submit another one
+         if (mgr->submit_job(jds[ci][i])){
+           jds[ci^1][njds[ci^1]++] = jds[ci][i];  // remember for next iter
+           nsubmitted++;
+         }
+         else {
+           printf("submit_job(jds[%d]) failed, status = %d\n",
+                  i, jds[ci][i]->status);
+         }
+       }
+      }
+    }
+    ci ^= 1;   // toggle current
+  }
+
+  // stop timing
+  mb_time t_stop = mb_time::time();
+  double delta = (t_stop - t_start).double_time();
+  printf("elapsed time: %10.3f\n", delta);
+
+  delete mgr;
+}
+
+int
+main(int argc, char **argv)
+{
+  unsigned int nspes = 0;
+  int ch;
+
+  while ((ch = getopt(argc, argv, "n:")) != EOF){
+    switch(ch){
+    case 'n':
+      nspes = strtol(optarg, 0, 0);
+      break;
+
+    case '?':
+    default:
+      fprintf(stderr, "usage: benchmark_nop [-n <nspes>]\n");
+      return 1;
+    }
+  }
+
+  run_test(nspes);
+  return 0;
+}





reply via email to

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