modif cmake configuration
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1277 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
1432128e88
commit
350bdfc7de
29 changed files with 144616 additions and 0 deletions
9
branches/cmakemodif/paradiseo-peo/src/rmc/CMakeLists.txt
Normal file
9
branches/cmakemodif/paradiseo-peo/src/rmc/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
|
||||
|
||||
######################################################################################
|
||||
### 1) Where must cmake go now ?
|
||||
######################################################################################
|
||||
|
||||
SUBDIRS(mpi)
|
||||
|
||||
######################################################################################
|
||||
57
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/CMakeLists.txt
Normal file
57
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
SET(CMAKE_CXX_FLAGS_RELEASE "-O0 -g")
|
||||
|
||||
######################################################################################
|
||||
### 0) Set the compiler
|
||||
######################################################################################
|
||||
|
||||
SET (CMAKE_CXX_COMPILER mpicxx)
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 1) Include the sources
|
||||
######################################################################################
|
||||
|
||||
INCLUDE_DIRECTORIES(${EO_SRC_DIR}/src)
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${XML2_CFLAGS}")
|
||||
|
||||
######################################################################################
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 2) Define your target(s): just the rmc_mpi library here
|
||||
######################################################################################
|
||||
|
||||
SET(RMC_MPI_LIB_OUTPUT_PATH ${ParadisEO-PEO_BINARY_DIR}/lib)
|
||||
SET(LIBRARY_OUTPUT_PATH ${RMC_MPI_LIB_OUTPUT_PATH})
|
||||
|
||||
SET (RMC_MPI_SOURCES node.cpp
|
||||
param.cpp
|
||||
comm.cpp
|
||||
cooperative.cpp
|
||||
mess.cpp
|
||||
rmc.cpp
|
||||
scheduler.cpp
|
||||
synchron.cpp
|
||||
worker.cpp
|
||||
send.cpp
|
||||
recv.cpp
|
||||
xml_parser.cpp
|
||||
schema.cpp
|
||||
runner.cpp
|
||||
service.cpp)
|
||||
|
||||
ADD_LIBRARY(rmc_mpi STATIC ${RMC_MPI_SOURCES})
|
||||
ADD_DEPENDENCIES(rmc_mpi peo)
|
||||
######################################################################################
|
||||
|
||||
|
||||
######################################################################################
|
||||
### 3) Optionnal: define your lib version:
|
||||
######################################################################################
|
||||
|
||||
SET(RMC_MPI_VERSION ${GLOBAL_VERSION})
|
||||
SET_TARGET_PROPERTIES(rmc_mpi PROPERTIES VERSION "${RMC_MPI_VERSION}")
|
||||
######################################################################################
|
||||
|
||||
112
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/comm.cpp
Normal file
112
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/comm.cpp
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
/*
|
||||
* <comm.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape
|
||||
*
|
||||
* 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 <mpi.h>
|
||||
|
||||
#include "comm.h"
|
||||
#include "mess.h"
|
||||
#include "node.h"
|
||||
#include "param.h"
|
||||
#include "../../core/peo_debug.h"
|
||||
#include "../../core/runner.h"
|
||||
#include "send.h"
|
||||
#include "recv.h"
|
||||
#include "scheduler.h"
|
||||
|
||||
static sem_t sem_comm_init;
|
||||
|
||||
static Communicator * the_thread;
|
||||
|
||||
|
||||
Communicator :: Communicator (int * __argc, char * * * __argv)
|
||||
{
|
||||
|
||||
the_thread = this;
|
||||
initNode (__argc, __argv);
|
||||
loadRMCParameters (* __argc, * __argv);
|
||||
|
||||
sem_post (& sem_comm_init);
|
||||
}
|
||||
|
||||
void Communicator :: start ()
|
||||
{
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
||||
/* Zzz Zzz Zzz :-))) */
|
||||
sleep ();
|
||||
|
||||
sendMessages ();
|
||||
|
||||
if (! atLeastOneActiveRunner () && ! atLeastOneActiveThread() && allResourcesFree ())
|
||||
break;
|
||||
|
||||
receiveMessages ();
|
||||
}
|
||||
|
||||
waitBuffers ();
|
||||
printDebugMessage ("finalizing");
|
||||
|
||||
//synchronizeNodes ();
|
||||
}
|
||||
|
||||
void initCommunication ()
|
||||
{
|
||||
|
||||
static bool initializedSemaphore = false;
|
||||
|
||||
if (initializedSemaphore)
|
||||
{
|
||||
sem_destroy(& sem_comm_init);
|
||||
}
|
||||
|
||||
sem_init (& sem_comm_init, 0, 0);
|
||||
initializedSemaphore = true;
|
||||
}
|
||||
|
||||
void waitNodeInitialization ()
|
||||
{
|
||||
|
||||
sem_wait (& sem_comm_init);
|
||||
}
|
||||
|
||||
void wakeUpCommunicator ()
|
||||
{
|
||||
|
||||
the_thread -> wakeUp ();
|
||||
}
|
||||
60
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/comm.h
Normal file
60
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/comm.h
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* <comm.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape
|
||||
*
|
||||
* 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 __comm_mpi_h
|
||||
#define __comm_mpi_h
|
||||
|
||||
#include "../../core/communicable.h"
|
||||
#include "../../core/reac_thread.h"
|
||||
|
||||
class Communicator : public ReactiveThread
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
/* Ctor */
|
||||
Communicator (int * __argc, char * * * __argv);
|
||||
|
||||
void start ();
|
||||
};
|
||||
|
||||
extern void initCommunication ();
|
||||
|
||||
extern void waitNodeInitialization ();
|
||||
|
||||
extern void wakeUpCommunicator ();
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* <coop.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape
|
||||
*
|
||||
* 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 "../../core/cooperative.h"
|
||||
#include "send.h"
|
||||
#include "tags.h"
|
||||
#include "schema.h"
|
||||
#include "mess.h"
|
||||
#include "../../core/peo_debug.h"
|
||||
|
||||
Runner * Cooperative :: getOwner ()
|
||||
{
|
||||
|
||||
return owner;
|
||||
}
|
||||
|
||||
void Cooperative :: setOwner (Runner & __runner)
|
||||
{
|
||||
|
||||
owner = & __runner;
|
||||
}
|
||||
|
||||
void Cooperative :: send (Cooperative * __coop)
|
||||
{
|
||||
|
||||
:: send (this, getRankOfRunner (__coop -> getOwner () -> getDefinitionID ()), COOP_TAG);
|
||||
// stop ();
|
||||
}
|
||||
|
||||
void Cooperative :: synchronizeCoopEx ()
|
||||
{
|
||||
:: send (this, my_node -> rk_sched, SYNCHRONIZE_REQ_TAG);
|
||||
}
|
||||
|
||||
Cooperative * getCooperative (COOP_ID __key)
|
||||
{
|
||||
|
||||
return dynamic_cast <Cooperative *> (getCommunicable (__key));
|
||||
}
|
||||
|
||||
void Cooperative :: notifySending ()
|
||||
{
|
||||
|
||||
//getOwner -> setPassive ();
|
||||
// resume ();
|
||||
}
|
||||
|
||||
void Cooperative :: notifyReceiving ()
|
||||
{}
|
||||
|
||||
void Cooperative :: notifySendingSyncReq ()
|
||||
{}
|
||||
|
||||
void Cooperative :: notifySynchronized ()
|
||||
{}
|
||||
345
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/mess.cpp
Normal file
345
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/mess.cpp
Normal file
|
|
@ -0,0 +1,345 @@
|
|||
/*
|
||||
* <mess.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape
|
||||
*
|
||||
* 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 <mpi.h>
|
||||
#include <vector>
|
||||
|
||||
#include "mess.h"
|
||||
#include "../../core/peo_debug.h"
|
||||
#include "node.h"
|
||||
|
||||
#define MPI_BUF_SIZE 1024*512
|
||||
|
||||
static char mpi_buf [MPI_BUF_SIZE];
|
||||
|
||||
static int pos_buf;
|
||||
|
||||
static std :: vector <char *> act_buf; /* Active buffers */
|
||||
|
||||
static std :: vector <MPI_Request *> act_req; /* Active requests */
|
||||
|
||||
void initBuffers ()
|
||||
{
|
||||
|
||||
pos_buf = 0;
|
||||
act_buf.clear ();
|
||||
act_req.clear ();
|
||||
}
|
||||
|
||||
void cleanBuffers ()
|
||||
{
|
||||
|
||||
for (unsigned i = 0; i < act_req.size ();)
|
||||
{
|
||||
|
||||
MPI_Status stat ;
|
||||
int flag ;
|
||||
|
||||
MPI_Test (act_req [i], & flag, & stat) ;
|
||||
if (flag)
|
||||
{
|
||||
|
||||
delete[] act_buf [i] ;
|
||||
delete act_req [i] ;
|
||||
|
||||
act_buf [i] = act_buf.back () ;
|
||||
act_buf.pop_back () ;
|
||||
|
||||
act_req [i] = act_req.back () ;
|
||||
act_req.pop_back () ;
|
||||
}
|
||||
else
|
||||
i ++;
|
||||
}
|
||||
}
|
||||
|
||||
void waitBuffers ()
|
||||
{
|
||||
|
||||
// printDebugMessage ("waiting the termination of the asynchronous operations to complete");
|
||||
|
||||
for (unsigned i = 0; i < act_req.size (); i ++)
|
||||
{
|
||||
|
||||
MPI_Status stat ;
|
||||
|
||||
MPI_Wait (act_req [i], & stat) ;
|
||||
|
||||
delete[] act_buf [i] ;
|
||||
delete act_req [i] ;
|
||||
}
|
||||
}
|
||||
|
||||
bool probeMessage (int & __src, int & __tag)
|
||||
{
|
||||
|
||||
int flag;
|
||||
|
||||
MPI_Status stat;
|
||||
|
||||
MPI_Iprobe (MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, & flag, & stat);
|
||||
|
||||
__src = stat.MPI_SOURCE;
|
||||
__tag = stat.MPI_TAG;
|
||||
|
||||
return flag;
|
||||
}
|
||||
|
||||
void waitMessage ()
|
||||
{
|
||||
|
||||
MPI_Status stat;
|
||||
|
||||
MPI_Probe (MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, & stat);
|
||||
}
|
||||
|
||||
void initMessage ()
|
||||
{
|
||||
|
||||
pos_buf = 0;
|
||||
}
|
||||
|
||||
void sendMessage (int __to, int __tag)
|
||||
{
|
||||
|
||||
cleanBuffers ();
|
||||
act_buf.push_back (new char [pos_buf]);
|
||||
act_req.push_back (new MPI_Request);
|
||||
memcpy (act_buf.back (), mpi_buf, pos_buf);
|
||||
MPI_Isend (act_buf.back (), pos_buf, MPI_PACKED, __to, __tag, MPI_COMM_WORLD, act_req.back ());
|
||||
}
|
||||
|
||||
void sendMessageToAll (int __tag)
|
||||
{
|
||||
|
||||
for (int i = 0; i < getNumberOfNodes (); i ++)
|
||||
sendMessage (i, __tag);
|
||||
}
|
||||
|
||||
void receiveMessage (int __from, int __tag)
|
||||
{
|
||||
|
||||
MPI_Status stat;
|
||||
MPI_Request req;
|
||||
|
||||
MPI_Irecv (mpi_buf, MPI_BUF_SIZE, MPI_PACKED, __from, __tag, MPI_COMM_WORLD, & req);
|
||||
MPI_Wait (& req, & stat);
|
||||
}
|
||||
|
||||
void synchronizeNodes ()
|
||||
{
|
||||
|
||||
MPI_Barrier ( MPI_COMM_WORLD );
|
||||
}
|
||||
|
||||
/* Char */
|
||||
void pack (const char & __c)
|
||||
{
|
||||
|
||||
MPI_Pack ((void *) & __c, 1, MPI_CHAR, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
||||
}
|
||||
|
||||
/* Boolean */
|
||||
void pack (const bool & __b, int __nitem)
|
||||
{
|
||||
|
||||
MPI_Pack ((void *) & __b, __nitem, MPI_INT, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
||||
}
|
||||
|
||||
/* Float */
|
||||
void pack (const float & __f, int __nitem)
|
||||
{
|
||||
|
||||
MPI_Pack ((void *) & __f, __nitem, MPI_FLOAT, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
||||
}
|
||||
|
||||
/* Double */
|
||||
void pack (const double & __d, int __nitem)
|
||||
{
|
||||
|
||||
MPI_Pack ((void *) & __d, __nitem, MPI_DOUBLE, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
||||
}
|
||||
|
||||
/* Integer */
|
||||
void pack (const int & __i, int __nitem)
|
||||
{
|
||||
|
||||
MPI_Pack ((void *) & __i, __nitem, MPI_INT, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
||||
}
|
||||
|
||||
/* Unsigned int. */
|
||||
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);
|
||||
}
|
||||
|
||||
/* Short int. */
|
||||
void pack (const short & __sh, int __nitem)
|
||||
{
|
||||
|
||||
MPI_Pack ((void *) & __sh, __nitem, MPI_SHORT, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
||||
}
|
||||
|
||||
/* Unsigned short */
|
||||
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);
|
||||
}
|
||||
|
||||
/* Long */
|
||||
void pack (const long & __l, int __nitem)
|
||||
{
|
||||
|
||||
MPI_Pack ((void *) & __l, __nitem, MPI_LONG, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
|
||||
}
|
||||
|
||||
/* Unsigned long */
|
||||
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);
|
||||
}
|
||||
|
||||
/* String */
|
||||
void pack (const char * __str)
|
||||
{
|
||||
|
||||
int len = strlen (__str) + 1;
|
||||
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);
|
||||
}
|
||||
|
||||
void pack (const std::string & __str)
|
||||
{
|
||||
|
||||
size_t size = __str.size() + 1;
|
||||
char * buffer = new char[ size ];
|
||||
strncpy( buffer, __str.c_str(), size );
|
||||
pack (buffer);
|
||||
delete [] buffer;
|
||||
}
|
||||
|
||||
/* Char */
|
||||
void unpack (char & __c)
|
||||
{
|
||||
|
||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __c, 1, MPI_CHAR, MPI_COMM_WORLD);
|
||||
}
|
||||
|
||||
/* Boolean */
|
||||
extern void unpack (bool & __b, int __nitem )
|
||||
{
|
||||
|
||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __b, __nitem, MPI_INT, MPI_COMM_WORLD);
|
||||
}
|
||||
|
||||
/* Float */
|
||||
void unpack (float & __f, int __nitem)
|
||||
{
|
||||
|
||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __f, __nitem, MPI_FLOAT, MPI_COMM_WORLD);
|
||||
}
|
||||
|
||||
/* Double */
|
||||
void unpack (double & __d, int __nitem)
|
||||
{
|
||||
|
||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __d, __nitem, MPI_DOUBLE, MPI_COMM_WORLD);
|
||||
}
|
||||
|
||||
/* Integer */
|
||||
void unpack (int & __i, int __nitem)
|
||||
{
|
||||
|
||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __i, __nitem, MPI_INT, MPI_COMM_WORLD);
|
||||
}
|
||||
|
||||
/* Unsigned int. */
|
||||
void unpack (unsigned int & __ui, int __nitem)
|
||||
{
|
||||
|
||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __ui, __nitem, MPI_UNSIGNED, MPI_COMM_WORLD);
|
||||
}
|
||||
|
||||
/* Short int. */
|
||||
void unpack (short & __sh, int __nitem)
|
||||
{
|
||||
|
||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __sh, __nitem, MPI_SHORT, MPI_COMM_WORLD);
|
||||
}
|
||||
|
||||
/* Unsigned short */
|
||||
void unpack (unsigned short & __ush, int __nitem)
|
||||
{
|
||||
|
||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __ush, __nitem, MPI_UNSIGNED_SHORT, MPI_COMM_WORLD);
|
||||
}
|
||||
|
||||
/* Long */
|
||||
void unpack (long & __l, int __nitem)
|
||||
{
|
||||
|
||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __l, __nitem, MPI_LONG, MPI_COMM_WORLD);
|
||||
}
|
||||
|
||||
/* Unsigned long */
|
||||
void unpack (unsigned long & __ul, int __nitem)
|
||||
{
|
||||
|
||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __ul, __nitem, MPI_UNSIGNED_LONG, MPI_COMM_WORLD);
|
||||
}
|
||||
|
||||
/* String */
|
||||
void unpack (char * __str)
|
||||
{
|
||||
|
||||
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, __str, len, MPI_CHAR, MPI_COMM_WORLD);
|
||||
}
|
||||
void unpack (std::string & __str)
|
||||
{
|
||||
|
||||
char * buffer;
|
||||
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, buffer, len, MPI_CHAR, MPI_COMM_WORLD);
|
||||
__str.assign( buffer );
|
||||
|
||||
}
|
||||
|
||||
64
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/mess.h
Normal file
64
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/mess.h
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* <mess.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape
|
||||
*
|
||||
* 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 __mess_rmc_h
|
||||
#define __mess_rmc_h
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "../../core/messaging.h"
|
||||
|
||||
extern void initMessage ();
|
||||
|
||||
extern void sendMessage (int __to, int __tag);
|
||||
|
||||
extern void sendMessageToAll (int __tag);
|
||||
|
||||
extern void receiveMessage (int __from, int __tag);
|
||||
|
||||
extern void initBuffers ();
|
||||
|
||||
extern void cleanBuffers ();
|
||||
|
||||
extern void waitBuffers ();
|
||||
|
||||
extern bool probeMessage (int & __src, int & __tag);
|
||||
|
||||
extern void waitMessage ();
|
||||
|
||||
extern void synchronizeNodes ();
|
||||
|
||||
#endif
|
||||
155
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/node.cpp
Normal file
155
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/node.cpp
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* <node.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape
|
||||
*
|
||||
* 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 <mpi.h>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <cassert>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "mess.h"
|
||||
|
||||
|
||||
class MPIThreadedEnv
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
static void init ( int * __argc, char * * * __argv )
|
||||
{
|
||||
|
||||
static MPIThreadedEnv mpiThreadedEnv( __argc, __argv );
|
||||
}
|
||||
|
||||
static void finalize ()
|
||||
{
|
||||
|
||||
static bool finalizedEnvironment = false;
|
||||
|
||||
if (! finalizedEnvironment )
|
||||
{
|
||||
|
||||
MPI_Finalize ();
|
||||
finalizedEnvironment = true;
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/* No instance of this class can be created outside its domain! */
|
||||
MPIThreadedEnv ( int * __argc, char * * * __argv )
|
||||
{
|
||||
|
||||
static bool MPIThreadedEnvInitialized = false;
|
||||
int provided = 1;
|
||||
|
||||
if (! MPIThreadedEnvInitialized)
|
||||
{
|
||||
|
||||
MPI_Init_thread (__argc, __argv, MPI_THREAD_FUNNELED, & provided);
|
||||
|
||||
assert (provided == MPI_THREAD_FUNNELED); /* The MPI implementation must be multi-threaded.
|
||||
Yet, only one thread performs the comm.
|
||||
operations */
|
||||
MPIThreadedEnvInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
~MPIThreadedEnv()
|
||||
{
|
||||
|
||||
finalize ();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
static int rk, sz; /* Rank & size */
|
||||
|
||||
static std :: map <std :: string, int> name_to_rk;
|
||||
|
||||
static std :: vector <std :: string> rk_to_name;
|
||||
|
||||
|
||||
int getNodeRank ()
|
||||
{
|
||||
|
||||
return rk;
|
||||
}
|
||||
|
||||
int getNumberOfNodes ()
|
||||
{
|
||||
|
||||
return sz;
|
||||
}
|
||||
|
||||
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 );
|
||||
}
|
||||
|
||||
int getRankFromName (const std :: string & __name)
|
||||
{
|
||||
|
||||
return atoi (__name.c_str ());
|
||||
}
|
||||
|
||||
void initNode (int * __argc, char * * * __argv)
|
||||
{
|
||||
|
||||
rk_to_name.clear ();
|
||||
name_to_rk.clear ();
|
||||
|
||||
MPIThreadedEnv :: init ( __argc, __argv );
|
||||
//synchronizeNodes();
|
||||
|
||||
MPI_Comm_rank (MPI_COMM_WORLD, & rk); /* Who ? */
|
||||
MPI_Comm_size (MPI_COMM_WORLD, & sz); /* How many ? */
|
||||
|
||||
char names [sz] [MPI_MAX_PROCESSOR_NAME];
|
||||
int len;
|
||||
|
||||
/* Processor names */
|
||||
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 */
|
||||
|
||||
for (int i = 0; i < sz; i ++)
|
||||
{
|
||||
rk_to_name.push_back (names [i]);
|
||||
name_to_rk [names [i]] = i;
|
||||
}
|
||||
}
|
||||
75
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/node.h
Normal file
75
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/node.h
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* <node.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape
|
||||
*
|
||||
* 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 __node_h
|
||||
#define __node_h
|
||||
|
||||
#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 );
|
||||
|
||||
extern int getRankFromName (const std :: string & __name); /* It gives the rank of the process
|
||||
expressed by its name */
|
||||
|
||||
extern void initNode (int * __argc, char * * * __argv);
|
||||
|
||||
#endif
|
||||
50
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/param.cpp
Normal file
50
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/param.cpp
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* <param.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape
|
||||
*
|
||||
* 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 <utils/eoParser.h>
|
||||
|
||||
#include "schema.h"
|
||||
|
||||
void loadRMCParameters (int & __argc, char * * & __argv)
|
||||
{
|
||||
|
||||
eoParser parser (__argc, __argv);
|
||||
|
||||
/* Schema */
|
||||
eoValueParam <std :: string> schema_param ("schema.xml", "schema", "?");
|
||||
parser.processParam (schema_param);
|
||||
loadSchema (schema_param.value ().c_str ());
|
||||
}
|
||||
42
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/param.h
Normal file
42
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/param.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* <param.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape
|
||||
*
|
||||
* 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 __rmc_param_h
|
||||
#define __rmc_param_h
|
||||
|
||||
extern void loadRMCParameters (int & __argc, char * * & __argv);
|
||||
|
||||
#endif
|
||||
156
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/recv.cpp
Normal file
156
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/recv.cpp
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
/*
|
||||
* <recv.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape
|
||||
*
|
||||
* 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 "comm.h"
|
||||
#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 ();
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
if (! atLeastOneActiveThread ())
|
||||
{
|
||||
|
||||
waitMessage ();
|
||||
}
|
||||
|
||||
int src, tag;
|
||||
|
||||
while (probeMessage (src, tag))
|
||||
{
|
||||
|
||||
receiveMessage (src, tag);
|
||||
initMessage ();
|
||||
|
||||
switch (tag)
|
||||
{
|
||||
|
||||
case RUNNER_STOP_TAG:
|
||||
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:
|
||||
unpackResourceRequest ();
|
||||
break;
|
||||
|
||||
case SCHED_RESULT_TAG:
|
||||
{
|
||||
/* Unpacking the resource */
|
||||
SERVICE_ID serv_id;
|
||||
unpack (serv_id);
|
||||
Service * serv = getService (serv_id);
|
||||
int dest;
|
||||
unpack (dest);
|
||||
WORKER_ID worker_id;
|
||||
unpack (worker_id);
|
||||
|
||||
/* Going back ... */
|
||||
initMessage ();
|
||||
pack (worker_id);
|
||||
pack (serv_id);
|
||||
serv -> packData ();
|
||||
serv -> notifySendingData ();
|
||||
sendMessage (dest, TASK_DATA_TAG);
|
||||
break;
|
||||
}
|
||||
|
||||
case TASK_DATA_TAG:
|
||||
{
|
||||
WORKER_ID worker_id;
|
||||
unpack (worker_id);
|
||||
Worker * worker = getWorker (worker_id);
|
||||
worker -> setSource (src);
|
||||
worker -> unpackData ();
|
||||
worker -> wakeUp ();
|
||||
break;
|
||||
}
|
||||
|
||||
case TASK_RESULT_TAG:
|
||||
{
|
||||
SERVICE_ID serv_id;
|
||||
unpack (serv_id);
|
||||
Service * serv = getService (serv_id);
|
||||
serv -> unpackResult ();
|
||||
break;
|
||||
}
|
||||
|
||||
case TASK_DONE_TAG:
|
||||
unpackTaskDone ();
|
||||
break;
|
||||
|
||||
default:
|
||||
;
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
while ( ! atLeastOneActiveThread () && atLeastOneActiveRunner () /*&& ! allResourcesFree ()*/ );
|
||||
}
|
||||
42
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/recv.h
Normal file
42
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/recv.h
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* <recv.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape
|
||||
*
|
||||
* 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 __recv_h
|
||||
#define __recv_h
|
||||
|
||||
extern void receiveMessages ();
|
||||
|
||||
#endif
|
||||
91
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/rmc.cpp
Normal file
91
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/rmc.cpp
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
* <rmc.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape
|
||||
*
|
||||
* 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 "send.h"
|
||||
#include "worker.h"
|
||||
#include "schema.h"
|
||||
#include "comm.h"
|
||||
#include "scheduler.h"
|
||||
#include "../../core/peo_debug.h"
|
||||
|
||||
static std :: vector <pthread_t *> ll_threads; /* Low level threads */
|
||||
static std :: vector <Worker *> worker_threads; /* Worker threads */
|
||||
static Communicator* communicator_thread = NULL; /* Communicator thread */
|
||||
|
||||
|
||||
void runRMC ()
|
||||
{
|
||||
|
||||
/* Worker(s) ? */
|
||||
for (unsigned i = 0; i < my_node -> num_workers; i ++)
|
||||
{
|
||||
worker_threads.push_back (new Worker);
|
||||
addThread (worker_threads.back(), ll_threads);
|
||||
}
|
||||
|
||||
wakeUpCommunicator ();
|
||||
}
|
||||
|
||||
void initRMC (int & __argc, char * * & __argv)
|
||||
{
|
||||
|
||||
/* Communication */
|
||||
initCommunication ();
|
||||
communicator_thread = new Communicator (& __argc, & __argv);
|
||||
addThread (communicator_thread, ll_threads);
|
||||
waitNodeInitialization ();
|
||||
initSending ();
|
||||
|
||||
/* Scheduler */
|
||||
if (isScheduleNode ())
|
||||
initScheduler ();
|
||||
}
|
||||
|
||||
void finalizeRMC ()
|
||||
{
|
||||
|
||||
printDebugMessage ("before join threads RMC");
|
||||
|
||||
joinThreads (ll_threads);
|
||||
for (unsigned i = 0; i < worker_threads.size(); i++ )
|
||||
{
|
||||
delete worker_threads [i];
|
||||
}
|
||||
worker_threads.clear ();
|
||||
delete communicator_thread;
|
||||
|
||||
printDebugMessage ("after join threads RMC");
|
||||
}
|
||||
65
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/runner.cpp
Normal file
65
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/runner.cpp
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* <runner.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape
|
||||
*
|
||||
* 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 "../../core/messaging.h"
|
||||
#include "../../core/runner.h"
|
||||
#include "node.h"
|
||||
#include "mess.h"
|
||||
#include "send.h"
|
||||
#include "tags.h"
|
||||
#include "schema.h"
|
||||
|
||||
|
||||
bool Runner :: isAssignedLocally ()
|
||||
{
|
||||
|
||||
for (unsigned i = 0; i < my_node -> id_run.size (); i ++)
|
||||
if (my_node -> id_run [i] == def_id)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void Runner :: terminate ()
|
||||
{
|
||||
|
||||
sendToAll (this, RUNNER_STOP_TAG);
|
||||
}
|
||||
|
||||
void Runner :: packTermination ()
|
||||
{
|
||||
|
||||
pack (def_id);
|
||||
}
|
||||
124
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/scheduler.cpp
Normal file
124
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/scheduler.cpp
Normal file
|
|
@ -0,0 +1,124 @@
|
|||
/*
|
||||
* <scheduler.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape
|
||||
*
|
||||
* 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 "scheduler.h"
|
||||
#include "tags.h"
|
||||
#include "mess.h"
|
||||
#include "../../core/peo_debug.h"
|
||||
|
||||
static std :: queue <SCHED_RESOURCE> resources; /* Free resources */
|
||||
|
||||
static std :: queue <SCHED_REQUEST> requests; /* Requests */
|
||||
|
||||
static unsigned initNumberOfRes = 0;
|
||||
|
||||
extern void wakeUpCommunicator();
|
||||
|
||||
void initScheduler ()
|
||||
{
|
||||
|
||||
resources = std :: queue <SCHED_RESOURCE> ();
|
||||
requests = std :: queue <SCHED_REQUEST> ();
|
||||
initNumberOfRes = 0;
|
||||
|
||||
for (unsigned i = 0; i < the_schema.size (); i ++)
|
||||
{
|
||||
|
||||
const Node & node = the_schema [i];
|
||||
|
||||
if (node.rk_sched == my_node -> rk)
|
||||
for (unsigned j = 0; j < node.num_workers; j ++)
|
||||
resources.push (std :: pair <RANK_ID, WORKER_ID> (i, j + 1));
|
||||
}
|
||||
initNumberOfRes = resources.size ();
|
||||
}
|
||||
|
||||
bool allResourcesFree ()
|
||||
{
|
||||
return resources.size () == initNumberOfRes;
|
||||
}
|
||||
|
||||
unsigned numResourcesFree ()
|
||||
{
|
||||
return resources.size ();
|
||||
}
|
||||
|
||||
static void update ()
|
||||
{
|
||||
|
||||
unsigned num_alloc = std :: min (resources.size (), requests.size ());
|
||||
|
||||
for (unsigned i = 0; i < num_alloc; i ++)
|
||||
{
|
||||
|
||||
SCHED_REQUEST req = requests.front ();
|
||||
requests.pop ();
|
||||
|
||||
SCHED_RESOURCE res = resources.front ();
|
||||
resources.pop ();
|
||||
|
||||
printDebugMessage ("allocating a resource.");
|
||||
initMessage ();
|
||||
pack (req.second);
|
||||
pack (res);
|
||||
sendMessage (req.first, SCHED_RESULT_TAG);
|
||||
}
|
||||
}
|
||||
|
||||
void unpackResourceRequest ()
|
||||
{
|
||||
|
||||
printDebugMessage ("queuing a resource request.");
|
||||
SCHED_REQUEST req;
|
||||
unpack (req);
|
||||
requests.push (req);
|
||||
update ();
|
||||
}
|
||||
|
||||
void unpackTaskDone ()
|
||||
{
|
||||
|
||||
printDebugMessage ("I'm notified a worker is now idle.");
|
||||
SCHED_RESOURCE res;
|
||||
unpack (res);
|
||||
resources.push (res);
|
||||
if (resources.size () == initNumberOfRes)
|
||||
printDebugMessage ("all the resources are now free.");
|
||||
update ();
|
||||
wakeUpCommunicator();
|
||||
}
|
||||
62
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/scheduler.h
Normal file
62
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/scheduler.h
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* <scheduler.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape
|
||||
*
|
||||
* 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 __scheduler_h
|
||||
#define __scheduler_h
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "schema.h"
|
||||
#include "worker.h"
|
||||
|
||||
typedef std :: pair <RANK_ID, WORKER_ID> SCHED_RESOURCE;
|
||||
|
||||
typedef std :: pair <RANK_ID, SERVICE_ID> SCHED_REQUEST;
|
||||
|
||||
/* Initializing the list of available workers */
|
||||
extern void initScheduler ();
|
||||
|
||||
/* Processing a resource request from a service */
|
||||
extern void unpackResourceRequest ();
|
||||
|
||||
/* Being known a worker is now idle :-) */
|
||||
extern void unpackTaskDone ();
|
||||
|
||||
extern bool allResourcesFree ();
|
||||
|
||||
extern unsigned numResourcesFree ();
|
||||
|
||||
#endif
|
||||
207
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/schema.cpp
Normal file
207
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/schema.cpp
Normal file
|
|
@ -0,0 +1,207 @@
|
|||
/*
|
||||
* <schema.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape
|
||||
*
|
||||
* 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 <set>
|
||||
#include <cassert>
|
||||
|
||||
#include "schema.h"
|
||||
#include "xml_parser.h"
|
||||
#include "comm.h"
|
||||
#include "node.h"
|
||||
#include "../../core/peo_debug.h"
|
||||
|
||||
|
||||
std :: vector <Node> the_schema;
|
||||
|
||||
Node * my_node;
|
||||
|
||||
static unsigned maxSpecifiedRunnerID = 0;
|
||||
|
||||
|
||||
RANK_ID getRankOfRunner (RUNNER_ID __key)
|
||||
{
|
||||
|
||||
for (unsigned i = 0; i < the_schema.size (); i ++)
|
||||
for (unsigned j = 0; j < the_schema [i].id_run.size (); j ++)
|
||||
if (the_schema [i].id_run [j] == __key)
|
||||
return the_schema [i].rk;
|
||||
assert (false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void loadNode (int __rk_sched)
|
||||
{
|
||||
|
||||
Node node;
|
||||
|
||||
node.rk_sched = __rk_sched;
|
||||
|
||||
/* ATT: name*/
|
||||
node.rk = getRankFromName (getAttributeValue ("name"));
|
||||
/* ATT: num_workers */
|
||||
node.num_workers = atoi (getAttributeValue ("num_workers").c_str ());
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
||||
/* TAG: <runner> | </node> */
|
||||
std :: string name = getNextNode ();
|
||||
assert (name == "runner" || name == "node");
|
||||
if (name == "runner")
|
||||
{
|
||||
/* TAG: </node> */
|
||||
node.id_run.push_back (atoi (getNextNode ().c_str ()));
|
||||
if ( node.id_run.back() > maxSpecifiedRunnerID )
|
||||
maxSpecifiedRunnerID = node.id_run.back();
|
||||
/* TAG: </runner> */
|
||||
assert (getNextNode () == "runner");
|
||||
}
|
||||
else
|
||||
{
|
||||
/* TAG: </node> */
|
||||
node.execution_id_run = node.id_run;
|
||||
the_schema.push_back (node);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void loadGroup ()
|
||||
{
|
||||
|
||||
std :: string name;
|
||||
|
||||
/* ATT: scheduler*/
|
||||
int rk_sched = getRankFromName (getAttributeValue ("scheduler"));
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
||||
/* TAG: <node> | </group> */
|
||||
name = getNextNode ();
|
||||
assert (name == "node" || name == "group");
|
||||
if (name == "node")
|
||||
/* TAG: <node> */
|
||||
loadNode (rk_sched);
|
||||
else
|
||||
/* TAG: </group> */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
bool isScheduleNode ()
|
||||
{
|
||||
|
||||
return my_node -> rk == my_node -> rk_sched;
|
||||
}
|
||||
|
||||
void loadSchema (const char * __filename)
|
||||
{
|
||||
|
||||
openXMLDocument (__filename);
|
||||
|
||||
std :: string name;
|
||||
|
||||
/* TAG: <schema> */
|
||||
name = getNextNode ();
|
||||
assert (name == "schema");
|
||||
|
||||
the_schema.clear();
|
||||
maxSpecifiedRunnerID = 0;
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
||||
/* TAG: <group> | </schema> */
|
||||
name = getNextNode ();
|
||||
assert (name == "group" || name == "schema");
|
||||
if (name == "group")
|
||||
/* TAG: <group> */
|
||||
loadGroup ();
|
||||
else
|
||||
/* TAG: </schema> */
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
std :: set<unsigned> uniqueRunnerIDs;
|
||||
unsigned nbUniqueIDs = 0;
|
||||
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] );
|
||||
/* In case a duplicate ID has been found */
|
||||
if ( uniqueRunnerIDs.size() == nbUniqueIDs )
|
||||
{
|
||||
the_schema [i].execution_id_run[j] = ++maxSpecifiedRunnerID;
|
||||
}
|
||||
nbUniqueIDs = uniqueRunnerIDs.size();
|
||||
}
|
||||
}
|
||||
|
||||
/* Looking for my node */
|
||||
for (unsigned i = 0; i < the_schema.size (); i ++)
|
||||
{
|
||||
if (the_schema [i].rk == getNodeRank ())
|
||||
my_node = & (the_schema [i]);
|
||||
}
|
||||
|
||||
|
||||
/* About me */
|
||||
char mess [1000];
|
||||
|
||||
sprintf (mess, "my rank is %d", my_node -> rk);
|
||||
printDebugMessage (mess);
|
||||
|
||||
if (isScheduleNode ())
|
||||
printDebugMessage ("I'am a scheduler");
|
||||
|
||||
for (unsigned i = 0; i < my_node -> id_run.size (); i ++)
|
||||
{
|
||||
sprintf (mess, "I manage the runner %d", my_node -> id_run [i]);
|
||||
printDebugMessage (mess);
|
||||
}
|
||||
|
||||
if (my_node -> num_workers)
|
||||
{
|
||||
|
||||
sprintf (mess, "I manage %d worker(s)", my_node -> num_workers);
|
||||
printDebugMessage (mess);
|
||||
}
|
||||
|
||||
closeXMLDocument ();
|
||||
}
|
||||
59
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/schema.h
Normal file
59
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/schema.h
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* <schema.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape
|
||||
*
|
||||
* 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 __schema_h
|
||||
#define __schema_h
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <cassert>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "node.h"
|
||||
#include "../../core/runner.h"
|
||||
|
||||
|
||||
extern Node * my_node;
|
||||
|
||||
extern bool isScheduleNode ();
|
||||
|
||||
extern RANK_ID getRankOfRunner (RUNNER_ID __key);
|
||||
|
||||
extern std :: vector <Node> the_schema;
|
||||
|
||||
extern void loadSchema (const char * __filename);
|
||||
|
||||
#endif
|
||||
178
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/send.cpp
Normal file
178
branches/cmakemodif/paradiseo-peo/src/rmc/mpi/send.cpp
Normal file
|
|
@ -0,0 +1,178 @@
|
|||
/*
|
||||
* <send.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Sebastien Cahon, Alexandru-Adrian Tantar, Clive Canape
|
||||
*
|
||||
* 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 <mpi.h>
|
||||
#include <semaphore.h>
|
||||
#include <queue>
|
||||
|
||||
#include "tags.h"
|
||||
#include "comm.h"
|
||||
#include "worker.h"
|
||||
#include "scheduler.h"
|
||||
#include "mess.h"
|
||||
#include "node.h"
|
||||
#include "../../core/cooperative.h"
|
||||
#include "../../core/peo_debug.h"
|
||||
|
||||
#define TO_ALL -1
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
||||
Communicable * comm;
|
||||
int to;
|
||||
int tag;
|
||||
|
||||
}
|
||||
SEND_REQUEST;
|
||||
|
||||
|
||||
static std :: queue <SEND_REQUEST> mess;
|
||||
|
||||
static sem_t sem_send;
|
||||
|
||||
static bool contextInitialized = false;
|
||||
|
||||
|
||||
void initSending ()
|
||||
{
|
||||
|
||||
static bool initializedSemaphore = false;
|
||||
|
||||
mess = std :: queue <SEND_REQUEST> ();
|
||||
|
||||
if (initializedSemaphore)
|
||||
{
|
||||
sem_destroy(& sem_send);
|
||||
}
|
||||
|
||||
sem_init (& sem_send, 0, 1);
|
||||
initializedSemaphore = true;
|
||||
|
||||
contextInitialized = false;
|
||||
}
|
||||
|
||||
void send (Communicable * __comm, int __to, int __tag)
|
||||
{
|
||||
|
||||
SEND_REQUEST req;
|
||||
req.comm = __comm;
|
||||
req.to = __to;
|
||||
req.tag = __tag;
|
||||
|
||||
sem_wait (& sem_send);
|
||||
mess.push (req);
|
||||
sem_post (& sem_send);
|
||||
wakeUpCommunicator ();
|
||||
}
|
||||
|
||||
void sendToAll (Communicable * __comm, int __tag)
|
||||
{
|
||||
|
||||
send (__comm, TO_ALL, __tag);
|
||||
}
|
||||
|
||||
extern void initializeContext ();
|
||||
|
||||
void sendMessages ()
|
||||
{
|
||||
|
||||
if (! contextInitialized)
|
||||
{
|
||||
contextInitialized = true;
|
||||
initializeContext();
|
||||
}
|
||||
|
||||
sem_wait (& sem_send);
|
||||
|
||||
while (! mess.empty ())
|
||||
{
|
||||
|
||||
SEND_REQUEST req = mess.front ();
|
||||
|
||||
Communicable * comm = req.comm;
|
||||
|
||||
initMessage ();
|
||||
|
||||
switch (req.tag)
|
||||
{
|
||||
|
||||
case RUNNER_STOP_TAG:
|
||||
dynamic_cast <Runner *> (comm) -> packTermination ();
|
||||
dynamic_cast <Runner *> (comm) -> notifySendingTermination ();
|
||||
break;
|
||||
|
||||
case COOP_TAG:
|
||||
dynamic_cast <Cooperative *> (comm) -> pack ();
|
||||
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 ();
|
||||
break;
|
||||
|
||||
case TASK_RESULT_TAG:
|
||||
dynamic_cast <Worker *> (comm) -> packResult ();
|
||||
dynamic_cast <Worker *> (comm) -> notifySendingResult ();
|
||||
break;
|
||||
|
||||
case TASK_DONE_TAG:
|
||||
dynamic_cast <Worker *> (comm) -> packTaskDone ();
|
||||
dynamic_cast <Worker *> (comm) -> notifySendingTaskDone ();
|
||||
break;
|
||||
|
||||
default :
|
||||
break;
|
||||
|
||||
};
|
||||
|
||||
if (req.to == TO_ALL)
|
||||
sendMessageToAll (req.tag);
|
||||
else
|
||||
sendMessage (req.to, req.tag);
|
||||
|
||||
mess.pop ();
|
||||
}
|
||||
|
||||
sem_post (& sem_send);
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue