git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@810 331e1502-861f-0410-8da2-ba01fb791d7f

This commit is contained in:
atantar 2007-11-23 16:41:23 +00:00
commit 7526792805
49 changed files with 449 additions and 420 deletions

View file

@ -46,6 +46,7 @@ static std :: map <const Communicable *, unsigned> comm_to_key; /* Map of regist
unsigned Communicable :: num_comm = 0; unsigned Communicable :: num_comm = 0;
Communicable :: Communicable () { Communicable :: Communicable () {
comm_to_key [this] = key = ++ num_comm; comm_to_key [this] = key = ++ num_comm;
@ -70,7 +71,7 @@ Communicable * getCommunicable (COMM_ID __key) {
} }
COMM_ID getKey (const Communicable * __comm) { COMM_ID getKey (const Communicable * __comm) {
return comm_to_key [__comm]; return comm_to_key [__comm];
} }

View file

@ -47,10 +47,10 @@ class Communicable {
public : public :
Communicable (); Communicable ();
virtual ~ Communicable (); virtual ~ Communicable ();
COMM_ID getKey (); COMM_ID getKey ();
void lock (); /* It suspends the current process if the semaphore is locked */ void lock (); /* It suspends the current process if the semaphore is locked */
void unlock (); /* It unlocks the shared semaphore */ void unlock (); /* It unlocks the shared semaphore */
@ -67,7 +67,7 @@ protected :
COMM_ID key; COMM_ID key;
sem_t sem_lock; sem_t sem_lock;
sem_t sem_stop; sem_t sem_stop;
}; };
@ -75,6 +75,4 @@ extern void initCommunicableEnv ();
extern Communicable * getCommunicable (COMM_ID __key); extern Communicable * getCommunicable (COMM_ID __key);
//extern COMM_ID getKey (const Communicable * __comm);
#endif #endif

View file

@ -51,7 +51,7 @@ public :
void setOwner (Runner & __runner); void setOwner (Runner & __runner);
virtual void pack () = 0; virtual void pack () = 0;
virtual void unpack () = 0; virtual void unpack () = 0;
void send (Cooperative * __coop); void send (Cooperative * __coop);

View file

@ -44,7 +44,14 @@
template <class F, class T> void pack (const eoVector <F, T> & __v) { template <class F, class T> void pack (const eoVector <F, T> & __v) {
pack (__v.fitness ()) ; if (__v.invalid()) {
pack((unsigned)0);
}
else {
pack((unsigned)1);
pack (__v.fitness ());
}
unsigned len = __v.size (); unsigned len = __v.size ();
pack (len); pack (len);
for (unsigned i = 0 ; i < len; i ++) for (unsigned i = 0 ; i < len; i ++)
@ -53,9 +60,16 @@ template <class F, class T> void pack (const eoVector <F, T> & __v) {
template <class F, class T> void unpack (eoVector <F, T> & __v) { template <class F, class T> void unpack (eoVector <F, T> & __v) {
F fit; unsigned valid; unpack(valid);
unpack (fit);
__v.fitness (fit); if (! valid) {
__v.invalidate();
}
else {
F fit;
unpack (fit);
__v.fitness (fit);
}
unsigned len; unsigned len;
unpack (len); unpack (len);

View file

@ -71,13 +71,13 @@ extern void pack (const char * __str);
/* Pointer */ /* Pointer */
template <class T> void pack (const T * __ptr) { template <class T> void pack (const T * __ptr) {
pack ((unsigned long) __ptr); pack ((unsigned long) __ptr);
} }
/* Pair */ /* Pair */
template <class U, class V> void pack (const std :: pair <U, V> & __pair) { template <class U, class V> void pack (const std :: pair <U, V> & __pair) {
pack (__pair.first); pack (__pair.first);
pack (__pair.second); pack (__pair.second);
} }
@ -116,7 +116,7 @@ extern void unpack (char * __str);
/* Pointer */ /* Pointer */
template <class T> void unpack (T * & __ptr) { template <class T> void unpack (T * & __ptr) {
unsigned long p; unsigned long p;
unpack (p); unpack (p);
__ptr = (T *) p; __ptr = (T *) p;
@ -124,10 +124,9 @@ template <class T> void unpack (T * & __ptr) {
/* Pair */ /* Pair */
template <class U, class V> void unpack (std :: pair <U, V> & __pair) { template <class U, class V> void unpack (std :: pair <U, V> & __pair) {
unpack (__pair.first); unpack (__pair.first);
unpack (__pair.second); unpack (__pair.second);
} }
#endif #endif

View file

@ -50,12 +50,14 @@
#define DEBUG_PATH "./log/" #define DEBUG_PATH "./log/"
static bool debug = true; static bool debug = true;
static char host [MAX_BUFF_SIZE]; static char host [MAX_BUFF_SIZE];
std :: vector <FILE *> files; std :: vector <FILE *> files;
void setDebugMode (bool __dbg) { void setDebugMode (bool __dbg) {
debug = __dbg; debug = __dbg;
@ -65,7 +67,7 @@ void setDebugMode (bool __dbg) {
extern int getNodeRank (); extern int getNodeRank ();
void initDebugging () { void initDebugging () {
mkdir (DEBUG_PATH, S_IRWXU); mkdir (DEBUG_PATH, S_IRWXU);
// files.push_back (stdout); // files.push_back (stdout);
char buff [MAX_BUFF_SIZE]; char buff [MAX_BUFF_SIZE];

View file

@ -44,7 +44,6 @@ void peo :: finalize () {
printDebugMessage ("waiting for the termination of all threads"); printDebugMessage ("waiting for the termination of all threads");
joinRunners (); joinRunners ();
finalizeRMC (); finalizeRMC ();
printDebugMessage ("this is the end"); printDebugMessage ("this is the end");

View file

@ -38,11 +38,14 @@
#include "peo_init.h" #include "peo_init.h"
#include "peo_param.h" #include "peo_param.h"
#include "peo_debug.h" #include "peo_debug.h"
#include "rmc.h" #include "rmc.h"
#include "runner.h"
extern void initCommunicableEnv (); extern void initCommunicableEnv ();
extern void initBuffers ();
extern void initThreadsEnv (); extern void initThreadsEnv ();
extern void initReactiveThreadsEnv (); extern void initReactiveThreadsEnv ();
@ -50,10 +53,14 @@ extern void initReactiveThreadsEnv ();
extern void initRunnersEnv (); extern void initRunnersEnv ();
extern void initWorkersEnv (); extern void initWorkersEnv ();
extern void initScheduler ();
static void initExecutionEnv() { static void initExecutionEnv() {
initCommunicableEnv (); initCommunicableEnv ();
initBuffers ();
initScheduler();
initThreadsEnv (); initThreadsEnv ();
initReactiveThreadsEnv (); initReactiveThreadsEnv ();
@ -62,27 +69,28 @@ static void initExecutionEnv() {
initWorkersEnv (); initWorkersEnv ();
} }
namespace peo { namespace peo {
int * argc; int * argc;
char * * * argv; char * * * argv;
void init (int & __argc, char * * & __argv) { void init (int & __argc, char * * & __argv) {
argc = & __argc; argc = & __argc;
argv = & __argv; argv = & __argv;
/* Initializing the execution environment */ /* Initializing the execution environment */
initExecutionEnv(); initExecutionEnv();
/* Initializing the the Resource Management and Communication */
initRMC (__argc, __argv);
/* Loading the common parameters */ /* Loading the common parameters */
loadParameters (__argc, __argv); loadParameters (__argc, __argv);
/* Initializing the the Resource Management and Communication */
initRMC ( *peo::argc, *peo::argv);
/* */ /* */
initDebugging (); initDebugging ();
} }

View file

@ -40,9 +40,9 @@
namespace peo { namespace peo {
extern int * argc; extern int * argc;
extern char * * * argv; extern char * * * argv;
extern void init (int & __argc, char * * & __argv); extern void init (int & __argc, char * * & __argv);
} }

View file

@ -40,7 +40,6 @@
#include "peo_debug.h" #include "peo_debug.h"
void peo :: loadParameters (int & __argc, char * * & __argv) { void peo :: loadParameters (int & __argc, char * * & __argv) {
eoParser parser (__argc, __argv); eoParser parser (__argc, __argv);

View file

@ -38,7 +38,7 @@
#define __peo_param_h #define __peo_param_h
namespace peo { namespace peo {
extern void loadParameters (int & __argc, char * * & __argv); extern void loadParameters (int & __argc, char * * & __argv);
} }

View file

@ -34,11 +34,11 @@
* *
*/ */
#include "peo_init.h"
#include "peo_run.h" #include "peo_run.h"
#include "rmc.h" #include "rmc.h"
#include "runner.h" #include "runner.h"
void peo :: run () { void peo :: run () {
startRunners (); startRunners ();

View file

@ -38,7 +38,7 @@
#define __peo_run_h #define __peo_run_h
namespace peo { namespace peo {
extern void run (); extern void run ();
} }

View file

@ -40,6 +40,7 @@ static bool the_end = false;
static std :: vector <ReactiveThread *> reac_threads; static std :: vector <ReactiveThread *> reac_threads;
ReactiveThread :: ReactiveThread () { ReactiveThread :: ReactiveThread () {
reac_threads.push_back (this); reac_threads.push_back (this);

View file

@ -43,14 +43,14 @@
class ReactiveThread : public Thread { class ReactiveThread : public Thread {
public: public:
/* Ctor */ /* Ctor */
ReactiveThread (); ReactiveThread ();
void sleep (); void sleep ();
void wakeUp (); void wakeUp ();
private: private:
@ -62,6 +62,4 @@ extern void initReactiveThreadsEnv ();
extern void stopReactiveThreads (); extern void stopReactiveThreads ();
extern bool theEnd ();
#endif /*REAC_THREAD_H_*/ #endif /*REAC_THREAD_H_*/

View file

@ -43,7 +43,7 @@ void RingTopology :: setNeighbors (Cooperative * __mig,
__to.clear () ; __to.clear () ;
int len = mig.size () ; int len = mig.size () ;
for (int i = 0 ; i < len ; i ++) for (int i = 0 ; i < len ; i ++)
if (mig [i] == __mig) { if (mig [i] == __mig) {
__from.push_back (mig [(i - 1 + len) % len]) ; __from.push_back (mig [(i - 1 + len) % len]) ;

View file

@ -40,9 +40,9 @@
#include "topology.h" #include "topology.h"
class RingTopology : public Topology { class RingTopology : public Topology {
public : public :
void setNeighbors (Cooperative * __mig, void setNeighbors (Cooperative * __mig,
std :: vector <Cooperative *> & __from, std :: vector <Cooperative *> & __from,
std :: vector <Cooperative *> & __to); std :: vector <Cooperative *> & __to);

View file

@ -95,50 +95,19 @@ Runner * getRunner (RUNNER_ID __key) {
return dynamic_cast <Runner *> (getCommunicable (__key)); return dynamic_cast <Runner *> (getCommunicable (__key));
} }
void packExecutionContext () {
num_local_exec_runners = 0;
for (unsigned i = 0; i < the_runners.size (); i ++)
if (the_runners [i] -> isAssignedLocally ()) num_local_exec_runners ++;
pack(num_local_exec_runners);
}
void unpackExecutionContext () {
unsigned num_remote_runners;
unpack(num_remote_runners);
num_exec_runners += num_remote_runners;
}
void initializeContext () { void initializeContext () {
initMessage (); num_local_exec_runners = 0;
packExecutionContext ();
sendMessageToAll (EXECUTION_CONTEXT_TAG);
int src, tag; // setting up the execution IDs & counting the number of local exec. runners
for (unsigned i = 0; i < getNumberOfNodes(); i ++) { for (unsigned i = 0; i < the_runners.size (); i ++) {
the_runners [i] -> setExecutionID ( my_node -> execution_id_run[ i ] );
cleanBuffers (); if (the_runners [i] -> isAssignedLocally ()) num_local_exec_runners ++;
waitMessage ();
probeMessage ( src, tag );
receiveMessage( src, tag );
initMessage ();
unpackExecutionContext ();
} }
cleanBuffers (); collectiveCountOfRunners( &num_local_exec_runners, &num_exec_runners );
// setting up the execution IDs // synchronizeNodes ();
for (unsigned i = 0; i < the_runners.size (); i ++)
the_runners [i] -> setExecutionID ( my_node -> execution_id_run[ i ] );
// synchronizing - all the nodes have to finish initializing
// the context before actually executing the runners
synchronizeNodes ();
for (unsigned i = 0; i < the_runners.size (); i ++) for (unsigned i = 0; i < the_runners.size (); i ++)
if (the_runners [i] -> isAssignedLocally ()) the_runners [i] -> notifyContextInitialized (); if (the_runners [i] -> isAssignedLocally ()) the_runners [i] -> notifyContextInitialized ();
@ -217,6 +186,7 @@ void unpackTerminationOfRunner () {
printDebugMessage ("All the runners have terminated - now stopping the reactive threads."); printDebugMessage ("All the runners have terminated - now stopping the reactive threads.");
stopReactiveThreads (); stopReactiveThreads ();
printDebugMessage ("Reactive threads stopped!");
} }
} }

View file

@ -40,7 +40,7 @@ void Service :: setOwner (Thread & __owner) {
owner = & __owner; owner = & __owner;
} }
Thread * Service :: getOwner () { Thread * Service :: getOwner () {
return owner; return owner;

View file

@ -48,7 +48,7 @@ class Service : public Communicable {
public : public :
void setOwner (Thread & __owner); void setOwner (Thread & __owner);
Thread * getOwner (); Thread * getOwner ();
void requestResourceRequest (unsigned __how_many = 1); void requestResourceRequest (unsigned __how_many = 1);
@ -58,7 +58,7 @@ public :
virtual void unpackData (); virtual void unpackData ();
virtual void execute (); virtual void execute ();
virtual void packResult (); virtual void packResult ();
virtual void unpackResult (); virtual void unpackResult ();

Some files were not shown because too many files have changed in this diff Show more