commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: eb
Subject: [Commit-gnuradio] r7949 - in gnuradio/branches/developers/eb/gcell-wip/src: apps include lib lib/spu
Date: Wed, 5 Mar 2008 19:59:16 -0700 (MST)

Author: eb
Date: 2008-03-05 19:59:15 -0700 (Wed, 05 Mar 2008)
New Revision: 7949

Added:
   gnuradio/branches/developers/eb/gcell-wip/src/include/gc_logging.h
   gnuradio/branches/developers/eb/gcell-wip/src/lib/spu/gc_logging.c
Removed:
   gnuradio/branches/developers/eb/gcell-wip/src/include/gc_proc_ids_private.h
Modified:
   gnuradio/branches/developers/eb/gcell-wip/src/apps/benchmark_dma.cc
   gnuradio/branches/developers/eb/gcell-wip/src/include/gc_spu_args.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/Makefile.am
   gnuradio/branches/developers/eb/gcell-wip/src/lib/spu/gc_main.c
Log:
work-in-progress: added support for high-speed logging from SPEs

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 00:13:13 UTC (rev 7948)
+++ gnuradio/branches/developers/eb/gcell-wip/src/apps/benchmark_dma.cc 
2008-03-06 02:59:15 UTC (rev 7949)
@@ -38,6 +38,7 @@
 #define        BENCHMARK_GET_PUT       (BENCHMARK_PUT|BENCHMARK_GET)
 
 
+#if 0
 static bool
 power_of_2_p(unsigned long x)
 {
@@ -48,6 +49,7 @@
 
   return false;
 }
+#endif
 
 static void
 init_jd(gc_job_desc *jd, unsigned int usecs,

Added: gnuradio/branches/developers/eb/gcell-wip/src/include/gc_logging.h
===================================================================
--- gnuradio/branches/developers/eb/gcell-wip/src/include/gc_logging.h          
                (rev 0)
+++ gnuradio/branches/developers/eb/gcell-wip/src/include/gc_logging.h  
2008-03-06 02:59:15 UTC (rev 7949)
@@ -0,0 +1,144 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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.
+ */
+#ifndef INCLUDED_GC_LOGGING_H
+#define INCLUDED_GC_LOGGING_H
+
+#include <gc_types.h>
+
+__GC_BEGIN_DECLS
+
+typedef struct gc_log {
+  gc_eaddr_t           base;           // gc_log_entry_t * (16 byte aligned)
+  uint32_t     nentries;       // number of entries (power-of-2)
+} gc_log_t;
+
+typedef struct gc_log_entry {
+  uint32_t     seqno;          // monotonic sequence number
+  uint32_t     timestamp;      // decrementer value (wraps every 53s on PS3)
+  uint16_t     subsystem;      // 0 to 255 reserved for system, user gets 256 
and up
+  uint16_t     event;
+  uint32_t     info[5];
+} _AL16 gc_log_entry_t;
+
+#define        GCL_SS_SYS      0       // lowest system reserved subsystem
+#define        GCL_SS_USER   256       // lowest user reserved subsystem
+
+
+
+#if defined(__SPU__)
+
+/*!
+ * System fills in seqno and timestamp.  User is responsible for the rest.
+ */
+
+void _gc_log_write(gc_log_entry_t entry);
+
+#ifdef ENABLE_GC_LOGGING
+#define gc_log_write(entry) _gc_log_write(entry)
+#else
+#define gc_log_write(entry) do { } while (0)
+#endif
+
+inline static void
+gc_log_write0(int subsystem, int event)
+{
+  gc_log_entry_t e;
+  e.subsystem = subsystem;
+  e.event = event;
+  gc_log_write(e);
+}
+
+inline static void
+gc_log_write1(int subsystem, int event,
+             uint32_t info0)
+{
+  gc_log_entry_t e;
+  e.subsystem = subsystem;
+  e.event = event;
+  e.info[0] = info0;
+  gc_log_write(e);
+}
+
+inline static void
+gc_log_write2(int subsystem, int event,
+             uint32_t info0, uint32_t info1)
+{
+  gc_log_entry_t e;
+  e.subsystem = subsystem;
+  e.event = event;
+  e.info[0] = info0;
+  e.info[1] = info1;
+  gc_log_write(e);
+}
+
+inline static void
+gc_log_write3(int subsystem, int event,
+             uint32_t info0, uint32_t info1, uint32_t info2)
+{
+  gc_log_entry_t e;
+  e.subsystem = subsystem;
+  e.event = event;
+  e.info[0] = info0;
+  e.info[1] = info1;
+  e.info[2] = info2;
+  gc_log_write(e);
+}
+
+inline static void
+gc_log_write4(int subsystem, int event,
+             uint32_t info0, uint32_t info1, uint32_t info2, uint32_t info3)
+{
+  gc_log_entry_t e;
+  e.subsystem = subsystem;
+  e.event = event;
+  e.info[0] = info0;
+  e.info[1] = info1;
+  e.info[2] = info2;
+  e.info[3] = info3;
+  gc_log_write(e);
+}
+
+inline static void
+gc_log_write5(int subsystem, int event,
+             uint32_t info0, uint32_t info1, uint32_t info2, uint32_t info3, 
uint32_t info4)
+{
+  gc_log_entry_t e;
+  e.subsystem = subsystem;
+  e.event = event;
+  e.info[0] = info0;
+  e.info[1] = info1;
+  e.info[2] = info2;
+  e.info[3] = info3;
+  e.info[4] = info4;
+  gc_log_write(e);
+}
+
+/*!
+ * One time initialization called by system runtime
+ */
+void
+_gc_log_init(gc_log_t log_info);
+
+#endif
+
+__GC_END_DECLS
+
+#endif /* INCLUDED_GC_LOGGING_H */


Property changes on: 
gnuradio/branches/developers/eb/gcell-wip/src/include/gc_logging.h
___________________________________________________________________
Name: svn:eol-style
   + native

Deleted: 
gnuradio/branches/developers/eb/gcell-wip/src/include/gc_proc_ids_private.h

Modified: gnuradio/branches/developers/eb/gcell-wip/src/include/gc_spu_args.h
===================================================================
--- gnuradio/branches/developers/eb/gcell-wip/src/include/gc_spu_args.h 
2008-03-06 00:13:13 UTC (rev 7948)
+++ gnuradio/branches/developers/eb/gcell-wip/src/include/gc_spu_args.h 
2008-03-06 02:59:15 UTC (rev 7949)
@@ -22,6 +22,7 @@
 #define INCLUDED_GC_SPU_ARGS_H
 
 #include <gc_types.h>
+#include <gc_logging.h>
 
 // args passed to SPE at initialization time
 
@@ -32,6 +33,7 @@
   uint32_t     nspus;          // number of spus we're using
   uint32_t     proc_def_ls_addr;  // LS addr of proc_def table
   uint32_t     nproc_defs;        // number of proc_defs in table
+  gc_log_t     log;               // logging info
 } _AL16 gc_spu_args_t;
 
 

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 00:13:13 UTC (rev 7948)
+++ gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager.h  
2008-03-06 02:59:15 UTC (rev 7949)
@@ -45,11 +45,14 @@
   unsigned int nspes;              // how many SPEs shall we use? 0 -> all of 
them
   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)
   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),
     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 00:13:13 UTC (rev 7948)
+++ gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager_impl.cc    
2008-03-06 02:59:15 UTC (rev 7949)
@@ -31,7 +31,13 @@
 #include <stdlib.h>
 #include <atomic_dec_if_positive.h>
 #include <memory_barrier.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
 
+
 static const size_t CACHE_LINE_SIZE = 128;
 
 static const unsigned int DEFAULT_MAX_JOBS = 128;
@@ -221,27 +227,11 @@
   _d_comp_info_boost =
     boost::shared_ptr<void>((void *) d_comp_info, free_deleter());
 
+
   // get a handle to the spe program
 
-#if 0
-  // FIXME pass this in (or something)
-  const char *spu_progname = "../apps/spu/gcell_qa";
-
-  spe_program_handle_t *spe_image = spe_image_open(spu_progname);
-  if (spe_image == 0){
-    char buf[128];
-    snprintf(buf, sizeof(buf), "spe_image_open(\"%s\")", spu_progname);
-    perror(buf);
-    throw std::runtime_error(buf);
-  }
-  d_spe_image = spe_program_handle_sptr(spe_image, 
spe_program_handle_deleter());
-
-#else
-
   spe_program_handle_t *spe_image = d_options.program_handle;
 
-#endif  
-
   // fish proc_def table out of SPE ELF file
 
   if (!gcpd_find_table(spe_image, &d_proc_def, &d_nproc_defs, 
&d_proc_def_ls_addr)){
@@ -270,6 +260,8 @@
     d_worker[i].spu_args->nspus = d_options.nspes;
     d_worker[i].spu_args->proc_def_ls_addr = d_proc_def_ls_addr;
     d_worker[i].spu_args->nproc_defs = d_nproc_defs;
+    d_worker[i].spu_args->log.base = 0;
+    d_worker[i].spu_args->log.nentries = 0;
     d_worker[i].state = WS_INIT;
 
     int r = spe_program_load(d_worker[i].spe_ctx, spe_image);
@@ -279,6 +271,8 @@
     }
   }
 
+  setup_logfiles();
+
   // ----------------------------------------------------------------
   // initalize the free list of job descriptors
   
@@ -1171,6 +1165,56 @@
 }
 
 ////////////////////////////////////////////////////////////////////////
+
+void
+gc_job_manager_impl::setup_logfiles()
+{
+  if (!d_options.enable_logging)
+    return;
+
+  if (d_options.nlog_entries == 0)
+    d_options.nlog_entries = 4096;
+
+  // 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);
+  s = ((s + pagesize - 1) / pagesize) * pagesize;
+  d_options.nlog_entries = s / sizeof(gc_log_entry_t);
+
+  for (unsigned int i = 0; i < d_options.nspes; i++){
+    char filename[100];
+    snprintf(filename, sizeof(filename), "spu_log.%02d", i);
+    int fd = open(filename, O_CREAT|O_TRUNC|O_RDWR, 0664);
+    if (fd == -1){
+      perror(filename);
+      return;
+    }
+    lseek(fd, s - 1, SEEK_SET);
+    write(fd, "\0", 1);
+    void *p = mmap(0, s, PROT_READ|PROT_WRITE, MAP_SHARED, fd, 0);
+    if (p == MAP_FAILED){
+      perror("gc_job_manager_impl::setup_logfiles: mmap");
+      close(fd);
+      return;
+    }
+    close(fd);
+    d_spu_args[i].log.base = ptr_to_ea(p);
+    d_spu_args[i].log.nentries = d_options.nlog_entries;
+  }
+}
+
+void
+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);
+  }
+}
+
+////////////////////////////////////////////////////////////////////////
 //
 // 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 00:13:13 UTC (rev 7948)
+++ gnuradio/branches/developers/eb/gcell-wip/src/lib/gc_job_manager_impl.h     
2008-03-06 02:59:15 UTC (rev 7949)
@@ -165,6 +165,9 @@
   bool bv_isset(unsigned long *bv, unsigned int bitno);
   bool bv_isclr(unsigned long *bv, unsigned int bitno);
 
+  void setup_logfiles();
+  void sync_logfiles();
+
   friend gc_job_manager *gc_make_job_manager(const gc_jm_options *options);
   
   gc_job_manager_impl(const gc_jm_options *options = 0);

Modified: gnuradio/branches/developers/eb/gcell-wip/src/lib/spu/Makefile.am
===================================================================
--- gnuradio/branches/developers/eb/gcell-wip/src/lib/spu/Makefile.am   
2008-03-06 00:13:13 UTC (rev 7948)
+++ gnuradio/branches/developers/eb/gcell-wip/src/lib/spu/Makefile.am   
2008-03-06 02:59:15 UTC (rev 7949)
@@ -31,6 +31,7 @@
        gc_delay.c \
        gc_spu_jd_queue.c \
        spu_buffers.c \
+       gc_logging.c \
        gc_main.c
 
 

Added: gnuradio/branches/developers/eb/gcell-wip/src/lib/spu/gc_logging.c
===================================================================
--- gnuradio/branches/developers/eb/gcell-wip/src/lib/spu/gc_logging.c          
                (rev 0)
+++ gnuradio/branches/developers/eb/gcell-wip/src/lib/spu/gc_logging.c  
2008-03-06 02:59:15 UTC (rev 7949)
@@ -0,0 +1,57 @@
+/* -*- c++ -*- */
+/*
+ * Copyright 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_logging.h>
+#include <spu_intrinsics.h>
+#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;
+
+void
+_gc_log_init(gc_log_t info)
+{
+  spu_write_decrementer(~0);
+
+  log_base_ea = info.base;
+  log_idx_mask = info.nentries - 1;
+  log_idx = 0;
+  log_seqno = 0;
+  log_tag = mfc_tag_reserve();
+}
+
+void
+_gc_log_write(gc_log_entry_t entry)
+{
+  if (log_base_ea == 0)
+    return;
+
+  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);
+  log_idx = (log_idx + 1) & log_idx_mask;
+}
+  


Property changes on: 
gnuradio/branches/developers/eb/gcell-wip/src/lib/spu/gc_logging.c
___________________________________________________________________
Name: svn:eol-style
   + native

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 00:13:13 UTC (rev 7948)
+++ gnuradio/branches/developers/eb/gcell-wip/src/lib/spu/gc_main.c     
2008-03-06 02:59:15 UTC (rev 7949)
@@ -121,12 +121,11 @@
   if (put_in_progress & PBI_MASK(1))
     tag_mask |= (1 << (put_tags + 1));
 
-  if (0){
-    printf("fci: waiting for tag_mask 0x%08x\n", tag_mask);
-  }
-
   mfc_write_tag_mask(tag_mask);                // the tags we're interested in
   mfc_read_tag_status_all();           // wait for DMA to complete
+
+  // printf("(2) pip 0x%x pb_idx %d\n", put_in_progress, pb_idx);
+
   put_in_progress = 0;                 // mark them all complete
 
   // send PPE a message
@@ -289,6 +288,8 @@
       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);
+
        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));
@@ -642,6 +643,9 @@
   // initialize pointer to procedure entry table
   gc_proc_def = (gc_proc_def_t *) spu_args.proc_def_ls_addr;
 
+  // initialize logging
+  _gc_log_init(spu_args.log);
+
   backoff_init();              // initialize backoff parameters
 
   main_loop();





reply via email to

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