summaryrefslogtreecommitdiff
path: root/gcell/src/lib/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'gcell/src/lib/runtime')
-rw-r--r--gcell/src/lib/runtime/Makefile.am28
-rw-r--r--gcell/src/lib/runtime/gc_job_manager.cc112
-rw-r--r--gcell/src/lib/runtime/gc_job_manager.h116
-rw-r--r--gcell/src/lib/runtime/gc_job_manager_impl.cc29
-rw-r--r--gcell/src/lib/runtime/gc_job_manager_impl.h5
-rwxr-xr-xgcell/src/lib/runtime/gcell-embedspu-libtool29
-rw-r--r--gcell/src/lib/runtime/qa_gcell_runtime.cc (renamed from gcell/src/lib/runtime/qa_lib.cc)6
-rw-r--r--gcell/src/lib/runtime/qa_gcell_runtime.h (renamed from gcell/src/lib/runtime/qa_lib.h)10
-rw-r--r--gcell/src/lib/runtime/qa_job_manager.cc97
-rw-r--r--gcell/src/lib/runtime/spu/gc_spu_config.h2
-rw-r--r--gcell/src/lib/runtime/spu/gcell_runtime_qa.c (renamed from gcell/src/lib/runtime/spu/gcell_qa.c)0
11 files changed, 318 insertions, 116 deletions
diff --git a/gcell/src/lib/runtime/Makefile.am b/gcell/src/lib/runtime/Makefile.am
index 3f2077c08..a68d2bcd0 100644
--- a/gcell/src/lib/runtime/Makefile.am
+++ b/gcell/src/lib/runtime/Makefile.am
@@ -20,8 +20,6 @@
include $(top_srcdir)/Makefile.common
-# SUBDIRS = spu .
-
IBM_PPU_SYNC_INCLUDES = -I$(top_srcdir)/gcell/src/ibm/sync/ppu_source
@@ -29,6 +27,8 @@ AM_CPPFLAGS = $(DEFINES) $(OMNITHREAD_INCLUDES) $(MBLOCK_INCLUDES) $(CPPUNIT_INC
$(GCELL_INCLUDES) $(IBM_PPU_SYNC_INCLUDES) $(WITH_INCLUDES)
+dist_bin_SCRIPTS = gcell-embedspu-libtool
+
noinst_LTLIBRARIES = libruntime.la libruntime-qa.la
libruntime_la_SOURCES = \
@@ -39,7 +39,7 @@ libruntime_la_SOURCES = \
gc_proc_def_utils.cc
libruntime_qa_la_SOURCES = \
- qa_lib.cc \
+ qa_gcell_runtime.cc \
qa_jd_queue.cc \
qa_jd_stack.cc \
qa_job_manager.cc
@@ -55,22 +55,14 @@ noinst_HEADERS = \
qa_jd_queue.h \
qa_jd_stack.h \
qa_job_manager.h \
- qa_lib.h
+ qa_gcell_runtime.h
-
-# This kruft is required to link the QA SPU executable into the PPE shared lib w/o warnings
-gcell_qa.lo: ../spu/gcell_qa
- ppu-embedspu -m32 -fpic gcell_qa ../spu/gcell_qa .libs/gcell_qa.o
- @rm -f gcell_qa.lo
- @echo "# gcell_qa.lo - a libtool object file" >> gcell_qa.lo
- @echo "# Generated by ltmain.sh - GNU libtool 1.5.22 (1.1220.2.365 2005/12/18 22:14:06)" >> gcell_qa.lo
- @echo "#" >> gcell_qa.lo
- @echo "# Please DO NOT delete this file!" >> gcell_qa.lo
- @echo "# It is necessary for linking the library." >> gcell_qa.lo
- @echo "" >> gcell_qa.lo
- @echo "pic_object='.libs/gcell_qa.o'" >> gcell_qa.lo
- @echo "non_pic_object=none" >> gcell_qa.lo
+# generate a libtool.lo that contains an embeded SPU executable
+gcell_runtime_qa.lo: ../spu/gcell_runtime_qa
+ $(GCELL_EMBEDSPU_LIBTOOL) $@ $<
libruntime_qa_la_LIBADD = \
- gcell_qa.lo \
+ gcell_runtime_qa.lo \
libruntime.la
+
+CLEANFILES = gcell_runtime_qa.lo
diff --git a/gcell/src/lib/runtime/gc_job_manager.cc b/gcell/src/lib/runtime/gc_job_manager.cc
index 94090bedf..9ede5e156 100644
--- a/gcell/src/lib/runtime/gc_job_manager.cc
+++ b/gcell/src/lib/runtime/gc_job_manager.cc
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2007 Free Software Foundation, Inc.
+ * Copyright 2007,2008 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -24,11 +24,17 @@
#endif
#include "gc_job_manager.h"
#include "gc_job_manager_impl.h"
+#include <boost/weak_ptr.hpp>
+#include <stdio.h>
-gc_job_manager *
+
+static boost::weak_ptr<gc_job_manager> s_singleton;
+
+
+gc_job_manager_sptr
gc_make_job_manager(const gc_jm_options *options)
{
- return new gc_job_manager_impl(options);
+ return gc_job_manager_sptr(new gc_job_manager_impl(options));
}
gc_job_manager::gc_job_manager(const gc_jm_options *options)
@@ -52,3 +58,103 @@ gc_job_manager::debug()
{
return 0;
}
+
+void
+gc_job_manager::set_singleton(gc_job_manager_sptr mgr)
+{
+ s_singleton = mgr;
+}
+
+gc_job_manager_sptr
+gc_job_manager::singleton()
+{
+ return gc_job_manager_sptr(s_singleton);
+}
+
+// ------------------------------------------------------------------------
+
+
+// custom deleter
+class spe_program_handle_deleter {
+public:
+ void operator()(spe_program_handle_t *program) {
+ if (program){
+ int r = spe_image_close(program);
+ if (r != 0){
+ perror("spe_image_close");
+ }
+ }
+ }
+};
+
+// nop custom deleter
+class nop_spe_program_handle_deleter {
+public:
+ void operator()(spe_program_handle_t *program) {
+ }
+};
+
+spe_program_handle_sptr
+gc_program_handle_from_filename(const std::string &filename)
+{
+ return spe_program_handle_sptr(spe_image_open(filename.c_str()),
+ spe_program_handle_deleter());
+}
+
+
+spe_program_handle_sptr
+gc_program_handle_from_address(spe_program_handle_t *handle)
+{
+ return spe_program_handle_sptr(handle, nop_spe_program_handle_deleter());
+}
+
+const std::string
+gc_job_status_string(gc_job_status_t status)
+{
+ switch(status){
+ case JS_OK: return "JS_OK";
+ case JS_SHUTTING_DOWN: return "JS_SHUTTING_DOWN";
+ case JS_TOO_MANY_CLIENTS: return "JS_TOO_MANY_CLIENTS";
+ case JS_UNKNOWN_PROC: return "JS_UNKNOWN_PROC";
+ case JS_BAD_DIRECTION: return "JS_BAD_DIRECTION";
+ case JS_BAD_EAH: return "JS_BAD_EAH";
+ case JS_BAD_N_DIRECT: return "JS_BAD_N_DIRECT";
+ case JS_BAD_N_EA: return "JS_BAD_N_EA";
+ case JS_ARGS_TOO_LONG: return "JS_ARGS_TOO_LONG";
+ case JS_BAD_JUJU: return "JS_BAD_JUJU";
+ case JS_BAD_JOB_DESC: return "JS_BAD_JOB_DESC";
+ default:
+ char buf[100];
+ snprintf(buf, sizeof(buf), "unknown gc_job_status_t (%d)\n", status);
+ return buf;
+ }
+}
+
+/*
+ * exception classes
+ */
+
+gc_exception::gc_exception(const std::string &msg)
+ : runtime_error(msg)
+{
+}
+
+gc_unknown_proc::gc_unknown_proc(const std::string &msg)
+ : gc_exception("gc_unknown_proc: " + msg)
+{
+}
+
+gc_bad_alloc::gc_bad_alloc(const std::string &msg)
+ : gc_exception("gc_bad_alloc: " + msg)
+{
+}
+
+gc_bad_align::gc_bad_align(const std::string &msg)
+ : gc_exception("gc_bad_align: " + msg)
+{
+}
+
+gc_bad_submit::gc_bad_submit(const std::string &name, gc_job_status_t status)
+ : gc_exception("gc_bad_submit(" + name + "): " + gc_job_status_string(status))
+{
+}
diff --git a/gcell/src/lib/runtime/gc_job_manager.h b/gcell/src/lib/runtime/gc_job_manager.h
index 9c8e70bf8..aa30dc24b 100644
--- a/gcell/src/lib/runtime/gc_job_manager.h
+++ b/gcell/src/lib/runtime/gc_job_manager.h
@@ -23,17 +23,52 @@
#define INCLUDED_GC_JOB_MANAGER_H
#include <boost/utility.hpp>
+#include <boost/shared_ptr.hpp>
#include <vector>
#include <string>
+#include <stdexcept>
#include <libspe2.h>
#include "gc_job_desc.h"
class gc_job_manager;
+typedef boost::shared_ptr<gc_job_manager> gc_job_manager_sptr;
+typedef boost::shared_ptr<spe_program_handle_t> spe_program_handle_sptr;
-enum gc_wait_mode {
- GC_WAIT_ANY,
- GC_WAIT_ALL,
-};
+/*!
+ * \brief Return a boost::shared_ptr to an spe_program_handle_t
+ *
+ * \param filename is the name of the SPE ELF executable to open.
+ *
+ * Calls spe_image_open to open the file. If successful returns a
+ * boost::shared_ptr that will call spe_image_close when it's time to
+ * free the object.
+ *
+ * Returns the equivalent of the NULL pointer if the file cannot be
+ * opened, or if it's not an SPE ELF object file.
+ *
+ * \sa gc_program_handle_from_address
+ */
+spe_program_handle_sptr
+gc_program_handle_from_filename(const std::string &filename);
+
+/*!
+ * \brief Return a boost::shared_ptr to an spe_program_handle_t
+ *
+ * \param handle is a non-zero pointer to an embedded SPE image.
+ *
+ * If successful returns a boost::shared_ptr that does nothing when
+ * it's time to free the object.
+ *
+ * \sa gc_program_handle_from_filename
+ */
+spe_program_handle_sptr
+gc_program_handle_from_address(spe_program_handle_t *handle);
+
+/*!
+ * \brief map gc_job_status_t into a string
+ */
+const std::string
+gc_job_status_string(gc_job_status_t status);
/*
* \brief Options that configure the job_manager.
@@ -46,23 +81,59 @@ struct gc_jm_options {
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 log2_nlog_entries; // log2 of number of log entries (default is 12 == 4k)
- spe_program_handle_t *program_handle; // program to load into SPEs
+ uint32_t log2_nlog_entries; // log2 of number of log entries (default is 12 == 4k)
+ spe_program_handle_sptr 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), log2_nlog_entries(12),
- program_handle(0)
+ enable_logging(false), log2_nlog_entries(12)
{
}
};
+enum gc_wait_mode {
+ GC_WAIT_ANY,
+ GC_WAIT_ALL,
+};
+
+/*
+ * exception classes
+ */
+class gc_exception : public std::runtime_error
+{
+public:
+ gc_exception(const std::string &msg);
+};
+
+class gc_unknown_proc : public gc_exception
+{
+public:
+ gc_unknown_proc(const std::string &msg);
+};
+
+class gc_bad_alloc : public gc_exception
+{
+public:
+ gc_bad_alloc(const std::string &msg);
+};
+
+class gc_bad_align : public gc_exception
+{
+public:
+ gc_bad_align(const std::string &msg);
+};
+
+class gc_bad_submit : public gc_exception
+{
+public:
+ gc_bad_submit(const std::string &name, gc_job_status_t status);
+};
/*
* \brief Create an instance of the job manager
*/
-gc_job_manager *
+gc_job_manager_sptr
gc_make_job_manager(const gc_jm_options *options = 0);
@@ -92,7 +163,7 @@ public:
/*!
* \brief Return a pointer to a properly aligned job descriptor,
- * or zero if none are available.
+ * or throws gc_bad_alloc if there are none available.
*/
virtual gc_job_desc *alloc_job_desc() = 0;
@@ -139,6 +210,8 @@ public:
* A thread may only wait for jobs which it submitted.
*
* \returns number of jobs completed, or -1 if error.
+ * The caller must examine the status field of each job to confirm
+ * successful completion of the job.
*/
virtual int
wait_jobs(unsigned int njobs,
@@ -154,7 +227,7 @@ public:
/*!
* Return gc_proc_id_t associated with spu procedure \p proc_name if one
- * exists, otherwise return GCP_UNKNOWN_PROC.
+ * exists, otherwise throws gc_unknown_proc.
*/
virtual gc_proc_id_t lookup_proc(const std::string &proc_name) = 0;
@@ -163,6 +236,27 @@ public:
*/
virtual std::vector<std::string> proc_names() = 0;
+ /*!
+ * \brief Set the singleton gc_job_manager instance.
+ * \param mgr is the job manager instance.
+ *
+ * The singleton is weakly held, thus the caller must maintain
+ * a reference to the mgr for the duration. (If we held the
+ * manager strongly, the destructor would never be called, and the
+ * resources (SPEs) would not be returned.) Bottom line: the
+ * caller is responsible for life-time management.
+ */
+ static void set_singleton(gc_job_manager_sptr mgr);
+
+ /*!
+ * \brief Retrieve the singleton gc_job_manager instance.
+ *
+ * Returns the singleton gc_job_manager instance or raises
+ * boost::bad_weak_ptr if the singleton is empty.
+ */
+ static gc_job_manager_sptr singleton();
+
+
virtual void set_debug(int debug);
virtual int debug();
};
diff --git a/gcell/src/lib/runtime/gc_job_manager_impl.cc b/gcell/src/lib/runtime/gc_job_manager_impl.cc
index dd08154d0..59deb4ae5 100644
--- a/gcell/src/lib/runtime/gc_job_manager_impl.cc
+++ b/gcell/src/lib/runtime/gc_job_manager_impl.cc
@@ -65,19 +65,6 @@ public:
}
};
-// custom deleter
-class spe_program_handle_deleter {
-public:
- void operator()(spe_program_handle_t *program) {
- if (program){
- int r = spe_image_close(program);
- if (r != 0){
- perror("spe_image_close");
- }
- }
- }
-};
-
// custom deleter of anything that can be freed with "free"
class free_deleter {
@@ -150,7 +137,7 @@ gc_job_manager_impl::gc_job_manager_impl(const gc_jm_options *options)
if (d_options.max_client_threads == 0)
d_options.max_client_threads = DEFAULT_MAX_CLIENT_THREADS;
- if (d_options.program_handle == 0){
+ if (!d_options.program_handle){
fprintf(stderr, "gc_job_manager: options->program_handle must be non-zero\n");
throw std::runtime_error("gc_job_manager: options->program_handle must be non-zero");
}
@@ -236,7 +223,7 @@ gc_job_manager_impl::gc_job_manager_impl(const gc_jm_options *options)
// get a handle to the spe program
- spe_program_handle_t *spe_image = d_options.program_handle;
+ spe_program_handle_t *spe_image = d_options.program_handle.get();
// fish proc_def table out of SPE ELF file
@@ -431,8 +418,12 @@ gc_job_manager_impl::bv_isclr(unsigned long *bv, unsigned int bitno)
gc_job_desc *
gc_job_manager_impl::alloc_job_desc()
{
- // stack is lock free, thus safe to call from any thread
- return gc_jd_stack_pop(d_free_list);
+ // stack is lock free, and safe to call from any thread
+ gc_job_desc *jd = gc_jd_stack_pop(d_free_list);
+ if (jd == 0)
+ throw gc_bad_alloc("alloc_job_desc: none available");
+
+ return jd;
}
void
@@ -557,7 +548,7 @@ bool
gc_job_manager_impl::wait_job(gc_job_desc *jd)
{
bool done;
- return wait_jobs(1, &jd, &done, GC_WAIT_ANY) == 1;
+ return wait_jobs(1, &jd, &done, GC_WAIT_ANY) == 1 && jd->status == JS_OK;
}
int
@@ -1246,7 +1237,7 @@ gc_job_manager_impl::lookup_proc(const std::string &proc_name)
if (proc_name == d_proc_def[i].name)
return i;
- return GCP_UNKNOWN_PROC;
+ throw gc_unknown_proc(proc_name);
}
std::vector<std::string>
diff --git a/gcell/src/lib/runtime/gc_job_manager_impl.h b/gcell/src/lib/runtime/gc_job_manager_impl.h
index 46897848c..fcc24dc0c 100644
--- a/gcell/src/lib/runtime/gc_job_manager_impl.h
+++ b/gcell/src/lib/runtime/gc_job_manager_impl.h
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2007 Free Software Foundation, Inc.
+ * Copyright 2007,2008 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -29,7 +29,6 @@
#include "gc_spu_args.h"
#include <libspe2.h>
#include <vector>
-#include <boost/shared_ptr.hpp>
#include <boost/scoped_array.hpp>
typedef boost::shared_ptr<spe_gang_context> spe_gang_context_sptr;
@@ -169,7 +168,7 @@ private:
void sync_logfiles();
void unmap_logfiles();
- friend gc_job_manager *gc_make_job_manager(const gc_jm_options *options);
+ friend gc_job_manager_sptr gc_make_job_manager(const gc_jm_options *options);
gc_job_manager_impl(const gc_jm_options *options = 0);
diff --git a/gcell/src/lib/runtime/gcell-embedspu-libtool b/gcell/src/lib/runtime/gcell-embedspu-libtool
new file mode 100755
index 000000000..a4ee53b7e
--- /dev/null
+++ b/gcell/src/lib/runtime/gcell-embedspu-libtool
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+if [ $# -ne 2 ]; then
+ echo "usage: gcell-embedspu-libtool file.lo spu_executable_file" 1>&2
+ exit 1
+fi
+
+lo_file=$1
+spu_executable=$2
+symbol_name=${lo_file%%.lo}
+
+# generate the .o file that wraps the SPU executable
+ppu-embedspu -m32 -fpic ${symbol_name} ${spu_executable} .libs/${symbol_name}.o
+
+# generate the .lo libtool file that points at all the right places
+rm -f $lo_file
+cat >$lo_file.new <<EOF
+# $lo_file - a libtool object file
+# Generated by ltmain.sh - GNU libtool 1.5.22 (1.1220.2.365 2005/12/18 22:14:06)
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+pic_object='.libs/${symbol_name}.o'
+non_pic_object=none
+EOF
+
+mv $lo_file.new $lo_file
+
diff --git a/gcell/src/lib/runtime/qa_lib.cc b/gcell/src/lib/runtime/qa_gcell_runtime.cc
index d8a8960c6..fef9a7fb4 100644
--- a/gcell/src/lib/runtime/qa_lib.cc
+++ b/gcell/src/lib/runtime/qa_gcell_runtime.cc
@@ -25,15 +25,15 @@
* add them here.
*/
-#include <qa_lib.h>
+#include <qa_gcell_runtime.h>
#include <qa_jd_stack.h>
#include <qa_jd_queue.h>
#include <qa_job_manager.h>
CppUnit::TestSuite *
-qa_lib::suite()
+qa_gcell_runtime::suite()
{
- CppUnit::TestSuite *s = new CppUnit::TestSuite("lib");
+ CppUnit::TestSuite *s = new CppUnit::TestSuite("runtime");
s->addTest(qa_jd_stack::suite());
s->addTest(qa_jd_queue::suite());
diff --git a/gcell/src/lib/runtime/qa_lib.h b/gcell/src/lib/runtime/qa_gcell_runtime.h
index 594efcdc8..36180c919 100644
--- a/gcell/src/lib/runtime/qa_lib.h
+++ b/gcell/src/lib/runtime/qa_gcell_runtime.h
@@ -18,18 +18,18 @@
* 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_LIB_H
-#define INCLUDED_QA_LIB_H
+#ifndef INCLUDED_QA_GCELL_RUNTIME_H
+#define INCLUDED_QA_GCELL_RUNTIME_H
#include <cppunit/TestSuite.h>
-//! collect all the tests for the lib directory
+//! collect all the tests for the runtime directory
-class qa_lib {
+class qa_gcell_runtime {
public:
//! return suite of tests
static CppUnit::TestSuite *suite();
};
-#endif /* INCLUDED_QA_LIB_H */
+#endif /* INCLUDED_QA_GCELL_RUNTIME_H */
diff --git a/gcell/src/lib/runtime/qa_job_manager.cc b/gcell/src/lib/runtime/qa_job_manager.cc
index 3f2780c52..53a1ec681 100644
--- a/gcell/src/lib/runtime/qa_job_manager.cc
+++ b/gcell/src/lib/runtime/qa_job_manager.cc
@@ -29,7 +29,8 @@
#include <malloc.h>
-extern spe_program_handle_t gcell_qa; // handle to embedded SPU executable w/ QA routines
+// handle to embedded SPU executable w/ QA routines
+extern spe_program_handle_t gcell_runtime_qa;
#if 0
static void
@@ -173,23 +174,21 @@ qa_job_manager::t15()
void
qa_job_manager::t1_body()
{
- gc_job_manager *mgr;
+ gc_job_manager_sptr mgr;
gc_jm_options opts;
- opts.program_handle = &gcell_qa;
+ opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
mgr = gc_make_job_manager(&opts);
- delete mgr;
}
void
qa_job_manager::t2_body()
{
- gc_job_manager *mgr = 0;
+ gc_job_manager_sptr mgr;
gc_jm_options opts;
- opts.program_handle = &gcell_qa;
+ opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
opts.nspes = 100;
opts.gang_schedule = false;
mgr = gc_make_job_manager(&opts);
- delete mgr;
}
void
@@ -200,13 +199,12 @@ qa_job_manager::t3_body()
// cppunit. cppunit is the prime suspect.
#if 0
- gc_job_manager *mgr = 0;
+ gc_job_manager_sptr mgr;
gc_jm_options opts;
- opts.program_handle = &gcell_qa;
+ opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
opts.nspes = 100;
opts.gang_schedule = true;
CPPUNIT_ASSERT_THROW(mgr = gc_make_job_manager(&opts), std::out_of_range);
- delete mgr;
#endif
}
@@ -222,9 +220,9 @@ init_jd(gc_job_desc *jd, gc_proc_id_t proc_id)
void
qa_job_manager::t4_body()
{
- gc_job_manager *mgr;
+ gc_job_manager_sptr mgr;
gc_jm_options opts;
- opts.program_handle = &gcell_qa;
+ opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
opts.nspes = 1;
mgr = gc_make_job_manager(&opts);
//mgr->set_debug(-1);
@@ -232,8 +230,8 @@ qa_job_manager::t4_body()
gc_job_desc *jds[NJOBS];
bool done[NJOBS];
- gc_proc_id_t gcp_no_such = mgr->lookup_proc("--no-such-proc-name--");
- CPPUNIT_ASSERT_EQUAL(GCP_UNKNOWN_PROC, gcp_no_such);
+ gc_proc_id_t gcp_no_such;
+ CPPUNIT_ASSERT_THROW(gcp_no_such = mgr->lookup_proc("--no-such-proc-name--"), gc_unknown_proc);
gc_proc_id_t gcp_qa_nop = mgr->lookup_proc("qa_nop");
CPPUNIT_ASSERT(gcp_qa_nop != GCP_UNKNOWN_PROC);
@@ -256,16 +254,14 @@ qa_job_manager::t4_body()
for (int i = 0; i < NJOBS; i++){
mgr->free_job_desc(jds[i]);
}
-
- delete mgr;
}
void
qa_job_manager::t5_body()
{
- gc_job_manager *mgr;
+ gc_job_manager_sptr mgr;
gc_jm_options opts;
- opts.program_handle = &gcell_qa;
+ opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
opts.nspes = 0; // use them all
mgr = gc_make_job_manager(&opts);
//mgr->set_debug(-1);
@@ -293,16 +289,14 @@ qa_job_manager::t5_body()
for (int i = 0; i < NJOBS; i++){
mgr->free_job_desc(jds[i]);
}
-
- delete mgr;
}
void
qa_job_manager::t6_body()
{
- gc_job_manager *mgr;
+ gc_job_manager_sptr mgr;
gc_jm_options opts;
- opts.program_handle = &gcell_qa;
+ opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
opts.nspes = 1;
mgr = gc_make_job_manager(&opts);
gc_proc_id_t gcp_qa_nop = mgr->lookup_proc("qa_nop");
@@ -330,7 +324,6 @@ qa_job_manager::t6_body()
}
mgr->free_job_desc(jd);
- delete mgr;
}
static int
@@ -344,7 +337,7 @@ sum_shorts(short *p, int nshorts)
}
static void
-test_sum_shorts(gc_job_manager *mgr, short *buf, int nshorts)
+test_sum_shorts(gc_job_manager_sptr mgr, short *buf, int nshorts)
{
gc_job_desc *jd = mgr->alloc_job_desc();
gc_proc_id_t gcp_qa_sum_shorts = mgr->lookup_proc("qa_sum_shorts");
@@ -379,9 +372,9 @@ static short short_buf[NS] _AL128; // for known alignment
void
qa_job_manager::t7_body()
{
- gc_job_manager *mgr;
+ gc_job_manager_sptr mgr;
gc_jm_options opts;
- opts.program_handle = &gcell_qa;
+ opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
opts.nspes = 1;
mgr = gc_make_job_manager(&opts);
@@ -400,8 +393,6 @@ qa_job_manager::t7_body()
for (int offset = 0; offset <= 64; offset++){
test_sum_shorts(mgr, &short_buf[offset], ea_args_maxsize/sizeof(short));
}
-
- delete mgr;
}
//
@@ -410,9 +401,9 @@ qa_job_manager::t7_body()
void
qa_job_manager::t8_body()
{
- gc_job_manager *mgr;
+ gc_job_manager_sptr mgr;
gc_jm_options opts;
- opts.program_handle = &gcell_qa;
+ opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
opts.nspes = 1;
mgr = gc_make_job_manager(&opts);
gc_job_desc *jd = mgr->alloc_job_desc();
@@ -433,7 +424,6 @@ qa_job_manager::t8_body()
}
mgr->free_job_desc(jd);
- delete mgr;
}
//
@@ -444,9 +434,9 @@ qa_job_manager::t9_body()
{
static const int N = 127;
static const int M = 201;
- gc_job_manager *mgr;
+ gc_job_manager_sptr mgr;
gc_jm_options opts;
- opts.program_handle = &gcell_qa;
+ opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
opts.nspes = 1;
mgr = gc_make_job_manager(&opts);
gc_job_desc *jd = mgr->alloc_job_desc();
@@ -474,7 +464,6 @@ qa_job_manager::t9_body()
}
mgr->free_job_desc(jd);
- delete mgr;
}
static bool
@@ -510,7 +499,7 @@ confirm_seq(const unsigned char *buf, size_t len, unsigned char v)
}
static void
-test_put_seq(gc_job_manager *mgr, int offset, int len, int starting_val)
+test_put_seq(gc_job_manager_sptr mgr, int offset, int len, int starting_val)
{
gc_job_desc *jd = mgr->alloc_job_desc();
gc_proc_id_t gcp_qa_put_seq = mgr->lookup_proc("qa_put_seq");
@@ -556,9 +545,9 @@ test_put_seq(gc_job_manager *mgr, int offset, int len, int starting_val)
void
qa_job_manager::t10_body()
{
- gc_job_manager *mgr;
+ gc_job_manager_sptr mgr;
gc_jm_options opts;
- opts.program_handle = &gcell_qa;
+ opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
opts.nspes = 1;
mgr = gc_make_job_manager(&opts);
@@ -576,8 +565,6 @@ qa_job_manager::t10_body()
for (int offset = 0; offset <= 64; offset++){
test_put_seq(mgr, offset, ea_args_maxsize, starting_val++);
}
-
- delete mgr;
}
//
@@ -586,9 +573,9 @@ qa_job_manager::t10_body()
void
qa_job_manager::t11_body()
{
- gc_job_manager *mgr;
+ gc_job_manager_sptr mgr;
gc_jm_options opts;
- opts.program_handle = &gcell_qa;
+ opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
opts.nspes = 1;
mgr = gc_make_job_manager(&opts);
gc_job_desc *jd = mgr->alloc_job_desc();
@@ -611,7 +598,6 @@ qa_job_manager::t11_body()
}
mgr->free_job_desc(jd);
- delete mgr;
}
//
@@ -622,9 +608,9 @@ qa_job_manager::t12_body()
{
static const int N = 127;
static const int M = 201;
- gc_job_manager *mgr;
+ gc_job_manager_sptr mgr;
gc_jm_options opts;
- opts.program_handle = &gcell_qa;
+ opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
opts.nspes = 1;
mgr = gc_make_job_manager(&opts);
gc_job_desc *jd = mgr->alloc_job_desc();
@@ -662,7 +648,6 @@ qa_job_manager::t12_body()
}
mgr->free_job_desc(jd);
- delete mgr;
}
//
@@ -671,9 +656,9 @@ qa_job_manager::t12_body()
void
qa_job_manager::t13_body()
{
- gc_job_manager *mgr;
+ gc_job_manager_sptr mgr;
gc_jm_options opts;
- opts.program_handle = &gcell_qa;
+ opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
opts.nspes = 1;
mgr = gc_make_job_manager(&opts);
@@ -720,8 +705,6 @@ qa_job_manager::t13_body()
CPPUNIT_ASSERT(ok);
}
mgr->free_job_desc(jd);
-
- delete mgr;
}
/*
@@ -743,9 +726,9 @@ qa_job_manager::t14_body()
memset(buf, 0xff, LEN_PER_JOB * NJOBS);
- gc_job_manager *mgr;
+ gc_job_manager_sptr mgr;
gc_jm_options opts;
- opts.program_handle = &gcell_qa;
+ opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
opts.nspes = 1;
mgr = gc_make_job_manager(&opts);
@@ -788,11 +771,19 @@ qa_job_manager::t14_body()
// cleanup
for (int i = 0; i < NJOBS; i++)
mgr->free_job_desc(jd[i]);
-
- delete mgr;
}
void
qa_job_manager::t15_body()
{
+ gc_jm_options opts;
+ opts.program_handle = gc_program_handle_from_address(&gcell_runtime_qa);
+ opts.nspes = 1;
+ gc_job_manager_sptr mgr = gc_make_job_manager(&opts);
+
+ gc_job_manager::set_singleton(mgr);
+
+ CPPUNIT_ASSERT(gc_job_manager::singleton());
+ mgr.reset();
+ CPPUNIT_ASSERT_THROW(gc_job_manager::singleton(), boost::bad_weak_ptr);
}
diff --git a/gcell/src/lib/runtime/spu/gc_spu_config.h b/gcell/src/lib/runtime/spu/gc_spu_config.h
index 997645e68..6eff71060 100644
--- a/gcell/src/lib/runtime/spu/gc_spu_config.h
+++ b/gcell/src/lib/runtime/spu/gc_spu_config.h
@@ -24,7 +24,7 @@
#include <gc_job_desc.h>
#define CACHE_LINE_SIZE 128 // in bytes
-#define GC_SPU_BUFSIZE_BASE (32 * 1024) // must be multiple of CACHE_LINE_SIZE
+#define GC_SPU_BUFSIZE_BASE (40 * 1024) // must be multiple of CACHE_LINE_SIZE
#define GC_SPU_BUFSIZE (GC_SPU_BUFSIZE_BASE + MAX_ARGS_EA * CACHE_LINE_SIZE)
#define NGETBUFS 1 // single buffer job arg gets
diff --git a/gcell/src/lib/runtime/spu/gcell_qa.c b/gcell/src/lib/runtime/spu/gcell_runtime_qa.c
index 51bf38a6a..51bf38a6a 100644
--- a/gcell/src/lib/runtime/spu/gcell_qa.c
+++ b/gcell/src/lib/runtime/spu/gcell_runtime_qa.c