commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r7950 - in gnuradio/branches/developers/eb/gcell-wip/s


From: eb
Subject: [Commit-gnuradio] r7950 - in gnuradio/branches/developers/eb/gcell-wip/src: apps include lib lib/spu
Date: Wed, 5 Mar 2008 21:18:25 -0700 (MST)

Author: eb
Date: 2008-03-05 21:18:24 -0700 (Wed, 05 Mar 2008)
New Revision: 7950

Modified:
   gnuradio/branches/developers/eb/gcell-wip/src/apps/benchmark_dma.cc
   gnuradio/branches/developers/eb/gcell-wip/src/include/gc_logging.h
   gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager.h
   gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager_impl.cc
   gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager_impl.h
   gnuradio/branches/developers/eb/gcell-wip/src/lib/spu/gc_logging.c
   gnuradio/branches/developers/eb/gcell-wip/src/lib/spu/gc_main.c
Log:
added logging to gc_main

Modified: gnuradio/branches/developers/eb/gcell-wip/src/apps/benchmark_dma.cc
===================================================================
--- gnuradio/branches/developers/eb/gcell-wip/src/apps/benchmark_dma.cc 
2008-03-06 02:59:15 UTC (rev 7949)
+++ gnuradio/branches/developers/eb/gcell-wip/src/apps/benchmark_dma.cc 
2008-03-06 04:18:24 UTC (rev 7950)
@@ -92,10 +92,10 @@
 static void
 run_test(unsigned int nspes, unsigned int usecs, unsigned int dma_size, int 
getput_mask)
 {
-  static const int64_t TOTAL_SIZE_DMA = 20LL << 30;
+  static const int64_t TOTAL_SIZE_DMA = 5LL << 30;
   static const int NJDS = 64;
-  unsigned int njobs = (unsigned int)(TOTAL_SIZE_DMA / dma_size);
-  //unsigned int njobs = NJDS * 16;
+  //unsigned int njobs = (unsigned int)(TOTAL_SIZE_DMA / dma_size);
+  unsigned int njobs = NJDS * 16;
   unsigned int nsubmitted = 0;
   unsigned int ncompleted = 0;
   gc_job_desc *all_jds[NJDS];
@@ -120,7 +120,7 @@
   gc_jm_options opts;
   opts.program_handle = &benchmark_procs;
   opts.nspes = nspes;
-  opts.gang_schedule = true;
+  opts.enable_logging = true;
   gc_job_manager *mgr = gc_make_job_manager(&opts);
 
   if ((gcp_benchmark_udelay = mgr->lookup_proc("benchmark_udelay")) == 
GCP_UNKNOWN_PROC){

Modified: gnuradio/branches/developers/eb/gcell-wip/src/include/gc_logging.h
===================================================================
--- gnuradio/branches/developers/eb/gcell-wip/src/include/gc_logging.h  
2008-03-06 02:59:15 UTC (rev 7949)
+++ gnuradio/branches/developers/eb/gcell-wip/src/include/gc_logging.h  
2008-03-06 04:18:24 UTC (rev 7950)
@@ -22,6 +22,7 @@
 #define INCLUDED_GC_LOGGING_H
 
 #include <gc_types.h>
+#include <string.h>
 
 __GC_BEGIN_DECLS
 
@@ -42,7 +43,13 @@
 #define        GCL_SS_USER   256       // lowest user reserved subsystem
 
 
+/*
+ * The resulting log files can be displayed using using:
+ *
+ *  $ od -t x4 -w32 spu_log.00 | less
+ */
 
+
 #if defined(__SPU__)
 
 /*!
@@ -63,6 +70,11 @@
   gc_log_entry_t e;
   e.subsystem = subsystem;
   e.event = event;
+  e.info[0] = 0;
+  e.info[1] = 0;
+  e.info[2] = 0;
+  e.info[3] = 0;
+  e.info[4] = 0;
   gc_log_write(e);
 }
 
@@ -74,6 +86,10 @@
   e.subsystem = subsystem;
   e.event = event;
   e.info[0] = info0;
+  e.info[1] = 0;
+  e.info[2] = 0;
+  e.info[3] = 0;
+  e.info[4] = 0;
   gc_log_write(e);
 }
 
@@ -86,6 +102,9 @@
   e.event = event;
   e.info[0] = info0;
   e.info[1] = info1;
+  e.info[2] = 0;
+  e.info[3] = 0;
+  e.info[4] = 0;
   gc_log_write(e);
 }
 
@@ -99,6 +118,8 @@
   e.info[0] = info0;
   e.info[1] = info1;
   e.info[2] = info2;
+  e.info[3] = 0;
+  e.info[4] = 0;
   gc_log_write(e);
 }
 
@@ -113,6 +134,7 @@
   e.info[1] = info1;
   e.info[2] = info2;
   e.info[3] = info3;
+  e.info[4] = 0;
   gc_log_write(e);
 }
 

Modified: gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager.h
===================================================================
--- gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager.h  
2008-03-06 02:59:15 UTC (rev 7949)
+++ gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager.h  
2008-03-06 04:18:24 UTC (rev 7950)
@@ -46,13 +46,13 @@
   bool gang_schedule;              // shall we gang schedule?
   bool use_affinity;               // shall we try for affinity (FIXME not 
implmented)
   bool enable_logging;             // shall we log SPE events?
-  uint32_t nlog_entries;           // number of log entries (default is 4k)
+  uint32_t log2_nlog_entries;           // log2 of number of log entries 
(default is 12 == 4k)
   spe_program_handle_t *program_handle;  // program to load into SPEs
 
   gc_jm_options() :
     max_jobs(0), max_client_threads(0), nspes(0),
     gang_schedule(true), use_affinity(false),
-    enable_logging(false), nlog_entries(4096),
+    enable_logging(false), log2_nlog_entries(12),
     program_handle(0)
   {
   }

Modified: 
gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager_impl.cc
===================================================================
--- gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager_impl.cc    
2008-03-06 02:59:15 UTC (rev 7949)
+++ gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager_impl.cc    
2008-03-06 04:18:24 UTC (rev 7950)
@@ -115,6 +115,12 @@
   return p;
 }
 
+static bool
+is_power_of_2(uint32_t x)
+{
+  return (x != 0) && !(x & (x - 1));
+}
+
 ////////////////////////////////////////////////////////////////////////
 
 
@@ -353,6 +359,8 @@
 
   // clear cti, since we've deleted the underlying data
   pthread_setspecific(s_client_key, 0);
+
+  unmap_logfiles();
 }
 
 bool
@@ -1172,15 +1180,16 @@
   if (!d_options.enable_logging)
     return;
 
-  if (d_options.nlog_entries == 0)
-    d_options.nlog_entries = 4096;
+  if (d_options.log2_nlog_entries == 0)
+    d_options.log2_nlog_entries = 12;
 
   // must end up a multiple of the page size
 
   size_t pagesize = getpagesize();
-  size_t s = d_options.nlog_entries * sizeof(gc_log_entry_t);
+  size_t s = (1 << d_options.log2_nlog_entries) * sizeof(gc_log_entry_t);
   s = ((s + pagesize - 1) / pagesize) * pagesize;
-  d_options.nlog_entries = s / sizeof(gc_log_entry_t);
+  size_t nentries = s / sizeof(gc_log_entry_t);
+  assert(is_power_of_2(nentries));
 
   for (unsigned int i = 0; i < d_options.nspes; i++){
     char filename[100];
@@ -1199,8 +1208,9 @@
       return;
     }
     close(fd);
+    memset(p, 0, s);
     d_spu_args[i].log.base = ptr_to_ea(p);
-    d_spu_args[i].log.nentries = d_options.nlog_entries;
+    d_spu_args[i].log.nentries = nentries;
   }
 }
 
@@ -1208,12 +1218,23 @@
 gc_job_manager_impl::sync_logfiles()
 {
   for (unsigned int i = 0; i < d_options.nspes; i++){
-    msync(ea_to_ptr(d_spu_args[i].log.base),
-         d_spu_args[i].log.nentries * sizeof(gc_log_entry_t),
-         MS_ASYNC);
+    if (d_spu_args[i].log.base)
+      msync(ea_to_ptr(d_spu_args[i].log.base),
+           d_spu_args[i].log.nentries * sizeof(gc_log_entry_t),
+           MS_ASYNC);
   }
 }
 
+void
+gc_job_manager_impl::unmap_logfiles()
+{
+  for (unsigned int i = 0; i < d_options.nspes; i++){
+    if (d_spu_args[i].log.base)
+      munmap(ea_to_ptr(d_spu_args[i].log.base),
+            d_spu_args[i].log.nentries * sizeof(gc_log_entry_t));
+  }
+}
+
 ////////////////////////////////////////////////////////////////////////
 //
 // lookup proc names in d_proc_def table

Modified: 
gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager_impl.h
===================================================================
--- gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager_impl.h     
2008-03-06 02:59:15 UTC (rev 7949)
+++ gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager_impl.h     
2008-03-06 04:18:24 UTC (rev 7950)
@@ -167,6 +167,7 @@
 
   void setup_logfiles();
   void sync_logfiles();
+  void unmap_logfiles();
 
   friend gc_job_manager *gc_make_job_manager(const gc_jm_options *options);
   

Modified: gnuradio/branches/developers/eb/gcell-wip/src/lib/spu/gc_logging.c
===================================================================
--- gnuradio/branches/developers/eb/gcell-wip/src/lib/spu/gc_logging.c  
2008-03-06 02:59:15 UTC (rev 7949)
+++ gnuradio/branches/developers/eb/gcell-wip/src/lib/spu/gc_logging.c  
2008-03-06 04:18:24 UTC (rev 7950)
@@ -24,12 +24,16 @@
 #include <spu_mfcio.h>
 #include <gc_spu_args.h>
 
-static gc_eaddr_t  log_base_ea;                // base address of log entries 
in EA
-static uint32_t           log_idx_mask;        // nentries - 1
-static uint32_t           log_idx;             // current log entry index
-static uint32_t           log_seqno;
-static int        log_tag;
+static gc_eaddr_t     log_base_ea;     // base address of log entries in EA
+static uint32_t              log_idx_mask;     // nentries - 1
+static uint32_t              log_idx;          // current log entry index
+static uint32_t              log_seqno;
 
+static int           log_tags;         // two consecutive tags
+static int           tmp_buffer_busy;  // bitmask: buffer busy state
+static int           tmp_buffer_idx;   // 0 or 1
+static gc_log_entry_t tmp_buffer[2];
+
 void
 _gc_log_init(gc_log_t info)
 {
@@ -39,7 +43,12 @@
   log_idx_mask = info.nentries - 1;
   log_idx = 0;
   log_seqno = 0;
-  log_tag = mfc_tag_reserve();
+
+  log_tags = mfc_multi_tag_reserve(2);
+  tmp_buffer_busy = 0;
+  tmp_buffer_idx = 0;
+
+  gc_log_write0(GCL_SS_SYS, 0);
 }
 
 void
@@ -51,7 +60,18 @@
   entry.seqno = log_seqno++;
   entry.timestamp = spu_read_decrementer();
 
-  mfc_put(&entry, log_base_ea + log_idx * sizeof(entry), sizeof(entry), 
log_tag, 0, 0);
+  if (tmp_buffer_busy & (1 << tmp_buffer_idx)){
+    mfc_write_tag_mask(1 << (log_tags + tmp_buffer_idx));
+    mfc_read_tag_status_all();
+  }
+
+  tmp_buffer[tmp_buffer_idx] = entry;  // save local copy
+
+  mfc_put(&tmp_buffer[tmp_buffer_idx],
+         log_base_ea + log_idx * sizeof(entry), sizeof(entry),
+         log_tags + tmp_buffer_idx, 0, 0);
+
+  tmp_buffer_busy |= (1 << tmp_buffer_idx);
+  tmp_buffer_idx ^= 0x1;
   log_idx = (log_idx + 1) & log_idx_mask;
 }
-  

Modified: gnuradio/branches/developers/eb/gcell-wip/src/lib/spu/gc_main.c
===================================================================
--- gnuradio/branches/developers/eb/gcell-wip/src/lib/spu/gc_main.c     
2008-03-06 02:59:15 UTC (rev 7949)
+++ gnuradio/branches/developers/eb/gcell-wip/src/lib/spu/gc_main.c     
2008-03-06 04:18:24 UTC (rev 7950)
@@ -19,6 +19,8 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
+#define ENABLE_GC_LOGGING      // define to enable logging
+
 #include <spu_intrinsics.h>
 #include <spu_mfcio.h>
 #include <sync_utils.h>
@@ -121,13 +123,14 @@
   if (put_in_progress & PBI_MASK(1))
     tag_mask |= (1 << (put_tags + 1));
 
+  gc_log_write2(GCL_SS_SYS, 8, put_in_progress, tag_mask);
+
   mfc_write_tag_mask(tag_mask);                // the tags we're interested in
   mfc_read_tag_status_all();           // wait for DMA to complete
+  put_in_progress = 0;                 // mark them all complete
 
-  // printf("(2) pip 0x%x pb_idx %d\n", put_in_progress, pb_idx);
+  gc_log_write1(GCL_SS_SYS, 9, put_in_progress);
 
-  put_in_progress = 0;                 // mark them all complete
-
   // send PPE a message
   spu_writech(SPU_WrOutIntrMbox, MK_MBOX_MSG(OP_JOBS_DONE, ci_idx));
 
@@ -285,14 +288,18 @@
       // Do we have any "put" args?  If so ensure that previous
       // dma from this buffer is complete
 
+      gc_log_write2(GCL_SS_SYS, 5, put_in_progress, jd->sys.direction_union);
+
       if ((jd->sys.direction_union & GCJD_DMA_PUT)
          && (put_in_progress & PBI_MASK(pb_idx))){
 
-       // printf("(1) pip 0x%x pb_idx %d\n", put_in_progress, pb_idx);
+       gc_log_write2(GCL_SS_SYS, 6, put_in_progress, 1 << put_tag);
 
        mfc_write_tag_mask(1 << put_tag);       // the tag we're interested in
        mfc_read_tag_status_all();              // wait for DMA to complete
        put_in_progress &= ~(PBI_MASK(pb_idx));
+
+       gc_log_write1(GCL_SS_SYS, 7, put_in_progress);
       }
 
 
@@ -510,6 +517,7 @@
        }
        if (started_dma){
          put_in_progress |= PBI_MASK(pb_idx);          // note it's running
+         gc_log_write2(GCL_SS_SYS, 4, put_in_progress, pb_idx);
          pb_idx ^= 1;                                  // toggle current buffer
        }
       }
@@ -535,8 +543,10 @@
 #if 0 // FIXME
   flush_completion_info();
 #else
-  if (comp_info.ncomplete == GC_CI_NJOBS)
+  if (comp_info.ncomplete == GC_CI_NJOBS){
+    gc_log_write0(GCL_SS_SYS, 2);
     flush_completion_info();
+  }
 #endif  
 }
 
@@ -612,8 +622,10 @@
     // If we've got job completion info for the PPE and we can send a
     // message without blocking, do it.
 
-    if (comp_info.ncomplete != 0 && spu_readchcnt(SPU_WrOutIntrMbox) != 0)
+    if (comp_info.ncomplete != 0 && spu_readchcnt(SPU_WrOutIntrMbox) != 0){
+      gc_log_write0(GCL_SS_SYS, 1);
       flush_completion_info();
+    }
   }
 }
 





reply via email to

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