commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: eb
Subject: [Commit-gnuradio] r6994 - in gnuradio/branches/developers/eb/gcell/src: include lib
Date: Sun, 18 Nov 2007 21:48:01 -0700 (MST)

Author: eb
Date: 2007-11-18 21:48:01 -0700 (Sun, 18 Nov 2007)
New Revision: 6994

Added:
   gnuradio/branches/developers/eb/gcell/src/include/compiler.h
   gnuradio/branches/developers/eb/gcell/src/include/gc_jd_stack.h
   gnuradio/branches/developers/eb/gcell/src/include/memory_barrier.h
   gnuradio/branches/developers/eb/gcell/src/lib/gc_jd_stack.c
Modified:
   gnuradio/branches/developers/eb/gcell/src/include/gc_job_desc_private.h
   gnuradio/branches/developers/eb/gcell/src/include/gc_types.h
   gnuradio/branches/developers/eb/gcell/src/lib/Makefile.am
Log:
Cell work-in-progress.  Lock-free stack ready for testing.


Added: gnuradio/branches/developers/eb/gcell/src/include/compiler.h
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/include/compiler.h                
                (rev 0)
+++ gnuradio/branches/developers/eb/gcell/src/include/compiler.h        
2007-11-19 04:48:01 UTC (rev 6994)
@@ -0,0 +1,36 @@
+/* -*- 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.
+ */
+
+#ifndef INCLUDED_COMPILER_H
+#define INCLUDED_COMPILER_H
+
+/*!
+ * \brief Compiler specific hackery.  These are for GCC.
+ */
+
+#define _AL16  __attribute__((aligned (16)))
+#define _AL128 __attribute__((aligned (128)))
+
+#define likely(x)       __builtin_expect(!!(x), 1)
+#define unlikely(x)     __builtin_expect(!!(x), 0)
+
+
+#endif /* INCLUDED_COMPILER_H */


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

Added: gnuradio/branches/developers/eb/gcell/src/include/gc_jd_stack.h
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/include/gc_jd_stack.h             
                (rev 0)
+++ gnuradio/branches/developers/eb/gcell/src/include/gc_jd_stack.h     
2007-11-19 04:48:01 UTC (rev 6994)
@@ -0,0 +1,68 @@
+/* -*- 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.
+ */
+
+#ifndef INCLUDED_GC_JD_STACK_H
+#define INCLUDED_GC_JD_STACK_H
+
+#include "gc_types.h"
+#include "gc_job_desc.h"
+
+__GC_BEGIN_DECLS
+
+/*!
+ * \brief Lock free stack for job descriptors (used for free list)
+ *
+ * This is aligned to a cache line, and fills the cache line,
+ * to avoid inadvertently losing reservations created with
+ * the load-and-reserve instructions.
+ */
+
+typedef struct gc_jd_stack
+{
+  gc_eaddr_t   top;
+  uint8_t      _pad[120];      // pad out to a full cache line
+} _AL128 gc_jd_stack_t;
+
+
+/*!
+ * \brief Initialize the stack to empty.
+ */
+void 
+gc_jd_stack_init(gc_jd_stack_t *stack);
+  
+
+/*!
+ * \brief Add \p item to the top of \p stack.
+ */
+void 
+gc_jd_stack_push(gc_jd_stack_t *stack, gc_job_desc_t *item);
+
+
+/*!
+ * \brief pop and return top item on stack, or 0 if stack is empty
+ */
+gc_job_desc_t *
+gc_jd_stack_pop(gc_jd_stack_t *stack);
+
+__GC_END_DECLS
+
+
+#endif /* INCLUDED_GC_JD_STACK_H */


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

Modified: 
gnuradio/branches/developers/eb/gcell/src/include/gc_job_desc_private.h
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/include/gc_job_desc_private.h     
2007-11-19 04:10:53 UTC (rev 6993)
+++ gnuradio/branches/developers/eb/gcell/src/include/gc_job_desc_private.h     
2007-11-19 04:48:01 UTC (rev 6994)
@@ -29,7 +29,7 @@
  */
 typedef struct gc_job_desc_private
 {
-  gc_eaddr_t   link;           // used to implement job queue
+  gc_eaddr_t   next;           // used to implement job queue and free list
 
   // FIXME:
   // notifier_method

Modified: gnuradio/branches/developers/eb/gcell/src/include/gc_types.h
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/include/gc_types.h        
2007-11-19 04:10:53 UTC (rev 6993)
+++ gnuradio/branches/developers/eb/gcell/src/include/gc_types.h        
2007-11-19 04:48:01 UTC (rev 6994)
@@ -24,12 +24,10 @@
 
 #include <stdint.h>
 #include <gc_cdefs.h>
+#include "compiler.h"
 
 __GC_BEGIN_DECLS
 
-#define _AL16  __attribute__((aligned (16)))
-#define _AL128 __attribute__((aligned (128)))
-
 /*!
  * \brief 64-bit integer type representing an effective address (EA)
  *

Added: gnuradio/branches/developers/eb/gcell/src/include/memory_barrier.h
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/include/memory_barrier.h          
                (rev 0)
+++ gnuradio/branches/developers/eb/gcell/src/include/memory_barrier.h  
2007-11-19 04:48:01 UTC (rev 6994)
@@ -0,0 +1,66 @@
+/* -*- 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.
+ */
+
+#ifndef INCLUDED_MEMORY_BARRIER_H
+#define INCLUDED_MEMORY_BARRIER_H
+
+/*
+ * powerpc memory barriers
+ *
+ * The sync instruction guarantees that all memory accesses initiated
+ * by this processor have been performed (with respect to all other
+ * mechanisms that access memory).  The eieio instruction is a barrier
+ * providing an ordering (separately) for (a) cacheable stores and (b)
+ * loads and stores to non-cacheable memory (e.g. I/O devices).
+ *
+ * smp_mb() prevents loads and stores being reordered across this point.
+ * smp_rmb() prevents loads being reordered across this point.
+ * smp_wmb() prevents stores being reordered across this point.
+ *
+ * We have to use the sync instructions for smp_mb(), since lwsync
+ * doesn't order loads with respect to previous stores.  Lwsync is
+ * fine for smp_rmb(), though.  For smp_wmb(), we use eieio since it
+ * is only used to order updates to system memory.
+ *
+ * For details, see "PowerPC Virtual Environment Architecture, Book
+ * II".  Especially Chapter 1, "Storage Model" and Chapter 3, "Storage
+ * Control Instructions." (site:ibm.com)
+ */
+
+#include <ppu_intrinsics.h>
+
+static inline void smp_mb(void)
+{
+  __sync();
+}
+
+static inline void smp_rmb(void)
+{
+  __lwsync();
+}
+
+static inline void smp_wmb(void)
+{
+  __eieio();
+}
+
+
+#endif /* INCLUDED_MEMORY_BARRIER_H */


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

Modified: gnuradio/branches/developers/eb/gcell/src/lib/Makefile.am
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/Makefile.am   2007-11-19 
04:10:53 UTC (rev 6993)
+++ gnuradio/branches/developers/eb/gcell/src/lib/Makefile.am   2007-11-19 
04:48:01 UTC (rev 6994)
@@ -28,6 +28,7 @@
 
 libgcell_la_SOURCES = \
        gc_job_manager.cc \
-       gc_job_manager_impl.cc
+       gc_job_manager_impl.cc \
+       gc_jd_stack.c
 
 

Added: gnuradio/branches/developers/eb/gcell/src/lib/gc_jd_stack.c
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/gc_jd_stack.c                 
        (rev 0)
+++ gnuradio/branches/developers/eb/gcell/src/lib/gc_jd_stack.c 2007-11-19 
04:48:01 UTC (rev 6994)
@@ -0,0 +1,108 @@
+/* -*- 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 "gc_jd_stack.h"
+#include "memory_barrier.h"
+#include <ppu_intrinsics.h>
+
+void 
+gc_jd_stack_init(gc_jd_stack_t *stack)
+{
+  stack->top = 0;
+}
+  
+
+#ifdef __powerpc64__  // 64-bit mode
+
+void 
+gc_jd_stack_push(gc_jd_stack_t *stack, gc_job_desc_t *item)
+{
+  gc_eaddr_t   top;
+  gc_eaddr_t   item_ea = voidstar_to_ea(item);
+  unsigned int done;
+
+  do {
+    top = __ldarx(&stack->top);
+    item->sys.next = top;
+    __eieio();       // order store of item->next before store of stack->top
+    done = __stdcx(&stack->top, item_ea);
+  } while (unlikely(done == 0));
+}
+
+gc_job_desc_t *
+gc_jd_stack_pop(gc_jd_stack_t *stack)
+{
+  gc_eaddr_t   s;
+  gc_eaddr_t   t;
+  unsigned int done;
+
+  do {
+    s  = __ldarx(&stack->top);
+    if (s == 0)                        /* stack's empty */
+      return 0;
+    t = ((gc_job_desc_t *) ea_to_voidstar(s))->sys.next;
+    done = __stdcx(&stack->top, t);
+  } while (unlikely(done == 0));
+
+  return ea_to_voidstar(t);
+}
+
+#else  // 32-bit mode
+
+/*
+ * In 32-bit mode, gc_eaddr's will have the top 32-bits zero.
+ * The ldarx/stdcx instructions aren't availble in 32-bit mode,
+ * thus we use lwarx/stwcx on the low 32-bits of the 64-bit addresses.
+ * Since we're big-endian, the low 32-bits are at word offset 1.
+ */
+void 
+gc_jd_stack_push(gc_jd_stack_t *stack, gc_job_desc_t *item)
+{
+  gc_eaddr_t   top;
+  unsigned int done;
+
+  do {
+    top = __lwarx((int32_t *)(&stack->top) + 1);
+    item->sys.next = top;
+    __eieio();       // order store of item->next before store of stack->top
+    done = __stwcx((int32_t *)(&stack->top) + 1, item);
+  } while (unlikely(done == 0));
+}
+
+gc_job_desc_t *
+gc_jd_stack_pop(gc_jd_stack_t *stack)
+{
+  gc_eaddr_t   s;
+  gc_eaddr_t   t;
+  unsigned int done;
+
+  do {
+    s  = __lwarx((int32_t *)(&stack->top) + 1);
+    if (s == 0)                        /* stack's empty */
+      return 0;
+    t = ((gc_job_desc_t *) ea_to_voidstar(s))->sys.next;
+    done = __stwcx((int32_t *)(&stack->top) + 1, (uint32_t) t);
+  } while (unlikely(done == 0));
+
+  return ea_to_voidstar(t);
+}
+
+#endif


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





reply via email to

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