Style for PEO
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@906 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
f4740e571c
commit
b74a446baa
82 changed files with 1946 additions and 1663 deletions
|
|
@ -47,7 +47,8 @@ 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,46 +56,54 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initCommunicableEnv () {
|
void initCommunicableEnv ()
|
||||||
|
{
|
||||||
|
|
||||||
key_to_comm.resize (1);
|
key_to_comm.resize (1);
|
||||||
comm_to_key.clear ();
|
comm_to_key.clear ();
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,10 @@
|
||||||
|
|
||||||
typedef unsigned COMM_ID;
|
typedef unsigned COMM_ID;
|
||||||
|
|
||||||
class Communicable {
|
class Communicable
|
||||||
|
{
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
Communicable ();
|
Communicable ();
|
||||||
|
|
||||||
|
|
@ -58,18 +59,18 @@ public :
|
||||||
void stop (); /* It suspends the current process */
|
void stop (); /* It suspends the current process */
|
||||||
void resume (); /* It resumes ___________ */
|
void resume (); /* It resumes ___________ */
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
static unsigned num_comm;
|
static unsigned num_comm;
|
||||||
|
|
||||||
protected :
|
protected :
|
||||||
|
|
||||||
COMM_ID key;
|
COMM_ID key;
|
||||||
|
|
||||||
sem_t sem_lock;
|
sem_t sem_lock;
|
||||||
|
|
||||||
sem_t sem_stop;
|
sem_t sem_stop;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void initCommunicableEnv ();
|
extern void initCommunicableEnv ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,10 @@
|
||||||
|
|
||||||
typedef unsigned COOP_ID;
|
typedef unsigned COOP_ID;
|
||||||
|
|
||||||
class Cooperative : public Communicable {
|
class Cooperative : public Communicable
|
||||||
|
{
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
Runner * getOwner ();
|
Runner * getOwner ();
|
||||||
|
|
||||||
|
|
@ -69,11 +70,11 @@ public :
|
||||||
|
|
||||||
virtual void notifySynchronized ();
|
virtual void notifySynchronized ();
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
Runner * owner;
|
Runner * owner;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Cooperative * getCooperative (COOP_ID __key);
|
extern Cooperative * getCooperative (COOP_ID __key);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,14 +42,16 @@
|
||||||
#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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,12 +43,15 @@
|
||||||
#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()) {
|
if (__v.invalid())
|
||||||
|
{
|
||||||
pack((unsigned)0);
|
pack((unsigned)0);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
pack((unsigned)1);
|
pack((unsigned)1);
|
||||||
pack (__v.fitness ());
|
pack (__v.fitness ());
|
||||||
}
|
}
|
||||||
|
|
@ -59,14 +62,18 @@ template <class F, class T> void pack (const eoVector <F, T> & __v) {
|
||||||
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)
|
||||||
|
{
|
||||||
|
|
||||||
unsigned valid; unpack(valid);
|
unsigned valid;
|
||||||
|
unpack(valid);
|
||||||
|
|
||||||
if (! valid) {
|
if (! valid)
|
||||||
|
{
|
||||||
__v.invalidate();
|
__v.invalidate();
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
F fit;
|
F fit;
|
||||||
unpack (fit);
|
unpack (fit);
|
||||||
__v.fitness (fit);
|
__v.fitness (fit);
|
||||||
|
|
@ -79,12 +86,15 @@ 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)
|
||||||
|
{
|
||||||
|
|
||||||
if (__v.invalid()) {
|
if (__v.invalid())
|
||||||
|
{
|
||||||
pack((unsigned)0);
|
pack((unsigned)0);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
pack((unsigned)1);
|
pack((unsigned)1);
|
||||||
pack (__v.fitness ());
|
pack (__v.fitness ());
|
||||||
pack (__v.best());
|
pack (__v.best());
|
||||||
|
|
@ -100,14 +110,18 @@ 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)
|
||||||
|
{
|
||||||
|
|
||||||
unsigned valid; unpack(valid);
|
unsigned valid;
|
||||||
|
unpack(valid);
|
||||||
|
|
||||||
if (! valid) {
|
if (! valid)
|
||||||
|
{
|
||||||
__v.invalidate();
|
__v.invalidate();
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
F fit;
|
F fit;
|
||||||
unpack (fit);
|
unpack (fit);
|
||||||
__v.fitness (fit);
|
__v.fitness (fit);
|
||||||
|
|
|
||||||
|
|
@ -75,13 +75,15 @@ extern void pack (const char * __str);
|
||||||
extern void pack (const std::string & __str);
|
extern void pack (const std::string & __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);
|
||||||
|
|
@ -124,7 +126,8 @@ extern void unpack (char * __str);
|
||||||
extern void unpack (std::string & __str);
|
extern void unpack (std::string & __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);
|
||||||
|
|
@ -132,7 +135,8 @@ 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);
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,8 @@ 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);
|
||||||
|
|
@ -66,7 +67,8 @@ 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,7 +77,8 @@ 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)
|
||||||
|
|
@ -83,9 +86,11 @@ void endDebugging () {
|
||||||
files.clear();
|
files.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void printDebugMessage (const char * __mess) {
|
void printDebugMessage (const char * __mess)
|
||||||
|
{
|
||||||
|
|
||||||
if (debug) {
|
if (debug)
|
||||||
|
{
|
||||||
|
|
||||||
char buff [MAX_BUFF_SIZE];
|
char buff [MAX_BUFF_SIZE];
|
||||||
char localTime [MAX_BUFF_SIZE];
|
char localTime [MAX_BUFF_SIZE];
|
||||||
|
|
@ -102,7 +107,8 @@ 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]);
|
||||||
|
|
|
||||||
|
|
@ -39,7 +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");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,8 @@
|
||||||
#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 ();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,8 @@ extern void initScheduler ();
|
||||||
extern void initSynchron ();
|
extern void initSynchron ();
|
||||||
|
|
||||||
|
|
||||||
static void initExecutionEnv() {
|
static void initExecutionEnv()
|
||||||
|
{
|
||||||
|
|
||||||
initCommunicableEnv ();
|
initCommunicableEnv ();
|
||||||
initBuffers ();
|
initBuffers ();
|
||||||
|
|
@ -72,13 +73,15 @@ static void initExecutionEnv() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,8 @@
|
||||||
#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;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,8 @@
|
||||||
#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);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,8 @@
|
||||||
#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);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,8 @@
|
||||||
#include "runner.h"
|
#include "runner.h"
|
||||||
|
|
||||||
|
|
||||||
void peo :: run () {
|
void peo :: run ()
|
||||||
|
{
|
||||||
|
|
||||||
startRunners ();
|
startRunners ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,8 @@
|
||||||
#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 ();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,29 +41,34 @@ 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 initReactiveThreadsEnv () {
|
void initReactiveThreadsEnv ()
|
||||||
|
{
|
||||||
|
|
||||||
the_end = false;
|
the_end = false;
|
||||||
reac_threads.clear ();
|
reac_threads.clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
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 ++)
|
||||||
|
|
@ -71,4 +76,7 @@ void stopReactiveThreads () {
|
||||||
reac_threads.clear ();
|
reac_threads.clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool theEnd () { return the_end; }
|
bool theEnd ()
|
||||||
|
{
|
||||||
|
return the_end;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,10 @@
|
||||||
#include "thread.h"
|
#include "thread.h"
|
||||||
|
|
||||||
|
|
||||||
class ReactiveThread : public Thread {
|
class ReactiveThread : public Thread
|
||||||
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/* Ctor */
|
/* Ctor */
|
||||||
ReactiveThread ();
|
ReactiveThread ();
|
||||||
|
|
@ -53,10 +54,10 @@ public:
|
||||||
|
|
||||||
void wakeUp ();
|
void wakeUp ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
sem_t sem;
|
sem_t sem;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void initReactiveThreadsEnv ();
|
extern void initReactiveThreadsEnv ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,14 +38,16 @@
|
||||||
|
|
||||||
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;
|
||||||
|
|
|
||||||
|
|
@ -39,14 +39,15 @@
|
||||||
|
|
||||||
#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);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,8 @@ extern int getNumberOfNodes ();
|
||||||
extern void wakeUpCommunicator ();
|
extern void wakeUpCommunicator ();
|
||||||
|
|
||||||
|
|
||||||
Runner :: Runner () {
|
Runner :: Runner ()
|
||||||
|
{
|
||||||
|
|
||||||
exec_id = 0;
|
exec_id = 0;
|
||||||
def_id = ++ num_def_runners;
|
def_id = ++ num_def_runners;
|
||||||
|
|
@ -77,32 +78,38 @@ Runner :: Runner () {
|
||||||
sem_init (& sem_cntxt, 0, 0);
|
sem_init (& sem_cntxt, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
RUNNER_ID Runner :: getDefinitionID () {
|
RUNNER_ID Runner :: getDefinitionID ()
|
||||||
|
{
|
||||||
|
|
||||||
return def_id;
|
return def_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
RUNNER_ID Runner :: getExecutionID () {
|
RUNNER_ID Runner :: getExecutionID ()
|
||||||
|
{
|
||||||
|
|
||||||
return exec_id;
|
return exec_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Runner :: setExecutionID (const RUNNER_ID& execution_id) {
|
void Runner :: setExecutionID (const RUNNER_ID& execution_id)
|
||||||
|
{
|
||||||
|
|
||||||
exec_id = execution_id;
|
exec_id = execution_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
Runner * getRunner (RUNNER_ID __key) {
|
Runner * getRunner (RUNNER_ID __key)
|
||||||
|
{
|
||||||
|
|
||||||
return dynamic_cast <Runner *> (getCommunicable (__key));
|
return dynamic_cast <Runner *> (getCommunicable (__key));
|
||||||
}
|
}
|
||||||
|
|
||||||
void initializeContext () {
|
void initializeContext ()
|
||||||
|
{
|
||||||
|
|
||||||
num_local_exec_runners = 0;
|
num_local_exec_runners = 0;
|
||||||
|
|
||||||
// setting up the execution IDs & counting the number of local exec. runners
|
// setting up the execution IDs & counting the number of local exec. runners
|
||||||
for (unsigned i = 0; i < the_runners.size (); i ++) {
|
for (unsigned i = 0; i < the_runners.size (); i ++)
|
||||||
|
{
|
||||||
the_runners [i] -> setExecutionID ( my_node -> execution_id_run[ i ] );
|
the_runners [i] -> setExecutionID ( my_node -> execution_id_run[ i ] );
|
||||||
if (the_runners [i] -> isAssignedLocally ()) num_local_exec_runners ++;
|
if (the_runners [i] -> isAssignedLocally ()) num_local_exec_runners ++;
|
||||||
}
|
}
|
||||||
|
|
@ -115,17 +122,20 @@ void initializeContext () {
|
||||||
if (the_runners [i] -> isAssignedLocally ()) the_runners [i] -> notifyContextInitialized ();
|
if (the_runners [i] -> isAssignedLocally ()) the_runners [i] -> notifyContextInitialized ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Runner :: waitStarting () {
|
void Runner :: waitStarting ()
|
||||||
|
{
|
||||||
|
|
||||||
sem_wait (& sem_start);
|
sem_wait (& sem_start);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Runner :: waitContextInitialization () {
|
void Runner :: waitContextInitialization ()
|
||||||
|
{
|
||||||
|
|
||||||
sem_wait (& sem_cntxt);
|
sem_wait (& sem_cntxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Runner :: start () {
|
void Runner :: start ()
|
||||||
|
{
|
||||||
|
|
||||||
setActive ();
|
setActive ();
|
||||||
|
|
||||||
|
|
@ -136,11 +146,13 @@ void Runner :: start () {
|
||||||
terminate ();
|
terminate ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void startRunners () {
|
void startRunners ()
|
||||||
|
{
|
||||||
|
|
||||||
/* Runners */
|
/* Runners */
|
||||||
for (unsigned i = 0; i < the_runners.size (); i ++)
|
for (unsigned i = 0; i < the_runners.size (); i ++)
|
||||||
if (the_runners [i] -> isAssignedLocally ()) {
|
if (the_runners [i] -> isAssignedLocally ())
|
||||||
|
{
|
||||||
addThread (the_runners [i], ll_threads);
|
addThread (the_runners [i], ll_threads);
|
||||||
the_runners [i] -> waitStarting ();
|
the_runners [i] -> waitStarting ();
|
||||||
}
|
}
|
||||||
|
|
@ -148,34 +160,40 @@ void startRunners () {
|
||||||
printDebugMessage ("launched the parallel runners");
|
printDebugMessage ("launched the parallel runners");
|
||||||
}
|
}
|
||||||
|
|
||||||
void joinRunners () {
|
void joinRunners ()
|
||||||
|
{
|
||||||
|
|
||||||
joinThreads (ll_threads);
|
joinThreads (ll_threads);
|
||||||
the_runners.clear();
|
the_runners.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool atLeastOneActiveRunner () {
|
bool atLeastOneActiveRunner ()
|
||||||
|
{
|
||||||
|
|
||||||
return num_exec_runners;
|
return num_exec_runners;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned numberOfActiveRunners () {
|
unsigned numberOfActiveRunners ()
|
||||||
|
{
|
||||||
|
|
||||||
return num_exec_runners;
|
return num_exec_runners;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Runner :: notifyContextInitialized () {
|
void Runner :: notifyContextInitialized ()
|
||||||
|
{
|
||||||
|
|
||||||
sem_post (& sem_cntxt);
|
sem_post (& sem_cntxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Runner :: notifySendingTermination () {
|
void Runner :: notifySendingTermination ()
|
||||||
|
{
|
||||||
|
|
||||||
printDebugMessage ("I am informed that everyone received my termination notification.");
|
printDebugMessage ("I am informed that everyone received my termination notification.");
|
||||||
setPassive ();
|
setPassive ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void unpackTerminationOfRunner () {
|
void unpackTerminationOfRunner ()
|
||||||
|
{
|
||||||
|
|
||||||
RUNNER_ID finished_id;
|
RUNNER_ID finished_id;
|
||||||
unpack (finished_id);
|
unpack (finished_id);
|
||||||
|
|
@ -184,7 +202,8 @@ void unpackTerminationOfRunner () {
|
||||||
|
|
||||||
printDebugMessage ("I'm noticed of the termination of a runner");
|
printDebugMessage ("I'm noticed of the termination of a runner");
|
||||||
|
|
||||||
if (!num_exec_runners) {
|
if (!num_exec_runners)
|
||||||
|
{
|
||||||
|
|
||||||
printDebugMessage ("All the runners have terminated - now stopping the reactive threads.");
|
printDebugMessage ("All the runners have terminated - now stopping the reactive threads.");
|
||||||
stopReactiveThreads ();
|
stopReactiveThreads ();
|
||||||
|
|
@ -194,7 +213,8 @@ void unpackTerminationOfRunner () {
|
||||||
wakeUpCommunicator ();
|
wakeUpCommunicator ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void initRunnersEnv () {
|
void initRunnersEnv ()
|
||||||
|
{
|
||||||
|
|
||||||
ll_threads.clear ();
|
ll_threads.clear ();
|
||||||
the_runners.clear ();
|
the_runners.clear ();
|
||||||
|
|
|
||||||
|
|
@ -46,9 +46,10 @@
|
||||||
typedef unsigned RUNNER_ID;
|
typedef unsigned RUNNER_ID;
|
||||||
|
|
||||||
|
|
||||||
class Runner : public Communicable, public Thread {
|
class Runner : public Communicable, public Thread
|
||||||
|
{
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
Runner ();
|
Runner ();
|
||||||
|
|
||||||
|
|
@ -76,14 +77,14 @@ public :
|
||||||
|
|
||||||
void packTermination ();
|
void packTermination ();
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
sem_t sem_start;
|
sem_t sem_start;
|
||||||
sem_t sem_cntxt;
|
sem_t sem_cntxt;
|
||||||
|
|
||||||
unsigned def_id;
|
unsigned def_id;
|
||||||
unsigned exec_id;
|
unsigned exec_id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern void initRunnersEnv ();
|
extern void initRunnersEnv ();
|
||||||
|
|
|
||||||
|
|
@ -36,38 +36,49 @@
|
||||||
|
|
||||||
#include "service.h"
|
#include "service.h"
|
||||||
|
|
||||||
void Service :: setOwner (Thread & __owner) {
|
void Service :: setOwner (Thread & __owner)
|
||||||
|
{
|
||||||
|
|
||||||
owner = & __owner;
|
owner = & __owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread * Service :: getOwner () {
|
Thread * Service :: getOwner ()
|
||||||
|
{
|
||||||
|
|
||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
Service * getService (SERVICE_ID __key) {
|
Service * getService (SERVICE_ID __key)
|
||||||
|
{
|
||||||
|
|
||||||
return dynamic_cast <Service *> (getCommunicable (__key));
|
return dynamic_cast <Service *> (getCommunicable (__key));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service :: notifySendingData () { }
|
void Service :: notifySendingData ()
|
||||||
|
{ }
|
||||||
|
|
||||||
void Service :: notifySendingResourceRequest () {
|
void Service :: notifySendingResourceRequest ()
|
||||||
|
{
|
||||||
|
|
||||||
num_sent_rr --;
|
num_sent_rr --;
|
||||||
if (! num_sent_rr)
|
if (! num_sent_rr)
|
||||||
notifySendingAllResourceRequests ();
|
notifySendingAllResourceRequests ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service :: notifySendingAllResourceRequests () { }
|
void Service :: notifySendingAllResourceRequests ()
|
||||||
|
{ }
|
||||||
|
|
||||||
void Service :: packData () {}
|
void Service :: packData ()
|
||||||
|
{}
|
||||||
|
|
||||||
void Service :: unpackData () {}
|
void Service :: unpackData ()
|
||||||
|
{}
|
||||||
|
|
||||||
void Service :: execute () {}
|
void Service :: execute ()
|
||||||
|
{}
|
||||||
|
|
||||||
void Service :: packResult () {}
|
void Service :: packResult ()
|
||||||
|
{}
|
||||||
|
|
||||||
void Service :: unpackResult () {}
|
void Service :: unpackResult ()
|
||||||
|
{}
|
||||||
|
|
|
||||||
|
|
@ -43,9 +43,10 @@
|
||||||
|
|
||||||
typedef unsigned SERVICE_ID;
|
typedef unsigned SERVICE_ID;
|
||||||
|
|
||||||
class Service : public Communicable {
|
class Service : public Communicable
|
||||||
|
{
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
void setOwner (Thread & __owner);
|
void setOwner (Thread & __owner);
|
||||||
|
|
||||||
|
|
@ -66,13 +67,13 @@ public :
|
||||||
virtual void notifySendingResourceRequest ();
|
virtual void notifySendingResourceRequest ();
|
||||||
virtual void notifySendingAllResourceRequests ();
|
virtual void notifySendingAllResourceRequests ();
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
Thread * owner; /* Owner thread (i.e. 'uses' that service) */
|
Thread * owner; /* Owner thread (i.e. 'uses' that service) */
|
||||||
|
|
||||||
unsigned num_sent_rr; /* Number of RR not really sent (i.e. still in the sending queue)*/
|
unsigned num_sent_rr; /* Number of RR not really sent (i.e. still in the sending queue)*/
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Service * getService (SERVICE_ID __key);
|
extern Service * getService (SERVICE_ID __key);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -43,47 +43,56 @@ static std :: vector <Thread *> threads;
|
||||||
unsigned num_act = 0;
|
unsigned num_act = 0;
|
||||||
|
|
||||||
|
|
||||||
Thread :: Thread () {
|
Thread :: Thread ()
|
||||||
|
{
|
||||||
|
|
||||||
threads.push_back (this);
|
threads.push_back (this);
|
||||||
act = false;
|
act = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Thread :: ~ Thread () {
|
Thread :: ~ Thread ()
|
||||||
|
{
|
||||||
|
|
||||||
/* Nothing ! */
|
/* Nothing ! */
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread :: setActive () {
|
void Thread :: setActive ()
|
||||||
|
{
|
||||||
|
|
||||||
if (! act) {
|
if (! act)
|
||||||
|
{
|
||||||
|
|
||||||
act = true;
|
act = true;
|
||||||
num_act ++;
|
num_act ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Thread :: setPassive () {
|
void Thread :: setPassive ()
|
||||||
|
{
|
||||||
|
|
||||||
if (act) {
|
if (act)
|
||||||
|
{
|
||||||
|
|
||||||
act = false;
|
act = false;
|
||||||
num_act --;
|
num_act --;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void initThreadsEnv () {
|
void initThreadsEnv ()
|
||||||
|
{
|
||||||
|
|
||||||
threads.clear ();
|
threads.clear ();
|
||||||
num_act = 0;
|
num_act = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool atLeastOneActiveThread () {
|
bool atLeastOneActiveThread ()
|
||||||
|
{
|
||||||
|
|
||||||
return num_act;
|
return num_act;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void * launch (void * __arg) {
|
static void * launch (void * __arg)
|
||||||
|
{
|
||||||
|
|
||||||
Thread * thr = (Thread *) __arg;
|
Thread * thr = (Thread *) __arg;
|
||||||
thr -> start ();
|
thr -> start ();
|
||||||
|
|
@ -91,16 +100,19 @@ static void * launch (void * __arg) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void addThread (Thread * __hl_thread, std :: vector <pthread_t *> & __ll_threads) {
|
void addThread (Thread * __hl_thread, std :: vector <pthread_t *> & __ll_threads)
|
||||||
|
{
|
||||||
|
|
||||||
pthread_t * ll_thr = new pthread_t;
|
pthread_t * ll_thr = new pthread_t;
|
||||||
__ll_threads.push_back (ll_thr);
|
__ll_threads.push_back (ll_thr);
|
||||||
pthread_create (ll_thr, 0, launch, __hl_thread);
|
pthread_create (ll_thr, 0, launch, __hl_thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
void joinThreads (std :: vector <pthread_t *> & __threads) {
|
void joinThreads (std :: vector <pthread_t *> & __threads)
|
||||||
|
{
|
||||||
|
|
||||||
for (unsigned i = 0; i < __threads.size (); i ++) {
|
for (unsigned i = 0; i < __threads.size (); i ++)
|
||||||
|
{
|
||||||
pthread_join (* __threads [i], 0);
|
pthread_join (* __threads [i], 0);
|
||||||
delete __threads [i];
|
delete __threads [i];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,10 @@
|
||||||
|
|
||||||
|
|
||||||
/* A high-level thread */
|
/* A high-level thread */
|
||||||
class Thread {
|
class Thread
|
||||||
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/* Ctor */
|
/* Ctor */
|
||||||
Thread ();
|
Thread ();
|
||||||
|
|
@ -58,10 +59,10 @@ public:
|
||||||
void setPassive ();/* The current process is not going to perform send operations
|
void setPassive ();/* The current process is not going to perform send operations
|
||||||
(but it may receive messages) */
|
(but it may receive messages) */
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
bool act;
|
bool act;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void initThreadsEnv ();
|
extern void initThreadsEnv ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,17 +36,20 @@
|
||||||
|
|
||||||
#include "topology.h"
|
#include "topology.h"
|
||||||
|
|
||||||
Topology :: ~ Topology () {
|
Topology :: ~ Topology ()
|
||||||
|
{
|
||||||
|
|
||||||
/* Nothing ! */
|
/* Nothing ! */
|
||||||
}
|
}
|
||||||
|
|
||||||
void Topology :: add (Cooperative & __mig) {
|
void Topology :: add (Cooperative & __mig)
|
||||||
|
{
|
||||||
|
|
||||||
mig.push_back (& __mig) ;
|
mig.push_back (& __mig) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
Topology :: operator std :: vector <Cooperative *>& () {
|
Topology :: operator std :: vector <Cooperative *>& ()
|
||||||
|
{
|
||||||
|
|
||||||
return mig;
|
return mig;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,10 @@
|
||||||
|
|
||||||
#include "cooperative.h"
|
#include "cooperative.h"
|
||||||
|
|
||||||
class Topology {
|
class Topology
|
||||||
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual ~Topology ();
|
virtual ~Topology ();
|
||||||
|
|
||||||
|
|
@ -55,9 +56,9 @@ public:
|
||||||
|
|
||||||
operator std :: vector <Cooperative *>& ();
|
operator std :: vector <Cooperative *>& ();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
std :: vector <Cooperative *> mig;
|
std :: vector <Cooperative *> mig;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -234,8 +234,8 @@ template< class EOT , class TYPE> void peoAsyncIslandMig< EOT , TYPE> :: unpack(
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class EOT , class TYPE> void peoAsyncIslandMig< EOT, TYPE > :: packSynchronizeReq() {
|
template< class EOT , class TYPE> void peoAsyncIslandMig< EOT, TYPE > :: packSynchronizeReq()
|
||||||
}
|
{}
|
||||||
|
|
||||||
template< class EOT , class TYPE> void peoAsyncIslandMig< EOT , TYPE> :: emigrate()
|
template< class EOT , class TYPE> void peoAsyncIslandMig< EOT , TYPE> :: emigrate()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -44,21 +44,24 @@
|
||||||
/************************** DEFINE A DATA ******************************************/
|
/************************** DEFINE A DATA ******************************************/
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
|
|
||||||
class peoData {
|
class peoData
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
virtual void pack () {}
|
virtual void pack ()
|
||||||
virtual void unpack () {}
|
{}
|
||||||
|
virtual void unpack ()
|
||||||
|
{}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Specific implementation : migration of a population
|
// Specific implementation : migration of a population
|
||||||
|
|
||||||
template<class EOT>
|
template<class EOT>
|
||||||
class peoPop: public eoPop<EOT>, public peoData
|
class peoPop: public eoPop<EOT>, public peoData
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
virtual void pack ()
|
virtual void pack ()
|
||||||
{
|
{
|
||||||
|
|
@ -76,7 +79,7 @@ public:
|
||||||
::unpack ((*this)[i]);
|
::unpack ((*this)[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
|
|
@ -84,27 +87,30 @@ public:
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
|
|
||||||
class continuator
|
class continuator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual bool check()=0;
|
virtual bool check()=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Specific implementation : migration of a population
|
// Specific implementation : migration of a population
|
||||||
|
|
||||||
template < class EOT> class eoContinuator : public continuator{
|
template < class EOT> class eoContinuator : public continuator
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
eoContinuator(eoContinue<EOT> & _cont, const eoPop<EOT> & _pop): cont (_cont), pop(_pop){}
|
eoContinuator(eoContinue<EOT> & _cont, const eoPop<EOT> & _pop): cont (_cont), pop(_pop)
|
||||||
|
{}
|
||||||
|
|
||||||
virtual bool check(){
|
virtual bool check()
|
||||||
|
{
|
||||||
return cont(pop);
|
return cont(pop);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
eoContinue<EOT> & cont ;
|
eoContinue<EOT> & cont ;
|
||||||
const eoPop<EOT> & pop;
|
const eoPop<EOT> & pop;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
|
|
@ -112,18 +118,20 @@ protected:
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
|
|
||||||
template < class TYPE> class selector
|
template < class TYPE> class selector
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void operator()(TYPE &)=0;
|
virtual void operator()(TYPE &)=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Specific implementation : migration of a population
|
// Specific implementation : migration of a population
|
||||||
|
|
||||||
template < class EOT, class TYPE> class eoSelector : public selector< TYPE >{
|
template < class EOT, class TYPE> class eoSelector : public selector< TYPE >
|
||||||
public:
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
eoSelector(eoSelectOne<EOT> & _select, unsigned _nb_select, const TYPE & _source): selector (_select), nb_select(_nb_select), source(_source){}
|
eoSelector(eoSelectOne<EOT> & _select, unsigned _nb_select, const TYPE & _source): selector (_select), nb_select(_nb_select), source(_source)
|
||||||
|
{}
|
||||||
|
|
||||||
virtual void operator()(TYPE & _dest)
|
virtual void operator()(TYPE & _dest)
|
||||||
{
|
{
|
||||||
|
|
@ -133,11 +141,11 @@ public:
|
||||||
_dest[i] = selector(source);
|
_dest[i] = selector(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
eoSelectOne<EOT> & selector ;
|
eoSelectOne<EOT> & selector ;
|
||||||
unsigned nb_select;
|
unsigned nb_select;
|
||||||
const TYPE & source;
|
const TYPE & source;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
|
|
@ -145,27 +153,29 @@ protected:
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
|
|
||||||
template < class TYPE> class replacement
|
template < class TYPE> class replacement
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void operator()(TYPE &)=0;
|
virtual void operator()(TYPE &)=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Specific implementation : migration of a population
|
// Specific implementation : migration of a population
|
||||||
|
|
||||||
template < class EOT, class TYPE> class eoReplace : public replacement< TYPE >{
|
template < class EOT, class TYPE> class eoReplace : public replacement< TYPE >
|
||||||
public:
|
{
|
||||||
eoReplace(eoReplacement<EOT> & _replace, TYPE & _destination): replace(_replace), destination(_destination){}
|
public:
|
||||||
|
eoReplace(eoReplacement<EOT> & _replace, TYPE & _destination): replace(_replace), destination(_destination)
|
||||||
|
{}
|
||||||
|
|
||||||
virtual void operator()(TYPE & _source)
|
virtual void operator()(TYPE & _source)
|
||||||
{
|
{
|
||||||
replace(destination, _source);
|
replace(destination, _source);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
eoReplacement<EOT> & replace;
|
eoReplacement<EOT> & replace;
|
||||||
TYPE & destination;
|
TYPE & destination;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
|
|
@ -173,11 +183,12 @@ protected:
|
||||||
/**************************************************************************************/
|
/**************************************************************************************/
|
||||||
|
|
||||||
class eoSyncContinue: public continuator
|
class eoSyncContinue: public continuator
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
eoSyncContinue (unsigned __period, unsigned __init_counter = 0): period (__period),counter (__init_counter) {}
|
eoSyncContinue (unsigned __period, unsigned __init_counter = 0): period (__period),counter (__init_counter)
|
||||||
|
{}
|
||||||
|
|
||||||
virtual bool check()
|
virtual bool check()
|
||||||
{
|
{
|
||||||
|
|
@ -185,13 +196,13 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
unsigned period;
|
unsigned period;
|
||||||
|
|
||||||
unsigned counter;
|
unsigned counter;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ template< class EOT, class FitT = EOT::Fitness, class FunctionArg = const EOT& >
|
||||||
template< class EOT, class FitT = typename EOT::Fitness, class FunctionArg = const EOT& >
|
template< class EOT, class FitT = typename EOT::Fitness, class FunctionArg = const EOT& >
|
||||||
#endif
|
#endif
|
||||||
struct peoEvalFunc: public eoEvalFunc<EOT>
|
struct peoEvalFunc: public eoEvalFunc<EOT>
|
||||||
{
|
{
|
||||||
|
|
||||||
peoEvalFunc( FitT (* _eval)( FunctionArg ) )
|
peoEvalFunc( FitT (* _eval)( FunctionArg ) )
|
||||||
: eoEvalFunc<EOT>(), evalFunc( _eval )
|
: eoEvalFunc<EOT>(), evalFunc( _eval )
|
||||||
|
|
@ -56,7 +56,7 @@ struct peoEvalFunc: public eoEvalFunc<EOT>
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FitT (* evalFunc )( FunctionArg );
|
FitT (* evalFunc )( FunctionArg );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -226,12 +226,12 @@ template< class EOT > void peoMoeoPopEval< EOT > :: unpackResult()
|
||||||
|
|
||||||
/* Unpacking the computed fitness */
|
/* Unpacking the computed fitness */
|
||||||
// unpack( fit );
|
// unpack( fit );
|
||||||
unsigned len;
|
unsigned len;
|
||||||
std::vector < double > object;
|
std::vector < double > object;
|
||||||
|
|
||||||
unpack(len);
|
unpack(len);
|
||||||
object.resize(len);
|
object.resize(len);
|
||||||
for (unsigned i = 0 ; i < len; i ++)
|
for (unsigned i = 0 ; i < len; i ++)
|
||||||
unpack (object[i]);
|
unpack (object[i]);
|
||||||
/* Unpacking the @ of the associated individual */
|
/* Unpacking the @ of the associated individual */
|
||||||
unpack( ad_sol );
|
unpack( ad_sol );
|
||||||
|
|
@ -239,7 +239,7 @@ for (unsigned i = 0 ; i < len; i ++)
|
||||||
|
|
||||||
/* Associating the fitness the local solution */
|
/* Associating the fitness the local solution */
|
||||||
// merge_eval( *ad_sol, object );
|
// merge_eval( *ad_sol, object );
|
||||||
ad_sol->objectiveVector(object);
|
ad_sol->objectiveVector(object);
|
||||||
progression[ ad_sol ].second--;
|
progression[ ad_sol ].second--;
|
||||||
|
|
||||||
/* Notifying the container of the termination of the evaluation */
|
/* Notifying the container of the termination of the evaluation */
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
|
|
||||||
|
|
||||||
template < typename EntityType > class peoMultiStart : public Service
|
template < typename EntityType > class peoMultiStart : public Service
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
@ -261,7 +261,7 @@ template < typename EntityType > class peoMultiStart : public Service
|
||||||
unsigned num_term;
|
unsigned num_term;
|
||||||
unsigned dataIndex;
|
unsigned dataIndex;
|
||||||
unsigned functionIndex;
|
unsigned functionIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template < typename EntityType > void peoMultiStart< EntityType >::packData()
|
template < typename EntityType > void peoMultiStart< EntityType >::packData()
|
||||||
|
|
|
||||||
|
|
@ -45,13 +45,13 @@
|
||||||
//! The class is provided as a mean of declaring that no aggregation is required for the evaluation function - the fitness
|
//! The class is provided as a mean of declaring that no aggregation is required for the evaluation function - the fitness
|
||||||
//! value is explicitly specified.
|
//! value is explicitly specified.
|
||||||
template< class EOT > class peoNoAggEvalFunc : public peoAggEvalFunc< EOT >
|
template< class EOT > class peoNoAggEvalFunc : public peoAggEvalFunc< EOT >
|
||||||
{
|
{
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
//! Operator which sets as fitness the <b>__fit</b> value for the <b>__sol</b> individual
|
//! Operator which sets as fitness the <b>__fit</b> value for the <b>__sol</b> individual
|
||||||
void operator()( EOT& __sol, const typename EOT :: Fitness& __fit );
|
void operator()( EOT& __sol, const typename EOT :: Fitness& __fit );
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template< class EOT > void peoNoAggEvalFunc< EOT > :: operator()( EOT& __sol, const typename EOT :: Fitness& __fit )
|
template< class EOT > void peoNoAggEvalFunc< EOT > :: operator()( EOT& __sol, const typename EOT :: Fitness& __fit )
|
||||||
|
|
|
||||||
|
|
@ -147,9 +147,9 @@
|
||||||
//! the associated distinctly parametrized migration objects. The interconnecting element is the underlying topology, defined at step 1
|
//! the associated distinctly parametrized migration objects. The interconnecting element is the underlying topology, defined at step 1
|
||||||
//! (the same C++ migTopology object has to be passed as parameter for all the migration objects, in order to interconnect them).
|
//! (the same C++ migTopology object has to be passed as parameter for all the migration objects, in order to interconnect them).
|
||||||
template< class EOT, class TYPE > class peoSyncIslandMig : public Cooperative, public eoUpdater
|
template< class EOT, class TYPE > class peoSyncIslandMig : public Cooperative, public eoUpdater
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//! Constructor for the peoSyncIslandMig class; the characteristics of the migration model are defined
|
//! Constructor for the peoSyncIslandMig class; the characteristics of the migration model are defined
|
||||||
//! through the specified parameters - out of the box objects provided in EO, etc., or custom, derived objects may be passed as parameters.
|
//! through the specified parameters - out of the box objects provided in EO, etc., or custom, derived objects may be passed as parameters.
|
||||||
|
|
@ -195,13 +195,13 @@ public:
|
||||||
void notifySynchronized();
|
void notifySynchronized();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void emigrate();
|
void emigrate();
|
||||||
void immigrate();
|
void immigrate();
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
eoSyncContinue cont; // continuator
|
eoSyncContinue cont; // continuator
|
||||||
selector <TYPE> & select; // the selection strategy
|
selector <TYPE> & select; // the selection strategy
|
||||||
|
|
@ -220,7 +220,7 @@ private:
|
||||||
|
|
||||||
std :: vector< Cooperative* > in, out, all;
|
std :: vector< Cooperative* > in, out, all;
|
||||||
unsigned nbMigrations;
|
unsigned nbMigrations;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template< class EOT, class TYPE > peoSyncIslandMig< EOT,TYPE > :: peoSyncIslandMig(
|
template< class EOT, class TYPE > peoSyncIslandMig< EOT,TYPE > :: peoSyncIslandMig(
|
||||||
|
|
@ -256,7 +256,8 @@ template< class EOT, class TYPE > void peoSyncIslandMig< EOT, TYPE > :: unpack()
|
||||||
explicitPassive = true;
|
explicitPassive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class EOT, class TYPE > void peoSyncIslandMig< EOT,TYPE > :: packSynchronizeReq() {
|
template< class EOT, class TYPE > void peoSyncIslandMig< EOT,TYPE > :: packSynchronizeReq()
|
||||||
|
{
|
||||||
|
|
||||||
packSynchronRequest( all );
|
packSynchronRequest( all );
|
||||||
}
|
}
|
||||||
|
|
@ -280,7 +281,8 @@ template< class EOT, class TYPE > void peoSyncIslandMig< EOT , TYPE > :: immigra
|
||||||
{
|
{
|
||||||
assert( imm.size() );
|
assert( imm.size() );
|
||||||
|
|
||||||
while ( imm.size() ) {
|
while ( imm.size() )
|
||||||
|
{
|
||||||
replace( imm.front() ) ;
|
replace( imm.front() ) ;
|
||||||
imm.pop();
|
imm.pop();
|
||||||
}
|
}
|
||||||
|
|
@ -294,16 +296,19 @@ template< class EOT, class TYPE > void peoSyncIslandMig< EOT , TYPE > :: operato
|
||||||
if ( cont.check() )
|
if ( cont.check() )
|
||||||
{
|
{
|
||||||
explicitPassive = standbyMigration = false;
|
explicitPassive = standbyMigration = false;
|
||||||
topology.setNeighbors( this, in, out ); all = topology;
|
topology.setNeighbors( this, in, out );
|
||||||
|
all = topology;
|
||||||
nbMigrations = 0;
|
nbMigrations = 0;
|
||||||
synchronizeCoopEx(); stop();
|
synchronizeCoopEx();
|
||||||
|
stop();
|
||||||
// sending emigrants
|
// sending emigrants
|
||||||
emigrate();
|
emigrate();
|
||||||
// synchronizing
|
// synchronizing
|
||||||
sem_wait( &sync );
|
sem_wait( &sync );
|
||||||
// receiving immigrants
|
// receiving immigrants
|
||||||
immigrate();
|
immigrate();
|
||||||
synchronizeCoopEx(); stop();
|
synchronizeCoopEx();
|
||||||
|
stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -316,19 +321,22 @@ template< class EOT, class TYPE > void peoSyncIslandMig< EOT , TYPE > :: notifyR
|
||||||
{
|
{
|
||||||
nbMigrations++;
|
nbMigrations++;
|
||||||
|
|
||||||
if ( nbMigrations == in.size() ) {
|
if ( nbMigrations == in.size() )
|
||||||
|
{
|
||||||
|
|
||||||
if ( standbyMigration ) getOwner()->setActive();
|
if ( standbyMigration ) getOwner()->setActive();
|
||||||
sem_post( &sync );
|
sem_post( &sync );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class EOT, class TYPE > void peoSyncIslandMig< EOT, TYPE > :: notifySendingSyncReq () {
|
template< class EOT, class TYPE > void peoSyncIslandMig< EOT, TYPE > :: notifySendingSyncReq ()
|
||||||
|
{
|
||||||
|
|
||||||
getOwner()->setPassive();
|
getOwner()->setPassive();
|
||||||
}
|
}
|
||||||
|
|
||||||
template< class EOT, class TYPE > void peoSyncIslandMig< EOT, TYPE > :: notifySynchronized () {
|
template< class EOT, class TYPE > void peoSyncIslandMig< EOT, TYPE > :: notifySynchronized ()
|
||||||
|
{
|
||||||
|
|
||||||
standbyMigration = true;
|
standbyMigration = true;
|
||||||
getOwner()->setActive();
|
getOwner()->setActive();
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,9 @@ extern int getNodeRank();
|
||||||
|
|
||||||
|
|
||||||
template< class EOT > class peoTransform : public Service, public eoTransform< EOT >
|
template< class EOT > class peoTransform : public Service, public eoTransform< EOT >
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
peoTransform(
|
peoTransform(
|
||||||
|
|
||||||
|
|
@ -74,7 +74,7 @@ public:
|
||||||
void notifySendingData();
|
void notifySendingData();
|
||||||
void notifySendingAllResourceRequests();
|
void notifySendingAllResourceRequests();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
eoQuadOp< EOT >& cross;
|
eoQuadOp< EOT >& cross;
|
||||||
double cross_rate;
|
double cross_rate;
|
||||||
|
|
@ -89,7 +89,7 @@ private:
|
||||||
EOT father, mother;
|
EOT father, mother;
|
||||||
|
|
||||||
unsigned num_term;
|
unsigned num_term;
|
||||||
};
|
};
|
||||||
|
|
||||||
template< class EOT > peoTransform< EOT > :: peoTransform(
|
template< class EOT > peoTransform< EOT > :: peoTransform(
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
|
|
||||||
|
|
||||||
class peoWrapper : public Runner
|
class peoWrapper : public Runner
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
@ -155,7 +155,7 @@ class peoWrapper : public Runner
|
||||||
private:
|
private:
|
||||||
|
|
||||||
AbstractAlgorithm* algorithm;
|
AbstractAlgorithm* algorithm;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,8 @@ static sem_t sem_comm_init;
|
||||||
static Communicator * the_thread;
|
static Communicator * the_thread;
|
||||||
|
|
||||||
|
|
||||||
Communicator :: Communicator (int * __argc, char * * * __argv) {
|
Communicator :: Communicator (int * __argc, char * * * __argv)
|
||||||
|
{
|
||||||
|
|
||||||
the_thread = this;
|
the_thread = this;
|
||||||
initNode (__argc, __argv);
|
initNode (__argc, __argv);
|
||||||
|
|
@ -61,9 +62,11 @@ Communicator :: Communicator (int * __argc, char * * * __argv) {
|
||||||
sem_post (& sem_comm_init);
|
sem_post (& sem_comm_init);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Communicator :: start () {
|
void Communicator :: start ()
|
||||||
|
{
|
||||||
|
|
||||||
while (true) {
|
while (true)
|
||||||
|
{
|
||||||
|
|
||||||
/* Zzz Zzz Zzz :-))) */
|
/* Zzz Zzz Zzz :-))) */
|
||||||
sleep ();
|
sleep ();
|
||||||
|
|
@ -82,11 +85,13 @@ void Communicator :: start () {
|
||||||
//synchronizeNodes ();
|
//synchronizeNodes ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void initCommunication () {
|
void initCommunication ()
|
||||||
|
{
|
||||||
|
|
||||||
static bool initializedSemaphore = false;
|
static bool initializedSemaphore = false;
|
||||||
|
|
||||||
if (initializedSemaphore) {
|
if (initializedSemaphore)
|
||||||
|
{
|
||||||
sem_destroy(& sem_comm_init);
|
sem_destroy(& sem_comm_init);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,12 +99,14 @@ void initCommunication () {
|
||||||
initializedSemaphore = true;
|
initializedSemaphore = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void waitNodeInitialization () {
|
void waitNodeInitialization ()
|
||||||
|
{
|
||||||
|
|
||||||
sem_wait (& sem_comm_init);
|
sem_wait (& sem_comm_init);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wakeUpCommunicator () {
|
void wakeUpCommunicator ()
|
||||||
|
{
|
||||||
|
|
||||||
the_thread -> wakeUp ();
|
the_thread -> wakeUp ();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,15 +40,16 @@
|
||||||
#include "../../core/communicable.h"
|
#include "../../core/communicable.h"
|
||||||
#include "../../core/reac_thread.h"
|
#include "../../core/reac_thread.h"
|
||||||
|
|
||||||
class Communicator : public ReactiveThread {
|
class Communicator : public ReactiveThread
|
||||||
|
{
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
/* Ctor */
|
/* Ctor */
|
||||||
Communicator (int * __argc, char * * * __argv);
|
Communicator (int * __argc, char * * * __argv);
|
||||||
|
|
||||||
void start ();
|
void start ();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void initCommunication ();
|
extern void initCommunication ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,42 +41,48 @@
|
||||||
#include "mess.h"
|
#include "mess.h"
|
||||||
#include "../../core/peo_debug.h"
|
#include "../../core/peo_debug.h"
|
||||||
|
|
||||||
Runner * Cooperative :: getOwner () {
|
Runner * Cooperative :: getOwner ()
|
||||||
|
{
|
||||||
|
|
||||||
return owner;
|
return owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cooperative :: setOwner (Runner & __runner) {
|
void Cooperative :: setOwner (Runner & __runner)
|
||||||
|
{
|
||||||
|
|
||||||
owner = & __runner;
|
owner = & __runner;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cooperative :: send (Cooperative * __coop) {
|
void Cooperative :: send (Cooperative * __coop)
|
||||||
|
{
|
||||||
|
|
||||||
:: send (this, getRankOfRunner (__coop -> getOwner () -> getDefinitionID ()), COOP_TAG);
|
:: send (this, getRankOfRunner (__coop -> getOwner () -> getDefinitionID ()), COOP_TAG);
|
||||||
// stop ();
|
// stop ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cooperative :: synchronizeCoopEx () {
|
void Cooperative :: synchronizeCoopEx ()
|
||||||
|
{
|
||||||
:: send (this, my_node -> rk_sched, SYNCHRONIZE_REQ_TAG);
|
:: send (this, my_node -> rk_sched, SYNCHRONIZE_REQ_TAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
Cooperative * getCooperative (COOP_ID __key) {
|
Cooperative * getCooperative (COOP_ID __key)
|
||||||
|
{
|
||||||
|
|
||||||
return dynamic_cast <Cooperative *> (getCommunicable (__key));
|
return dynamic_cast <Cooperative *> (getCommunicable (__key));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cooperative :: notifySending () {
|
void Cooperative :: notifySending ()
|
||||||
|
{
|
||||||
|
|
||||||
//getOwner -> setPassive ();
|
//getOwner -> setPassive ();
|
||||||
// resume ();
|
// resume ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cooperative :: notifyReceiving () {
|
void Cooperative :: notifyReceiving ()
|
||||||
}
|
{}
|
||||||
|
|
||||||
void Cooperative :: notifySendingSyncReq () {
|
void Cooperative :: notifySendingSyncReq ()
|
||||||
}
|
{}
|
||||||
|
|
||||||
void Cooperative :: notifySynchronized () {
|
void Cooperative :: notifySynchronized ()
|
||||||
}
|
{}
|
||||||
|
|
|
||||||
|
|
@ -51,22 +51,26 @@ static std :: vector <char *> act_buf; /* Active buffers */
|
||||||
|
|
||||||
static std :: vector <MPI_Request *> act_req; /* Active requests */
|
static std :: vector <MPI_Request *> act_req; /* Active requests */
|
||||||
|
|
||||||
void initBuffers () {
|
void initBuffers ()
|
||||||
|
{
|
||||||
|
|
||||||
pos_buf = 0;
|
pos_buf = 0;
|
||||||
act_buf.clear ();
|
act_buf.clear ();
|
||||||
act_req.clear ();
|
act_req.clear ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanBuffers () {
|
void cleanBuffers ()
|
||||||
|
{
|
||||||
|
|
||||||
for (unsigned i = 0; i < act_req.size ();) {
|
for (unsigned i = 0; i < act_req.size ();)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Status stat ;
|
MPI_Status stat ;
|
||||||
int flag ;
|
int flag ;
|
||||||
|
|
||||||
MPI_Test (act_req [i], & flag, & stat) ;
|
MPI_Test (act_req [i], & flag, & stat) ;
|
||||||
if (flag) {
|
if (flag)
|
||||||
|
{
|
||||||
|
|
||||||
delete[] act_buf [i] ;
|
delete[] act_buf [i] ;
|
||||||
delete act_req [i] ;
|
delete act_req [i] ;
|
||||||
|
|
@ -82,11 +86,13 @@ void cleanBuffers () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void waitBuffers () {
|
void waitBuffers ()
|
||||||
|
{
|
||||||
|
|
||||||
printDebugMessage ("waiting the termination of the asynchronous operations to complete");
|
printDebugMessage ("waiting the termination of the asynchronous operations to complete");
|
||||||
|
|
||||||
for (unsigned i = 0; i < act_req.size (); i ++) {
|
for (unsigned i = 0; i < act_req.size (); i ++)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Status stat ;
|
MPI_Status stat ;
|
||||||
|
|
||||||
|
|
@ -97,7 +103,8 @@ void waitBuffers () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool probeMessage (int & __src, int & __tag) {
|
bool probeMessage (int & __src, int & __tag)
|
||||||
|
{
|
||||||
|
|
||||||
int flag;
|
int flag;
|
||||||
|
|
||||||
|
|
@ -111,19 +118,22 @@ bool probeMessage (int & __src, int & __tag) {
|
||||||
return flag;
|
return flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
void waitMessage () {
|
void waitMessage ()
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Status stat;
|
MPI_Status stat;
|
||||||
|
|
||||||
MPI_Probe (MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, & stat);
|
MPI_Probe (MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, & stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void initMessage () {
|
void initMessage ()
|
||||||
|
{
|
||||||
|
|
||||||
pos_buf = 0;
|
pos_buf = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendMessage (int __to, int __tag) {
|
void sendMessage (int __to, int __tag)
|
||||||
|
{
|
||||||
|
|
||||||
cleanBuffers ();
|
cleanBuffers ();
|
||||||
act_buf.push_back (new char [pos_buf]);
|
act_buf.push_back (new char [pos_buf]);
|
||||||
|
|
@ -132,13 +142,15 @@ void sendMessage (int __to, int __tag) {
|
||||||
MPI_Isend (act_buf.back (), pos_buf, MPI_PACKED, __to, __tag, MPI_COMM_WORLD, act_req.back ());
|
MPI_Isend (act_buf.back (), pos_buf, MPI_PACKED, __to, __tag, MPI_COMM_WORLD, act_req.back ());
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendMessageToAll (int __tag) {
|
void sendMessageToAll (int __tag)
|
||||||
|
{
|
||||||
|
|
||||||
for (int i = 0; i < getNumberOfNodes (); i ++)
|
for (int i = 0; i < getNumberOfNodes (); i ++)
|
||||||
sendMessage (i, __tag);
|
sendMessage (i, __tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
void receiveMessage (int __from, int __tag) {
|
void receiveMessage (int __from, int __tag)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Status stat;
|
MPI_Status stat;
|
||||||
MPI_Request req;
|
MPI_Request req;
|
||||||
|
|
@ -147,80 +159,93 @@ void receiveMessage (int __from, int __tag) {
|
||||||
MPI_Wait (& req, & stat);
|
MPI_Wait (& req, & stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void synchronizeNodes () {
|
void synchronizeNodes ()
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Barrier ( MPI_COMM_WORLD );
|
MPI_Barrier ( MPI_COMM_WORLD );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Char */
|
/* Char */
|
||||||
void pack (const char & __c) {
|
void pack (const char & __c)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Pack ((void *) & __c, 1, MPI_CHAR, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
MPI_Pack ((void *) & __c, 1, MPI_CHAR, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Boolean */
|
/* Boolean */
|
||||||
void pack (const bool & __b, int __nitem){
|
void pack (const bool & __b, int __nitem)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Pack ((void *) & __b, __nitem, MPI_INT, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
MPI_Pack ((void *) & __b, __nitem, MPI_INT, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Float */
|
/* Float */
|
||||||
void pack (const float & __f, int __nitem) {
|
void pack (const float & __f, int __nitem)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Pack ((void *) & __f, __nitem, MPI_FLOAT, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
MPI_Pack ((void *) & __f, __nitem, MPI_FLOAT, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Double */
|
/* Double */
|
||||||
void pack (const double & __d, int __nitem) {
|
void pack (const double & __d, int __nitem)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Pack ((void *) & __d, __nitem, MPI_DOUBLE, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
MPI_Pack ((void *) & __d, __nitem, MPI_DOUBLE, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Integer */
|
/* Integer */
|
||||||
void pack (const int & __i, int __nitem) {
|
void pack (const int & __i, int __nitem)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Pack ((void *) & __i, __nitem, MPI_INT, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
MPI_Pack ((void *) & __i, __nitem, MPI_INT, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unsigned int. */
|
/* Unsigned int. */
|
||||||
void pack (const unsigned int & __ui, int __nitem) {
|
void pack (const unsigned int & __ui, int __nitem)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Pack ((void *) & __ui, __nitem, MPI_UNSIGNED, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
MPI_Pack ((void *) & __ui, __nitem, MPI_UNSIGNED, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Short int. */
|
/* Short int. */
|
||||||
void pack (const short & __sh, int __nitem) {
|
void pack (const short & __sh, int __nitem)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Pack ((void *) & __sh, __nitem, MPI_SHORT, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
MPI_Pack ((void *) & __sh, __nitem, MPI_SHORT, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unsigned short */
|
/* Unsigned short */
|
||||||
void pack (const unsigned short & __ush, int __nitem) {
|
void pack (const unsigned short & __ush, int __nitem)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Pack ((void *) & __ush, __nitem, MPI_UNSIGNED_SHORT, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
MPI_Pack ((void *) & __ush, __nitem, MPI_UNSIGNED_SHORT, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Long */
|
/* Long */
|
||||||
void pack (const long & __l, int __nitem) {
|
void pack (const long & __l, int __nitem)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Pack ((void *) & __l, __nitem, MPI_LONG, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
MPI_Pack ((void *) & __l, __nitem, MPI_LONG, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unsigned long */
|
/* Unsigned long */
|
||||||
void pack (const unsigned long & __ul, int __nitem) {
|
void pack (const unsigned long & __ul, int __nitem)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Pack ((void *) & __ul, __nitem, MPI_UNSIGNED_LONG, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
MPI_Pack ((void *) & __ul, __nitem, MPI_UNSIGNED_LONG, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* String */
|
/* String */
|
||||||
void pack (const char * __str) {
|
void pack (const char * __str)
|
||||||
|
{
|
||||||
|
|
||||||
int len = strlen (__str) + 1;
|
int len = strlen (__str) + 1;
|
||||||
MPI_Pack (& len, 1, MPI_INT, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
MPI_Pack (& len, 1, MPI_INT, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
||||||
MPI_Pack ((void *) __str, len, MPI_CHAR, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
MPI_Pack ((void *) __str, len, MPI_CHAR, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
void pack (const std::string & __str) {
|
void pack (const std::string & __str)
|
||||||
|
{
|
||||||
|
|
||||||
size_t size = __str.size() + 1;
|
size_t size = __str.size() + 1;
|
||||||
char * buffer = new char[ size ];
|
char * buffer = new char[ size ];
|
||||||
|
|
@ -230,73 +255,85 @@ void pack (const std::string & __str) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Char */
|
/* Char */
|
||||||
void unpack (char & __c) {
|
void unpack (char & __c)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __c, 1, MPI_CHAR, MPI_COMM_WORLD);
|
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __c, 1, MPI_CHAR, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Boolean */
|
/* Boolean */
|
||||||
extern void unpack (bool & __b, int __nitem ){
|
extern void unpack (bool & __b, int __nitem )
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __b, __nitem, MPI_INT, MPI_COMM_WORLD);
|
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __b, __nitem, MPI_INT, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Float */
|
/* Float */
|
||||||
void unpack (float & __f, int __nitem) {
|
void unpack (float & __f, int __nitem)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __f, __nitem, MPI_FLOAT, MPI_COMM_WORLD);
|
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __f, __nitem, MPI_FLOAT, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Double */
|
/* Double */
|
||||||
void unpack (double & __d, int __nitem) {
|
void unpack (double & __d, int __nitem)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __d, __nitem, MPI_DOUBLE, MPI_COMM_WORLD);
|
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __d, __nitem, MPI_DOUBLE, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Integer */
|
/* Integer */
|
||||||
void unpack (int & __i, int __nitem) {
|
void unpack (int & __i, int __nitem)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __i, __nitem, MPI_INT, MPI_COMM_WORLD);
|
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __i, __nitem, MPI_INT, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unsigned int. */
|
/* Unsigned int. */
|
||||||
void unpack (unsigned int & __ui, int __nitem) {
|
void unpack (unsigned int & __ui, int __nitem)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __ui, __nitem, MPI_UNSIGNED, MPI_COMM_WORLD);
|
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __ui, __nitem, MPI_UNSIGNED, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Short int. */
|
/* Short int. */
|
||||||
void unpack (short & __sh, int __nitem) {
|
void unpack (short & __sh, int __nitem)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __sh, __nitem, MPI_SHORT, MPI_COMM_WORLD);
|
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __sh, __nitem, MPI_SHORT, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unsigned short */
|
/* Unsigned short */
|
||||||
void unpack (unsigned short & __ush, int __nitem) {
|
void unpack (unsigned short & __ush, int __nitem)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __ush, __nitem, MPI_UNSIGNED_SHORT, MPI_COMM_WORLD);
|
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __ush, __nitem, MPI_UNSIGNED_SHORT, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Long */
|
/* Long */
|
||||||
void unpack (long & __l, int __nitem) {
|
void unpack (long & __l, int __nitem)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __l, __nitem, MPI_LONG, MPI_COMM_WORLD);
|
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __l, __nitem, MPI_LONG, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unsigned long */
|
/* Unsigned long */
|
||||||
void unpack (unsigned long & __ul, int __nitem) {
|
void unpack (unsigned long & __ul, int __nitem)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __ul, __nitem, MPI_UNSIGNED_LONG, MPI_COMM_WORLD);
|
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __ul, __nitem, MPI_UNSIGNED_LONG, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* String */
|
/* String */
|
||||||
void unpack (char * __str) {
|
void unpack (char * __str)
|
||||||
|
{
|
||||||
|
|
||||||
int len;
|
int len;
|
||||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & len, 1, MPI_INT, MPI_COMM_WORLD);
|
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & len, 1, MPI_INT, MPI_COMM_WORLD);
|
||||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, __str, len, MPI_CHAR, MPI_COMM_WORLD);
|
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, __str, len, MPI_CHAR, MPI_COMM_WORLD);
|
||||||
}
|
}
|
||||||
void unpack (std::string & __str) {
|
void unpack (std::string & __str)
|
||||||
|
{
|
||||||
|
|
||||||
char * buffer;
|
char * buffer;
|
||||||
int len;
|
int len;
|
||||||
|
|
|
||||||
|
|
@ -43,35 +43,41 @@
|
||||||
#include "mess.h"
|
#include "mess.h"
|
||||||
|
|
||||||
|
|
||||||
class MPIThreadedEnv {
|
class MPIThreadedEnv
|
||||||
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static void init ( int * __argc, char * * * __argv ) {
|
static void init ( int * __argc, char * * * __argv )
|
||||||
|
{
|
||||||
|
|
||||||
static MPIThreadedEnv mpiThreadedEnv( __argc, __argv );
|
static MPIThreadedEnv mpiThreadedEnv( __argc, __argv );
|
||||||
}
|
}
|
||||||
|
|
||||||
static void finalize () {
|
static void finalize ()
|
||||||
|
{
|
||||||
|
|
||||||
static bool finalizedEnvironment = false;
|
static bool finalizedEnvironment = false;
|
||||||
|
|
||||||
if (! finalizedEnvironment ) {
|
if (! finalizedEnvironment )
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Finalize ();
|
MPI_Finalize ();
|
||||||
finalizedEnvironment = true;
|
finalizedEnvironment = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/* No instance of this class can be created outside its domain! */
|
/* No instance of this class can be created outside its domain! */
|
||||||
MPIThreadedEnv ( int * __argc, char * * * __argv ) {
|
MPIThreadedEnv ( int * __argc, char * * * __argv )
|
||||||
|
{
|
||||||
|
|
||||||
static bool MPIThreadedEnvInitialized = false;
|
static bool MPIThreadedEnvInitialized = false;
|
||||||
int provided = 1;
|
int provided = 1;
|
||||||
|
|
||||||
if (! MPIThreadedEnvInitialized) {
|
if (! MPIThreadedEnvInitialized)
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Init_thread (__argc, __argv, MPI_THREAD_FUNNELED, & provided);
|
MPI_Init_thread (__argc, __argv, MPI_THREAD_FUNNELED, & provided);
|
||||||
|
|
||||||
|
|
@ -82,11 +88,12 @@ private:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
~MPIThreadedEnv() {
|
~MPIThreadedEnv()
|
||||||
|
{
|
||||||
|
|
||||||
finalize ();
|
finalize ();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static int rk, sz; /* Rank & size */
|
static int rk, sz; /* Rank & size */
|
||||||
|
|
@ -96,27 +103,32 @@ static std :: map <std :: string, int> name_to_rk;
|
||||||
static std :: vector <std :: string> rk_to_name;
|
static std :: vector <std :: string> rk_to_name;
|
||||||
|
|
||||||
|
|
||||||
int getNodeRank () {
|
int getNodeRank ()
|
||||||
|
{
|
||||||
|
|
||||||
return rk;
|
return rk;
|
||||||
}
|
}
|
||||||
|
|
||||||
int getNumberOfNodes () {
|
int getNumberOfNodes ()
|
||||||
|
{
|
||||||
|
|
||||||
return sz;
|
return sz;
|
||||||
}
|
}
|
||||||
|
|
||||||
void collectiveCountOfRunners ( unsigned int* num_local_exec_runners, unsigned int* num_exec_runners ) {
|
void collectiveCountOfRunners ( unsigned int* num_local_exec_runners, unsigned int* num_exec_runners )
|
||||||
|
{
|
||||||
|
|
||||||
MPI_Allreduce( num_local_exec_runners, num_exec_runners, 1, MPI_UNSIGNED, MPI_SUM, MPI_COMM_WORLD );
|
MPI_Allreduce( num_local_exec_runners, num_exec_runners, 1, MPI_UNSIGNED, MPI_SUM, MPI_COMM_WORLD );
|
||||||
}
|
}
|
||||||
|
|
||||||
int getRankFromName (const std :: string & __name) {
|
int getRankFromName (const std :: string & __name)
|
||||||
|
{
|
||||||
|
|
||||||
return atoi (__name.c_str ());
|
return atoi (__name.c_str ());
|
||||||
}
|
}
|
||||||
|
|
||||||
void initNode (int * __argc, char * * * __argv) {
|
void initNode (int * __argc, char * * * __argv)
|
||||||
|
{
|
||||||
|
|
||||||
rk_to_name.clear ();
|
rk_to_name.clear ();
|
||||||
name_to_rk.clear ();
|
name_to_rk.clear ();
|
||||||
|
|
@ -134,7 +146,8 @@ void initNode (int * __argc, char * * * __argv) {
|
||||||
MPI_Get_processor_name (names [0], & len); /* Me */
|
MPI_Get_processor_name (names [0], & len); /* Me */
|
||||||
MPI_Allgather (names, MPI_MAX_PROCESSOR_NAME, MPI_CHAR, names, MPI_MAX_PROCESSOR_NAME, MPI_CHAR, MPI_COMM_WORLD); /* Broadcast */
|
MPI_Allgather (names, MPI_MAX_PROCESSOR_NAME, MPI_CHAR, names, MPI_MAX_PROCESSOR_NAME, MPI_CHAR, MPI_COMM_WORLD); /* Broadcast */
|
||||||
|
|
||||||
for (int i = 0; i < sz; i ++) {
|
for (int i = 0; i < sz; i ++)
|
||||||
|
{
|
||||||
rk_to_name.push_back (names [i]);
|
rk_to_name.push_back (names [i]);
|
||||||
name_to_rk [names [i]] = i;
|
name_to_rk [names [i]] = i;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,8 @@
|
||||||
|
|
||||||
typedef int RANK_ID;
|
typedef int RANK_ID;
|
||||||
|
|
||||||
struct Node {
|
struct Node
|
||||||
|
{
|
||||||
|
|
||||||
RANK_ID rk; /* Rank */
|
RANK_ID rk; /* Rank */
|
||||||
std :: string name; /* Host name */
|
std :: string name; /* Host name */
|
||||||
|
|
@ -52,7 +53,7 @@ struct Node {
|
||||||
int rk_sched; /* rank of the scheduler */
|
int rk_sched; /* rank of the scheduler */
|
||||||
std :: vector <RUNNER_ID> id_run; /* List of runner def. IDs */
|
std :: vector <RUNNER_ID> id_run; /* List of runner def. IDs */
|
||||||
std :: vector <RUNNER_ID> execution_id_run; /* List of runtime execution runner IDs */
|
std :: vector <RUNNER_ID> execution_id_run; /* List of runtime execution runner IDs */
|
||||||
};
|
};
|
||||||
|
|
||||||
extern Node * my_node;
|
extern Node * my_node;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,8 @@
|
||||||
|
|
||||||
#include "schema.h"
|
#include "schema.h"
|
||||||
|
|
||||||
void loadRMCParameters (int & __argc, char * * & __argv) {
|
void loadRMCParameters (int & __argc, char * * & __argv)
|
||||||
|
{
|
||||||
|
|
||||||
eoParser parser (__argc, __argv);
|
eoParser parser (__argc, __argv);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -45,25 +45,30 @@
|
||||||
#include "../../core/cooperative.h"
|
#include "../../core/cooperative.h"
|
||||||
#include "../../core/peo_debug.h"
|
#include "../../core/peo_debug.h"
|
||||||
|
|
||||||
void receiveMessages () {
|
void receiveMessages ()
|
||||||
|
{
|
||||||
|
|
||||||
cleanBuffers ();
|
cleanBuffers ();
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
|
|
||||||
if (! atLeastOneActiveThread ()) {
|
if (! atLeastOneActiveThread ())
|
||||||
|
{
|
||||||
|
|
||||||
waitMessage ();
|
waitMessage ();
|
||||||
}
|
}
|
||||||
|
|
||||||
int src, tag;
|
int src, tag;
|
||||||
|
|
||||||
while (probeMessage (src, tag)) {
|
while (probeMessage (src, tag))
|
||||||
|
{
|
||||||
|
|
||||||
receiveMessage (src, tag);
|
receiveMessage (src, tag);
|
||||||
initMessage ();
|
initMessage ();
|
||||||
|
|
||||||
switch (tag) {
|
switch (tag)
|
||||||
|
{
|
||||||
|
|
||||||
case RUNNER_STOP_TAG:
|
case RUNNER_STOP_TAG:
|
||||||
unpackTerminationOfRunner ();
|
unpackTerminationOfRunner ();
|
||||||
|
|
@ -146,5 +151,6 @@ void receiveMessages () {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
} while ( ! atLeastOneActiveThread () && atLeastOneActiveRunner () /*&& ! allResourcesFree ()*/ );
|
}
|
||||||
|
while ( ! atLeastOneActiveThread () && atLeastOneActiveRunner () /*&& ! allResourcesFree ()*/ );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,10 +46,12 @@ static std :: vector <Worker *> worker_threads; /* Worker threads */
|
||||||
static Communicator* communicator_thread = NULL; /* Communicator thread */
|
static Communicator* communicator_thread = NULL; /* Communicator thread */
|
||||||
|
|
||||||
|
|
||||||
void runRMC () {
|
void runRMC ()
|
||||||
|
{
|
||||||
|
|
||||||
/* Worker(s) ? */
|
/* Worker(s) ? */
|
||||||
for (unsigned i = 0; i < my_node -> num_workers; i ++) {
|
for (unsigned i = 0; i < my_node -> num_workers; i ++)
|
||||||
|
{
|
||||||
worker_threads.push_back (new Worker);
|
worker_threads.push_back (new Worker);
|
||||||
addThread (worker_threads.back(), ll_threads);
|
addThread (worker_threads.back(), ll_threads);
|
||||||
}
|
}
|
||||||
|
|
@ -57,7 +59,8 @@ void runRMC () {
|
||||||
wakeUpCommunicator ();
|
wakeUpCommunicator ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void initRMC (int & __argc, char * * & __argv) {
|
void initRMC (int & __argc, char * * & __argv)
|
||||||
|
{
|
||||||
|
|
||||||
/* Communication */
|
/* Communication */
|
||||||
initCommunication ();
|
initCommunication ();
|
||||||
|
|
@ -71,12 +74,14 @@ void initRMC (int & __argc, char * * & __argv) {
|
||||||
initScheduler ();
|
initScheduler ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void finalizeRMC () {
|
void finalizeRMC ()
|
||||||
|
{
|
||||||
|
|
||||||
printDebugMessage ("before join threads RMC");
|
printDebugMessage ("before join threads RMC");
|
||||||
|
|
||||||
joinThreads (ll_threads);
|
joinThreads (ll_threads);
|
||||||
for (unsigned i = 0; i < worker_threads.size(); i++ ) {
|
for (unsigned i = 0; i < worker_threads.size(); i++ )
|
||||||
|
{
|
||||||
delete worker_threads [i];
|
delete worker_threads [i];
|
||||||
}
|
}
|
||||||
worker_threads.clear ();
|
worker_threads.clear ();
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,8 @@
|
||||||
#include "schema.h"
|
#include "schema.h"
|
||||||
|
|
||||||
|
|
||||||
bool Runner :: isAssignedLocally () {
|
bool Runner :: isAssignedLocally ()
|
||||||
|
{
|
||||||
|
|
||||||
for (unsigned i = 0; i < my_node -> id_run.size (); i ++)
|
for (unsigned i = 0; i < my_node -> id_run.size (); i ++)
|
||||||
if (my_node -> id_run [i] == def_id)
|
if (my_node -> id_run [i] == def_id)
|
||||||
|
|
@ -51,12 +52,14 @@ bool Runner :: isAssignedLocally () {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Runner :: terminate () {
|
void Runner :: terminate ()
|
||||||
|
{
|
||||||
|
|
||||||
sendToAll (this, RUNNER_STOP_TAG);
|
sendToAll (this, RUNNER_STOP_TAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Runner :: packTermination () {
|
void Runner :: packTermination ()
|
||||||
|
{
|
||||||
|
|
||||||
pack (def_id);
|
pack (def_id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,13 +49,15 @@ static unsigned initNumberOfRes = 0;
|
||||||
|
|
||||||
extern void wakeUpCommunicator();
|
extern void wakeUpCommunicator();
|
||||||
|
|
||||||
void initScheduler () {
|
void initScheduler ()
|
||||||
|
{
|
||||||
|
|
||||||
resources = std :: queue <SCHED_RESOURCE> ();
|
resources = std :: queue <SCHED_RESOURCE> ();
|
||||||
requests = std :: queue <SCHED_REQUEST> ();
|
requests = std :: queue <SCHED_REQUEST> ();
|
||||||
initNumberOfRes = 0;
|
initNumberOfRes = 0;
|
||||||
|
|
||||||
for (unsigned i = 0; i < the_schema.size (); i ++) {
|
for (unsigned i = 0; i < the_schema.size (); i ++)
|
||||||
|
{
|
||||||
|
|
||||||
const Node & node = the_schema [i];
|
const Node & node = the_schema [i];
|
||||||
|
|
||||||
|
|
@ -66,19 +68,23 @@ void initScheduler () {
|
||||||
initNumberOfRes = resources.size ();
|
initNumberOfRes = resources.size ();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool allResourcesFree () {
|
bool allResourcesFree ()
|
||||||
|
{
|
||||||
return resources.size () == initNumberOfRes;
|
return resources.size () == initNumberOfRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned numResourcesFree () {
|
unsigned numResourcesFree ()
|
||||||
|
{
|
||||||
return resources.size ();
|
return resources.size ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void update () {
|
static void update ()
|
||||||
|
{
|
||||||
|
|
||||||
unsigned num_alloc = std :: min (resources.size (), requests.size ());
|
unsigned num_alloc = std :: min (resources.size (), requests.size ());
|
||||||
|
|
||||||
for (unsigned i = 0; i < num_alloc; i ++) {
|
for (unsigned i = 0; i < num_alloc; i ++)
|
||||||
|
{
|
||||||
|
|
||||||
SCHED_REQUEST req = requests.front ();
|
SCHED_REQUEST req = requests.front ();
|
||||||
requests.pop ();
|
requests.pop ();
|
||||||
|
|
@ -94,7 +100,8 @@ static void update () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void unpackResourceRequest () {
|
void unpackResourceRequest ()
|
||||||
|
{
|
||||||
|
|
||||||
printDebugMessage ("queuing a resource request.");
|
printDebugMessage ("queuing a resource request.");
|
||||||
SCHED_REQUEST req;
|
SCHED_REQUEST req;
|
||||||
|
|
@ -103,7 +110,8 @@ void unpackResourceRequest () {
|
||||||
update ();
|
update ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void unpackTaskDone () {
|
void unpackTaskDone ()
|
||||||
|
{
|
||||||
|
|
||||||
printDebugMessage ("I'm notified a worker is now idle.");
|
printDebugMessage ("I'm notified a worker is now idle.");
|
||||||
SCHED_RESOURCE res;
|
SCHED_RESOURCE res;
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,8 @@ Node * my_node;
|
||||||
static unsigned maxSpecifiedRunnerID = 0;
|
static unsigned maxSpecifiedRunnerID = 0;
|
||||||
|
|
||||||
|
|
||||||
RANK_ID getRankOfRunner (RUNNER_ID __key) {
|
RANK_ID getRankOfRunner (RUNNER_ID __key)
|
||||||
|
{
|
||||||
|
|
||||||
for (unsigned i = 0; i < the_schema.size (); i ++)
|
for (unsigned i = 0; i < the_schema.size (); i ++)
|
||||||
for (unsigned j = 0; j < the_schema [i].id_run.size (); j ++)
|
for (unsigned j = 0; j < the_schema [i].id_run.size (); j ++)
|
||||||
|
|
@ -61,7 +62,8 @@ RANK_ID getRankOfRunner (RUNNER_ID __key) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loadNode (int __rk_sched) {
|
static void loadNode (int __rk_sched)
|
||||||
|
{
|
||||||
|
|
||||||
Node node;
|
Node node;
|
||||||
|
|
||||||
|
|
@ -72,12 +74,14 @@ static void loadNode (int __rk_sched) {
|
||||||
/* ATT: num_workers */
|
/* ATT: num_workers */
|
||||||
node.num_workers = atoi (getAttributeValue ("num_workers").c_str ());
|
node.num_workers = atoi (getAttributeValue ("num_workers").c_str ());
|
||||||
|
|
||||||
while (true) {
|
while (true)
|
||||||
|
{
|
||||||
|
|
||||||
/* TAG: <runner> | </node> */
|
/* TAG: <runner> | </node> */
|
||||||
std :: string name = getNextNode ();
|
std :: string name = getNextNode ();
|
||||||
assert (name == "runner" || name == "node");
|
assert (name == "runner" || name == "node");
|
||||||
if (name == "runner") {
|
if (name == "runner")
|
||||||
|
{
|
||||||
/* TAG: </node> */
|
/* TAG: </node> */
|
||||||
node.id_run.push_back (atoi (getNextNode ().c_str ()));
|
node.id_run.push_back (atoi (getNextNode ().c_str ()));
|
||||||
if ( node.id_run.back() > maxSpecifiedRunnerID )
|
if ( node.id_run.back() > maxSpecifiedRunnerID )
|
||||||
|
|
@ -85,7 +89,8 @@ static void loadNode (int __rk_sched) {
|
||||||
/* TAG: </runner> */
|
/* TAG: </runner> */
|
||||||
assert (getNextNode () == "runner");
|
assert (getNextNode () == "runner");
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
/* TAG: </node> */
|
/* TAG: </node> */
|
||||||
node.execution_id_run = node.id_run;
|
node.execution_id_run = node.id_run;
|
||||||
the_schema.push_back (node);
|
the_schema.push_back (node);
|
||||||
|
|
@ -94,14 +99,16 @@ static void loadNode (int __rk_sched) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loadGroup () {
|
static void loadGroup ()
|
||||||
|
{
|
||||||
|
|
||||||
std :: string name;
|
std :: string name;
|
||||||
|
|
||||||
/* ATT: scheduler*/
|
/* ATT: scheduler*/
|
||||||
int rk_sched = getRankFromName (getAttributeValue ("scheduler"));
|
int rk_sched = getRankFromName (getAttributeValue ("scheduler"));
|
||||||
|
|
||||||
while (true) {
|
while (true)
|
||||||
|
{
|
||||||
|
|
||||||
/* TAG: <node> | </group> */
|
/* TAG: <node> | </group> */
|
||||||
name = getNextNode ();
|
name = getNextNode ();
|
||||||
|
|
@ -115,12 +122,14 @@ static void loadGroup () {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isScheduleNode () {
|
bool isScheduleNode ()
|
||||||
|
{
|
||||||
|
|
||||||
return my_node -> rk == my_node -> rk_sched;
|
return my_node -> rk == my_node -> rk_sched;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadSchema (const char * __filename) {
|
void loadSchema (const char * __filename)
|
||||||
|
{
|
||||||
|
|
||||||
openXMLDocument (__filename);
|
openXMLDocument (__filename);
|
||||||
|
|
||||||
|
|
@ -133,7 +142,8 @@ void loadSchema (const char * __filename) {
|
||||||
the_schema.clear();
|
the_schema.clear();
|
||||||
maxSpecifiedRunnerID = 0;
|
maxSpecifiedRunnerID = 0;
|
||||||
|
|
||||||
while (true) {
|
while (true)
|
||||||
|
{
|
||||||
|
|
||||||
/* TAG: <group> | </schema> */
|
/* TAG: <group> | </schema> */
|
||||||
name = getNextNode ();
|
name = getNextNode ();
|
||||||
|
|
@ -147,12 +157,16 @@ void loadSchema (const char * __filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std :: set<unsigned> uniqueRunnerIDs; unsigned nbUniqueIDs = 0;
|
std :: set<unsigned> uniqueRunnerIDs;
|
||||||
for (unsigned i = 0; i < the_schema.size (); i ++) {
|
unsigned nbUniqueIDs = 0;
|
||||||
for (unsigned j = 0; j < the_schema [i].id_run.size(); j ++) {
|
for (unsigned i = 0; i < the_schema.size (); i ++)
|
||||||
|
{
|
||||||
|
for (unsigned j = 0; j < the_schema [i].id_run.size(); j ++)
|
||||||
|
{
|
||||||
uniqueRunnerIDs.insert( the_schema [i].id_run[j] );
|
uniqueRunnerIDs.insert( the_schema [i].id_run[j] );
|
||||||
/* In case a duplicate ID has been found */
|
/* In case a duplicate ID has been found */
|
||||||
if ( uniqueRunnerIDs.size() == nbUniqueIDs ) {
|
if ( uniqueRunnerIDs.size() == nbUniqueIDs )
|
||||||
|
{
|
||||||
the_schema [i].execution_id_run[j] = ++maxSpecifiedRunnerID;
|
the_schema [i].execution_id_run[j] = ++maxSpecifiedRunnerID;
|
||||||
}
|
}
|
||||||
nbUniqueIDs = uniqueRunnerIDs.size();
|
nbUniqueIDs = uniqueRunnerIDs.size();
|
||||||
|
|
@ -160,7 +174,8 @@ void loadSchema (const char * __filename) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Looking for my node */
|
/* Looking for my node */
|
||||||
for (unsigned i = 0; i < the_schema.size (); i ++) {
|
for (unsigned i = 0; i < the_schema.size (); i ++)
|
||||||
|
{
|
||||||
if (the_schema [i].rk == getNodeRank ())
|
if (the_schema [i].rk == getNodeRank ())
|
||||||
my_node = & (the_schema [i]);
|
my_node = & (the_schema [i]);
|
||||||
}
|
}
|
||||||
|
|
@ -175,12 +190,14 @@ void loadSchema (const char * __filename) {
|
||||||
if (isScheduleNode ())
|
if (isScheduleNode ())
|
||||||
printDebugMessage ("I'am a scheduler");
|
printDebugMessage ("I'am a scheduler");
|
||||||
|
|
||||||
for (unsigned i = 0; i < my_node -> id_run.size (); i ++) {
|
for (unsigned i = 0; i < my_node -> id_run.size (); i ++)
|
||||||
|
{
|
||||||
sprintf (mess, "I manage the runner %d", my_node -> id_run [i]);
|
sprintf (mess, "I manage the runner %d", my_node -> id_run [i]);
|
||||||
printDebugMessage (mess);
|
printDebugMessage (mess);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (my_node -> num_workers) {
|
if (my_node -> num_workers)
|
||||||
|
{
|
||||||
|
|
||||||
sprintf (mess, "I manage %d worker(s)", my_node -> num_workers);
|
sprintf (mess, "I manage %d worker(s)", my_node -> num_workers);
|
||||||
printDebugMessage (mess);
|
printDebugMessage (mess);
|
||||||
|
|
|
||||||
|
|
@ -50,13 +50,15 @@
|
||||||
#define TO_ALL -1
|
#define TO_ALL -1
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct
|
||||||
|
{
|
||||||
|
|
||||||
Communicable * comm;
|
Communicable * comm;
|
||||||
int to;
|
int to;
|
||||||
int tag;
|
int tag;
|
||||||
|
|
||||||
} SEND_REQUEST;
|
}
|
||||||
|
SEND_REQUEST;
|
||||||
|
|
||||||
|
|
||||||
static std :: queue <SEND_REQUEST> mess;
|
static std :: queue <SEND_REQUEST> mess;
|
||||||
|
|
@ -66,13 +68,15 @@ static sem_t sem_send;
|
||||||
static bool contextInitialized = false;
|
static bool contextInitialized = false;
|
||||||
|
|
||||||
|
|
||||||
void initSending () {
|
void initSending ()
|
||||||
|
{
|
||||||
|
|
||||||
static bool initializedSemaphore = false;
|
static bool initializedSemaphore = false;
|
||||||
|
|
||||||
mess = std :: queue <SEND_REQUEST> ();
|
mess = std :: queue <SEND_REQUEST> ();
|
||||||
|
|
||||||
if (initializedSemaphore) {
|
if (initializedSemaphore)
|
||||||
|
{
|
||||||
sem_destroy(& sem_send);
|
sem_destroy(& sem_send);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -82,7 +86,8 @@ void initSending () {
|
||||||
contextInitialized = false;
|
contextInitialized = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void send (Communicable * __comm, int __to, int __tag) {
|
void send (Communicable * __comm, int __to, int __tag)
|
||||||
|
{
|
||||||
|
|
||||||
SEND_REQUEST req;
|
SEND_REQUEST req;
|
||||||
req.comm = __comm;
|
req.comm = __comm;
|
||||||
|
|
@ -95,23 +100,27 @@ void send (Communicable * __comm, int __to, int __tag) {
|
||||||
wakeUpCommunicator ();
|
wakeUpCommunicator ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sendToAll (Communicable * __comm, int __tag) {
|
void sendToAll (Communicable * __comm, int __tag)
|
||||||
|
{
|
||||||
|
|
||||||
send (__comm, TO_ALL, __tag);
|
send (__comm, TO_ALL, __tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern void initializeContext ();
|
extern void initializeContext ();
|
||||||
|
|
||||||
void sendMessages () {
|
void sendMessages ()
|
||||||
|
{
|
||||||
|
|
||||||
if (! contextInitialized) {
|
if (! contextInitialized)
|
||||||
|
{
|
||||||
contextInitialized = true;
|
contextInitialized = true;
|
||||||
initializeContext();
|
initializeContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
sem_wait (& sem_send);
|
sem_wait (& sem_send);
|
||||||
|
|
||||||
while (! mess.empty ()) {
|
while (! mess.empty ())
|
||||||
|
{
|
||||||
|
|
||||||
SEND_REQUEST req = mess.front ();
|
SEND_REQUEST req = mess.front ();
|
||||||
|
|
||||||
|
|
@ -119,7 +128,8 @@ void sendMessages () {
|
||||||
|
|
||||||
initMessage ();
|
initMessage ();
|
||||||
|
|
||||||
switch (req.tag) {
|
switch (req.tag)
|
||||||
|
{
|
||||||
|
|
||||||
case RUNNER_STOP_TAG:
|
case RUNNER_STOP_TAG:
|
||||||
dynamic_cast <Runner *> (comm) -> packTermination ();
|
dynamic_cast <Runner *> (comm) -> packTermination ();
|
||||||
|
|
|
||||||
|
|
@ -41,14 +41,16 @@
|
||||||
#include "send.h"
|
#include "send.h"
|
||||||
#include "scheduler.h"
|
#include "scheduler.h"
|
||||||
|
|
||||||
void Service :: requestResourceRequest (unsigned __how_many) {
|
void Service :: requestResourceRequest (unsigned __how_many)
|
||||||
|
{
|
||||||
|
|
||||||
num_sent_rr = __how_many;
|
num_sent_rr = __how_many;
|
||||||
for (unsigned i = 0; i < __how_many; i ++)
|
for (unsigned i = 0; i < __how_many; i ++)
|
||||||
send (this, my_node -> rk_sched, SCHED_REQUEST_TAG);
|
send (this, my_node -> rk_sched, SCHED_REQUEST_TAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service :: packResourceRequest () {
|
void Service :: packResourceRequest ()
|
||||||
|
{
|
||||||
|
|
||||||
SCHED_REQUEST req;
|
SCHED_REQUEST req;
|
||||||
req.first = getNodeRank ();
|
req.first = getNodeRank ();
|
||||||
|
|
|
||||||
|
|
@ -50,26 +50,30 @@ extern void wakeUpCommunicator();
|
||||||
extern RANK_ID getRankOfRunner (RUNNER_ID __key);
|
extern RANK_ID getRankOfRunner (RUNNER_ID __key);
|
||||||
|
|
||||||
/* Initializing the list of runners to be synchronized */
|
/* Initializing the list of runners to be synchronized */
|
||||||
void initSynchron () {
|
void initSynchron ()
|
||||||
|
{
|
||||||
|
|
||||||
syncRunners = SYNC();
|
syncRunners = SYNC();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* packing a synchronization request from a service */
|
/* packing a synchronization request from a service */
|
||||||
void packSynchronRequest ( const std :: vector <Cooperative *>& coops ) {
|
void packSynchronRequest ( const std :: vector <Cooperative *>& coops )
|
||||||
|
{
|
||||||
|
|
||||||
/* Number of coops to synchronize */
|
/* Number of coops to synchronize */
|
||||||
pack( (unsigned)( coops.size() ) );
|
pack( (unsigned)( coops.size() ) );
|
||||||
|
|
||||||
/* Coops to synchronize */
|
/* Coops to synchronize */
|
||||||
for (unsigned i = 0; i < coops.size(); i ++) {
|
for (unsigned i = 0; i < coops.size(); i ++)
|
||||||
|
{
|
||||||
pack( coops[ i ]->getOwner()->getDefinitionID() );
|
pack( coops[ i ]->getOwner()->getDefinitionID() );
|
||||||
pack( coops[ i ]->getKey() );
|
pack( coops[ i ]->getKey() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Processing a synchronization request from a service */
|
/* Processing a synchronization request from a service */
|
||||||
void unpackSynchronRequest () {
|
void unpackSynchronRequest ()
|
||||||
|
{
|
||||||
|
|
||||||
unsigned req_num_entries;
|
unsigned req_num_entries;
|
||||||
unpack (req_num_entries);
|
unpack (req_num_entries);
|
||||||
|
|
@ -79,7 +83,8 @@ void unpackSynchronRequest () {
|
||||||
|
|
||||||
/* Adding entries for each of the runners to be synchronized */
|
/* Adding entries for each of the runners to be synchronized */
|
||||||
SyncEntry req_entry;
|
SyncEntry req_entry;
|
||||||
for (unsigned i = 0; i < req_num_entries; i ++) {
|
for (unsigned i = 0; i < req_num_entries; i ++)
|
||||||
|
{
|
||||||
|
|
||||||
unpack (req_entry.runner);
|
unpack (req_entry.runner);
|
||||||
unpack (req_entry.coop);
|
unpack (req_entry.coop);
|
||||||
|
|
@ -91,24 +96,28 @@ void unpackSynchronRequest () {
|
||||||
SYNC::iterator sync_it = syncRunners.find (req_sync);
|
SYNC::iterator sync_it = syncRunners.find (req_sync);
|
||||||
|
|
||||||
/* The vector does not exist - insert a new sync */
|
/* The vector does not exist - insert a new sync */
|
||||||
if (sync_it == syncRunners.end ()) {
|
if (sync_it == syncRunners.end ())
|
||||||
|
{
|
||||||
req_sync.second = 1;
|
req_sync.second = 1;
|
||||||
syncRunners.insert (req_sync);
|
syncRunners.insert (req_sync);
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
|
|
||||||
/* The vector exists - updating the entry */
|
/* The vector exists - updating the entry */
|
||||||
std::pair< SYNC_RUNNERS, unsigned >& sync_req_entry = const_cast< std::pair< SYNC_RUNNERS, unsigned >& > (*sync_it);
|
std::pair< SYNC_RUNNERS, unsigned >& sync_req_entry = const_cast< std::pair< SYNC_RUNNERS, unsigned >& > (*sync_it);
|
||||||
sync_req_entry.second ++;
|
sync_req_entry.second ++;
|
||||||
|
|
||||||
/* All the runners to be synchronized sent the SYNC_REQUEST signal */
|
/* All the runners to be synchronized sent the SYNC_REQUEST signal */
|
||||||
if (sync_req_entry.second == sync_req_entry.first.size()) {
|
if (sync_req_entry.second == sync_req_entry.first.size())
|
||||||
|
{
|
||||||
|
|
||||||
/* Remove the entry */
|
/* Remove the entry */
|
||||||
syncRunners.erase (sync_it);
|
syncRunners.erase (sync_it);
|
||||||
|
|
||||||
/* Send SYNCHRONIZED signals to all the coop objects */
|
/* Send SYNCHRONIZED signals to all the coop objects */
|
||||||
for (unsigned i = 0; i < req_sync.first.size(); i ++) {
|
for (unsigned i = 0; i < req_sync.first.size(); i ++)
|
||||||
|
{
|
||||||
|
|
||||||
initMessage ();
|
initMessage ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -44,31 +44,39 @@
|
||||||
#include "../../core/runner.h"
|
#include "../../core/runner.h"
|
||||||
#include "../../core/cooperative.h"
|
#include "../../core/cooperative.h"
|
||||||
|
|
||||||
struct SyncEntry {
|
struct SyncEntry
|
||||||
|
{
|
||||||
|
|
||||||
RUNNER_ID runner;
|
RUNNER_ID runner;
|
||||||
COOP_ID coop;
|
COOP_ID coop;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SyncCompare {
|
struct SyncCompare
|
||||||
|
{
|
||||||
|
|
||||||
bool operator()( const std::pair< std::vector< SyncEntry >, unsigned >& A, const std::pair< std::vector< SyncEntry >, unsigned >& B ) {
|
bool operator()( const std::pair< std::vector< SyncEntry >, unsigned >& A, const std::pair< std::vector< SyncEntry >, unsigned >& B )
|
||||||
|
{
|
||||||
|
|
||||||
const std::vector< SyncEntry >& syncA = A.first;
|
const std::vector< SyncEntry >& syncA = A.first;
|
||||||
const std::vector< SyncEntry >& syncB = B.first;
|
const std::vector< SyncEntry >& syncB = B.first;
|
||||||
|
|
||||||
if ( syncA.size() == syncB.size() ) {
|
if ( syncA.size() == syncB.size() )
|
||||||
|
{
|
||||||
std::vector< SyncEntry >::const_iterator itA = syncA.begin();
|
std::vector< SyncEntry >::const_iterator itA = syncA.begin();
|
||||||
std::vector< SyncEntry >::const_iterator itB = syncB.begin();
|
std::vector< SyncEntry >::const_iterator itB = syncB.begin();
|
||||||
|
|
||||||
while ( (*itA).runner < (*itB).runner && itA != syncA.end() ) { itA++; itB++; }
|
while ( (*itA).runner < (*itB).runner && itA != syncA.end() )
|
||||||
|
{
|
||||||
|
itA++;
|
||||||
|
itB++;
|
||||||
|
}
|
||||||
|
|
||||||
return itA == syncA.end();
|
return itA == syncA.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
return syncA.size() < syncB.size();
|
return syncA.size() < syncB.size();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::vector< SyncEntry > SYNC_RUNNERS;
|
typedef std::vector< SyncEntry > SYNC_RUNNERS;
|
||||||
typedef std::set< std::pair< SYNC_RUNNERS, unsigned >, SyncCompare > SYNC;
|
typedef std::set< std::pair< SYNC_RUNNERS, unsigned >, SyncCompare > SYNC;
|
||||||
|
|
|
||||||
|
|
@ -48,12 +48,14 @@ static std :: vector <Worker *> key_to_worker (1); /* Vector of registered worke
|
||||||
|
|
||||||
extern void wakeUpCommunicator ();
|
extern void wakeUpCommunicator ();
|
||||||
|
|
||||||
Worker * getWorker (WORKER_ID __key) {
|
Worker * getWorker (WORKER_ID __key)
|
||||||
|
{
|
||||||
|
|
||||||
return key_to_worker [__key];
|
return key_to_worker [__key];
|
||||||
}
|
}
|
||||||
|
|
||||||
Worker :: Worker () {
|
Worker :: Worker ()
|
||||||
|
{
|
||||||
|
|
||||||
recvAndCompleted = false;
|
recvAndCompleted = false;
|
||||||
taskAssigned = 0;
|
taskAssigned = 0;
|
||||||
|
|
@ -63,13 +65,15 @@ Worker :: Worker () {
|
||||||
sem_init( &sem_task_done, 0, 0 );
|
sem_init( &sem_task_done, 0, 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worker :: packResult () {
|
void Worker :: packResult ()
|
||||||
|
{
|
||||||
|
|
||||||
pack (serv_id);
|
pack (serv_id);
|
||||||
serv -> packResult ();
|
serv -> packResult ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worker :: unpackData () {
|
void Worker :: unpackData ()
|
||||||
|
{
|
||||||
|
|
||||||
taskAssigned ++;
|
taskAssigned ++;
|
||||||
printDebugMessage ("unpacking the ID. of the service.");
|
printDebugMessage ("unpacking the ID. of the service.");
|
||||||
|
|
@ -81,46 +85,54 @@ void Worker :: unpackData () {
|
||||||
setActive ();
|
setActive ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worker :: packTaskDone () {
|
void Worker :: packTaskDone ()
|
||||||
|
{
|
||||||
|
|
||||||
pack (getNodeRank ());
|
pack (getNodeRank ());
|
||||||
pack (id);
|
pack (id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worker :: notifySendingResult () {
|
void Worker :: notifySendingResult ()
|
||||||
|
{
|
||||||
|
|
||||||
/* Notifying the scheduler of the termination */
|
/* Notifying the scheduler of the termination */
|
||||||
recvAndCompleted = true;
|
recvAndCompleted = true;
|
||||||
wakeUp ();
|
wakeUp ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worker :: notifySendingTaskDone () {
|
void Worker :: notifySendingTaskDone ()
|
||||||
|
{
|
||||||
|
|
||||||
sem_post(&sem_task_done);
|
sem_post(&sem_task_done);
|
||||||
setPassive ();
|
setPassive ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worker :: setSource (int __rank) {
|
void Worker :: setSource (int __rank)
|
||||||
|
{
|
||||||
|
|
||||||
src = __rank;
|
src = __rank;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Worker :: start () {
|
void Worker :: start ()
|
||||||
|
{
|
||||||
|
|
||||||
while (true) {
|
while (true)
|
||||||
|
{
|
||||||
|
|
||||||
sleep ();
|
sleep ();
|
||||||
|
|
||||||
if (! atLeastOneActiveRunner () && ! taskAssigned)
|
if (! atLeastOneActiveRunner () && ! taskAssigned)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (recvAndCompleted) {
|
if (recvAndCompleted)
|
||||||
|
{
|
||||||
send (this, my_node -> rk_sched, TASK_DONE_TAG);
|
send (this, my_node -> rk_sched, TASK_DONE_TAG);
|
||||||
recvAndCompleted = false;
|
recvAndCompleted = false;
|
||||||
sem_wait(&sem_task_done);
|
sem_wait(&sem_task_done);
|
||||||
taskAssigned --;
|
taskAssigned --;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
|
|
||||||
serv -> execute ();
|
serv -> execute ();
|
||||||
send (this, src, TASK_RESULT_TAG);
|
send (this, src, TASK_RESULT_TAG);
|
||||||
|
|
@ -133,7 +145,8 @@ void Worker :: start () {
|
||||||
wakeUpCommunicator();
|
wakeUpCommunicator();
|
||||||
}
|
}
|
||||||
|
|
||||||
void initWorkersEnv () {
|
void initWorkersEnv ()
|
||||||
|
{
|
||||||
|
|
||||||
key_to_worker.resize (1);
|
key_to_worker.resize (1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,10 @@
|
||||||
|
|
||||||
typedef unsigned WORKER_ID;
|
typedef unsigned WORKER_ID;
|
||||||
|
|
||||||
class Worker : public Communicable, public ReactiveThread {
|
class Worker : public Communicable, public ReactiveThread
|
||||||
|
{
|
||||||
|
|
||||||
public :
|
public :
|
||||||
|
|
||||||
Worker ();
|
Worker ();
|
||||||
|
|
||||||
|
|
@ -64,7 +65,7 @@ public :
|
||||||
|
|
||||||
void setSource (int __rank);
|
void setSource (int __rank);
|
||||||
|
|
||||||
private :
|
private :
|
||||||
|
|
||||||
WORKER_ID id;
|
WORKER_ID id;
|
||||||
SERVICE_ID serv_id;
|
SERVICE_ID serv_id;
|
||||||
|
|
@ -76,7 +77,7 @@ private :
|
||||||
|
|
||||||
sem_t sem_task_done;
|
sem_t sem_task_done;
|
||||||
sem_t sem_task_asgn;
|
sem_t sem_task_asgn;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern void initWorkersEnv ();
|
extern void initWorkersEnv ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,23 +40,27 @@
|
||||||
|
|
||||||
static xmlTextReaderPtr reader;
|
static xmlTextReaderPtr reader;
|
||||||
|
|
||||||
void openXMLDocument (const char * __filename) {
|
void openXMLDocument (const char * __filename)
|
||||||
|
{
|
||||||
|
|
||||||
reader = xmlNewTextReaderFilename (__filename);
|
reader = xmlNewTextReaderFilename (__filename);
|
||||||
|
|
||||||
if (! reader) {
|
if (! reader)
|
||||||
|
{
|
||||||
|
|
||||||
fprintf (stderr, "unable to open '%s'.\n", __filename);
|
fprintf (stderr, "unable to open '%s'.\n", __filename);
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void closeXMLDocument () {
|
void closeXMLDocument ()
|
||||||
|
{
|
||||||
|
|
||||||
xmlFreeTextReader (reader);
|
xmlFreeTextReader (reader);
|
||||||
}
|
}
|
||||||
|
|
||||||
std :: string getAttributeValue (const std :: string & __attr) {
|
std :: string getAttributeValue (const std :: string & __attr)
|
||||||
|
{
|
||||||
|
|
||||||
xmlChar * value = xmlTextReaderGetAttribute (reader, (const xmlChar *) __attr.c_str ());
|
xmlChar * value = xmlTextReaderGetAttribute (reader, (const xmlChar *) __attr.c_str ());
|
||||||
|
|
||||||
|
|
@ -67,7 +71,8 @@ std :: string getAttributeValue (const std :: string & __attr) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isSep (const xmlChar * __text) {
|
static bool isSep (const xmlChar * __text)
|
||||||
|
{
|
||||||
|
|
||||||
for (unsigned i = 0; i < strlen ((char *) __text); i ++)
|
for (unsigned i = 0; i < strlen ((char *) __text); i ++)
|
||||||
if (__text [i] != ' ' && __text [i] != '\t' && __text [i] != '\n')
|
if (__text [i] != ' ' && __text [i] != '\t' && __text [i] != '\n')
|
||||||
|
|
@ -75,15 +80,18 @@ static bool isSep (const xmlChar * __text) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std :: string getNextNode () {
|
std :: string getNextNode ()
|
||||||
|
{
|
||||||
|
|
||||||
xmlChar * name, * value;
|
xmlChar * name, * value;
|
||||||
|
|
||||||
do {
|
do
|
||||||
|
{
|
||||||
xmlTextReaderRead (reader);
|
xmlTextReaderRead (reader);
|
||||||
name = xmlTextReaderName (reader);
|
name = xmlTextReaderName (reader);
|
||||||
value = xmlTextReaderValue (reader);
|
value = xmlTextReaderValue (reader);
|
||||||
} while (! strcmp ((char *) name, "#text") && isSep (value));
|
}
|
||||||
|
while (! strcmp ((char *) name, "#text") && isSep (value));
|
||||||
|
|
||||||
std :: string str;
|
std :: string str;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,7 @@ template < class POT > class eoPrint : public eoContinue <POT>
|
||||||
|
|
||||||
void peoPSOSeq ()
|
void peoPSOSeq ()
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
const unsigned int VEC_SIZE = 4;
|
const unsigned int VEC_SIZE = 4;
|
||||||
const unsigned int POP_SIZE = 10;
|
const unsigned int POP_SIZE = 10;
|
||||||
const unsigned int NEIGHBORHOOD_SIZE= 5;
|
const unsigned int NEIGHBORHOOD_SIZE= 5;
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,7 @@ double peoPSOSeq ()
|
||||||
continuatorSeq.add(fitContSeq);
|
continuatorSeq.add(fitContSeq);
|
||||||
eoCheckPoint<Indi> checkpointSeq(continuatorSeq);
|
eoCheckPoint<Indi> checkpointSeq(continuatorSeq);
|
||||||
eoSyncEasyPSO < Indi > psaSeq(checkpointSeq, evalSeq, velocitySeq, flight);
|
eoSyncEasyPSO < Indi > psaSeq(checkpointSeq, evalSeq, velocitySeq, flight);
|
||||||
//Sequential
|
//Sequential
|
||||||
psaSeq (popSeq);
|
psaSeq (popSeq);
|
||||||
popSeq.sort ();
|
popSeq.sort ();
|
||||||
endSeq=clock();
|
endSeq=clock();
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ int main (int __argc, char *__argv[])
|
||||||
peoPSOSelect<Indi> mig_selec(topology);
|
peoPSOSelect<Indi> mig_selec(topology);
|
||||||
peoWorstPositionReplacement<Indi> mig_replac;
|
peoWorstPositionReplacement<Indi> mig_replac;
|
||||||
|
|
||||||
// Specific implementation (peoData.h)
|
// Specific implementation (peoData.h)
|
||||||
|
|
||||||
eoContinuator<Indi> cont(mig_cont, pop);
|
eoContinuator<Indi> cont(mig_cont, pop);
|
||||||
eoSelector <Indi, peoPop<Indi> > mig_select (mig_selec,1,pop);
|
eoSelector <Indi, peoPop<Indi> > mig_select (mig_selec,1,pop);
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ int main (int __argc, char * * __argv)
|
||||||
{
|
{
|
||||||
pop.sort();
|
pop.sort();
|
||||||
std :: cout << "\nResult before the local search\n";
|
std :: cout << "\nResult before the local search\n";
|
||||||
for(unsigned i=0;i<pop.size();i++)
|
for (unsigned i=0;i<pop.size();i++)
|
||||||
std::cout<<"\n"<<pop[i].fitness();
|
std::cout<<"\n"<<pop[i].fitness();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,7 +108,7 @@ int main (int __argc, char * * __argv)
|
||||||
{
|
{
|
||||||
std :: cout << "\nResult after the local search\n";
|
std :: cout << "\nResult after the local search\n";
|
||||||
pop.sort();
|
pop.sort();
|
||||||
for(unsigned i=0;i<pop.size();i++)
|
for (unsigned i=0;i<pop.size();i++)
|
||||||
std::cout<<"\n"<<pop[i].fitness();
|
std::cout<<"\n"<<pop[i].fitness();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ int main (int __argc, char * * __argv)
|
||||||
{
|
{
|
||||||
std :: cout << "\nResult before the EA\n";
|
std :: cout << "\nResult before the EA\n";
|
||||||
pop.sort();
|
pop.sort();
|
||||||
for(unsigned i=0;i<pop.size();i++)
|
for (unsigned i=0;i<pop.size();i++)
|
||||||
std::cout<<"\n"<<pop[i].fitness();
|
std::cout<<"\n"<<pop[i].fitness();
|
||||||
std :: cout << "\n\n";
|
std :: cout << "\n\n";
|
||||||
}
|
}
|
||||||
|
|
@ -106,7 +106,7 @@ int main (int __argc, char * * __argv)
|
||||||
{
|
{
|
||||||
std :: cout << "\nResult after the EA\n";
|
std :: cout << "\nResult after the EA\n";
|
||||||
pop.sort();
|
pop.sort();
|
||||||
for(unsigned i=0;i<pop.size();i++)
|
for (unsigned i=0;i<pop.size();i++)
|
||||||
std::cout<<"\n"<<pop[i].fitness();
|
std::cout<<"\n"<<pop[i].fitness();
|
||||||
std :: cout << "\n\n";
|
std :: cout << "\n\n";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,13 +50,14 @@ double f (const Indi & _indi)
|
||||||
|
|
||||||
template <class EOT>
|
template <class EOT>
|
||||||
class eoResizerInit: public eoInit<EOT>
|
class eoResizerInit: public eoInit<EOT>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
typedef typename EOT::AtomType AtomType;
|
typedef typename EOT::AtomType AtomType;
|
||||||
|
|
||||||
eoResizerInit(unsigned _size)
|
eoResizerInit(unsigned _size)
|
||||||
: size(_size){}
|
: size(_size)
|
||||||
|
{}
|
||||||
|
|
||||||
virtual void operator()(EOT& chrom)
|
virtual void operator()(EOT& chrom)
|
||||||
{
|
{
|
||||||
|
|
@ -65,7 +66,7 @@ class eoResizerInit: public eoInit<EOT>
|
||||||
}
|
}
|
||||||
private :
|
private :
|
||||||
unsigned size;
|
unsigned size;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int main( int __argc, char** __argv )
|
int main( int __argc, char** __argv )
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,6 @@
|
||||||
DisplayBestRoute :: DisplayBestRoute (eoPop <Route> & __pop
|
DisplayBestRoute :: DisplayBestRoute (eoPop <Route> & __pop
|
||||||
) : pop (__pop)
|
) : pop (__pop)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DisplayBestRoute :: operator () ()
|
void DisplayBestRoute :: operator () ()
|
||||||
|
|
|
||||||
|
|
@ -41,8 +41,7 @@ PartRouteEval :: PartRouteEval (float __from,
|
||||||
float __to
|
float __to
|
||||||
) : from (__from),
|
) : from (__from),
|
||||||
to (__to)
|
to (__to)
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
void PartRouteEval :: operator () (Route & __route)
|
void PartRouteEval :: operator () (Route & __route)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue