[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r7011 - gnuradio/branches/developers/eb/gcell/src/lib
From: |
eb |
Subject: |
[Commit-gnuradio] r7011 - gnuradio/branches/developers/eb/gcell/src/lib |
Date: |
Tue, 20 Nov 2007 20:51:05 -0700 (MST) |
Author: eb
Date: 2007-11-20 20:50:59 -0700 (Tue, 20 Nov 2007)
New Revision: 7011
Modified:
gnuradio/branches/developers/eb/gcell/src/lib/gc_job_manager_impl.cc
gnuradio/branches/developers/eb/gcell/src/lib/gc_job_manager_impl.h
Log:
work-in-progress on cell job manager
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-11-21 03:00:30 UTC (rev 7010)
+++ gnuradio/branches/developers/eb/gcell/src/lib/gc_job_manager_impl.cc
2007-11-21 03:50:59 UTC (rev 7011)
@@ -24,8 +24,6 @@
#endif
#include "gc_job_manager_impl.h"
-//#define _XOPEN_SOURCE 600 // to get XSI version of strerror_r
-//#include <string.h>
#include <stdio.h>
#include <stdexcept>
@@ -34,22 +32,23 @@
static const unsigned int DEFAULT_MAX_JOBS = 256;
static const unsigned int DEFAULT_MAX_CLIENT_THREADS = 64;
-#if 0
-static char *
-gc_strerror(int errnum, char *buf, size_t buflen)
-{
- // we're using the XSI version, not the GNU-specific version
- int r = strerror_r(errnum, buf, sizeof(buf));
- if (r != 0){ // trouble
- snprintf(buf, buflen, "Unknown error %d", errnum);
+
+// custom deleter of gang_contexts for use with boost::shared_ptr
+class gang_destroyer {
+public:
+ void operator()(spe_gang_context_ptr_t ctx) {
+ if (ctx){
+ int r = spe_gang_context_destroy(ctx);
+ if (r != 0){
+ perror("spe_gang_context_destroy");
+ }
+ }
}
- return buf;
-}
-#endif
+};
gc_job_manager_impl::gc_job_manager_impl(const gc_jm_options *options)
- : d_nspes(0), d_nclients(0)
+ : d_nclients(0)
{
if (options != 0)
d_options = *options;
@@ -73,6 +72,10 @@
}
}
+ // FIXME when we get that next gen Cell
+ if (nusable_spes > (int) MAX_SPES)
+ nusable_spes = MAX_SPES; // be safe in the meanwhile
+
//
// sanity check requested number of spes.
//
@@ -81,12 +84,12 @@
else {
if (d_options.nspes > (unsigned int) nusable_spes){
fprintf(stderr,
- "gc_job_manager: caller requested %d spes. There are only %d
available.\n",
+ "gc_job_manager: warning: caller requested %d spes. There are
only %d available.\n",
d_options.nspes, nusable_spes);
if (d_options.gang_schedule){
// If we're gang scheduling we'll never get scheduled if we
// ask for more than are available.
- throw std::out_of_range("not enough spes available");
+ throw std::out_of_range("gang_scheduling: not enough spes available");
}
}
}
@@ -95,23 +98,50 @@
printf("gc_job_manager: warning: affinity request was ignored\n");
}
- // we probably want to get smarter about partioning these on the blade server
-
if (d_options.gang_schedule){
- d_gang = spe_gang_context_create(0);
- if (d_gang == 0){
+ d_gang = spe_gang_context_sptr(spe_gang_context_create(0),
gang_destroyer());
+ if (!d_gang){
perror("gc_job_manager_impl[spe_gang_context_create]");
throw std::runtime_error("spe_gang_context_create");
}
}
- // FIXME more storage init. Think about shared pointers w/ custom
destructors
+ // create the spe contexts
+ int spe_flags = SPE_EVENTS_ENABLE | SPE_CFG_SIGNOTIFY1_OR |
SPE_CFG_SIGNOTIFY2_OR;
+
+ for (unsigned int i = 0; i < d_options.nspes; i++){
+ // FIXME affinity stuff goes here
+ d_worker[i].spe_ctx = spe_context_create(spe_flags, d_gang.get());;
+ if (d_worker[i].spe_ctx == 0){
+ perror("spe_context_create");
+ throw std::runtime_error("spe_context_create");
+ }
+ d_worker[i].state = WS_INIT;
+
+ // FIXME load some code in the SPE
+ }
+
+ // FIXME init d_jd
+ // FIXME init d_bvlen
+ // FIXME init d_job_busy
+ // FIXME init d_client_thread
+
gc_jd_stack_init(&d_free_list);
+
+ // FIXME sequence this...
+ // FIXME create event handler thread
+ // FIXME create N worker threads
+ // FIXME confirm everything started OK
+
+ // Done!
}
gc_job_manager_impl::~gc_job_manager_impl()
{
+ shutdown();
+
+ // FIXME whatever else needs to be done
}
bool
@@ -165,5 +195,6 @@
}
spe_ctx = 0;
}
+ state = WS_FREE;
}
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-11-21 03:00:30 UTC (rev 7010)
+++ gnuradio/branches/developers/eb/gcell/src/lib/gc_job_manager_impl.h
2007-11-21 03:50:59 UTC (rev 7011)
@@ -26,8 +26,9 @@
#include "gc_client_thread_info.h"
#include "gc_jd_stack.h"
#include <libspe2.h>
+#include <boost/shared_ptr.hpp>
-class gc_job_manager_impl;
+typedef boost::shared_ptr<spe_gang_context> spe_gang_context_sptr;
enum worker_state {
WS_FREE, // not in use
@@ -54,8 +55,7 @@
static const unsigned int MAX_SPES = 16;
gc_jm_options d_options;
- spe_gang_context_ptr_t d_gang;
- int d_nspes; // number of SPEs we've
allocated
+ spe_gang_context_sptr d_gang; // boost::shared_ptr
worker_ctx d_worker[MAX_SPES];
gc_job_desc_t *d_jd; // [limits.max_jobs]
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r7011 - gnuradio/branches/developers/eb/gcell/src/lib,
eb <=