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

This commit is contained in:
atantar 2007-11-18 17:00:47 +00:00
commit adb6419766
60 changed files with 1017 additions and 1095 deletions

View file

@ -46,8 +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;
key_to_comm.push_back (this); key_to_comm.push_back (this);
@ -55,48 +54,41 @@ Communicable :: Communicable ()
sem_init (& sem_stop, 0, 0); sem_init (& sem_stop, 0, 0);
} }
Communicable :: ~ Communicable () Communicable :: ~ Communicable () {
{
} }
COMM_ID Communicable :: getKey () COMM_ID Communicable :: getKey () {
{
return key; return key;
} }
Communicable * getCommunicable (COMM_ID __key) Communicable * getCommunicable (COMM_ID __key) {
{
assert (__key < key_to_comm.size ()); assert (__key < key_to_comm.size ());
return key_to_comm [__key]; return key_to_comm [__key];
} }
COMM_ID getKey (const Communicable * __comm) COMM_ID getKey (const Communicable * __comm) {
{
return comm_to_key [__comm]; return comm_to_key [__comm];
} }
void Communicable :: lock () void Communicable :: lock () {
{
sem_wait (& sem_lock); sem_wait (& sem_lock);
} }
void Communicable :: unlock () void Communicable :: unlock () {
{
sem_post (& sem_lock); sem_post (& sem_lock);
} }
void Communicable :: stop () void Communicable :: stop () {
{
sem_wait (& sem_stop); sem_wait (& sem_stop);
} }
void Communicable :: resume () void Communicable :: resume () {
{
sem_post (& sem_stop); sem_post (& sem_stop);
} }

View file

@ -41,8 +41,7 @@
typedef unsigned COMM_ID; typedef unsigned COMM_ID;
class Communicable class Communicable {
{
public : public :

View file

@ -42,8 +42,7 @@
typedef unsigned COOP_ID; typedef unsigned COOP_ID;
class Cooperative : public Communicable class Cooperative : public Communicable {
{
public : public :

View file

@ -34,23 +34,21 @@
* *
*/ */
#ifndef __eoPop_comm_h #ifndef __eoPop_mesg_h
#define __eoPop_comm_h #define __eoPop_mesg_h
#include <eoPop.h> #include <eoPop.h>
#include "messaging.h" #include "messaging.h"
template <class EOT> void pack (const eoPop <EOT> & __pop) template <class EOT> void pack (const eoPop <EOT> & __pop) {
{
pack ((unsigned) __pop.size ()); pack ((unsigned) __pop.size ());
for (unsigned i = 0; i < __pop.size (); i ++) for (unsigned i = 0; i < __pop.size (); i ++)
pack (__pop [i]); pack (__pop [i]);
} }
template <class EOT> void unpack (eoPop <EOT> & __pop) template <class EOT> void unpack (eoPop <EOT> & __pop) {
{
unsigned n; unsigned n;

View file

@ -34,43 +34,28 @@
* *
*/ */
#ifndef __eoVector_comm_h #ifndef __eoVector_mesg_h
#define __eoVector_comm_h #define __eoVector_mesg_h
#include <eoVector.h> #include <eoVector.h>
#include "messaging.h" #include "messaging.h"
template <class F, class T> void pack (const eoVector <F, T> & __v) template <class F, class T> void pack (const eoVector <F, T> & __v) {
{
if ( !__v.invalid() )
{
pack( (unsigned int) 1 );
pack (__v.fitness ()) ; pack (__v.fitness ()) ;
}
else
pack( (unsigned int) 0 );
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 ++)
pack (__v [i]); pack (__v [i]);
} }
template <class F, class T> void unpack (eoVector <F, T> & __v) template <class F, class T> void unpack (eoVector <F, T> & __v) {
{
F fit; F fit;
unsigned int vfit;
unpack( vfit );
if ( vfit )
{
unpack (fit); unpack (fit);
__v.fitness (fit); __v.fitness (fit);
}
else
__v.invalidate();
unsigned len; unsigned len;
unpack (len); unpack (len);
__v.resize (len); __v.resize (len);
@ -78,8 +63,7 @@ template <class F, class T> void unpack (eoVector <F, T> & __v)
unpack (__v [i]); unpack (__v [i]);
} }
template <class F, class T, class V> void pack (const eoVectorParticle <F, T, V> & __v) template <class F, class T, class V> void pack (const eoVectorParticle <F, T, V> & __v) {
{
pack (__v.fitness ()) ; pack (__v.fitness ()) ;
pack (__v.best()); pack (__v.best());
@ -93,8 +77,7 @@ template <class F, class T, class V> void pack (const eoVectorParticle <F, T, V>
pack (__v.velocities[i]); pack (__v.velocities[i]);
} }
template <class F, class T, class V> void unpack (eoVectorParticle <F, T, V> & __v) template <class F, class T, class V> void unpack (eoVectorParticle <F, T, V> & __v) {
{
F fit; F fit;
unpack(fit); unpack(fit);

View file

@ -70,15 +70,13 @@ extern void pack (const unsigned long & __ul, int __nitem = 1);
extern void pack (const char * __str); 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);
@ -118,8 +116,7 @@ extern void unpack (unsigned long & __ul, int __nitem = 1);
extern void unpack (char * __str); 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);
@ -127,8 +124,7 @@ 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);

View file

@ -56,8 +56,7 @@ 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;
gethostname (host, MAX_BUFF_SIZE); gethostname (host, MAX_BUFF_SIZE);
@ -65,8 +64,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);
@ -75,19 +73,16 @@ void initDebugging ()
files.push_back (fopen (buff, "w")); files.push_back (fopen (buff, "w"));
} }
void endDebugging () void endDebugging () {
{
for (unsigned i = 0; i < files.size (); i ++) for (unsigned i = 0; i < files.size (); i ++)
if (files [i] != stdout) if (files [i] != stdout)
fclose (files [i]); fclose (files [i]);
} }
void printDebugMessage (const char * __mess) void printDebugMessage (const char * __mess) {
{ return;
if (debug) {
if (debug)
{
char buff [MAX_BUFF_SIZE]; char buff [MAX_BUFF_SIZE];
time_t t = time (0); time_t t = time (0);
@ -101,8 +96,7 @@ void printDebugMessage (const char * __mess)
/* Message */ /* Message */
sprintf (buff, "%s", __mess); sprintf (buff, "%s", __mess);
for (unsigned i = 0; i < files.size (); i ++) for (unsigned i = 0; i < files.size (); i ++) {
{
fputs (buff, files [i]); fputs (buff, files [i]);
fputs ("\n", files [i]); fputs ("\n", files [i]);
fflush (files [i]); fflush (files [i]);

View file

@ -39,8 +39,8 @@
#include "runner.h" #include "runner.h"
#include "rmc.h" #include "rmc.h"
void peo :: finalize ()
{ void peo :: finalize () {
printDebugMessage ("waiting for the termination of all threads"); printDebugMessage ("waiting for the termination of all threads");

View file

@ -37,8 +37,7 @@
#ifndef __peo_finalize_h #ifndef __peo_finalize_h
#define __peo_finalize_h #define __peo_finalize_h
namespace peo namespace peo {
{
extern void finalize (); extern void finalize ();
} }

View file

@ -41,15 +41,13 @@
#include "peo_debug.h" #include "peo_debug.h"
#include "rmc.h" #include "rmc.h"
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;

View file

@ -37,8 +37,7 @@
#ifndef __peo_init_h #ifndef __peo_init_h
#define __peo_init_h #define __peo_init_h
namespace peo namespace peo {
{
extern int * argc; extern int * argc;

View file

@ -41,8 +41,7 @@
void peo :: loadParameters (int & __argc, char * * & __argv) void peo :: loadParameters (int & __argc, char * * & __argv) {
{
eoParser parser (__argc, __argv); eoParser parser (__argc, __argv);

View file

@ -37,8 +37,7 @@
#ifndef __peo_param_h #ifndef __peo_param_h
#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

@ -39,8 +39,7 @@
#include "rmc.h" #include "rmc.h"
#include "runner.h" #include "runner.h"
void peo :: run () void peo :: run () {
{
startRunners (); startRunners ();

View file

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

View file

@ -40,27 +40,23 @@ 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);
sem_init (& sem, 0, 0); sem_init (& sem, 0, 0);
} }
void ReactiveThread :: sleep () void ReactiveThread :: sleep () {
{
sem_wait (& sem); sem_wait (& sem);
} }
void ReactiveThread :: wakeUp () void ReactiveThread :: wakeUp () {
{
sem_post (& sem); sem_post (& sem);
} }
void stopReactiveThreads () void stopReactiveThreads () {
{
the_end = true; the_end = true;
for (unsigned i = 0; i < reac_threads.size (); i ++) for (unsigned i = 0; i < reac_threads.size (); i ++)

View file

@ -41,8 +41,7 @@
#include "thread.h" #include "thread.h"
class ReactiveThread : public Thread class ReactiveThread : public Thread {
{
public: public:

View file

@ -38,16 +38,14 @@
void RingTopology :: setNeighbors (Cooperative * __mig, void RingTopology :: setNeighbors (Cooperative * __mig,
std :: vector <Cooperative *> & __from, std :: vector <Cooperative *> & __from,
std :: vector <Cooperative *> & __to) std :: vector <Cooperative *> & __to) {
{
__from.clear () ; __from.clear () ;
__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]) ;
__to.push_back (mig [(i + 1) % len]) ; __to.push_back (mig [(i + 1) % len]) ;
break; break;

View file

@ -39,8 +39,7 @@
#include "topology.h" #include "topology.h"
class RingTopology : public Topology class RingTopology : public Topology {
{
public : public :

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