[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r7017 - in gnuradio/branches/developers/eb/gcell: . sr
From: |
eb |
Subject: |
[Commit-gnuradio] r7017 - in gnuradio/branches/developers/eb/gcell: . src/include src/lib |
Date: |
Fri, 23 Nov 2007 22:02:18 -0700 (MST) |
Author: eb
Date: 2007-11-23 22:02:17 -0700 (Fri, 23 Nov 2007)
New Revision: 7017
Added:
gnuradio/branches/developers/eb/gcell/src/include/gc_jd_queue.h
gnuradio/branches/developers/eb/gcell/src/lib/gc_jd_queue.c
gnuradio/branches/developers/eb/gcell/src/lib/qa_jd_queue.cc
gnuradio/branches/developers/eb/gcell/src/lib/qa_jd_queue.h
Modified:
gnuradio/branches/developers/eb/gcell/Makefile.common
gnuradio/branches/developers/eb/gcell/src/include/gc_jd_stack.h
gnuradio/branches/developers/eb/gcell/src/include/gc_job_desc.h
gnuradio/branches/developers/eb/gcell/src/include/gc_types.h
gnuradio/branches/developers/eb/gcell/src/lib/Makefile.am
gnuradio/branches/developers/eb/gcell/src/lib/gc_jd_stack.c
gnuradio/branches/developers/eb/gcell/src/lib/qa_job_manager.cc
gnuradio/branches/developers/eb/gcell/src/lib/qa_job_manager.h
gnuradio/branches/developers/eb/gcell/src/lib/qa_lib.cc
Log:
work-in-progress: job queue
Modified: gnuradio/branches/developers/eb/gcell/Makefile.common
===================================================================
--- gnuradio/branches/developers/eb/gcell/Makefile.common 2007-11-24
03:41:08 UTC (rev 7016)
+++ gnuradio/branches/developers/eb/gcell/Makefile.common 2007-11-24
05:02:17 UTC (rev 7017)
@@ -19,6 +19,9 @@
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
+IBM_PPU_SYNC_INCLUDES = -I$(top_srcdir)/src/ibm/sync/ppu_source
+IBM_SPU_SYNC_INCLUDES = -I$(top_srcdir)/src/ibm/sync/spu_source
+
STD_DEFINES_AND_INCLUDES= \
-I$(top_srcdir)/src/include \
-I$(top_srcdir)/src/lib \
Added: gnuradio/branches/developers/eb/gcell/src/include/gc_jd_queue.h
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/include/gc_jd_queue.h
(rev 0)
+++ gnuradio/branches/developers/eb/gcell/src/include/gc_jd_queue.h
2007-11-24 05:02:17 UTC (rev 7017)
@@ -0,0 +1,78 @@
+/* -*- 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_QUEUE_H
+#define INCLUDED_GC_JD_QUEUE_H
+
+#include "gc_types.h"
+#include "gc_job_desc.h"
+
+__GC_BEGIN_DECLS
+
+/*!
+ * \brief (Lock free someday...) queue for job descriptors
+ *
+ * This is the main data structure shared between PPEs and SPEs.
+ * It is used to enqueue work for SPEs. SPEs or PPEs may enqueue
+ * work. SPE's dequeue from here.
+ *
+ * This is aligned to a cache line, and fills the cache line,
+ * to avoid inadvertently losing reservations created with
+ * the load-and-reserve instructions.
+ *
+ * FIXME make it lock free ;) For now, use a mutex.
+ */
+
+typedef struct gc_jd_queue
+{
+ gc_eaddr_t head;
+ gc_eaddr_t tail;
+ volatile uint32_t mutex; // libsync mutex (spin lock)
+
+ // pad out to a full cache line
+ uint8_t _pad[128 - 2*sizeof(gc_eaddr_t) - sizeof(uint32_t)];
+} _AL128 gc_jd_queue_t;
+
+
+/*!
+ * \brief Initialize the queue to empty.
+ */
+void
+gc_jd_queue_init(gc_jd_queue_t *q);
+
+
+/*!
+ * \brief Add \p item to the tail of \p q.
+ */
+void
+gc_jd_queue_enqueue(gc_jd_queue_t *q, gc_job_desc_t *item);
+
+
+/*!
+ * \brief Remove and return item at head of queue, or 0 if queue is empty
+ */
+gc_job_desc_t *
+gc_jd_queue_dequeue(gc_jd_queue_t *q);
+
+__GC_END_DECLS
+
+
+#endif /* INCLUDED_GC_JD_QUEUE_H */
Property changes on:
gnuradio/branches/developers/eb/gcell/src/include/gc_jd_queue.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: gnuradio/branches/developers/eb/gcell/src/include/gc_jd_stack.h
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/include/gc_jd_stack.h
2007-11-24 03:41:08 UTC (rev 7016)
+++ gnuradio/branches/developers/eb/gcell/src/include/gc_jd_stack.h
2007-11-24 05:02:17 UTC (rev 7017)
@@ -38,7 +38,9 @@
typedef struct gc_jd_stack
{
gc_eaddr_t top;
- uint8_t _pad[120]; // pad out to a full cache line
+
+ // pad out to a full cache line
+ uint8_t _pad[128 - sizeof(gc_eaddr_t)];
} _AL128 gc_jd_stack_t;
Modified: gnuradio/branches/developers/eb/gcell/src/include/gc_job_desc.h
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/include/gc_job_desc.h
2007-11-24 03:41:08 UTC (rev 7016)
+++ gnuradio/branches/developers/eb/gcell/src/include/gc_job_desc.h
2007-11-24 05:02:17 UTC (rev 7017)
@@ -136,6 +136,23 @@
} _AL128 gc_job_desc_t;
+#if !defined(__SPU__)
+
+static inline gc_job_desc_t *
+ea_to_jdp(gc_eaddr_t ea)
+{
+ return (gc_job_desc_t *) ea_to_ptr(ea);
+}
+
+static inline gc_eaddr_t
+jdp_to_ea(gc_job_desc_t *item)
+{
+ return ptr_to_ea(item);
+}
+
+#endif
+
+
__GC_END_DECLS
#endif /* INCLUDED_GC_JOB_DESC_H */
Modified: gnuradio/branches/developers/eb/gcell/src/include/gc_types.h
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/include/gc_types.h
2007-11-24 03:41:08 UTC (rev 7016)
+++ gnuradio/branches/developers/eb/gcell/src/include/gc_types.h
2007-11-24 05:02:17 UTC (rev 7017)
@@ -38,14 +38,14 @@
#if !defined(__SPU__)
static inline void *
-ea_to_voidstar(gc_eaddr_t ea)
+ea_to_ptr(gc_eaddr_t ea)
{
// in 32-bit mode we're tossing the top 32-bits.
return (void *) (uintptr_t) ea;
}
static inline gc_eaddr_t
-voidstar_to_ea(void *p)
+ptr_to_ea(void *p)
{
// two steps to avoid compiler warning in 32-bit mode.
return (gc_eaddr_t) (uintptr_t) p;
Modified: gnuradio/branches/developers/eb/gcell/src/lib/Makefile.am
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/Makefile.am 2007-11-24
03:41:08 UTC (rev 7016)
+++ gnuradio/branches/developers/eb/gcell/src/lib/Makefile.am 2007-11-24
05:02:17 UTC (rev 7017)
@@ -20,7 +20,7 @@
include $(top_srcdir)/Makefile.common
-INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES)
+INCLUDES = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES)
$(IBM_PPU_SYNC_INCLUDES)
lib_LTLIBRARIES = libgcell.la libgcell-qa.la
@@ -28,6 +28,7 @@
libgcell_la_SOURCES = \
gc_job_manager.cc \
gc_job_manager_impl.cc \
+ gc_jd_queue.c \
gc_jd_stack.c
libgcell_la_LIBADD = \
@@ -36,6 +37,7 @@
libgcell_qa_la_SOURCES = \
qa_lib.cc \
+ qa_jd_queue.cc \
qa_jd_stack.cc \
qa_job_manager.cc
Added: gnuradio/branches/developers/eb/gcell/src/lib/gc_jd_queue.c
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/gc_jd_queue.c
(rev 0)
+++ gnuradio/branches/developers/eb/gcell/src/lib/gc_jd_queue.c 2007-11-24
05:02:17 UTC (rev 7017)
@@ -0,0 +1,78 @@
+/* -*- 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_queue.h"
+#include "memory_barrier.h"
+#include <mutex_init.h>
+#include <mutex_lock.h>
+#include <mutex_unlock.h>
+
+void
+gc_jd_queue_init(gc_jd_queue_t *q)
+{
+ _mutex_init(ptr_to_ea(&q->mutex));
+ q->head = 0;
+ q->tail = 0;
+ smp_wmb();
+}
+
+void
+gc_jd_queue_enqueue(gc_jd_queue_t *q, gc_job_desc_t *item)
+{
+ item->sys.next = 0;
+ _mutex_lock(ptr_to_ea(&q->mutex));
+ smp_rmb(); // import barrier
+
+ if (q->tail == 0){ // currently empty
+ q->tail = q->head = jdp_to_ea(item);
+ }
+ else { // not empty, append
+ ea_to_jdp(q->tail)->sys.next = jdp_to_ea(item);
+ q->tail = jdp_to_ea(item);
+ }
+
+ smp_wmb(); // orders stores above before clearing of mutex
+ _mutex_unlock(ptr_to_ea(&q->mutex));
+}
+
+gc_job_desc_t *
+gc_jd_queue_dequeue(gc_jd_queue_t *q)
+{
+ _mutex_lock(ptr_to_ea(&q->mutex));
+ smp_rmb(); // import barrier
+
+ gc_eaddr_t item_ea = q->head;
+ if (item_ea == 0){ // empty
+ _mutex_unlock(ptr_to_ea(&q->mutex));
+ return 0;
+ }
+
+ q->head = ea_to_jdp(item_ea)->sys.next;
+ if (q->head == 0) // now emtpy
+ q->tail = 0;
+
+ gc_job_desc_t *item = ea_to_jdp(item_ea);
+ item->sys.next = 0;
+
+ smp_wmb(); // orders stores above before clearing of mutex
+ _mutex_unlock(ptr_to_ea(&q->mutex));
+ return item;
+}
Property changes on: gnuradio/branches/developers/eb/gcell/src/lib/gc_jd_queue.c
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: gnuradio/branches/developers/eb/gcell/src/lib/gc_jd_stack.c
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/gc_jd_stack.c 2007-11-24
03:41:08 UTC (rev 7016)
+++ gnuradio/branches/developers/eb/gcell/src/lib/gc_jd_stack.c 2007-11-24
05:02:17 UTC (rev 7017)
@@ -36,7 +36,7 @@
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);
+ gc_eaddr_t item_ea = ptr_to_ea(item);
unsigned int done;
do {
@@ -58,11 +58,11 @@
s = __ldarx(&stack->top);
if (s == 0) /* stack's empty */
return 0;
- t = ((gc_job_desc_t *) ea_to_voidstar(s))->sys.next;
+ t = ((gc_job_desc_t *) ea_to_ptr(s))->sys.next;
done = __stdcx(&stack->top, t);
} while (unlikely(done == 0));
- return ea_to_voidstar(s);
+ return ea_to_ptr(s);
}
#else // 32-bit mode
@@ -98,11 +98,11 @@
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;
+ t = ((gc_job_desc_t *) ea_to_ptr(s))->sys.next;
done = __stwcx((int32_t *)(&stack->top) + 1, (uint32_t) t);
} while (unlikely(done == 0));
- return ea_to_voidstar(s);
+ return ea_to_ptr(s);
}
#endif
Added: gnuradio/branches/developers/eb/gcell/src/lib/qa_jd_queue.cc
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/qa_jd_queue.cc
(rev 0)
+++ gnuradio/branches/developers/eb/gcell/src/lib/qa_jd_queue.cc
2007-11-24 05:02:17 UTC (rev 7017)
@@ -0,0 +1,78 @@
+/* -*- 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 "qa_jd_queue.h"
+#include <cppunit/TestAssert.h>
+#include "gc_jd_queue.h"
+#include <stdio.h>
+
+
+
+static const int NJDS = 16;
+static gc_jd_queue_t queue;
+static gc_job_desc_t jds[NJDS];
+
+// no brainer, single threaded basic checkout
+void
+qa_jd_queue::t1()
+{
+ // N.B., queue allocated stuff doesn't obey ((aligned (N))) attributes
+ //const int NJDS = 8;
+ //gc_jd_queue_t queue;
+ //gc_job_desc_t jds[NJDS];
+
+ //printf("&queue = %p\n", &queue);
+ //printf("&jds[0] = %p\n", &jds[0]);
+ //printf("&jds[1] = %p\n", &jds[1]);
+
+ CPPUNIT_ASSERT(((uintptr_t) &queue & 0x7f) == 0);
+ CPPUNIT_ASSERT(((uintptr_t) &jds[0] & 0x7f) == 0);
+ CPPUNIT_ASSERT(((uintptr_t) &jds[1] & 0x7f) == 0);
+
+ gc_jd_queue_init(&queue);
+
+ CPPUNIT_ASSERT(gc_jd_queue_dequeue(&queue) == 0);
+
+ gc_jd_queue_enqueue(&queue, &jds[0]);
+ CPPUNIT_ASSERT_EQUAL(&jds[0], gc_jd_queue_dequeue(&queue));
+
+ CPPUNIT_ASSERT(gc_jd_queue_dequeue(&queue) == 0);
+
+ for (int i = 0; i < NJDS; i++)
+ gc_jd_queue_enqueue(&queue, &jds[i]);
+
+ for (int i = 0; i < NJDS; i++)
+ CPPUNIT_ASSERT_EQUAL(&jds[i], gc_jd_queue_dequeue(&queue));
+
+ CPPUNIT_ASSERT(gc_jd_queue_dequeue(&queue) == 0);
+}
+
+// FIXME multithreaded (running on PPE)
+void
+qa_jd_queue::t2()
+{
+}
+
+// FIXME multithreaded (running on PPE & SPE)
+void
+qa_jd_queue::t3()
+{
+}
Property changes on:
gnuradio/branches/developers/eb/gcell/src/lib/qa_jd_queue.cc
___________________________________________________________________
Name: svn:eol-style
+ native
Added: gnuradio/branches/developers/eb/gcell/src/lib/qa_jd_queue.h
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/qa_jd_queue.h
(rev 0)
+++ gnuradio/branches/developers/eb/gcell/src/lib/qa_jd_queue.h 2007-11-24
05:02:17 UTC (rev 7017)
@@ -0,0 +1,42 @@
+/* -*- 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_QA_JD_QUEUE_H
+#define INCLUDED_QA_JD_QUEUE_H
+
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/TestCase.h>
+
+class qa_jd_queue : public CppUnit::TestCase {
+
+ CPPUNIT_TEST_SUITE(qa_jd_queue);
+ CPPUNIT_TEST(t1);
+ CPPUNIT_TEST(t2);
+ CPPUNIT_TEST(t3);
+ CPPUNIT_TEST_SUITE_END();
+
+ private:
+ void t1();
+ void t2();
+ void t3();
+};
+
+
+#endif /* INCLUDED_QA_JD_QUEUE_H */
Property changes on: gnuradio/branches/developers/eb/gcell/src/lib/qa_jd_queue.h
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: gnuradio/branches/developers/eb/gcell/src/lib/qa_job_manager.cc
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/qa_job_manager.cc
2007-11-24 03:41:08 UTC (rev 7016)
+++ gnuradio/branches/developers/eb/gcell/src/lib/qa_job_manager.cc
2007-11-24 05:02:17 UTC (rev 7017)
@@ -25,20 +25,39 @@
#include <stdexcept>
#include <stdio.h>
+#include <malloc.h>
+
void
qa_job_manager::t1()
{
+ struct mallinfo before, after;
+
+ before = mallinfo();
+ t1_body();
+ after = mallinfo();
+
+ printf("before.uordblks = %6d\n", before.uordblks);
+ printf("after.uordblks = %6d\n", after.uordblks);
+ printf("delta = %d\n", after.uordblks - before.uordblks);
+}
+
+void
+qa_job_manager::t1_body()
+{
gc_job_manager *mgr;
-
mgr = gc_make_job_manager();
delete mgr;
+#if 1
+ // This seems to leak 352 bytes, but I'm not sure if it's us or the
+ // underlying exception handling mechanism
{
gc_jm_options opts;
opts.nspes = 100;
opts.gang_schedule = true;
CPPUNIT_ASSERT_THROW(mgr = gc_make_job_manager(&opts), std::out_of_range);
}
+#endif
{
gc_jm_options opts;
Modified: gnuradio/branches/developers/eb/gcell/src/lib/qa_job_manager.h
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/qa_job_manager.h
2007-11-24 03:41:08 UTC (rev 7016)
+++ gnuradio/branches/developers/eb/gcell/src/lib/qa_job_manager.h
2007-11-24 05:02:17 UTC (rev 7017)
@@ -35,6 +35,7 @@
private:
void t1();
+ void t1_body();
void t2();
void t3();
void t4();
Modified: gnuradio/branches/developers/eb/gcell/src/lib/qa_lib.cc
===================================================================
--- gnuradio/branches/developers/eb/gcell/src/lib/qa_lib.cc 2007-11-24
03:41:08 UTC (rev 7016)
+++ gnuradio/branches/developers/eb/gcell/src/lib/qa_lib.cc 2007-11-24
05:02:17 UTC (rev 7017)
@@ -27,6 +27,7 @@
#include <qa_lib.h>
#include <qa_jd_stack.h>
+#include <qa_jd_queue.h>
#include <qa_job_manager.h>
CppUnit::TestSuite *
@@ -35,6 +36,7 @@
CppUnit::TestSuite *s = new CppUnit::TestSuite("lib");
s->addTest(qa_jd_stack::suite());
+ s->addTest(qa_jd_queue::suite());
s->addTest(qa_job_manager::suite());
return s;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r7017 - in gnuradio/branches/developers/eb/gcell: . src/include src/lib,
eb <=