[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r7756 - gnuradio/branches/developers/eb/gcell/src/apps
From: |
eb |
Subject: |
[Commit-gnuradio] r7756 - gnuradio/branches/developers/eb/gcell/src/apps |
Date: |
Wed, 20 Feb 2008 14:48:33 -0700 (MST) |
Author: eb
Date: 2008-02-20 14:48:32 -0700 (Wed, 20 Feb 2008)
New Revision: 7756
Added:
gnuradio/branches/developers/eb/gcell/src/apps/benchmark_dma.cc
Modified:
gnuradio/branches/developers/eb/gcell/src/apps/
gnuradio/branches/developers/eb/gcell/src/apps/Makefile.am
Log:
work-in-progress
Property changes on: gnuradio/branches/developers/eb/gcell/src/apps
___________________________________________________________________
Name: svn:ignore
- Makefile
Makefile.in
.la
.lo
.deps
.libs
*.la
*.lo
test_all
benchmark_nop
+ Makefile
Makefile.in
.la
.lo
.deps
.libs
*.la
*.lo
test_all
benchmark_nop
benchmark_dma
Modified: gnuradio/branches/developers/eb/gcell/src/apps/Makefile.am
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/apps/Makefile.am 2008-02-20
20:43:17 UTC (rev 7755)
+++ gnuradio/branches/developers/eb/gcell/src/apps/Makefile.am 2008-02-20
21:48:32 UTC (rev 7756)
@@ -28,6 +28,7 @@
noinst_PROGRAMS = \
test_all \
+ benchmark_dma \
benchmark_nop
STDLIBS = \
@@ -38,5 +39,8 @@
test_all_SOURCES = test_all.cc
+benchmark_dma_SOURCES = benchmark_dma.cc
+benchmark_dma_LDADD = $(STDLIBS) -lmblock
+
benchmark_nop_SOURCES = benchmark_nop.cc
benchmark_nop_LDADD = $(STDLIBS) -lmblock
Copied: gnuradio/branches/developers/eb/gcell/src/apps/benchmark_dma.cc (from
rev 7748, gnuradio/branches/developers/eb/gcell/src/apps/benchmark_nop.cc)
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/apps/benchmark_dma.cc
(rev 0)
+++ gnuradio/branches/developers/eb/gcell/src/apps/benchmark_dma.cc
2008-02-20 21:48:32 UTC (rev 7756)
@@ -0,0 +1,182 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 2007,2008 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 "gc_proc_ids.h"
+#include "mb_time.h"
+#include <getopt.h>
+#include <stdlib.h>
+#include <boost/scoped_array.hpp>
+
+static void
+init_jd(gc_job_desc *jd, unsigned int usecs,
+ unsigned char *getbuf, size_t getbuf_len)
+{
+ jd->proc_id = GCP_QA_UDELAY;
+ jd->input.nargs = 1;
+ jd->input.arg[0].u32 = usecs;
+ jd->output.nargs = 0;
+ jd->eaa.nargs = 1;
+ jd->eaa.arg[0].direction = GCJD_DMA_GET;
+ jd->eaa.arg[0].ea_addr = ptr_to_ea(getbuf);
+ jd->eaa.arg[0].get_size = getbuf_len;
+}
+
+static void
+run_test(unsigned int nspes, unsigned int usecs, unsigned int dma_size)
+{
+ static const int64_t TOTAL_SIZE_DMA = 20LL << 30;
+ static const int NJDS = 64;
+ unsigned int njobs = (unsigned int)(TOTAL_SIZE_DMA / dma_size);
+ unsigned int nsubmitted = 0;
+ unsigned 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];
+
+ static const unsigned int GETBUFSIZE = 16 << 20; // 16MB
+ static const unsigned int GETBUFMASK = GETBUFSIZE - 1;
+ unsigned char *getbuf = new unsigned char[GETBUFSIZE];
+ boost::scoped_array<unsigned char> _getbuf(getbuf);
+ int gbi = 0;
+
+ // touch all pages to force allocation now
+ for (unsigned int i = 0; i < GETBUFSIZE; i += 4096)
+ getbuf[i] = 0;
+
+ 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], usecs, &getbuf[gbi], dma_size);
+ gbi = (gbi + dma_size) & GETBUFMASK;
+ }
+
+ 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);
+ // printf("%2d\n", n);
+ 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++;
+ // printf("ncompleted = %7d\n", 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("nspes: %2d udelay: %4d elapsed_time: %7.3f dma_size: %5d
dma_throughput: %7.3e\n",
+ mgr->nspes(), usecs, delta, dma_size, (double) njobs * dma_size /
delta);
+
+ delete mgr;
+}
+
+static bool
+power_of_2_p(unsigned long x)
+{
+ int nbits = sizeof(x) * 8;
+ for (int i = 0; i < nbits; i++)
+ if (x == (1UL << i))
+ return true;
+
+ return false;
+}
+
+int
+main(int argc, char **argv)
+{
+ unsigned int nspes = 0;
+ unsigned int usecs = 0;
+ unsigned int dma_size = 16 << 10;
+ int ch;
+
+ while ((ch = getopt(argc, argv, "n:u:s:")) != EOF){
+ switch(ch){
+ case 'n':
+ nspes = strtol(optarg, 0, 0);
+ break;
+
+ case 'u':
+ usecs = strtol(optarg, 0, 0);
+ break;
+
+ case 's':
+ dma_size = strtol(optarg, 0, 0);
+ if (!power_of_2_p(dma_size) || dma_size < 16){
+ fprintf(stderr, "-s <dma_size> must be a power of 2 >= 16\n");
+ return 1;
+ }
+ break;
+
+ case '?':
+ default:
+ fprintf(stderr, "usage: benchmark_dma [-n <nspes>] [-u <udelay>] [-s
<dma_size>]\n");
+ return 1;
+ }
+ }
+
+ run_test(nspes, usecs, dma_size);
+ return 0;
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r7756 - gnuradio/branches/developers/eb/gcell/src/apps,
eb <=