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

This commit is contained in:
atantar 2007-11-29 11:21:00 +00:00
commit 239b181bc7
16 changed files with 352 additions and 57 deletions

View file

@ -1,3 +1,9 @@
SET(CMAKE_DEFAULT_BUILD_TYPE Debug CACHE STRING "Variable that stores the default CMake build type" FORCE)
SET(CMAKE_CXX_FLAGS "-O0 -g")
SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g")
SET(CMAKE_CXX_FLAGS_RELEASE "-O0 -g")
SET(CMAKE_CXX_FLAGS_MINSIZEREL "-O0 -g")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O0 -g")
######################################################################################
### 0) Set the compiler
@ -29,10 +35,11 @@ SET(LIBRARY_OUTPUT_PATH ${RMC_MPI_LIB_OUTPUT_PATH})
SET (RMC_MPI_SOURCES node.cpp
param.cpp
comm.cpp
coop.cpp
cooperative.cpp
mess.cpp
rmc.cpp
scheduler.cpp
synchron.cpp
worker.cpp
send.cpp
recv.cpp

View file

@ -57,6 +57,10 @@ void Cooperative :: send (Cooperative * __coop) {
// stop ();
}
void Cooperative :: synchronizeCoopEx () {
:: send (this, my_node -> rk_sched, SYNCHRONIZE_REQ_TAG);
}
Cooperative * getCooperative (COOP_ID __key) {
return dynamic_cast <Cooperative *> (getCommunicable (__key));
@ -67,3 +71,12 @@ void Cooperative :: notifySending () {
//getOwner -> setPassive ();
// resume ();
}
void Cooperative :: notifyReceiving () {
}
void Cooperative :: notifySendingSyncReq () {
}
void Cooperative :: notifySynchronized () {
}

View file

@ -40,8 +40,28 @@
#include <string>
#include <cassert>
#include "../../core/runner.h"
typedef int RANK_ID;
struct Node {
RANK_ID rk; /* Rank */
std :: string name; /* Host name */
unsigned num_workers; /* Number of parallel workers */
int rk_sched; /* rank of the scheduler */
std :: vector <RUNNER_ID> id_run; /* List of runner def. IDs */
std :: vector <RUNNER_ID> execution_id_run; /* List of runtime execution runner IDs */
};
extern Node * my_node;
extern bool isScheduleNode ();
extern int getNodeRank (); /* It gives the rank of the calling process */
extern RANK_ID getRankOfRunner (RUNNER_ID __key);
extern int getNumberOfNodes (); /* It gives the size of the environment (Total number of nodes) */
extern void collectiveCountOfRunners ( unsigned int* num_local_exec_runners, unsigned int* num_exec_runners );

View file

@ -38,13 +38,13 @@
#include "tags.h"
#include "worker.h"
#include "scheduler.h"
#include "synchron.h"
#include "mess.h"
#include "node.h"
#include "../../core/runner.h"
#include "../../core/cooperative.h"
#include "../../core/peo_debug.h"
void receiveMessages () {
cleanBuffers ();
@ -66,14 +66,30 @@ void receiveMessages () {
switch (tag) {
case RUNNER_STOP_TAG:
unpackTerminationOfRunner ();
wakeUpCommunicator ();
unpackTerminationOfRunner ();
break;
case SYNCHRONIZE_REQ_TAG:
unpackSynchronRequest ();
break;
case SYNCHRONIZED_TAG:
{
RUNNER_ID runner_id;
unpack (runner_id);
COOP_ID coop_id;
unpack (coop_id);
getCooperative (coop_id) -> notifySynchronized ();
break;
}
case COOP_TAG:
COOP_ID coop_id;
unpack (coop_id);
getCooperative (coop_id) -> unpack ();
getCooperative (coop_id) -> notifyReceiving ();
break;
case SCHED_REQUEST_TAG:

View file

@ -41,29 +41,18 @@
#include <vector>
#include <cassert>
#include "node.h"
#include "../../core/runner.h"
typedef int RANK_ID;
struct Node {
RANK_ID rk; /* Rank */
std :: string name; /* Host name */
unsigned num_workers; /* Number of parallel workers */
int rk_sched; /* rank of the scheduler */
std :: vector <RUNNER_ID> id_run; /* List of runner def. IDs */
std :: vector <RUNNER_ID> execution_id_run; /* List of runtime execution runner IDs */
};
extern std :: vector <Node> the_schema;
extern Node * my_node;
extern void loadSchema (const char * __filename);
extern RANK_ID getRankOfRunner (RUNNER_ID __key);
extern bool isScheduleNode ();
extern RANK_ID getRankOfRunner (RUNNER_ID __key);
extern std :: vector <Node> the_schema;
extern void loadSchema (const char * __filename);
#endif

View file

@ -131,6 +131,11 @@ void sendMessages () {
dynamic_cast <Cooperative *> (comm) -> notifySending ();
break;
case SYNCHRONIZE_REQ_TAG:
dynamic_cast <Cooperative *> (comm) -> packSynchronizeReq ();
dynamic_cast <Cooperative *> (comm) -> notifySendingSyncReq ();
break;
case SCHED_REQUEST_TAG:
dynamic_cast <Service *> (comm) -> packResourceRequest ();
dynamic_cast <Service *> (comm) -> notifySendingResourceRequest ();
@ -155,6 +160,7 @@ void sendMessages () {
sendMessageToAll (req.tag);
else
sendMessage (req.to, req.tag);
mess.pop ();
}

View file

@ -0,0 +1,123 @@
/*
* <scheduler.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sebastien Cahon, Alexandru-Adrian Tantar
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
* Contact: paradiseo-help@lists.gforge.inria.fr
*
*/
#include <queue>
#include "synchron.h"
#include "../../core/messaging.h"
#include "node.h"
#include "tags.h"
#include "mess.h"
static SYNC syncRunners; /* Runners to be synchronized */
extern void wakeUpCommunicator();
extern RANK_ID getRankOfRunner (RUNNER_ID __key);
/* Initializing the list of runners to be synchronized */
void initSynchron () {
syncRunners = SYNC();
}
/* packing a synchronization request from a service */
void packSynchronRequest ( const std :: vector <Cooperative *>& coops ) {
/* Number of coops to synchronize */
pack( (unsigned)( coops.size() ) );
/* Coops to synchronize */
for (unsigned i = 0; i < coops.size(); i ++) {
pack( coops[ i ]->getOwner()->getDefinitionID() );
pack( coops[ i ]->getKey() );
}
}
/* Processing a synchronization request from a service */
void unpackSynchronRequest () {
unsigned req_num_entries;
unpack (req_num_entries);
/* Creating a sync vector + adding the created entry */
std::pair< SYNC_RUNNERS, unsigned > req_sync;
/* Adding entries for each of the runners to be synchronized */
SyncEntry req_entry;
for (unsigned i = 0; i < req_num_entries; i ++) {
unpack (req_entry.runner);
unpack (req_entry.coop);
req_sync.first.push_back (req_entry);
}
/* Looking for the sync vector */
SYNC::iterator sync_it = syncRunners.find (req_sync);
/* The vector does not exist - insert a new sync */
if (sync_it == syncRunners.end ()) {
req_sync.second = 1;
syncRunners.insert (req_sync);
}
else {
/* The vector exists - updating the entry */
std::pair< SYNC_RUNNERS, unsigned >& sync_req_entry = const_cast< std::pair< SYNC_RUNNERS, unsigned >& > (*sync_it);
sync_req_entry.second ++;
/* All the runners to be synchronized sent the SYNC_REQUEST signal */
if (sync_req_entry.second == sync_req_entry.first.size()) {
/* Remove the entry */
syncRunners.erase (sync_it);
/* Send SYNCHRONIZED signals to all the coop objects */
for (unsigned i = 0; i < req_sync.first.size(); i ++) {
initMessage ();
pack (req_sync.first [i].runner);
pack (req_sync.first [i].coop);
RANK_ID dest_rank = getRankOfRunner (req_sync.first [i].runner);
sendMessage (dest_rank, SYNCHRONIZED_TAG);
}
}
}
}

View file

@ -0,0 +1,85 @@
/*
* <synchron.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Sebastien Cahon, Alexandru-Adrian Tantar
*
* This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL
* license as circulated by CEA, CNRS and INRIA at the following URL
* "http://www.cecill.info".
*
* As a counterpart to the access to the source code and rights to copy,
* modify and redistribute granted by the license, users are provided only
* with a limited warranty and the software's author, the holder of the
* economic rights, and the successive licensors have only limited liability.
*
* In this respect, the user's attention is drawn to the risks associated
* with loading, using, modifying and/or developing or reproducing the
* software by the user in light of its specific status of free software,
* that may mean that it is complicated to manipulate, and that also
* therefore means that it is reserved for developers and experienced
* professionals having in-depth computer knowledge. Users are therefore
* encouraged to load and test the software's suitability as regards their
* requirements in conditions enabling the security of their systems and/or
* data to be ensured and, more generally, to use and operate it in the
* same conditions as regards security.
* The fact that you are presently reading this means that you have had
* knowledge of the CeCILL license and that you accept its terms.
*
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
* Contact: paradiseo-help@lists.gforge.inria.fr
*
*/
#ifndef __synchron_h
#define __synchron_h
#include <set>
#include <vector>
#include <utility>
#include "../../core/runner.h"
#include "../../core/cooperative.h"
struct SyncEntry {
RUNNER_ID runner;
COOP_ID coop;
};
struct SyncCompare {
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 >& syncB = B.first;
if ( syncA.size() == syncB.size() ) {
std::vector< SyncEntry >::const_iterator itA = syncA.begin();
std::vector< SyncEntry >::const_iterator itB = syncB.begin();
while ( (*itA).runner < (*itB).runner && itA != syncA.end() ) { itA++; itB++; }
return itA == syncA.end();
}
return syncA.size() < syncB.size();
}
};
typedef std::vector< SyncEntry > SYNC_RUNNERS;
typedef std::set< std::pair< SYNC_RUNNERS, unsigned >, SyncCompare > SYNC;
/* Initializing the list of runners to be synchronized */
extern void initSynchron ();
/* packing a synchronization request from a service */
extern void packSynchronRequest ( const std :: vector <Cooperative *>& coops );
/* Processing a synchronization request from a service */
extern void unpackSynchronRequest ();
#endif

View file

@ -48,4 +48,7 @@
#define TASK_RESULT_TAG 19
#define TASK_DONE_TAG 20
#define SYNCHRONIZE_REQ_TAG 1000
#define SYNCHRONIZED_TAG 1001
#endif