commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: eb
Subject: [Commit-gnuradio] r7748 - in gnuradio/branches/developers/eb/gcell/src: apps include lib lib/spu
Date: Tue, 19 Feb 2008 23:55:21 -0700 (MST)

Author: eb
Date: 2008-02-19 23:55:20 -0700 (Tue, 19 Feb 2008)
New Revision: 7748

Modified:
   gnuradio/branches/developers/eb/gcell/src/apps/benchmark_nop.cc
   gnuradio/branches/developers/eb/gcell/src/include/gc_proc_ids.h
   gnuradio/branches/developers/eb/gcell/src/lib/qa_job_manager.cc
   gnuradio/branches/developers/eb/gcell/src/lib/spu/gc_spu_procs.c
   gnuradio/branches/developers/eb/gcell/src/lib/spu/gcell_spu_main.c
Log:
Work-in-progress on job EA "get" args with arbitrary length and
alignment.  Looking good so far.  Need to write more QA code.


Modified: gnuradio/branches/developers/eb/gcell/src/apps/benchmark_nop.cc
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/apps/benchmark_nop.cc     
2008-02-20 05:33:31 UTC (rev 7747)
+++ gnuradio/branches/developers/eb/gcell/src/apps/benchmark_nop.cc     
2008-02-20 06:55:20 UTC (rev 7748)
@@ -28,7 +28,7 @@
 static void
 init_jd(gc_job_desc *jd, unsigned int usecs)
 {
-  jd->proc_id = GCP_UDELAY;
+  jd->proc_id = GCP_QA_UDELAY;
   jd->input.nargs = 1;
   jd->input.arg[0].u32 = usecs;
   jd->output.nargs = 0;

Modified: gnuradio/branches/developers/eb/gcell/src/include/gc_proc_ids.h
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/include/gc_proc_ids.h     
2008-02-20 05:33:31 UTC (rev 7747)
+++ gnuradio/branches/developers/eb/gcell/src/include/gc_proc_ids.h     
2008-02-20 06:55:20 UTC (rev 7748)
@@ -23,9 +23,9 @@
 
 // list of pre-defined procedure id's
 
-#define GCP_NOP                 0      // do nothing
-#define        GCP_UDELAY       1      // delay by arg[0] microseconds
-#define        GCP_ADD_SHORTS   2      // add elements of ea.arg[0], return in 
output.arg[0]
+#define GCP_QA_NOP              0 // do nothing
+#define        GCP_QA_UDELAY            1 // delay by arg[0] microseconds
+#define        GCP_QA_SUM_SHORTS        2 // sum elements of ea.arg[i], return 
in output.arg[i].s32
 
 #define        GCP_NPROC_IDS   16
 

Modified: gnuradio/branches/developers/eb/gcell/src/lib/qa_job_manager.cc
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/qa_job_manager.cc     
2008-02-20 05:33:31 UTC (rev 7747)
+++ gnuradio/branches/developers/eb/gcell/src/lib/qa_job_manager.cc     
2008-02-20 06:55:20 UTC (rev 7748)
@@ -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
  * 
@@ -194,7 +194,7 @@
 
   for (int i = 0; i < NJOBS; i++){
     jds[i] = mgr->alloc_job_desc();
-    init_jd(jds[i], GCP_NOP);
+    init_jd(jds[i], GCP_QA_NOP);
   }
 
   for (int i = 0; i < NJOBS; i++){
@@ -228,7 +228,7 @@
 
   for (int i = 0; i < NJOBS; i++){
     jds[i] = mgr->alloc_job_desc();
-    init_jd(jds[i], GCP_NOP);
+    init_jd(jds[i], GCP_QA_NOP);
   }
 
   for (int i = 0; i < NJOBS; i++){
@@ -258,8 +258,8 @@
   gc_job_desc *jd = mgr->alloc_job_desc();
 
   
-  // test for success with GCP_NOP procedure
-  init_jd(jd, GCP_NOP);
+  // test for success with GCP_QA_NOP procedure
+  init_jd(jd, GCP_QA_NOP);
   if (!mgr->submit_job(jd)){
     printf("submit_job(jd) failed, status = %d\n", jd->status);
   }
@@ -282,9 +282,63 @@
   delete mgr;
 }
 
+static int
+sum_shorts(short *p, int nshorts)
+{
+  int total = 0;
+  for (int i = 0; i < nshorts; i++)
+    total += p[i];
+
+  return total;
+}
+
+static void
+test_sum_shorts(gc_job_manager *mgr, short *buf, int nshorts)
+{
+  gc_job_desc *jd = mgr->alloc_job_desc();
+
+  init_jd(jd, GCP_QA_SUM_SHORTS);
+  jd->eaa.nargs = 1;
+  jd->eaa.arg[0].ea_addr = ptr_to_ea(buf);
+  jd->eaa.arg[0].direction = GCJD_DMA_GET;
+  jd->eaa.arg[0].get_size = nshorts * sizeof(short);
+  
+
+  if (!mgr->submit_job(jd)){
+    printf("submit_job(jd) failed, status = %d\n", jd->status);
+  }
+  else {
+    mgr->wait_job(jd);
+    CPPUNIT_ASSERT_EQUAL(JS_OK, jd->status);
+    int expected = sum_shorts(buf, nshorts);
+    int actual = jd->output.arg[0].s32;
+    CPPUNIT_ASSERT_EQUAL(expected, actual);
+  }
+
+  mgr->free_job_desc(jd);
+}
+
 void
 qa_job_manager::t7_body()
 {
+  gc_job_manager *mgr;
+  gc_jm_options opts;
+  opts.nspes = 0;              // use them all
+  mgr = gc_make_job_manager(&opts);
+
+  static const int NS = 32768;
+  static short buf[NS] _AL128; // for known alignment
+
+  for (int i = 0; i < NS; i++) // init buffer with known qty
+    buf[i] = 0x1234 + i;
+  
+  for (int offset = 0; offset <= 256; offset++){
+    for (int len = 0; len <= 256; len++){
+      test_sum_shorts(mgr, &buf[offset], len);
+    }
+  }
+
+  delete mgr;
 }
 
 void

Modified: gnuradio/branches/developers/eb/gcell/src/lib/spu/gc_spu_procs.c
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/spu/gc_spu_procs.c    
2008-02-20 05:33:31 UTC (rev 7747)
+++ gnuradio/branches/developers/eb/gcell/src/lib/spu/gc_spu_procs.c    
2008-02-20 06:55:20 UTC (rev 7748)
@@ -21,34 +21,55 @@
 
 #include <gc_spu_procs.h>
 #include <gc_delay.h>
+#include <stdio.h>
 
+
+#define _UNUSED __attribute__((unused))
+
 // FIXME move these out of here; only for QA usage
 
-void 
-gcp_nop(const gc_job_direct_args_t *input,
-       gc_job_direct_args_t *output, gc_job_ea_args_t *ea)
+void
+gcp_qa_nop(const gc_job_direct_args_t *input _UNUSED,
+          gc_job_direct_args_t *output _UNUSED,
+          gc_job_ea_args_t *eaa _UNUSED)
 {
 }
 
 void
-gcp_udelay(const gc_job_direct_args_t *input,
-          gc_job_direct_args_t *output, gc_job_ea_args_t *ea)
+gcp_qa_udelay(const gc_job_direct_args_t *input,
+             gc_job_direct_args_t *output _UNUSED,
+             gc_job_ea_args_t *eaa _UNUSED)
 {
   gc_udelay(input->arg[0].u32);
 }
 
+static int
+sum_shorts(short *p, int nshorts)
+{
+  int total = 0;
+  for (int i = 0; i < nshorts; i++)
+    total += p[i];
+
+  return total;
+}
+
 void
-gcp_add_shorts(const gc_job_direct_args_t *input,
-              gc_job_direct_args_t *output, gc_job_ea_args_t *ea)
+gcp_qa_sum_shorts(const gc_job_direct_args_t *input _UNUSED,
+                 gc_job_direct_args_t *output,
+                 gc_job_ea_args_t *eaa)
 {
-  // FIXME
+  for (unsigned int i = 0; i < eaa->nargs; i++){
+    short *p = eaa->arg[i].ls_addr;
+    int n = eaa->arg[i].get_size / sizeof(short);
+    output->arg[i].s32 = sum_shorts(p, n);
+    //printf("qa_sum_shorts(%p, %d) = %d\n",  p, n, output->arg[i].s32);
+  }
 }
 
+
 gc_spu_proc_t gc_proc_table[GCP_NPROC_IDS] = {
-  [GCP_NOP] = gcp_nop,
-  [GCP_UDELAY] = gcp_udelay,
-  [GCP_ADD_SHORTS] = gcp_add_shorts,
+  [GCP_QA_NOP] = gcp_qa_nop,
+  [GCP_QA_UDELAY] = gcp_qa_udelay,
+  [GCP_QA_SUM_SHORTS] = gcp_qa_sum_shorts,
 };
 
-
-

Modified: gnuradio/branches/developers/eb/gcell/src/lib/spu/gcell_spu_main.c
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/spu/gcell_spu_main.c  
2008-02-20 05:33:31 UTC (rev 7747)
+++ gnuradio/branches/developers/eb/gcell/src/lib/spu/gcell_spu_main.c  
2008-02-20 06:55:20 UTC (rev 7748)
@@ -216,11 +216,11 @@
       memset(dma_list, 0, sizeof(dma_list));
       int li = 0;
 
-      unsigned int   gbi = 0;                  // get buffer index
-      unsigned char *gb_base = gc_getbuf[gbi];
+      unsigned char *gb_base = gc_getbuf[0];
+      unsigned char *p = gb_base;
       
       // unsigned int pbi = 0;                 // put buffer index
-      // unsigned char *pb_base = gc_putbuf[gbi];
+      // unsigned char *pb_base = gc_putbuf[pbi];
       
       // assign LS addresses for buffers
       
@@ -234,8 +234,8 @@
          ea_base = ROUND_DN(eaa->arg[i].ea_addr, (gc_eaddr_t) CACHE_LINE_SIZE);
          offset = eaa->arg[i].ea_addr & (CACHE_LINE_SIZE-1);
          dma_len = ROUND_UP(eaa->arg[i].get_size + offset, CACHE_LINE_SIZE);
-         ls_base = gb_base;
-         gb_base += dma_len;
+         ls_base = p;
+         p += dma_len;
          eaa->arg[i].ls_addr = ls_base + offset;
 
          assert((mfc_ea2l(eaa->arg[i].ea_addr) & 0x7f) == 
((intptr_t)eaa->arg[i].ls_addr & 0x7f));
@@ -243,14 +243,26 @@
          assert(((intptr_t)ls_base & 0x7f) == 0);
          assert((dma_len & 0x7f) == 0);
          assert((eaa->arg[i].get_size <= dma_len)
-                && dma_len <= (eaa->arg[i].get_size + CACHE_LINE_SIZE - 1));
+                && dma_len <= (eaa->arg[i].get_size + offset + CACHE_LINE_SIZE 
- 1));
 
+         if (0){
+           printf("eaa->arg[%d]\n", i);
+           printf("  ea_addr   = %8llx\n", eaa->arg[i].ea_addr);
+           printf("  direct    = %s\n", eaa->arg[i].direction == GCJD_DMA_GET 
? "get" : "put");
+           printf("  get_size  = %6d\n", eaa->arg[i].get_size);
+           printf("  ls_addr   = %p\n", eaa->arg[i].ls_addr);
+         }
+         
          // add to dma list
          // FIXME not correct if top 32-bits of all EA's are NOT the same
          while (dma_len != 0){
            int n = MIN(dma_len, MFC_MAX_DMA_SIZE);
            dma_list[li].size = n;
            dma_list[li].eal = mfc_ea2l(ea_base);
+           if (0){
+             printf("  dma_list[%d].size = %6d\n", li, dma_list[li].size);
+             printf("  dma_list[%d].eal  = 0x%08x\n", li, dma_list[li].eal);
+           }
            dma_len -= n;
            ea_base += n;
            li++;





reply via email to

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