commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r7067 - in gnuradio/branches/developers/eb/gcell: . sr


From: eb
Subject: [Commit-gnuradio] r7067 - in gnuradio/branches/developers/eb/gcell: . src src/lib src/lib/spu src/spu-include
Date: Mon, 3 Dec 2007 23:19:00 -0700 (MST)

Author: eb
Date: 2007-12-03 23:18:59 -0700 (Mon, 03 Dec 2007)
New Revision: 7067

Added:
   gnuradio/branches/developers/eb/gcell/src/lib/spu/
   gnuradio/branches/developers/eb/gcell/src/lib/spu/Makefile.am
   gnuradio/branches/developers/eb/gcell/src/lib/spu/test_spu.c
   gnuradio/branches/developers/eb/gcell/src/spu-include/
   gnuradio/branches/developers/eb/gcell/src/spu-include/Makefile.am
Modified:
   gnuradio/branches/developers/eb/gcell/Makefile.common
   gnuradio/branches/developers/eb/gcell/configure.ac
   gnuradio/branches/developers/eb/gcell/src/lib/
   gnuradio/branches/developers/eb/gcell/src/lib/Makefile.am
   gnuradio/branches/developers/eb/gcell/src/lib/gc_job_manager.h
   gnuradio/branches/developers/eb/gcell/src/lib/gc_job_manager_impl.cc
   gnuradio/branches/developers/eb/gcell/src/lib/gc_job_manager_impl.h
   gnuradio/branches/developers/eb/gcell/src/lib/qa_job_manager.cc
Log:
Work-in-progress on cell job manager.  Is now sucessfully running very
basic code on the SPEs and managing the PPE threads.  spu portion
of build uses automake.


Modified: gnuradio/branches/developers/eb/gcell/Makefile.common
===================================================================
--- gnuradio/branches/developers/eb/gcell/Makefile.common       2007-12-04 
04:55:52 UTC (rev 7066)
+++ gnuradio/branches/developers/eb/gcell/Makefile.common       2007-12-04 
06:18:59 UTC (rev 7067)
@@ -27,3 +27,8 @@
        -I$(top_srcdir)/src/lib \
        $(GR_OMNITHREAD_CFLAGS)
 
+SPU_DEFINES_AND_INCLUDES= \
+       -I$(top_srcdir)/src/spu-include \
+       -I$(top_srcdir)/src/include \
+       -I$(top_srcdir)/src/lib
+

Modified: gnuradio/branches/developers/eb/gcell/configure.ac
===================================================================
--- gnuradio/branches/developers/eb/gcell/configure.ac  2007-12-04 04:55:52 UTC 
(rev 7066)
+++ gnuradio/branches/developers/eb/gcell/configure.ac  2007-12-04 06:18:59 UTC 
(rev 7067)
@@ -206,6 +206,8 @@
     src/apps/Makefile \
     src/include/Makefile \
     src/lib/Makefile \
+    src/lib/spu/Makefile \
+    src/spu-include/Makefile \
 ])
 
 dnl run_tests.sh is created from run_tests.in.sh.  Make it executable.


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

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



Modified: gnuradio/branches/developers/eb/gcell/src/lib/Makefile.am
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/Makefile.am   2007-12-04 
04:55:52 UTC (rev 7066)
+++ gnuradio/branches/developers/eb/gcell/src/lib/Makefile.am   2007-12-04 
06:18:59 UTC (rev 7067)
@@ -20,6 +20,8 @@
 
 include $(top_srcdir)/Makefile.common
 
+SUBDIRS = spu .
+
 INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES) 
$(IBM_PPU_SYNC_INCLUDES)
 
 

Modified: gnuradio/branches/developers/eb/gcell/src/lib/gc_job_manager.h
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/gc_job_manager.h      
2007-12-04 04:55:52 UTC (rev 7066)
+++ gnuradio/branches/developers/eb/gcell/src/lib/gc_job_manager.h      
2007-12-04 06:18:59 UTC (rev 7067)
@@ -84,7 +84,7 @@
   virtual gc_job_desc *alloc_job_desc() = 0;
 
   /*
-   *! Return a job descriptor previously allocated with alloc_job_desc()
+   *! Free a job descriptor previously allocated with alloc_job_desc()
    *
    * \param[in] jd pointer to job descriptor to free.
    */

Modified: gnuradio/branches/developers/eb/gcell/src/lib/gc_job_manager_impl.cc
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/gc_job_manager_impl.cc        
2007-12-04 04:55:52 UTC (rev 7066)
+++ gnuradio/branches/developers/eb/gcell/src/lib/gc_job_manager_impl.cc        
2007-12-04 06:18:59 UTC (rev 7067)
@@ -161,6 +161,20 @@
   _d_spu_args_boost =
     boost::shared_ptr<void>((void *) d_spu_args, free_deleter());
 
+  // get a handle to the spe program
+
+  // FIXME pass this in (or something)
+  const char *spu_progname = "../lib/spu/test_spu";
+
+  // FIXME we're leaking the handle..
+  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);
+  }
+
   int spe_flags = (SPE_EVENTS_ENABLE
                   | SPE_CFG_SIGNOTIFY1_OR
                   | SPE_CFG_SIGNOTIFY2_OR);
@@ -178,7 +192,11 @@
     d_worker[i].spu_args->spu_idx = i;
     d_worker[i].state = WS_INIT;
 
-    // FIXME load some code in the SPE
+    int r = spe_program_load(d_worker[i].spe_ctx, spe_image);
+    if (r != 0){
+      perror("spe_program_load");
+      throw std::runtime_error("spe_program_load");
+    }
   }
 
   // ----------------------------------------------------------------
@@ -412,7 +430,7 @@
   for (unsigned int i = 0; i < d_options.nspes; i++){
     spe_event_unit_t   eu;
     memset(&eu, 0, sizeof(eu));
-    eu.events = SPE_EVENT_ALL_EVENTS;
+    eu.events = SPE_EVENT_OUT_INTR_MBOX | SPE_EVENT_SPE_STOPPED;
     eu.spe = d_worker[i].spe_ctx;
     eu.data.u32 = i;   // set in events returned by spe_event_wait
 
@@ -458,7 +476,7 @@
 gc_job_manager_impl::set_eh_state(evt_handler_state s)
 {
   omni_mutex_lock      l(d_eh_mutex);
-  d_eh_state = EHS_DEAD;
+  d_eh_state = s;
   d_eh_cond.broadcast();
 }
 
@@ -598,21 +616,30 @@
       break;
 
     case EHS_SHUTTING_DOWN:
+
       // FIXME wait until job queue is empty, then tell them to exit
+
       send_all_spes(MK_MBOX_MSG(OP_EXIT, 0));
+      set_eh_state(EHS_WAITING_FOR_WORKERS_TO_DIE);
+      break;
 
-      // FIXME when all workers have died, we return.
-      // Not sure yet if we see the SPE_EXIT events.
-      // If we do, we can keep track here.
-      // In the meanwhile...
+    case EHS_WAITING_FOR_WORKERS_TO_DIE:
+      {
+       bool all_dead = true;
+       for (unsigned int i = 0; i < d_options.nspes; i++)
+         all_dead &= d_worker[i].state == WS_DEAD;
 
-      set_eh_state(EHS_DEAD);  // FIXME
-      printf("event_handler_loop: exiting\n");
-      return;
+       if (all_dead){
+         set_eh_state(EHS_DEAD);
+         printf("event_handler_loop: exiting\n");
+         return;
+       }
+      }
+      break;
 
     default:
       set_eh_state(EHS_DEAD);
-      printf("event_handler_loop: exiting\n");
+      printf("event_handler_loop(default): exiting\n");
       return;
     }
 
@@ -641,24 +668,8 @@
   w->state = WS_RUNNING;
   printf("worker[%d]: WS_RUNNING\n", w->spe_idx);
 
-  struct uregs {
-    gc_eaddr_t r3;          // Always pass pointers as 64-bit addresses
-    uint64_t   _pad_r3;     // in preferred slot.  Pad bottom half of reg.
-    gc_eaddr_t r4;
-    uint64_t   _pad_r4;
-    gc_eaddr_t r5;
-    uint64_t   _pad_r5;
-  } args;
-
-  assert(sizeof(args) == 48);
-
-  memset(&args, 0, sizeof(args));
-  args.r3 = ptr_to_ea(w->spe_ctx);
-  args.r4 = ptr_to_ea(w->spu_args);
-
   unsigned int entry = SPE_DEFAULT_ENTRY;
-  int r = spe_context_run(w->spe_ctx,  &entry,
-                         SPE_RUN_USER_REGS, &args, 0, &si);
+  int r = spe_context_run(w->spe_ctx,  &entry, 0, w->spu_args, 0, &si);
 
   if (r < 0){                  // error
     char buf[64];

Modified: gnuradio/branches/developers/eb/gcell/src/lib/gc_job_manager_impl.h
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/gc_job_manager_impl.h 
2007-12-04 04:55:52 UTC (rev 7066)
+++ gnuradio/branches/developers/eb/gcell/src/lib/gc_job_manager_impl.h 
2007-12-04 06:18:59 UTC (rev 7067)
@@ -58,6 +58,7 @@
   EHS_INIT,            // being initialized
   EHS_RUNNING,         // thread is running
   EHS_SHUTTING_DOWN,   // in process of shutting down everything
+  EHS_WAITING_FOR_WORKERS_TO_DIE,
   EHS_DEAD,            // thread is dead
 };
 
@@ -144,14 +145,8 @@
   void print_event(spe_event_unit_t *evt);
   void handle_event(spe_event_unit_t *evt);
 
-
   friend gc_job_manager *gc_make_job_manager(const gc_jm_options *options);
   
-
-  /*!
-   * \param nspes number of SPEs job manager should use.
-   * If nspes == -1, all available SPEs will be allocated.
-   */
   gc_job_manager_impl(const gc_jm_options *options = 0);
 
 public:

Modified: gnuradio/branches/developers/eb/gcell/src/lib/qa_job_manager.cc
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/qa_job_manager.cc     
2007-12-04 04:55:52 UTC (rev 7066)
+++ gnuradio/branches/developers/eb/gcell/src/lib/qa_job_manager.cc     
2007-12-04 06:18:59 UTC (rev 7067)
@@ -24,9 +24,30 @@
 #include "gc_job_manager.h"
 #include <stdexcept>
 #include <stdio.h>
+#include <time.h>
+#include <errno.h>
 
 #include <malloc.h>
 
+static void
+gc_msleep(unsigned long millisecs)
+{
+  int r;
+  struct timespec tv;
+  tv.tv_sec = millisecs / 1000;
+  tv.tv_nsec = (millisecs - (tv.tv_sec * 1000)) * 1000000;
+  
+  while (1){
+    r = nanosleep(&tv, &tv);
+    if (r == 0)
+      return;
+    if (r == -1 && errno == EINTR)
+      continue;
+    perror("nanosleep");
+    return;
+  }
+}
+
 void
 qa_job_manager::t1()
 {
@@ -46,6 +67,7 @@
 {
   gc_job_manager *mgr;
   mgr = gc_make_job_manager();
+  //gc_msleep(1000);
   delete mgr;
 
 #if 1
@@ -64,6 +86,7 @@
     opts.nspes = 100;
     opts.gang_schedule = false;
     mgr = gc_make_job_manager(&opts);
+    //gc_msleep(1000);
     delete mgr;
   }
 }


Property changes on: gnuradio/branches/developers/eb/gcell/src/lib/spu
___________________________________________________________________
Name: svn:ignore
   + Makefile
Makefile.in
.la
.lo
.deps
.libs
*.la
*.lo
test_spu


Added: gnuradio/branches/developers/eb/gcell/src/lib/spu/Makefile.am
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/spu/Makefile.am               
                (rev 0)
+++ gnuradio/branches/developers/eb/gcell/src/lib/spu/Makefile.am       
2007-12-04 06:18:59 UTC (rev 7067)
@@ -0,0 +1,36 @@
+#
+# 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.
+#
+
+AR=spu-ar
+RANLIB=spu-ranlib
+CC=spu-cc
+LD=spu-ld
+
+# Need to override user stuff (for PPU) even though it gives a warning
+CPPFLAGS=
+LDFLAGS=
+
+
+include $(top_srcdir)/Makefile.common
+
+AM_CPPFLAGS = $(SPU_DEFINES_AND_INCLUDES) $(IBM_SPU_SYNC_INCLUDES)
+
+noinst_PROGRAMS = \
+       test_spu


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

Added: gnuradio/branches/developers/eb/gcell/src/lib/spu/test_spu.c
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/spu/test_spu.c                
                (rev 0)
+++ gnuradio/branches/developers/eb/gcell/src/lib/spu/test_spu.c        
2007-12-04 06:18:59 UTC (rev 7067)
@@ -0,0 +1,44 @@
+/* -*- 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 <stdio.h>
+#include <spu_intrinsics.h>
+#include "gc_spu_args.h"
+#include "gc_mbox.h"
+
+int main(unsigned long long spe_id,
+        unsigned long long argp,
+        unsigned long long envp)
+{
+  printf("Hello Cell (0x%llx, 0x%llx, 0x%llx)\n",
+        spe_id, argp, envp);
+
+  while (1){
+    int cnt = spu_readchcnt(SPU_RdInMbox);
+    if (unlikely(cnt > 0)){
+      int msg = spu_readch(SPU_RdInMbox);
+      printf("mbox_msg: 0x%08x\n", msg);
+      if (MBOX_MSG_OP(msg) == OP_EXIT)
+       return 0;
+    }
+  }
+  return 0;
+}


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


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



Added: gnuradio/branches/developers/eb/gcell/src/spu-include/Makefile.am
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/spu-include/Makefile.am           
                (rev 0)
+++ gnuradio/branches/developers/eb/gcell/src/spu-include/Makefile.am   
2007-12-04 06:18:59 UTC (rev 7067)
@@ -0,0 +1,19 @@
+#
+# 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.
+#


Property changes on: 
gnuradio/branches/developers/eb/gcell/src/spu-include/Makefile.am
___________________________________________________________________
Name: svn:eol-style
   + native





reply via email to

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