Remove PEO from master
This commit is contained in:
parent
8cd56f37db
commit
948da627ea
185 changed files with 0 additions and 18909 deletions
|
|
@ -1,3 +0,0 @@
|
|||
Alexandru-Adrian Tantar
|
||||
Clive Canape
|
||||
Sébastien Cahon
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
######################################################################################
|
||||
### 0) Include dependencies
|
||||
######################################################################################
|
||||
|
||||
find_package(LibXml2 REQUIRED)
|
||||
|
||||
######################################################################################
|
||||
### 0) Include subdirectories
|
||||
######################################################################################
|
||||
|
||||
add_subdirectory(doc)
|
||||
add_subdirectory(src)
|
||||
|
||||
if(ENABLE_CMAKE_TESTING)
|
||||
add_subdirectory(test)
|
||||
endif(ENABLE_CMAKE_TESTING)
|
||||
|
||||
if(ENABLE_CMAKE_EXAMPLE)
|
||||
if(${CMAKE_VERBOSE_MAKEFILE})
|
||||
message("PEO Examples :")
|
||||
endif(${CMAKE_VERBOSE_MAKEFILE})
|
||||
add_subdirectory(tutorial)
|
||||
endif(ENABLE_CMAKE_EXAMPLE)
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
set(CTEST_PROJECT_NAME "ParadisEO")
|
||||
set(CTEST_NIGHTLY_START_TIME "00:00:00 EST")
|
||||
|
||||
set(CTEST_DROP_METHOD "http")
|
||||
set(CTEST_DROP_SITE "cdash.inria.fr")
|
||||
set(CTEST_DROP_LOCATION "/CDash/submit.php?project=ParadisEO")
|
||||
set(CTEST_DROP_SITE_CDASH TRUE)
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
######################################################################################
|
||||
### 0) Documentation
|
||||
######################################################################################
|
||||
|
||||
if(DOXYGEN_FOUND)
|
||||
# Directory where the generation will be launched
|
||||
set(PEO_DOC_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "Documentation directory")
|
||||
# Name of the doxygene configuration file
|
||||
set(PEO_DOC_CONFIG_FILE "peo.doxyfile" CACHE PATH "Documentation configuration file")
|
||||
if(DOXYGEN_EXECUTABLE)
|
||||
# Creating the custom target
|
||||
if(UNIX AND NOT ${CMAKE_VERBOSE_MAKEFILE})
|
||||
add_custom_target(doc-peo
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${PEO_DOC_CONFIG_FILE} 2> /dev/null > /dev/null
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
else(UNIX AND NOT ${CMAKE_VERBOSE_MAKEFILE})
|
||||
add_custom_target(doc-peo
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${PEO_DOC_CONFIG_FILE}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif(UNIX AND NOT ${CMAKE_VERBOSE_MAKEFILE})
|
||||
endif(DOXYGEN_EXECUTABLE)
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${PEO_DOC_CONFIG_FILE}.cmake"
|
||||
"${PEO_DOC_DIR}/${PEO_DOC_CONFIG_FILE}")
|
||||
|
||||
install(
|
||||
DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
DESTINATION local/share${INSTALL_SUB_DIR}/peo COMPONENT doc
|
||||
PATTERN "CMakeFiles" EXCLUDE
|
||||
PATTERN "cmake_install.cmake" EXCLUDE
|
||||
PATTERN "CTestTestfile.cmake" EXCLUDE
|
||||
PATTERN "Makefile" EXCLUDE
|
||||
PATTERN "peo.cfg" EXCLUDE
|
||||
PATTERN "peo.doxytag" EXCLUDE
|
||||
)
|
||||
else(DOXYGEN_FOUND)
|
||||
message(STATUS "Unable to generate the documentation, Doxygen package not found")
|
||||
endif(DOXYGEN_FOUND)
|
||||
|
||||
|
|
@ -1,239 +0,0 @@
|
|||
# Doxyfile 1.4.7
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
PROJECT_NAME = @PACKAGE_NAME@
|
||||
PROJECT_NUMBER = @PACKAGE_VERSION@
|
||||
OUTPUT_DIRECTORY = @CMAKE_BINARY_DIR@/doc
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
USE_WINDOWS_ENCODING = NO
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF = "The $name class" \
|
||||
"The $name widget" \
|
||||
"The $name file" \
|
||||
is \
|
||||
provides \
|
||||
specifies \
|
||||
contains \
|
||||
represents \
|
||||
a \
|
||||
an \
|
||||
the
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = NO
|
||||
STRIP_FROM_PATH = @CMAKE_SOURCE_DIR@
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = YES
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
DETAILS_AT_TOP = NO
|
||||
INHERIT_DOCS = YES
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 8
|
||||
ALIASES =
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
BUILTIN_STL_SUPPORT = NO
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
SUBGROUPING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = NO
|
||||
EXTRACT_PRIVATE = YES
|
||||
EXTRACT_STATIC = YES
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
HIDE_UNDOC_MEMBERS = YES
|
||||
HIDE_UNDOC_CLASSES = YES
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = YES
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = NO
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_DIRECTORIES = NO
|
||||
FILE_VERSION_FILTER =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
QUIET = YES
|
||||
WARNINGS = NO
|
||||
WARN_IF_UNDOCUMENTED = NO
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = @CMAKE_SOURCE_DIR@
|
||||
FILE_PATTERNS = *.cpp \
|
||||
*.h \
|
||||
NEWS \
|
||||
README
|
||||
RECURSIVE = YES
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS = *
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
SOURCE_BROWSER = YES
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = YES
|
||||
REFERENCES_RELATION = YES
|
||||
REFERENCES_LINK_SOURCE = YES
|
||||
USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = YES
|
||||
COLS_IN_ALPHA_INDEX = 3
|
||||
IGNORE_PREFIX = peo
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = NO
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
GENERATE_CHI = NO
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
DISABLE_INDEX = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
GENERATE_TREEVIEW = YES
|
||||
TREEVIEW_WIDTH = 250
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_LATEX = YES
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4wide
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
PDF_HYPERLINKS = YES
|
||||
USE_PDFLATEX = YES
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_MAN = YES
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_LINKS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_SCHEMA =
|
||||
XML_DTD =
|
||||
XML_PROGRAMLISTING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED =
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES = @EO_BIN_DIR@/doc/eo.doxytag=http://eodev.sourceforge.net/eo/doc/html \
|
||||
@MO_BIN_DIR@/doc/mo.doxytag=@MO_BIN_DIR@/doc/html
|
||||
GENERATE_TAGFILE = @CMAKE_BINARY_DIR@/doc/peo.doxytag
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
PERL_PATH = /usr/bin/perl
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = YES
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = NO
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = NO
|
||||
TEMPLATE_RELATIONS = NO
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
CALL_GRAPH = NO
|
||||
CALLER_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DIRECTORY_GRAPH = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
MAX_DOT_GRAPH_WIDTH = 1024
|
||||
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||
MAX_DOT_GRAPH_DEPTH = 0
|
||||
DOT_TRANSPARENT = NO
|
||||
DOT_MULTI_TARGETS = NO
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to the search engine
|
||||
#---------------------------------------------------------------------------
|
||||
SEARCHENGINE = YES
|
||||
|
|
@ -1,24 +0,0 @@
|
|||
######################################################################################
|
||||
### 0) Where must cmake go now ?
|
||||
######################################################################################
|
||||
|
||||
add_subdirectory(core)
|
||||
add_subdirectory(rmc)
|
||||
|
||||
######################################################################################
|
||||
### 3) Look for headers
|
||||
######################################################################################
|
||||
|
||||
file(GLOB HDRS peo)
|
||||
install(FILES ${HDRS} DESTINATION local/include${INSTALL_SUB_DIR}/peo COMPONENT headers)
|
||||
|
||||
######################################################################################
|
||||
### 2) Install directories
|
||||
######################################################################################
|
||||
|
||||
install(DIRECTORY core rmc
|
||||
DESTINATION local/include${INSTALL_SUB_DIR}/peo
|
||||
COMPONENT headers
|
||||
FILES_MATCHING PATTERN "*.h"
|
||||
)
|
||||
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
######################################################################################
|
||||
### 0) Include the sources
|
||||
######################################################################################
|
||||
|
||||
include_directories(${EO_SRC_DIR}/src)
|
||||
include_directories(${MOEO_SRC_DIR}/src)
|
||||
|
||||
######################################################################################
|
||||
### 2) Define your target(s): just the peo library here
|
||||
######################################################################################
|
||||
|
||||
set(CORE_LIB_OUTPUT_PATH ${PEO_BIN_DIR}/lib)
|
||||
set(LIBRARY_OUTPUT_PATH ${CORE_LIB_OUTPUT_PATH})
|
||||
|
||||
set(CORE_SOURCES peo_init.cpp
|
||||
peo_fin.cpp
|
||||
peo_run.cpp
|
||||
peo_param.cpp
|
||||
peo_debug.cpp
|
||||
thread.cpp
|
||||
reac_thread.cpp
|
||||
service.cpp
|
||||
runner.cpp
|
||||
communicable.cpp
|
||||
topology.cpp
|
||||
ring_topo.cpp
|
||||
star_topo.cpp
|
||||
random_topo.cpp
|
||||
complete_topo.cpp)
|
||||
|
||||
add_library(peo STATIC ${CORE_SOURCES})
|
||||
|
||||
install(TARGETS peo ARCHIVE DESTINATION local/${LIB} COMPONENT libraries)
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
/*
|
||||
* <communicable.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 <vector>
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
|
||||
#include "communicable.h"
|
||||
|
||||
static std :: vector <Communicable *> key_to_comm (1); /* Vector of registered cooperators */
|
||||
|
||||
static std :: map <const Communicable *, unsigned> comm_to_key; /* Map of registered cooperators */
|
||||
|
||||
unsigned Communicable :: num_comm = 0;
|
||||
|
||||
|
||||
Communicable :: Communicable ()
|
||||
{
|
||||
|
||||
comm_to_key [this] = key = ++ num_comm;
|
||||
key_to_comm.push_back (this);
|
||||
sem_init (& sem_lock, 0, 1);
|
||||
sem_init (& sem_stop, 0, 0);
|
||||
}
|
||||
|
||||
Communicable :: ~ Communicable ()
|
||||
{
|
||||
}
|
||||
|
||||
COMM_ID Communicable :: getKey ()
|
||||
{
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
Communicable * getCommunicable (COMM_ID __key)
|
||||
{
|
||||
|
||||
assert (__key < key_to_comm.size ());
|
||||
return key_to_comm [__key];
|
||||
}
|
||||
|
||||
COMM_ID getKey (const Communicable * __comm)
|
||||
{
|
||||
|
||||
return comm_to_key [__comm];
|
||||
}
|
||||
|
||||
void Communicable :: lock ()
|
||||
{
|
||||
|
||||
sem_wait (& sem_lock);
|
||||
}
|
||||
|
||||
void Communicable :: unlock ()
|
||||
{
|
||||
|
||||
sem_post (& sem_lock);
|
||||
}
|
||||
|
||||
void Communicable :: stop ()
|
||||
{
|
||||
sem_wait (& sem_stop);
|
||||
}
|
||||
|
||||
void Communicable :: resume ()
|
||||
{
|
||||
|
||||
sem_post (& sem_stop);
|
||||
}
|
||||
|
||||
void initCommunicableEnv ()
|
||||
{
|
||||
|
||||
key_to_comm.resize (1);
|
||||
comm_to_key.clear ();
|
||||
Communicable :: num_comm = 0;
|
||||
}
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
* <communicable.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 __communicable_h
|
||||
#define __communicable_h
|
||||
|
||||
#include <semaphore.h>
|
||||
|
||||
|
||||
typedef unsigned COMM_ID;
|
||||
|
||||
class Communicable
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
Communicable ();
|
||||
|
||||
virtual ~ Communicable ();
|
||||
|
||||
COMM_ID getKey ();
|
||||
|
||||
void lock (); /* It suspends the current process if the semaphore is locked */
|
||||
void unlock (); /* It unlocks the shared semaphore */
|
||||
|
||||
void stop (); /* It suspends the current process */
|
||||
void resume (); /* It resumes ___________ */
|
||||
|
||||
public :
|
||||
|
||||
static unsigned num_comm;
|
||||
|
||||
protected :
|
||||
|
||||
COMM_ID key;
|
||||
|
||||
sem_t sem_lock;
|
||||
|
||||
sem_t sem_stop;
|
||||
};
|
||||
|
||||
extern void initCommunicableEnv ();
|
||||
|
||||
extern Communicable * getCommunicable (COMM_ID __key);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
* <complete_topo.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 <cassert>
|
||||
#include "complete_topo.h"
|
||||
|
||||
void CompleteTopology :: setNeighbors (Cooperative * __mig,
|
||||
std :: vector <Cooperative *> & __from,
|
||||
std :: vector <Cooperative *> & __to)
|
||||
{
|
||||
|
||||
__from.clear () ;
|
||||
__to.clear () ;
|
||||
|
||||
for (unsigned i = 0; i < mig.size (); i ++)
|
||||
{
|
||||
if (mig [i] != __mig)
|
||||
{
|
||||
__from.push_back (mig [i]);
|
||||
__to.push_back (mig [i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
* <complete_topo.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 __complete_topo_h
|
||||
#define __complete_topo_h
|
||||
|
||||
#include "topology.h"
|
||||
|
||||
class CompleteTopology : public Topology
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
void setNeighbors (Cooperative * __mig,
|
||||
std :: vector <Cooperative *> & __from,
|
||||
std :: vector <Cooperative *> & __to);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
/*
|
||||
* <cooperative.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 __cooperative_h
|
||||
#define __cooperative_h
|
||||
|
||||
#include <vector>
|
||||
#include "communicable.h"
|
||||
#include "runner.h"
|
||||
|
||||
typedef unsigned COOP_ID;
|
||||
|
||||
class Cooperative : public Communicable
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
Runner * getOwner ();
|
||||
|
||||
void setOwner (Runner & __runner);
|
||||
|
||||
virtual void pack () = 0;
|
||||
|
||||
virtual void unpack () = 0;
|
||||
|
||||
virtual void packSynchronizeReq () = 0;
|
||||
|
||||
void send (Cooperative * __coop);
|
||||
|
||||
void synchronizeCoopEx ();
|
||||
|
||||
virtual void notifySending ();
|
||||
|
||||
virtual void notifyReceiving ();
|
||||
|
||||
virtual void notifySendingSyncReq ();
|
||||
|
||||
virtual void notifySynchronized ();
|
||||
|
||||
private :
|
||||
|
||||
Runner * owner;
|
||||
|
||||
};
|
||||
|
||||
extern Cooperative * getCooperative (COOP_ID __key);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
* <eoPop_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 __eoPop_mesg_h
|
||||
#define __eoPop_mesg_h
|
||||
|
||||
#include <eoPop.h>
|
||||
|
||||
#include "messaging.h"
|
||||
|
||||
|
||||
template <class EOT> void pack (eoPop <EOT> & __pop)
|
||||
{
|
||||
|
||||
pack ((unsigned) __pop.size ());
|
||||
for (unsigned i = 0; i < __pop.size (); i ++)
|
||||
pack (__pop [i]);
|
||||
}
|
||||
|
||||
template <class EOT> void unpack (eoPop <EOT> & __pop)
|
||||
{
|
||||
|
||||
unsigned n;
|
||||
|
||||
unpack (n);
|
||||
__pop.resize (n);
|
||||
for (unsigned i = 0; i < n; i ++)
|
||||
unpack (__pop [i]);
|
||||
}
|
||||
|
||||
template <class MOEOT> void pack (moeoArchive < MOEOT > & __pop)
|
||||
{
|
||||
|
||||
pack ((unsigned) __pop.size ());
|
||||
for (unsigned i = 0; i < __pop.size (); i ++)
|
||||
pack (__pop [i]);
|
||||
}
|
||||
|
||||
template <class MOEOT> void unpack (moeoArchive < MOEOT > & __pop)
|
||||
{
|
||||
|
||||
unsigned n;
|
||||
|
||||
unpack (n);
|
||||
__pop.resize (n);
|
||||
for (unsigned i = 0; i < n; i ++)
|
||||
unpack (__pop [i]);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,244 +0,0 @@
|
|||
/*
|
||||
* <eoVector_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 __eoVector_mesg_h
|
||||
#define __eoVector_mesg_h
|
||||
|
||||
#include <eoVector.h>
|
||||
|
||||
#include <core/moeoVector.h>
|
||||
#include <core/moeoObjectiveVector.h>
|
||||
|
||||
#include "messaging.h"
|
||||
|
||||
|
||||
|
||||
template <class F, class T> void pack (const eoVector <F, T> & __v)
|
||||
{
|
||||
|
||||
if (__v.invalid())
|
||||
{
|
||||
pack((unsigned)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
pack((unsigned)1);
|
||||
pack (__v.fitness ());
|
||||
}
|
||||
|
||||
unsigned len = __v.size ();
|
||||
pack (len);
|
||||
for (unsigned i = 0 ; i < len; i ++)
|
||||
pack (__v [i]);
|
||||
}
|
||||
|
||||
template <class F, class T> void unpack (eoVector <F, T> & __v)
|
||||
{
|
||||
|
||||
unsigned valid;
|
||||
unpack(valid);
|
||||
|
||||
if (! valid)
|
||||
{
|
||||
__v.invalidate();
|
||||
}
|
||||
else
|
||||
{
|
||||
F fit;
|
||||
unpack (fit);
|
||||
__v.fitness (fit);
|
||||
}
|
||||
|
||||
unsigned len;
|
||||
unpack (len);
|
||||
__v.resize (len);
|
||||
for (unsigned i = 0 ; i < len; i ++)
|
||||
unpack (__v [i]);
|
||||
}
|
||||
|
||||
template <class F, class T, class V> void pack (const eoVectorParticle <F, T, V> & __v)
|
||||
{
|
||||
|
||||
if (__v.invalid())
|
||||
{
|
||||
pack((unsigned)0);
|
||||
}
|
||||
else
|
||||
{
|
||||
pack((unsigned)1);
|
||||
pack (__v.fitness ());
|
||||
pack (__v.best());
|
||||
}
|
||||
|
||||
unsigned len = __v.size ();
|
||||
pack (len);
|
||||
for (unsigned i = 0 ; i < len; i ++)
|
||||
pack (__v [i]);
|
||||
for (unsigned i = 0 ; i < len; i ++)
|
||||
pack (__v.bestPositions[i]);
|
||||
for (unsigned i = 0 ; i < len; i ++)
|
||||
pack (__v.velocities[i]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <class F, class T, class V> void unpack (eoVectorParticle <F, T, V> & __v)
|
||||
{
|
||||
|
||||
unsigned valid;
|
||||
unpack(valid);
|
||||
|
||||
if (! valid)
|
||||
{
|
||||
__v.invalidate();
|
||||
}
|
||||
else
|
||||
{
|
||||
F fit;
|
||||
unpack (fit);
|
||||
__v.fitness (fit);
|
||||
unpack(fit);
|
||||
__v.best(fit);
|
||||
|
||||
}
|
||||
unsigned len;
|
||||
unpack (len);
|
||||
__v.resize (len);
|
||||
for (unsigned i = 0 ; i < len; i ++)
|
||||
unpack (__v [i]);
|
||||
for (unsigned i = 0 ; i < len; i ++)
|
||||
unpack (__v.bestPositions[i]);
|
||||
for (unsigned i = 0 ; i < len; i ++)
|
||||
unpack (__v.velocities[i]);
|
||||
}
|
||||
|
||||
|
||||
template <class Traits, class Type> void unpack (moeoObjectiveVector<Traits,Type> _objVec)
|
||||
{
|
||||
unsigned int len;
|
||||
|
||||
unpack (len);
|
||||
_objVec.resize(len);
|
||||
for (unsigned i = 0 ; i < len; i ++)
|
||||
unpack (_objVec[i]);
|
||||
}
|
||||
|
||||
|
||||
template <class Traits, class Type> void pack (const moeoObjectiveVector<Traits,Type> & _objVec)
|
||||
{
|
||||
unsigned int len = _objVec.nObjectives();
|
||||
pack(len);
|
||||
for (unsigned i=0; i<len; i++)
|
||||
pack(_objVec[i]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
template <class F, class T, class V, class W> void pack (moeoVector <F,T,V,W> &_v)
|
||||
{
|
||||
if (_v.invalid())
|
||||
pack((unsigned)0);
|
||||
else
|
||||
{
|
||||
pack((unsigned)1);
|
||||
pack (_v.fitness ());
|
||||
}
|
||||
if (_v.invalidDiversity())
|
||||
pack((unsigned)0);
|
||||
else
|
||||
{
|
||||
pack((unsigned)1);
|
||||
pack(_v.diversity());
|
||||
}
|
||||
unsigned len = _v.size ();
|
||||
pack (len);
|
||||
for (unsigned i = 0 ; i < len; i ++)
|
||||
pack (_v[i]);
|
||||
if (_v.invalidObjectiveVector())
|
||||
pack((unsigned)0);
|
||||
else
|
||||
{
|
||||
pack((unsigned)1);
|
||||
F object;
|
||||
object=_v.objectiveVector();
|
||||
len=object.nObjectives();
|
||||
pack (len);
|
||||
for (unsigned i = 0 ; i < len; i ++)
|
||||
pack (object[i]);
|
||||
}
|
||||
}
|
||||
|
||||
template <class F, class T, class V, class W> void unpack (moeoVector <F,T,V,W> &_v)
|
||||
{
|
||||
unsigned valid;
|
||||
unpack(valid);
|
||||
if (! valid)
|
||||
_v.invalidate();
|
||||
else
|
||||
{
|
||||
T fit;
|
||||
unpack (fit);
|
||||
_v.fitness (fit);
|
||||
}
|
||||
unpack(valid);
|
||||
if (! valid)
|
||||
_v.invalidateDiversity();
|
||||
else
|
||||
{
|
||||
V diver;
|
||||
unpack(diver);
|
||||
_v.diversity(diver);
|
||||
}
|
||||
unsigned len;
|
||||
unpack (len);
|
||||
_v.resize (len);
|
||||
for (unsigned i = 0 ; i < len; i ++)
|
||||
unpack (_v [i]);
|
||||
unpack(valid);
|
||||
if (! valid)
|
||||
_v.invalidateObjectiveVector();
|
||||
else
|
||||
{
|
||||
F object;
|
||||
unpack (len);
|
||||
object.resize(len);
|
||||
for (unsigned i = 0 ; i < len; i ++)
|
||||
unpack (object[i]);
|
||||
_v.objectiveVector(object);
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,145 +0,0 @@
|
|||
/*
|
||||
* <messaging.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_h
|
||||
#define __mess_h
|
||||
|
||||
#include <utility>
|
||||
#include <string>
|
||||
|
||||
/* Char */
|
||||
extern void pack (const char & __c);
|
||||
|
||||
/* Boolean */
|
||||
extern void pack (const bool & __b, int __nitem = 1);
|
||||
|
||||
/* Float */
|
||||
extern void pack (const float & __f, int __nitem = 1);
|
||||
|
||||
/* Double */
|
||||
extern void pack (const double & __d, int __nitem = 1);
|
||||
|
||||
/* Integer */
|
||||
extern void pack (const int & __i, int __nitem = 1);
|
||||
|
||||
/* Unsigned int. */
|
||||
extern void pack (const unsigned int & __ui, int __nitem = 1);
|
||||
|
||||
/* Short int. */
|
||||
extern void pack (const short & __sh, int __nitem = 1);
|
||||
|
||||
/* Unsigned short */
|
||||
extern void pack (const unsigned short & __ush, int __nitem = 1);
|
||||
|
||||
/* Long */
|
||||
extern void pack (const long & __l, int __nitem = 1);
|
||||
|
||||
/* Unsigned long */
|
||||
extern void pack (const unsigned long & __ul, int __nitem = 1);
|
||||
|
||||
/* String */
|
||||
extern void pack (const char * __str);
|
||||
extern void pack (const std::string & __str);
|
||||
|
||||
/* Pointer */
|
||||
template <class T> void pack (const T * __ptr)
|
||||
{
|
||||
|
||||
pack ((unsigned long) __ptr);
|
||||
}
|
||||
|
||||
/* Pair */
|
||||
template <class U, class V> void pack (const std :: pair <U, V> & __pair)
|
||||
{
|
||||
|
||||
pack (__pair.first);
|
||||
pack (__pair.second);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Char */
|
||||
extern void unpack (char & __c);
|
||||
|
||||
/* Boolean */
|
||||
extern void unpack (bool & __b, int __nitem = 1);
|
||||
|
||||
/* Float */
|
||||
extern void unpack (float & __f, int __nitem = 1);
|
||||
|
||||
/* Double */
|
||||
extern void unpack (double & __d, int __nitem = 1);
|
||||
|
||||
/* Integer */
|
||||
extern void unpack (int & __i, int __nitem = 1);
|
||||
|
||||
/* Unsigned int. */
|
||||
extern void unpack (unsigned int & __ui, int __nitem = 1);
|
||||
|
||||
/* Short int. */
|
||||
extern void unpack (short & __sh, int __nitem = 1);
|
||||
|
||||
/* Unsigned short */
|
||||
extern void unpack (unsigned short & __ush, int __nitem = 1);
|
||||
|
||||
/* Long */
|
||||
extern void unpack (long & __l, int __nitem = 1);
|
||||
|
||||
/* Unsigned long */
|
||||
extern void unpack (unsigned long & __ul, int __nitem = 1);
|
||||
|
||||
/* String */
|
||||
extern void unpack (char * __str);
|
||||
extern void unpack (std::string & __str);
|
||||
|
||||
/* Pointer */
|
||||
template <class T> void unpack (T * & __ptr)
|
||||
{
|
||||
|
||||
unsigned long p;
|
||||
unpack (p);
|
||||
__ptr = (T *) p;
|
||||
}
|
||||
|
||||
/* Pair */
|
||||
template <class U, class V> void unpack (std :: pair <U, V> & __pair)
|
||||
{
|
||||
|
||||
unpack (__pair.first);
|
||||
unpack (__pair.second);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,289 +0,0 @@
|
|||
/*
|
||||
* <peoAbstractDefs.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*/
|
||||
|
||||
#if !defined __peoAbstractDefs_h
|
||||
#define __peoAbstractDefs_h
|
||||
|
||||
|
||||
#include <queue>
|
||||
|
||||
#include "core/messaging.h"
|
||||
|
||||
|
||||
|
||||
template < typename Type > struct Entity;
|
||||
|
||||
struct AbstractEntity
|
||||
{
|
||||
|
||||
virtual ~AbstractEntity() {}
|
||||
|
||||
template < typename EntityType > operator EntityType& ()
|
||||
{
|
||||
|
||||
return ( reinterpret_cast< Entity< EntityType >& >( *this ) ).entity;
|
||||
}
|
||||
};
|
||||
|
||||
struct AbstractFunctor : virtual public AbstractEntity
|
||||
{
|
||||
|
||||
virtual ~AbstractFunctor() {}
|
||||
|
||||
virtual void operator()() {}
|
||||
};
|
||||
|
||||
struct AbstractUnaryFunctor : virtual public AbstractEntity
|
||||
{
|
||||
|
||||
virtual ~AbstractUnaryFunctor() {}
|
||||
|
||||
virtual void operator()( AbstractEntity& dataEntity ) {}
|
||||
};
|
||||
|
||||
struct AbstractBinaryFunctor : virtual public AbstractEntity
|
||||
{
|
||||
|
||||
virtual ~AbstractBinaryFunctor() {}
|
||||
|
||||
virtual void operator()( AbstractEntity& dataEntityA, AbstractEntity& dataEntityB ) {};
|
||||
};
|
||||
|
||||
|
||||
|
||||
template < typename EntityType > struct Entity : virtual public AbstractEntity
|
||||
{
|
||||
|
||||
Entity( EntityType& externalEntityRef ) : entity( externalEntityRef ) {}
|
||||
|
||||
EntityType& entity;
|
||||
};
|
||||
|
||||
template < typename FunctorType, typename DataType > struct FunctorEx : public Entity< DataType >, public AbstractFunctor
|
||||
{
|
||||
|
||||
FunctorEx( FunctorType& externalFunctorRef, DataType& externalDataRef )
|
||||
: externalFunctor( externalFunctorRef ), Entity< DataType >( externalDataRef ) {}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
|
||||
externalFunctor( Entity< DataType > :: entity );
|
||||
}
|
||||
|
||||
FunctorType& externalFunctor;
|
||||
};
|
||||
|
||||
template < typename FunctorType > struct FunctorEx< FunctorType, void > : public Entity< AbstractEntity >, public AbstractFunctor
|
||||
{
|
||||
|
||||
FunctorEx( FunctorType& externalFunctorRef )
|
||||
: externalFunctor( externalFunctorRef ), Entity< AbstractEntity >( *this ) {}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
|
||||
externalFunctor();
|
||||
}
|
||||
|
||||
FunctorType& externalFunctor;
|
||||
};
|
||||
|
||||
template < typename ReturnType, typename DataType > struct FnFunctorEx
|
||||
: public Entity< DataType >, public AbstractFunctor
|
||||
{
|
||||
|
||||
FnFunctorEx( ReturnType (*externalFunctorRef)( DataType& ), DataType& externalDataRef )
|
||||
: externalFunctor( externalFunctorRef ), Entity< DataType >( externalDataRef ) {}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
|
||||
externalFunctor( Entity< DataType > :: entity );
|
||||
}
|
||||
|
||||
ReturnType (*externalFunctor)( DataType& );
|
||||
};
|
||||
|
||||
template < typename ReturnType > struct FnFunctorEx< ReturnType, void >
|
||||
: public Entity< AbstractEntity >, public AbstractFunctor
|
||||
{
|
||||
|
||||
FnFunctorEx( ReturnType (*externalFunctorRef)() )
|
||||
: externalFunctor( externalFunctorRef ), Entity< AbstractEntity >( *this ) {}
|
||||
|
||||
void operator()()
|
||||
{
|
||||
|
||||
externalFunctor();
|
||||
}
|
||||
|
||||
ReturnType (*externalFunctor)();
|
||||
};
|
||||
|
||||
|
||||
|
||||
template < typename FunctorType > struct UnaryFunctor : public Entity< FunctorType >, public AbstractUnaryFunctor
|
||||
{
|
||||
|
||||
UnaryFunctor( FunctorType& externalFunctorRef ) : Entity< FunctorType >( externalFunctorRef ) {}
|
||||
|
||||
void operator()( AbstractEntity& dataEntity )
|
||||
{
|
||||
|
||||
Entity< FunctorType > :: entity( dataEntity );
|
||||
}
|
||||
};
|
||||
|
||||
template < typename ReturnType, typename DataType > struct UnaryFnFunctor
|
||||
: public Entity< AbstractEntity >, public AbstractUnaryFunctor
|
||||
{
|
||||
|
||||
UnaryFnFunctor( ReturnType (*externalFnRef)( DataType& ) ) : Entity< AbstractEntity >( *this ), externalFn( externalFnRef )
|
||||
{
|
||||
}
|
||||
|
||||
void operator()( AbstractEntity& dataEntity )
|
||||
{
|
||||
|
||||
externalFn( dataEntity );
|
||||
}
|
||||
|
||||
ReturnType (*externalFn)( DataType& );
|
||||
};
|
||||
|
||||
template < typename FunctorType > struct BinaryFunctor : public Entity< FunctorType >, public AbstractBinaryFunctor
|
||||
{
|
||||
|
||||
BinaryFunctor( FunctorType& externalFunctorRef ) : Entity< FunctorType >( externalFunctorRef ) {}
|
||||
|
||||
void operator()( AbstractEntity& dataEntityA, AbstractEntity& dataEntityB )
|
||||
{
|
||||
|
||||
Entity< FunctorType > :: entity( dataEntityA, dataEntityB );
|
||||
}
|
||||
};
|
||||
|
||||
struct AbstractMsgTransferQueue : virtual public AbstractEntity
|
||||
{
|
||||
|
||||
virtual ~AbstractMsgTransferQueue() {}
|
||||
|
||||
virtual void pushMessage() {}
|
||||
virtual void popMessage() {}
|
||||
|
||||
virtual bool empty()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual void packMessage() {}
|
||||
virtual void unpackMessage() {}
|
||||
};
|
||||
|
||||
template < typename EntityType > struct MsgTransferQueue : public Entity< EntityType >, public AbstractMsgTransferQueue
|
||||
{
|
||||
|
||||
MsgTransferQueue( EntityType& externalDataRef )
|
||||
: Entity< EntityType >( externalDataRef )
|
||||
{
|
||||
|
||||
aggregationFunctor = new BinaryFunctor< AssignmentFunctor >( assignmentFunctor );
|
||||
}
|
||||
|
||||
template < typename FunctorType >
|
||||
MsgTransferQueue( EntityType& externalDataRef, FunctorType& externalFunctorRef )
|
||||
: Entity< EntityType >( externalDataRef )
|
||||
{
|
||||
|
||||
aggregationFunctor = new BinaryFunctor< FunctorType >( externalFunctorRef );
|
||||
}
|
||||
|
||||
~MsgTransferQueue()
|
||||
{
|
||||
delete aggregationFunctor;
|
||||
}
|
||||
|
||||
void pushMessage()
|
||||
{
|
||||
|
||||
transferQueue.push( Entity< EntityType > :: entity );
|
||||
}
|
||||
|
||||
void popMessage()
|
||||
{
|
||||
|
||||
Entity< EntityType > message( transferQueue.front() );
|
||||
aggregationFunctor->operator()( *this, message );
|
||||
|
||||
transferQueue.pop();
|
||||
}
|
||||
|
||||
bool empty()
|
||||
{
|
||||
return transferQueue.empty();
|
||||
}
|
||||
|
||||
void packMessage()
|
||||
{
|
||||
|
||||
pack( transferQueue.front() );
|
||||
transferQueue.pop();
|
||||
}
|
||||
|
||||
void unpackMessage()
|
||||
{
|
||||
|
||||
EntityType transferredData;
|
||||
unpack( transferredData );
|
||||
transferQueue.push( transferredData );
|
||||
}
|
||||
|
||||
struct AssignmentFunctor
|
||||
{
|
||||
void operator()( EntityType& A, EntityType& B )
|
||||
{
|
||||
A = B;
|
||||
}
|
||||
} assignmentFunctor;
|
||||
|
||||
std::queue< EntityType > transferQueue;
|
||||
AbstractBinaryFunctor* aggregationFunctor;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,117 +0,0 @@
|
|||
/*
|
||||
* <peo_debug.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 "peo_debug.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <vector>
|
||||
|
||||
#include "peo_debug.h"
|
||||
|
||||
#define MAX_BUFF_SIZE 1000
|
||||
|
||||
#define DEBUG_PATH "./log/"
|
||||
|
||||
|
||||
static bool debug = false;
|
||||
|
||||
static char host [MAX_BUFF_SIZE];
|
||||
|
||||
std :: vector <FILE *> files;
|
||||
|
||||
|
||||
void setDebugMode (bool __dbg)
|
||||
{
|
||||
|
||||
debug = __dbg;
|
||||
gethostname (host, MAX_BUFF_SIZE);
|
||||
}
|
||||
|
||||
extern int getNodeRank ();
|
||||
|
||||
void initDebugging ()
|
||||
{
|
||||
|
||||
mkdir (DEBUG_PATH, S_IRWXU);
|
||||
// files.push_back (stdout);
|
||||
char buff [MAX_BUFF_SIZE];
|
||||
sprintf (buff, "%s/%d", DEBUG_PATH, getNodeRank ());
|
||||
files.push_back (fopen (buff, "w"));
|
||||
}
|
||||
|
||||
void endDebugging ()
|
||||
{
|
||||
|
||||
for (unsigned i = 0; i < files.size (); i ++)
|
||||
if (files [i] != stdout)
|
||||
fclose (files [i]);
|
||||
files.clear();
|
||||
}
|
||||
|
||||
void printDebugMessage (const char * __mess)
|
||||
{
|
||||
|
||||
if (debug)
|
||||
{
|
||||
|
||||
char buff [MAX_BUFF_SIZE];
|
||||
char localTime [MAX_BUFF_SIZE];
|
||||
time_t t = time (0);
|
||||
|
||||
/* Date */
|
||||
strcpy( localTime, ctime (& t) );
|
||||
localTime[ strlen( localTime )-1 ] = ']';
|
||||
sprintf (buff, "[%s][%s: ", host, localTime );
|
||||
|
||||
for (unsigned i = 0; i < files.size (); i ++)
|
||||
fprintf (files [i],"%s" ,buff);
|
||||
|
||||
/* Message */
|
||||
sprintf (buff, "%s", __mess);
|
||||
|
||||
for (unsigned i = 0; i < files.size (); i ++)
|
||||
{
|
||||
fputs (buff, files [i]);
|
||||
fputs ("\n", files [i]);
|
||||
fflush (files [i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* <peo_debug.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 __peo_debug_h
|
||||
#define __peo_debug_h
|
||||
|
||||
extern void initDebugging ();
|
||||
|
||||
extern void endDebugging ();
|
||||
|
||||
extern void setDebugMode (bool __dbg = true); /* (Des)activating the Debugging mode */
|
||||
|
||||
extern void printDebugMessage (const char * __mess); /* Print a new message both on the
|
||||
standard output and a target
|
||||
text-file in a subdirectory) */
|
||||
|
||||
#endif
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
* <peo_fin.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 "peo_fin.h"
|
||||
#include "peo_debug.h"
|
||||
#include "runner.h"
|
||||
#include "rmc.h"
|
||||
|
||||
void peo :: finalize ()
|
||||
{
|
||||
|
||||
printDebugMessage ("waiting for the termination of all threads");
|
||||
|
||||
joinRunners ();
|
||||
finalizeRMC ();
|
||||
|
||||
printDebugMessage ("this is the end");
|
||||
endDebugging ();
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* <peo_fin.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 __peo_finalize_h
|
||||
#define __peo_finalize_h
|
||||
|
||||
namespace peo
|
||||
{
|
||||
|
||||
extern void finalize ();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
/*
|
||||
* <peo_init.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 <stdio.h>
|
||||
|
||||
#include "peo_init.h"
|
||||
#include "peo_param.h"
|
||||
|
||||
#include "peo_debug.h"
|
||||
#include "rmc.h"
|
||||
#include "runner.h"
|
||||
|
||||
|
||||
extern void initCommunicableEnv ();
|
||||
extern void initBuffers ();
|
||||
|
||||
extern void initThreadsEnv ();
|
||||
extern void initReactiveThreadsEnv ();
|
||||
|
||||
extern void initRunnersEnv ();
|
||||
extern void initWorkersEnv ();
|
||||
|
||||
extern void initScheduler ();
|
||||
extern void initSynchron ();
|
||||
|
||||
|
||||
static void initExecutionEnv()
|
||||
{
|
||||
|
||||
initCommunicableEnv ();
|
||||
initBuffers ();
|
||||
initScheduler();
|
||||
initSynchron ();
|
||||
|
||||
initThreadsEnv ();
|
||||
initReactiveThreadsEnv ();
|
||||
|
||||
initRunnersEnv ();
|
||||
initWorkersEnv ();
|
||||
}
|
||||
|
||||
|
||||
namespace peo
|
||||
{
|
||||
|
||||
int * argc;
|
||||
|
||||
char * * * argv;
|
||||
|
||||
void init (int & __argc, char * * & __argv)
|
||||
{
|
||||
|
||||
argc = & __argc;
|
||||
|
||||
argv = & __argv;
|
||||
|
||||
/* Initializing the execution environment */
|
||||
initExecutionEnv();
|
||||
|
||||
/* Loading the common parameters */
|
||||
loadParameters (__argc, __argv);
|
||||
|
||||
/* Initializing the the Resource Management and Communication */
|
||||
initRMC ( *peo::argc, *peo::argv);
|
||||
|
||||
/* */
|
||||
initDebugging ();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* <peo_init.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 __peo_init_h
|
||||
#define __peo_init_h
|
||||
|
||||
namespace peo
|
||||
{
|
||||
|
||||
extern int * argc;
|
||||
|
||||
extern char * * * argv;
|
||||
|
||||
extern void init (int & __argc, char * * & __argv);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* <peo_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 "peo_param.h"
|
||||
#include "peo_debug.h"
|
||||
|
||||
|
||||
void peo :: loadParameters (int & __argc, char * * & __argv)
|
||||
{
|
||||
|
||||
eoParser parser (__argc, __argv);
|
||||
|
||||
/* Debug */
|
||||
eoValueParam <std :: string> debug_param ("false", "debug", "?");
|
||||
parser.processParam (debug_param);
|
||||
if (debug_param.value () == "true")
|
||||
setDebugMode ();
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* <peo_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 __peo_param_h
|
||||
#define __peo_param_h
|
||||
|
||||
namespace peo
|
||||
{
|
||||
|
||||
extern void loadParameters (int & __argc, char * * & __argv);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* <peo_run.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 "peo_run.h"
|
||||
#include "rmc.h"
|
||||
#include "runner.h"
|
||||
|
||||
|
||||
void peo :: run ()
|
||||
{
|
||||
|
||||
startRunners ();
|
||||
|
||||
runRMC ();
|
||||
}
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* <peo_run.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 __peo_run_h
|
||||
#define __peo_run_h
|
||||
|
||||
namespace peo
|
||||
{
|
||||
|
||||
extern void run ();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
* <random_topo.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 <cassert>
|
||||
#include "random_topo.h"
|
||||
|
||||
#include <utils/eoRNG.h>
|
||||
|
||||
void RandomTopology :: setNeighbors (Cooperative * __mig,
|
||||
std :: vector <Cooperative *> & __from,
|
||||
std :: vector <Cooperative *> & __to)
|
||||
{
|
||||
|
||||
__from.clear () ;
|
||||
__to.clear () ;
|
||||
|
||||
for (unsigned i = 0; i < mig.size (); i ++)
|
||||
{
|
||||
if (mig [i] != __mig && rng.uniform() < 0.5 )
|
||||
{
|
||||
__from.push_back (mig [i]);
|
||||
__to.push_back (mig [i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
* <random_topo.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 __random_topo_h
|
||||
#define __random_topo_h
|
||||
|
||||
#include "topology.h"
|
||||
|
||||
class RandomTopology : public Topology
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
void setNeighbors (Cooperative * __mig,
|
||||
std :: vector <Cooperative *> & __from,
|
||||
std :: vector <Cooperative *> & __to);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,82 +0,0 @@
|
|||
/*
|
||||
* <reac_thread.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 "reac_thread.h"
|
||||
|
||||
static bool the_end = false;
|
||||
|
||||
static std :: vector <ReactiveThread *> reac_threads;
|
||||
|
||||
|
||||
ReactiveThread :: ReactiveThread ()
|
||||
{
|
||||
|
||||
reac_threads.push_back (this);
|
||||
sem_init (& sem, 0, 0);
|
||||
}
|
||||
|
||||
void ReactiveThread :: sleep ()
|
||||
{
|
||||
|
||||
sem_wait (& sem);
|
||||
}
|
||||
|
||||
void ReactiveThread :: wakeUp ()
|
||||
{
|
||||
|
||||
sem_post (& sem);
|
||||
}
|
||||
|
||||
void initReactiveThreadsEnv ()
|
||||
{
|
||||
|
||||
the_end = false;
|
||||
reac_threads.clear ();
|
||||
}
|
||||
|
||||
void stopReactiveThreads ()
|
||||
{
|
||||
|
||||
the_end = true;
|
||||
for (unsigned i = 0; i < reac_threads.size (); i ++)
|
||||
reac_threads [i] -> wakeUp ();
|
||||
reac_threads.clear ();
|
||||
}
|
||||
|
||||
bool theEnd ()
|
||||
{
|
||||
return the_end;
|
||||
}
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* <reac_thread.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 REAC_THREAD_H_
|
||||
#define REAC_THREAD_H_
|
||||
|
||||
#include <semaphore.h>
|
||||
|
||||
#include "thread.h"
|
||||
|
||||
|
||||
class ReactiveThread : public Thread
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/* Ctor */
|
||||
ReactiveThread ();
|
||||
|
||||
void sleep ();
|
||||
|
||||
void wakeUp ();
|
||||
|
||||
private:
|
||||
|
||||
sem_t sem;
|
||||
};
|
||||
|
||||
extern void initReactiveThreadsEnv ();
|
||||
|
||||
extern void stopReactiveThreads ();
|
||||
|
||||
#endif /*REAC_THREAD_H_*/
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* <ring_topo.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 "ring_topo.h"
|
||||
|
||||
void RingTopology :: setNeighbors (Cooperative * __mig,
|
||||
std :: vector <Cooperative *> & __from,
|
||||
std :: vector <Cooperative *> & __to)
|
||||
{
|
||||
__from.clear () ;
|
||||
__to.clear () ;
|
||||
|
||||
int len = mig.size () ;
|
||||
|
||||
for (int i = 0 ; i < len ; i ++)
|
||||
if (mig [i] == __mig)
|
||||
{
|
||||
__from.push_back (mig [(i - 1 + len) % len]) ;
|
||||
__to.push_back (mig [(i + 1) % len]) ;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
* <ring_topo.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 __ring_topo_h
|
||||
#define __ring_topo_h
|
||||
|
||||
#include "topology.h"
|
||||
|
||||
class RingTopology : public Topology
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
void setNeighbors (Cooperative * __mig,
|
||||
std :: vector <Cooperative *> & __from,
|
||||
std :: vector <Cooperative *> & __to);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
* <rmc.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_h
|
||||
#define __rmc_h
|
||||
|
||||
extern void initRMC (int & __argc, char * * & __argv);
|
||||
|
||||
extern void runRMC (); /* Resource Management and Communication */
|
||||
|
||||
extern void finalizeRMC ();
|
||||
|
||||
#endif
|
||||
|
|
@ -1,227 +0,0 @@
|
|||
/*
|
||||
* <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 <vector>
|
||||
#include <iostream>
|
||||
#include "runner.h"
|
||||
#include "reac_thread.h"
|
||||
#include "peo_debug.h"
|
||||
#include "messaging.h"
|
||||
|
||||
#include "../rmc/mpi/mess.h"
|
||||
#include "../rmc/mpi/tags.h"
|
||||
|
||||
#include "../rmc/mpi/node.h"
|
||||
#include "../rmc/mpi/schema.h"
|
||||
|
||||
|
||||
static std :: vector <pthread_t *> ll_threads; /* Low-level runner threads */
|
||||
|
||||
static std :: vector <Runner *> the_runners;
|
||||
|
||||
static unsigned num_def_runners = 0; /* Number of defined runners */
|
||||
|
||||
static unsigned num_local_exec_runners = 0; /* Number of locally executing runners */
|
||||
|
||||
static unsigned num_exec_runners = 0; /* Number of globally executing runners */
|
||||
|
||||
|
||||
extern int getNodeRank ();
|
||||
|
||||
extern int getNumberOfNodes ();
|
||||
|
||||
extern void wakeUpCommunicator ();
|
||||
|
||||
|
||||
Runner :: Runner ()
|
||||
{
|
||||
|
||||
exec_id = 0;
|
||||
def_id = ++ num_def_runners;
|
||||
|
||||
the_runners.push_back (this);
|
||||
|
||||
sem_init (& sem_start, 0, 0);
|
||||
sem_init (& sem_cntxt, 0, 0);
|
||||
}
|
||||
|
||||
RUNNER_ID Runner :: getDefinitionID ()
|
||||
{
|
||||
|
||||
return def_id;
|
||||
}
|
||||
|
||||
RUNNER_ID Runner :: getExecutionID ()
|
||||
{
|
||||
|
||||
return exec_id;
|
||||
}
|
||||
|
||||
void Runner :: setExecutionID (const RUNNER_ID& execution_id)
|
||||
{
|
||||
|
||||
exec_id = execution_id;
|
||||
}
|
||||
|
||||
Runner * getRunner (RUNNER_ID __key)
|
||||
{
|
||||
|
||||
return dynamic_cast <Runner *> (getCommunicable (__key));
|
||||
}
|
||||
|
||||
void initializeContext ()
|
||||
{
|
||||
|
||||
num_local_exec_runners = 0;
|
||||
|
||||
//synchronizeNodes ();
|
||||
// setting up the execution IDs & counting the number of local exec. runners
|
||||
for (unsigned i = 0; i < the_runners.size (); i ++)
|
||||
{
|
||||
if (my_node->execution_id_run.size() > 0)
|
||||
the_runners [i] -> setExecutionID ( my_node -> execution_id_run[ i ] );
|
||||
if (the_runners [i] -> isAssignedLocally ()) num_local_exec_runners ++;
|
||||
}
|
||||
|
||||
collectiveCountOfRunners( &num_local_exec_runners, &num_exec_runners );
|
||||
|
||||
// synchronizeNodes ();
|
||||
|
||||
for (unsigned i = 0; i < the_runners.size (); i ++)
|
||||
if (the_runners [i] -> isAssignedLocally ()) the_runners [i] -> notifyContextInitialized ();
|
||||
}
|
||||
|
||||
void Runner :: waitStarting ()
|
||||
{
|
||||
|
||||
sem_wait (& sem_start);
|
||||
}
|
||||
|
||||
void Runner :: waitContextInitialization ()
|
||||
{
|
||||
|
||||
sem_wait (& sem_cntxt);
|
||||
}
|
||||
|
||||
void Runner :: start ()
|
||||
{
|
||||
|
||||
setActive ();
|
||||
|
||||
sem_post (& sem_start);
|
||||
|
||||
waitContextInitialization ();
|
||||
run ();
|
||||
terminate ();
|
||||
}
|
||||
|
||||
void startRunners ()
|
||||
{
|
||||
|
||||
/* Runners */
|
||||
for (unsigned i = 0; i < the_runners.size (); i ++)
|
||||
if (the_runners [i] -> isAssignedLocally ())
|
||||
{
|
||||
addThread (the_runners [i], ll_threads);
|
||||
the_runners [i] -> waitStarting ();
|
||||
}
|
||||
|
||||
printDebugMessage ("launched the parallel runners");
|
||||
}
|
||||
|
||||
void joinRunners ()
|
||||
{
|
||||
|
||||
joinThreads (ll_threads);
|
||||
the_runners.clear();
|
||||
}
|
||||
|
||||
bool atLeastOneActiveRunner ()
|
||||
{
|
||||
|
||||
return num_exec_runners;
|
||||
}
|
||||
|
||||
unsigned numberOfActiveRunners ()
|
||||
{
|
||||
|
||||
return num_exec_runners;
|
||||
}
|
||||
|
||||
void Runner :: notifyContextInitialized ()
|
||||
{
|
||||
|
||||
sem_post (& sem_cntxt);
|
||||
}
|
||||
|
||||
void Runner :: notifySendingTermination ()
|
||||
{
|
||||
|
||||
printDebugMessage ("I am informed that everyone received my termination notification.");
|
||||
setPassive ();
|
||||
}
|
||||
|
||||
void unpackTerminationOfRunner ()
|
||||
{
|
||||
|
||||
RUNNER_ID finished_id;
|
||||
unpack (finished_id);
|
||||
|
||||
num_exec_runners --;
|
||||
|
||||
printDebugMessage ("I'm noticed of the termination of a runner");
|
||||
|
||||
if (!num_exec_runners)
|
||||
{
|
||||
|
||||
printDebugMessage ("All the runners have terminated - now stopping the reactive threads.");
|
||||
stopReactiveThreads ();
|
||||
printDebugMessage ("Reactive threads stopped!");
|
||||
}
|
||||
|
||||
wakeUpCommunicator ();
|
||||
}
|
||||
|
||||
void initRunnersEnv ()
|
||||
{
|
||||
|
||||
ll_threads.clear ();
|
||||
the_runners.clear ();
|
||||
|
||||
num_def_runners = 0;
|
||||
num_local_exec_runners = 0;
|
||||
num_exec_runners = 0;
|
||||
}
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
/*
|
||||
* <runner.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 __runner_h
|
||||
#define __runner_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
#include "communicable.h"
|
||||
#include "thread.h"
|
||||
|
||||
|
||||
typedef unsigned RUNNER_ID;
|
||||
|
||||
|
||||
class Runner : public Communicable, public Thread
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
Runner ();
|
||||
|
||||
RUNNER_ID getDefinitionID ();
|
||||
|
||||
RUNNER_ID getExecutionID ();
|
||||
|
||||
void setExecutionID (const RUNNER_ID& execution_id);
|
||||
|
||||
bool isAssignedLocally ();
|
||||
|
||||
void waitStarting ();
|
||||
|
||||
void waitContextInitialization ();
|
||||
|
||||
void start ();
|
||||
|
||||
virtual void run () = 0;
|
||||
|
||||
void terminate ();
|
||||
|
||||
void notifyContextInitialized ();
|
||||
|
||||
void notifySendingTermination ();
|
||||
|
||||
void packTermination ();
|
||||
|
||||
private :
|
||||
|
||||
sem_t sem_start;
|
||||
sem_t sem_cntxt;
|
||||
|
||||
unsigned def_id;
|
||||
unsigned exec_id;
|
||||
};
|
||||
|
||||
|
||||
extern void initRunnersEnv ();
|
||||
|
||||
extern Runner * getRunner (RUNNER_ID __key);
|
||||
|
||||
extern void initializeContext ();
|
||||
|
||||
extern void startRunners ();
|
||||
|
||||
extern void joinRunners ();
|
||||
|
||||
extern bool atLeastOneActiveRunner ();
|
||||
|
||||
extern unsigned numberOfActiveRunners ();
|
||||
|
||||
extern void unpackTerminationOfRunner ();
|
||||
|
||||
#endif
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
/*
|
||||
* <service.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 "service.h"
|
||||
|
||||
void Service :: setOwner (Thread & __owner)
|
||||
{
|
||||
|
||||
owner = & __owner;
|
||||
}
|
||||
|
||||
Thread * Service :: getOwner ()
|
||||
{
|
||||
|
||||
return owner;
|
||||
}
|
||||
|
||||
Service * getService (SERVICE_ID __key)
|
||||
{
|
||||
|
||||
return dynamic_cast <Service *> (getCommunicable (__key));
|
||||
}
|
||||
|
||||
void Service :: notifySendingData ()
|
||||
{ }
|
||||
|
||||
void Service :: notifySendingResourceRequest ()
|
||||
{
|
||||
|
||||
num_sent_rr --;
|
||||
if (! num_sent_rr)
|
||||
notifySendingAllResourceRequests ();
|
||||
}
|
||||
|
||||
void Service :: notifySendingAllResourceRequests ()
|
||||
{ }
|
||||
|
||||
void Service :: packData ()
|
||||
{}
|
||||
|
||||
void Service :: unpackData ()
|
||||
{}
|
||||
|
||||
void Service :: execute ()
|
||||
{}
|
||||
|
||||
void Service :: packResult ()
|
||||
{}
|
||||
|
||||
void Service :: unpackResult ()
|
||||
{}
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
* <service.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 __service_h
|
||||
#define __service_h
|
||||
|
||||
#include "communicable.h"
|
||||
#include "thread.h"
|
||||
|
||||
|
||||
typedef unsigned SERVICE_ID;
|
||||
|
||||
class Service : public Communicable
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
void setOwner (Thread & __owner);
|
||||
|
||||
Thread * getOwner ();
|
||||
|
||||
void requestResourceRequest (unsigned __how_many = 1);
|
||||
void packResourceRequest ();
|
||||
|
||||
virtual void packData ();
|
||||
virtual void unpackData ();
|
||||
|
||||
virtual void execute ();
|
||||
|
||||
virtual void packResult ();
|
||||
virtual void unpackResult ();
|
||||
|
||||
virtual void notifySendingData ();
|
||||
virtual void notifySendingResourceRequest ();
|
||||
virtual void notifySendingAllResourceRequests ();
|
||||
|
||||
private :
|
||||
|
||||
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)*/
|
||||
|
||||
};
|
||||
|
||||
extern Service * getService (SERVICE_ID __key);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* <star_topo.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 <cassert>
|
||||
#include "star_topo.h"
|
||||
|
||||
StarTopology :: StarTopology () : center( NULL ) {}
|
||||
|
||||
void StarTopology :: setNeighbors (Cooperative * __mig,
|
||||
std :: vector <Cooperative *> & __from,
|
||||
std :: vector <Cooperative *> & __to)
|
||||
{
|
||||
|
||||
assert( center != NULL );
|
||||
|
||||
__from.clear () ;
|
||||
__to.clear () ;
|
||||
|
||||
if ( __mig == center )
|
||||
{
|
||||
|
||||
for (unsigned i = 0; i < mig.size (); i ++)
|
||||
{
|
||||
if (mig [i] != center)
|
||||
{
|
||||
__from.push_back (mig [i]);
|
||||
__to.push_back (mig [i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
__from.push_back (center);
|
||||
__to.push_back (center);
|
||||
}
|
||||
}
|
||||
|
||||
void StarTopology :: setCenter (Cooperative& __center)
|
||||
{
|
||||
|
||||
center = &__center;
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* <star_topo.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 __star_topo_h
|
||||
#define __star_topo_h
|
||||
|
||||
#include "topology.h"
|
||||
|
||||
class StarTopology : public Topology
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
StarTopology ();
|
||||
|
||||
void setNeighbors (Cooperative * __mig,
|
||||
std :: vector <Cooperative *> & __from,
|
||||
std :: vector <Cooperative *> & __to);
|
||||
|
||||
void setCenter (Cooperative& __center);
|
||||
|
||||
private :
|
||||
|
||||
Cooperative* center;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,120 +0,0 @@
|
|||
/*
|
||||
* <thread.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 <map>
|
||||
|
||||
#include "thread.h"
|
||||
|
||||
static std :: vector <Thread *> threads;
|
||||
|
||||
unsigned num_act = 0;
|
||||
|
||||
|
||||
Thread :: Thread ()
|
||||
{
|
||||
|
||||
threads.push_back (this);
|
||||
act = false;
|
||||
}
|
||||
|
||||
Thread :: ~ Thread ()
|
||||
{
|
||||
|
||||
/* Nothing ! */
|
||||
}
|
||||
|
||||
void Thread :: setActive ()
|
||||
{
|
||||
|
||||
if (! act)
|
||||
{
|
||||
|
||||
act = true;
|
||||
num_act ++;
|
||||
}
|
||||
}
|
||||
|
||||
void Thread :: setPassive ()
|
||||
{
|
||||
|
||||
if (act)
|
||||
{
|
||||
|
||||
act = false;
|
||||
num_act --;
|
||||
}
|
||||
}
|
||||
|
||||
void initThreadsEnv ()
|
||||
{
|
||||
|
||||
threads.clear ();
|
||||
num_act = 0;
|
||||
}
|
||||
|
||||
bool atLeastOneActiveThread ()
|
||||
{
|
||||
|
||||
return num_act;
|
||||
}
|
||||
|
||||
static void * launch (void * __arg)
|
||||
{
|
||||
|
||||
Thread * thr = (Thread *) __arg;
|
||||
thr -> start ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void addThread (Thread * __hl_thread, std :: vector <pthread_t *> & __ll_threads)
|
||||
{
|
||||
|
||||
pthread_t * ll_thr = new pthread_t;
|
||||
__ll_threads.push_back (ll_thr);
|
||||
pthread_create (ll_thr, 0, launch, __hl_thread);
|
||||
}
|
||||
|
||||
void joinThreads (std :: vector <pthread_t *> & __threads)
|
||||
{
|
||||
|
||||
for (unsigned i = 0; i < __threads.size (); i ++)
|
||||
{
|
||||
pthread_join (* __threads [i], 0);
|
||||
delete __threads [i];
|
||||
}
|
||||
__threads.clear();
|
||||
}
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
* <thread.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 THREAD_H_
|
||||
#define THREAD_H_
|
||||
|
||||
#include <vector>
|
||||
#include <pthread.h>
|
||||
|
||||
/* A high-level thread */
|
||||
class Thread
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/* Ctor */
|
||||
Thread ();
|
||||
|
||||
/* Dtor */
|
||||
virtual ~ Thread ();
|
||||
|
||||
/* Go ! */
|
||||
virtual void start () = 0;
|
||||
|
||||
void setActive ();/* It means the current process is going to send messages soon */
|
||||
void setPassive ();/* The current process is not going to perform send operations
|
||||
(but it may receive messages) */
|
||||
|
||||
private :
|
||||
|
||||
bool act;
|
||||
};
|
||||
|
||||
extern void initThreadsEnv ();
|
||||
|
||||
extern void addThread (Thread * __hl_thread, std :: vector <pthread_t *> & __ll_threads);
|
||||
|
||||
extern void joinThreads (std :: vector <pthread_t *> & __ll_threads);
|
||||
|
||||
extern bool atLeastOneActiveThread (); /* It returns 'true' iff at least one process is going
|
||||
to send messages */
|
||||
|
||||
#endif /*THREAD_H_*/
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* <topology.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 "topology.h"
|
||||
|
||||
Topology :: ~ Topology ()
|
||||
{
|
||||
|
||||
/* Nothing ! */
|
||||
}
|
||||
|
||||
void Topology :: add (Cooperative & __mig)
|
||||
{
|
||||
|
||||
mig.push_back (& __mig) ;
|
||||
}
|
||||
|
||||
Topology :: operator std :: vector <Cooperative *>& ()
|
||||
{
|
||||
|
||||
return mig;
|
||||
}
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* <topology.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 __topology_h
|
||||
#define __topology_h
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "cooperative.h"
|
||||
|
||||
class Topology
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
virtual ~Topology ();
|
||||
|
||||
void add (Cooperative & __mig);
|
||||
|
||||
virtual void setNeighbors (Cooperative * __mig,
|
||||
std :: vector <Cooperative *> & __from,
|
||||
std :: vector <Cooperative *> & __to) = 0;
|
||||
|
||||
operator std :: vector <Cooperative *>& ();
|
||||
|
||||
protected:
|
||||
|
||||
std :: vector <Cooperative *> mig;
|
||||
};
|
||||
|
||||
#endif
|
||||
42
peo/src/peo
42
peo/src/peo
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* <peo>
|
||||
* 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 __peo_
|
||||
#define __peo_
|
||||
|
||||
#include "peo.h"
|
||||
|
||||
#endif
|
||||
147
peo/src/peo.h
147
peo/src/peo.h
|
|
@ -1,147 +0,0 @@
|
|||
/*
|
||||
* <peo.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 __peo_h_
|
||||
#define __peo_h_
|
||||
|
||||
#include <eo>
|
||||
//#include <oldmo>
|
||||
#include <moeo>
|
||||
|
||||
/** @mainpage Welcome to Paradiseo-PEO
|
||||
|
||||
@section Introduction
|
||||
|
||||
PEO is an extension of the ANSI-C++ compliant evolutionary computation library EO.
|
||||
<BR>
|
||||
It contains classes for the most common parallel and distributed models and hybridization mechanisms.
|
||||
|
||||
@section authors AUTHORS
|
||||
|
||||
<TABLE>
|
||||
<TR>
|
||||
<TD>
|
||||
Sebastien CAHON
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
Alexandru-Adrian TANTAR
|
||||
</TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD>
|
||||
Clive Canape
|
||||
</TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
@section LICENSE
|
||||
|
||||
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
|
||||
|
||||
|
||||
@section Paradiseo Home Page
|
||||
|
||||
<A href=http://paradiseo.gforge.inria.fr>http://paradiseo.gforge.inria.fr</A>
|
||||
|
||||
@section Installation
|
||||
|
||||
The installation procedure of the package is detailed in the
|
||||
<a href="../../README">README</a> file in the top-directory of the source-tree.
|
||||
|
||||
*/
|
||||
|
||||
#include "core/peo_init.h"
|
||||
#include "core/peo_run.h"
|
||||
#include "core/peo_fin.h"
|
||||
|
||||
#include "core/messaging.h"
|
||||
#include "core/eoPop_mesg.h"
|
||||
#include "core/eoVector_mesg.h"
|
||||
|
||||
#include "peoWrapper.h"
|
||||
|
||||
/* <------- components for parallel algorithms -------> */
|
||||
#include "peoTransform.h"
|
||||
#include "peoEvalFunc.h"
|
||||
#include "peoPopEval.h"
|
||||
#include "peoMoeoPopEval.h"
|
||||
|
||||
/* Cooperative island model */
|
||||
#include "core/ring_topo.h"
|
||||
#include "core/star_topo.h"
|
||||
#include "core/random_topo.h"
|
||||
#include "core/complete_topo.h"
|
||||
#include "peoData.h"
|
||||
#include "peoSyncIslandMig.h"
|
||||
#include "peoAsyncIslandMig.h"
|
||||
#include "peoAsyncDataTransfer.h"
|
||||
#include "peoSyncDataTransfer.h"
|
||||
|
||||
/* Synchronous multi-start model */
|
||||
#include "peoMultiStart.h"
|
||||
/* <------- components for parallel algorithms -------> */
|
||||
|
||||
/* Parallel PSO */
|
||||
#include "peoPSO.h"
|
||||
|
||||
#endif
|
||||
|
|
@ -1,57 +0,0 @@
|
|||
/*
|
||||
* <peoAggEvalFunc.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 __peoAggEvalFunc_h
|
||||
#define __peoAggEvalFunc_h
|
||||
|
||||
#include <eoFunctor.h>
|
||||
|
||||
//! Interface class for creating an aggregate evaluation function.
|
||||
|
||||
//! The peoAggEvalFunc class offers only the interface for creating aggregate evaluation functions - there
|
||||
//! are no direct internal functions provided. The class inherits <b>public eoBF< EOT&, const typename EOT :: Fitness&, void ></b>
|
||||
//! thus requiring, for the derived classes, the creation of a function having the following signature:
|
||||
//!
|
||||
//! <table style="border:none; border-spacing:0px;text-align:left; vertical-align:top; font-size:8pt;" border="0">
|
||||
//! <tr><td>void operator()( EOT& __eot, const typename EOT :: Fitness& __partial_fittness ); </td> <td> </td></tr>
|
||||
//! </table>
|
||||
//!
|
||||
//! The aggregation object is called in an iterative manner for each of the results obtained by applying partial evaluation functions.
|
||||
template< class EOT > class peoAggEvalFunc : public eoBF< EOT&, const typename EOT :: Fitness&, void >
|
||||
{};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,208 +0,0 @@
|
|||
/*
|
||||
* <peoAsyncDataTransfer.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* 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 __peoAsyncDataTransfer_h
|
||||
#define __peoAsyncDataTransfer_h
|
||||
|
||||
|
||||
#include <queue>
|
||||
|
||||
#include <utils/eoUpdater.h>
|
||||
|
||||
#include "core/peoAbstractDefs.h"
|
||||
|
||||
#include "core/messaging.h"
|
||||
|
||||
#include "core/topology.h"
|
||||
#include "core/thread.h"
|
||||
#include "core/cooperative.h"
|
||||
#include "core/peo_debug.h"
|
||||
|
||||
|
||||
|
||||
class peoAsyncDataTransfer : public Cooperative, public eoUpdater
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
template< typename EndPointType >
|
||||
peoAsyncDataTransfer(
|
||||
|
||||
EndPointType& __endPoint,
|
||||
Topology& __topology
|
||||
|
||||
) : topology( __topology )
|
||||
{
|
||||
|
||||
source = new MsgTransferQueue< EndPointType >( __endPoint );
|
||||
destination = new MsgTransferQueue< EndPointType >( __endPoint );
|
||||
__topology.add( *this );
|
||||
}
|
||||
|
||||
template< typename EndPointType, typename FunctorType >
|
||||
peoAsyncDataTransfer(
|
||||
|
||||
EndPointType& __endPoint,
|
||||
Topology& __topology,
|
||||
FunctorType& externalFunctorRef
|
||||
|
||||
) : topology( __topology )
|
||||
{
|
||||
|
||||
source = new MsgTransferQueue< EndPointType >( __endPoint, externalFunctorRef );
|
||||
destination = new MsgTransferQueue< EndPointType >( __endPoint, externalFunctorRef );
|
||||
__topology.add( *this );
|
||||
}
|
||||
|
||||
template< typename SourceEndPointType, typename DestinationEndPointType >
|
||||
peoAsyncDataTransfer(
|
||||
|
||||
SourceEndPointType& __source,
|
||||
DestinationEndPointType& __destination,
|
||||
Topology& __topology
|
||||
|
||||
) : topology( __topology )
|
||||
{
|
||||
|
||||
source = new MsgTransferQueue< SourceEndPointType >( __source );
|
||||
destination = new MsgTransferQueue< DestinationEndPointType >( __destination );
|
||||
__topology.add( *this );
|
||||
}
|
||||
|
||||
template< typename SourceEndPointType, typename DestinationEndPointType, typename FunctorType >
|
||||
peoAsyncDataTransfer(
|
||||
|
||||
SourceEndPointType& __source,
|
||||
DestinationEndPointType& __destination,
|
||||
Topology& __topology,
|
||||
FunctorType& externalFunctorRef
|
||||
|
||||
) : topology( __topology )
|
||||
{
|
||||
|
||||
source = new MsgTransferQueue< SourceEndPointType >( __source, externalFunctorRef );
|
||||
destination = new MsgTransferQueue< DestinationEndPointType >( __destination, externalFunctorRef );
|
||||
__topology.add( *this );
|
||||
}
|
||||
|
||||
~peoAsyncDataTransfer()
|
||||
{
|
||||
delete source;
|
||||
delete destination;
|
||||
}
|
||||
|
||||
|
||||
void operator()()
|
||||
{
|
||||
|
||||
sendData(); // sending data
|
||||
receiveData(); // receiving data
|
||||
}
|
||||
|
||||
void pack()
|
||||
{
|
||||
lock ();
|
||||
|
||||
::pack( coop_em.front()->getKey() );
|
||||
source->packMessage();
|
||||
coop_em.pop();
|
||||
|
||||
unlock();
|
||||
}
|
||||
|
||||
void unpack()
|
||||
{
|
||||
|
||||
lock ();
|
||||
destination->unpackMessage();
|
||||
unlock();
|
||||
}
|
||||
|
||||
void packSynchronizeReq(){}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void sendData()
|
||||
{
|
||||
|
||||
std :: vector< Cooperative* > in, out;
|
||||
topology.setNeighbors( this, in, out );
|
||||
|
||||
for ( unsigned i = 0; i < out.size(); i++ )
|
||||
{
|
||||
|
||||
source->pushMessage();
|
||||
|
||||
coop_em.push( out[i] );
|
||||
send( out[i] );
|
||||
|
||||
printDebugMessage( "peoAsyncDataTransfer: sending data." );
|
||||
}
|
||||
}
|
||||
|
||||
void receiveData()
|
||||
{
|
||||
|
||||
lock ();
|
||||
{
|
||||
|
||||
while ( !( destination->empty() ) )
|
||||
{
|
||||
|
||||
printDebugMessage( "peoAsyncDataTransfer: received data." );
|
||||
destination->popMessage();
|
||||
printDebugMessage( "peoAsyncDataTransfer: done reading data." );
|
||||
}
|
||||
}
|
||||
unlock();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// the neighboring topology
|
||||
Topology& topology;
|
||||
|
||||
// source and destination end-points
|
||||
AbstractMsgTransferQueue* source;
|
||||
AbstractMsgTransferQueue* destination;
|
||||
|
||||
std :: queue< Cooperative* > coop_em;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,198 +0,0 @@
|
|||
/*
|
||||
* <peoAsyncIslandMig.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
|
||||
* peoData 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 __peoAsyncIslandMig_h
|
||||
#define __peoAsyncIslandMig_h
|
||||
|
||||
|
||||
#include <queue>
|
||||
|
||||
#include <utils/eoUpdater.h>
|
||||
#include <eoContinue.h>
|
||||
#include <eoSelect.h>
|
||||
#include <eoReplacement.h>
|
||||
#include <eoPop.h>
|
||||
|
||||
|
||||
#include "core/messaging.h"
|
||||
#include "core/eoPop_mesg.h"
|
||||
#include "core/eoVector_mesg.h"
|
||||
#include "core/topology.h"
|
||||
#include "core/thread.h"
|
||||
#include "core/cooperative.h"
|
||||
#include "core/peo_debug.h"
|
||||
|
||||
|
||||
//! @class peoAsyncIslandMig
|
||||
//! @brief Specific class for a asynchronous migration
|
||||
//! @see Cooperative eoUpdater
|
||||
//! @version 2.0
|
||||
//! @date january 2008
|
||||
template< class TYPESELECT, class TYPEREPLACE > class peoAsyncIslandMig : public Cooperative, public eoUpdater
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! @brief Constructor
|
||||
//! @param continuator & __cont
|
||||
//! @param selector <TYPE> & __select
|
||||
//! @param replacement <TYPE> & __replace
|
||||
//! @param Topology& __topology
|
||||
peoAsyncIslandMig(
|
||||
continuator & __cont,
|
||||
selector <TYPESELECT> & __select,
|
||||
replacement <TYPEREPLACE> & __replace,
|
||||
Topology& __topology
|
||||
);
|
||||
|
||||
//! @brief operator
|
||||
void operator()();
|
||||
//! @brief Function realizing packages
|
||||
void pack();
|
||||
//! @brief Function reconstituting packages
|
||||
void unpack();
|
||||
//! @brief Function packSynchronizeReq
|
||||
void packSynchronizeReq();
|
||||
|
||||
private:
|
||||
//! @brief Function which sends some emigrants
|
||||
void emigrate();
|
||||
//! @brief Function which receives some immigrants
|
||||
void immigrate();
|
||||
|
||||
private:
|
||||
//! @param continuator & cont
|
||||
//! @param selector <TYPESELECT> & select
|
||||
//! @param replacement <TYPEREPLACE> & replace
|
||||
//! @param Topology& topology
|
||||
//! @param std :: queue< TYPEREPLACE > imm
|
||||
//! @param std :: queue< TYPESELECT > em
|
||||
//! @param std :: queue< Cooperative* > coop_em
|
||||
continuator & cont;
|
||||
selector <TYPESELECT> & select;
|
||||
replacement <TYPEREPLACE> & replace;
|
||||
Topology& topology;
|
||||
std :: queue< TYPEREPLACE > imm;
|
||||
std :: queue< TYPESELECT > em;
|
||||
std :: queue< Cooperative* > coop_em;
|
||||
};
|
||||
|
||||
|
||||
template< class TYPESELECT , class TYPEREPLACE> peoAsyncIslandMig< TYPESELECT, TYPEREPLACE > :: peoAsyncIslandMig(
|
||||
|
||||
continuator & __cont,
|
||||
selector <TYPESELECT> & __select,
|
||||
replacement <TYPEREPLACE> & __replace,
|
||||
Topology& __topology
|
||||
|
||||
) : select( __select ), replace( __replace ), topology( __topology ), cont(__cont)
|
||||
{
|
||||
|
||||
__topology.add( *this );
|
||||
}
|
||||
|
||||
|
||||
template< class TYPESELECT , class TYPEREPLACE> void peoAsyncIslandMig< TYPESELECT, TYPEREPLACE > :: pack()
|
||||
{
|
||||
lock ();
|
||||
::pack( coop_em.front()->getKey() );
|
||||
::pack(em.front());
|
||||
coop_em.pop();
|
||||
em.pop();
|
||||
unlock();
|
||||
}
|
||||
|
||||
|
||||
template< class TYPESELECT, class TYPEREPLACE> void peoAsyncIslandMig< TYPESELECT , TYPEREPLACE> :: unpack()
|
||||
{
|
||||
lock ();
|
||||
TYPEREPLACE mig;
|
||||
::unpack(mig);
|
||||
imm.push( mig );
|
||||
unlock();
|
||||
}
|
||||
|
||||
template< class TYPESELECT , class TYPEREPLACE> void peoAsyncIslandMig< TYPESELECT, TYPEREPLACE > :: packSynchronizeReq()
|
||||
{}
|
||||
|
||||
template< class TYPESELECT , class TYPEREPLACE> void peoAsyncIslandMig< TYPESELECT , TYPEREPLACE> :: emigrate()
|
||||
{
|
||||
std :: vector< Cooperative* >in, out;
|
||||
topology.setNeighbors( this, in, out );
|
||||
|
||||
for ( unsigned i = 0; i < out.size(); i++ )
|
||||
{
|
||||
|
||||
TYPESELECT mig;
|
||||
select(mig);
|
||||
em.push( mig );
|
||||
coop_em.push( out[i] );
|
||||
send( out[i] );
|
||||
printDebugMessage( "sending some emigrants." );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template< class TYPESELECT, class TYPEREPLACE> void peoAsyncIslandMig< TYPESELECT , TYPEREPLACE> :: immigrate()
|
||||
{
|
||||
|
||||
lock ();
|
||||
{
|
||||
|
||||
while ( !imm.empty() )
|
||||
{
|
||||
replace(imm.front() );
|
||||
imm.pop();
|
||||
printDebugMessage( "receiving some immigrants." );
|
||||
}
|
||||
}
|
||||
unlock();
|
||||
}
|
||||
|
||||
|
||||
template< class TYPESELECT , class TYPEREPLACE> void peoAsyncIslandMig< TYPESELECT , TYPEREPLACE > :: operator()()
|
||||
{
|
||||
|
||||
if (! cont.check())
|
||||
{
|
||||
|
||||
emigrate();
|
||||
immigrate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,262 +0,0 @@
|
|||
/*
|
||||
* <peoData.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* Clive Canape, Thomas Legrand
|
||||
*
|
||||
* 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
|
||||
* peoData 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 _PEODATA_H
|
||||
#define _PEODATA_H
|
||||
|
||||
#include "core/eoVector_mesg.h"
|
||||
#include "core/messaging.h"
|
||||
|
||||
/**************************************************************************************/
|
||||
/************************** DEFINE A CONTINUATOR ***********************************/
|
||||
/**************************************************************************************/
|
||||
/*
|
||||
//! @class continuator
|
||||
//! @brief Abstract class for a continuator within the exchange of data by migration
|
||||
//! @version 1.0
|
||||
//! @date january 2008
|
||||
*/
|
||||
class continuator
|
||||
{
|
||||
public:
|
||||
/*
|
||||
//! @brief Virtual function of check
|
||||
//! @return true if the algorithm must continue
|
||||
*/
|
||||
virtual bool check()=0;
|
||||
// //! @brief Virtual destructor
|
||||
virtual ~continuator(){}
|
||||
};
|
||||
|
||||
/*
|
||||
//! @class eoContinuator
|
||||
//! @brief Specific class for a continuator within the exchange of migration of a population
|
||||
//! @see continuator
|
||||
//! @version 1.0
|
||||
//! @date january 2008
|
||||
*/
|
||||
template < class EOT> class eoContinuator : public continuator
|
||||
{
|
||||
public:
|
||||
/*
|
||||
//! @brief Constructor
|
||||
//! @param eoContinue<EOT> &
|
||||
//! @param eoPop<EOT> &
|
||||
*/
|
||||
eoContinuator(eoContinue<EOT> & _cont, const eoPop<EOT> & _pop): cont (_cont), pop(_pop)
|
||||
{}
|
||||
/*
|
||||
//! @brief Virtual function of check
|
||||
//! @return false if the algorithm must continue
|
||||
*/
|
||||
virtual bool check()
|
||||
{
|
||||
return cont(pop);
|
||||
}
|
||||
|
||||
protected:
|
||||
/*
|
||||
//! @param eoContinue<EOT> &
|
||||
//! @param eoPop<EOT> &
|
||||
*/
|
||||
eoContinue<EOT> & cont ;
|
||||
const eoPop<EOT> & pop;
|
||||
};
|
||||
|
||||
|
||||
/**************************************************************************************/
|
||||
/************************** DEFINE A SELECTOR **************************************/
|
||||
/**************************************************************************************/
|
||||
/*
|
||||
//! @class selector
|
||||
//! @brief Abstract class for a selector within the exchange of data by migration
|
||||
//! @version 1.0
|
||||
//! @date january 2008
|
||||
*/
|
||||
template < class TYPE> class selector
|
||||
{
|
||||
public:
|
||||
/*
|
||||
//! @brief Virtual operator on the template type
|
||||
//! @param TYPE &
|
||||
*/
|
||||
virtual void operator()(TYPE &)=0;
|
||||
// //! @brief Virtual destructor
|
||||
virtual ~selector(){}
|
||||
};
|
||||
|
||||
/*
|
||||
//! @class eoSelector
|
||||
//! @brief Specific class for a selector within the exchange of migration of a population
|
||||
//! @see selector
|
||||
//! @version 1.0
|
||||
//! @date january 2008
|
||||
*/
|
||||
template < class EOT, class TYPE> class eoSelector : public selector< TYPE >
|
||||
{
|
||||
public:
|
||||
/*
|
||||
//! @brief Constructor
|
||||
//! @param eoSelectOne<EOT> &
|
||||
//! @param unsigned _nb_select
|
||||
//! @param TYPE & _source (with TYPE which is the template type)
|
||||
*/
|
||||
eoSelector(eoSelectOne<EOT> & _select, unsigned _nb_select, const TYPE & _source): selector (_select), nb_select(_nb_select), source(_source)
|
||||
{}
|
||||
/*
|
||||
//! @brief Virtual operator on the template type
|
||||
//! @param TYPE & _dest
|
||||
*/
|
||||
virtual void operator()(TYPE & _dest)
|
||||
{
|
||||
size_t target = static_cast<size_t>(nb_select);
|
||||
_dest.resize(target);
|
||||
for (size_t i = 0; i < _dest.size(); ++i)
|
||||
_dest[i] = selector(source);
|
||||
}
|
||||
|
||||
protected:
|
||||
/*
|
||||
//! @param eoSelectOne<EOT> &
|
||||
//! @param unsigned nb_select
|
||||
//! @param TYPE & source
|
||||
*/
|
||||
eoSelectOne<EOT> & selector ;
|
||||
unsigned nb_select;
|
||||
const TYPE & source;
|
||||
};
|
||||
|
||||
|
||||
/**************************************************************************************/
|
||||
/************************** DEFINE A REPLACEMENT ***********************************/
|
||||
/**************************************************************************************/
|
||||
/*
|
||||
//! @class replacement
|
||||
//! @brief Abstract class for a replacement within the exchange of data by migration
|
||||
//! @version 1.0
|
||||
//! @date january 2008
|
||||
*/
|
||||
template < class TYPE> class replacement
|
||||
{
|
||||
public:
|
||||
/*
|
||||
//! @brief Virtual operator on the template type
|
||||
//! @param TYPE &
|
||||
*/
|
||||
virtual void operator()(TYPE &)=0;
|
||||
// //! @brief Virtual destructor
|
||||
virtual ~replacement(){}
|
||||
};
|
||||
|
||||
/*
|
||||
//! @class eoReplace
|
||||
//! @brief Specific class for a replacement within the exchange of migration of a population
|
||||
//! @see replacement
|
||||
//! @version 1.0
|
||||
//! @date january 2008
|
||||
*/
|
||||
template < class EOT, class TYPE> class eoReplace : public replacement< TYPE >
|
||||
{
|
||||
public:
|
||||
/*
|
||||
//! @brief Constructor
|
||||
//! @param eoReplacement<EOT> &
|
||||
//! @param TYPE & _destination (with TYPE which is the template type)
|
||||
*/
|
||||
eoReplace(eoReplacement<EOT> & _replace, TYPE & _destination): replace(_replace), destination(_destination)
|
||||
{}
|
||||
/*
|
||||
//! @brief Virtual operator on the template type
|
||||
//! @param TYPE & _source
|
||||
*/
|
||||
virtual void operator()(TYPE & _source)
|
||||
{
|
||||
replace(destination, _source);
|
||||
}
|
||||
|
||||
protected:
|
||||
/*
|
||||
//! @param eoReplacement<EOT> &
|
||||
//! @param TYPE & destination
|
||||
*/
|
||||
eoReplacement<EOT> & replace;
|
||||
TYPE & destination;
|
||||
};
|
||||
|
||||
|
||||
/**************************************************************************************/
|
||||
/************************ Continuator for synchrone migartion ************************/
|
||||
/**************************************************************************************/
|
||||
/*
|
||||
//! @class eoSyncContinue
|
||||
//! @brief Class for a continuator within the exchange of data by synchrone migration
|
||||
//! @see continuator
|
||||
//! @version 1.0
|
||||
//! @date january 2008
|
||||
*/
|
||||
class eoSyncContinue: public continuator
|
||||
{
|
||||
|
||||
public:
|
||||
/*
|
||||
//! @brief Constructor
|
||||
//! @param unsigned __period
|
||||
//! @param unsigned __init_counter
|
||||
*/
|
||||
eoSyncContinue (unsigned __period, unsigned __init_counter = 0): period (__period),counter (__init_counter)
|
||||
{}
|
||||
/*
|
||||
//! @brief Virtual function of check
|
||||
//! @return true if the algorithm must continue
|
||||
*/
|
||||
virtual bool check()
|
||||
{
|
||||
return ((++ counter) % period) != 0 ;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
/*
|
||||
//! @param unsigned period
|
||||
//! @param unsigned counter
|
||||
*/
|
||||
unsigned period;
|
||||
unsigned counter;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* <peoEvalFunc.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, INRIA, 2008
|
||||
*
|
||||
* 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: clive.canape@inria.fr
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef PEOEVALFUNC_H
|
||||
#define PEOEVALFUNC_H
|
||||
/*
|
||||
//! @class peoEvalFunc
|
||||
//! @brief Specific class for evaluation
|
||||
//! @see eoEvalFunc
|
||||
//! @version 1.0
|
||||
//! @date november 2007
|
||||
*/
|
||||
#ifdef _MSC_VER
|
||||
template< class EOT, class FitT = EOT::Fitness, class FunctionArg = const EOT& >
|
||||
#else
|
||||
template< class EOT, class FitT = typename EOT::Fitness, class FunctionArg = const EOT& >
|
||||
#endif
|
||||
struct peoEvalFunc: public eoEvalFunc<EOT>
|
||||
{
|
||||
/*
|
||||
//! @brief Constructor
|
||||
//! @param FitT (* _eval)( FunctionArg )
|
||||
*/
|
||||
peoEvalFunc( FitT (* _eval)( FunctionArg ) )
|
||||
: eoEvalFunc<EOT>(), evalFunc( _eval )
|
||||
{};
|
||||
/*
|
||||
//! @brief Virtual operator
|
||||
//! @param EOT & _peo
|
||||
*/
|
||||
virtual void operator() ( EOT & _peo )
|
||||
{
|
||||
_peo.fitness((*evalFunc)( _peo ));
|
||||
};
|
||||
|
||||
private:
|
||||
// //! @param FitT (* evalFunc )( FunctionArg )
|
||||
FitT (* evalFunc )( FunctionArg );
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -1,265 +0,0 @@
|
|||
/*
|
||||
* <peoMoeoPopEval.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* 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 __peoMoeoPopEval_h
|
||||
#define __peoMoeoPopEval_h
|
||||
|
||||
#include <queue>
|
||||
#include <eoEvalFunc.h>
|
||||
|
||||
#include "core/messaging.h"
|
||||
#include "core/peo_debug.h"
|
||||
#include "peoAggEvalFunc.h"
|
||||
#include "peoNoAggEvalFunc.h"
|
||||
|
||||
//! @class peoPopEval
|
||||
//! @brief Parallel evaluation functor wrapper with MOEO
|
||||
//! @see Service eoPopEvalFunc
|
||||
//! @version 1.0
|
||||
//! @date 2008
|
||||
template< class EOT > class peoMoeoPopEval : public Service, public eoPopEvalFunc<EOT>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor function - an EO-derived evaluation functor has to be specified; an internal reference
|
||||
//! is set towards the specified evaluation functor.
|
||||
//!
|
||||
//! @param eoEvalFunc< EOT >& __eval_func - EO-derived evaluation functor to be applied in parallel on each individual of a specified population
|
||||
peoMoeoPopEval( eoEvalFunc< EOT >& __eval_func );
|
||||
|
||||
//! Constructor function - a vector of EO-derived evaluation functors has to be specified as well as an aggregation function.
|
||||
//!
|
||||
//! @param const std :: vector< eoEvalFunc < EOT >* >& __funcs - vector of EO-derived partial evaluation functors;
|
||||
//! @param peoAggEvalFunc< EOT >& __merge_eval - aggregation functor for creating a fitness value out of the partial fitness values.
|
||||
peoMoeoPopEval( const std :: vector< eoEvalFunc < EOT >* >& __funcs, peoAggEvalFunc< EOT >& __merge_eval );
|
||||
|
||||
//! Operator for applying the evaluation functor (direct or aggregate) for each individual of the specified population.
|
||||
//!
|
||||
//! @param eoPop< EOT >& __pop - population to be evaluated by applying the evaluation functor specified in the constructor.
|
||||
void operator()(eoPop< EOT >& __pop);
|
||||
|
||||
//! @brief Operator ()( eoPop< EOT >& __dummy, eoPop< EOT >& __pop )
|
||||
//! @param eoPop< EOT >& __dummy
|
||||
//! @param eoPop< EOT >& __pop
|
||||
void operator()( eoPop< EOT >& __dummy, eoPop< EOT >& __pop );
|
||||
|
||||
//! Auxiliary function for transferring data between the process requesting an evaluation operation and the process that
|
||||
//! performs the actual evaluation phase. There is no need to explicitly call the function.
|
||||
void packData();
|
||||
|
||||
//! Auxiliary function for transferring data between the process requesting an evaluation operation and the process that
|
||||
//! performs the actual evaluation phase. There is no need to explicitly call the function.
|
||||
void unpackData();
|
||||
|
||||
//! Auxiliary function - it calls the specified evaluation functor(s). There is no need to explicitly call the function.
|
||||
void execute();
|
||||
|
||||
//! Auxiliary function for transferring data between the process requesting an evaluation operation and the process that
|
||||
//! performs the actual evaluation phase. There is no need to explicitly call the function.
|
||||
void packResult();
|
||||
|
||||
//! Auxiliary function for transferring data between the process requesting an evaluation operation and the process that
|
||||
//! performs the actual evaluation phase. There is no need to explicitly call the function.
|
||||
void unpackResult();
|
||||
|
||||
//! Auxiliary function for notifications between the process requesting an evaluation operation and the processes that
|
||||
//! performs the actual evaluation phase. There is no need to explicitly call the function.
|
||||
void notifySendingData();
|
||||
|
||||
//! Auxiliary function for notifications between the process requesting an evaluation operation and the processes that
|
||||
//! performs the actual evaluation phase. There is no need to explicitly call the function.
|
||||
void notifySendingAllResourceRequests();
|
||||
|
||||
private:
|
||||
//! @param std :: vector< eoEvalFunc < EOT >* >& funcs
|
||||
//! @param std :: vector< eoEvalFunc < EOT >* > one_func
|
||||
//! @param peoAggEvalFunc< EOT >& merge_eval
|
||||
//! @param peoNoAggEvalFunc< EOT > no_merge_eval
|
||||
//! @param std :: queue< EOT* >tasks
|
||||
//! @param std :: map< EOT*, std :: pair< unsigned, unsigned > > progression
|
||||
//! @param unsigned num_func
|
||||
//! @param EOT sol
|
||||
//! @param EOT *ad_sol
|
||||
//! @param unsigned total
|
||||
const std :: vector< eoEvalFunc < EOT >* >& funcs;
|
||||
std :: vector< eoEvalFunc < EOT >* > one_func;
|
||||
peoAggEvalFunc< EOT >& merge_eval;
|
||||
peoNoAggEvalFunc< EOT > no_merge_eval;
|
||||
std :: queue< EOT* >tasks;
|
||||
std :: map< EOT*, std :: pair< unsigned, unsigned > > progression;
|
||||
unsigned num_func;
|
||||
EOT sol;
|
||||
EOT *ad_sol;
|
||||
unsigned total;
|
||||
};
|
||||
|
||||
|
||||
template< class EOT > peoMoeoPopEval< EOT > :: peoMoeoPopEval( eoEvalFunc< EOT >& __eval_func ) :
|
||||
|
||||
funcs( one_func ), merge_eval( no_merge_eval )
|
||||
{
|
||||
|
||||
one_func.push_back( &__eval_func );
|
||||
}
|
||||
|
||||
|
||||
template< class EOT > peoMoeoPopEval< EOT > :: peoMoeoPopEval(
|
||||
|
||||
const std :: vector< eoEvalFunc< EOT >* >& __funcs,
|
||||
peoAggEvalFunc< EOT >& __merge_eval
|
||||
|
||||
) : funcs( __funcs ), merge_eval( __merge_eval )
|
||||
{}
|
||||
|
||||
template< class EOT > void peoMoeoPopEval< EOT >::operator()(eoPop< EOT >& __dummy, eoPop< EOT >& __pop )
|
||||
{
|
||||
this->operator()(__pop);
|
||||
}
|
||||
|
||||
template< class EOT > void peoMoeoPopEval< EOT >::operator()(eoPop< EOT >& __pop )
|
||||
{
|
||||
for ( unsigned i = 0; i < __pop.size(); i++ )
|
||||
{
|
||||
__pop[ i ].fitness(typename EOT :: Fitness() );
|
||||
progression[ &__pop[ i ] ].first = funcs.size() - 1;
|
||||
progression[ &__pop[ i ] ].second = funcs.size();
|
||||
for ( unsigned j = 0; j < funcs.size(); j++ )
|
||||
{
|
||||
/* Queuing the 'invalid' solution and its associated owner */
|
||||
tasks.push( &__pop[ i ] );
|
||||
}
|
||||
}
|
||||
total = funcs.size() * __pop.size();
|
||||
requestResourceRequest( funcs.size() * __pop.size() );
|
||||
stop();
|
||||
}
|
||||
|
||||
|
||||
template< class EOT > void peoMoeoPopEval< EOT > :: packData()
|
||||
{
|
||||
pack( progression[ tasks.front() ].first-- );
|
||||
|
||||
/* Packing the contents :-) of the solution */
|
||||
pack( *tasks.front() );
|
||||
|
||||
/* Packing the addresses of both the solution and the owner */
|
||||
pack( tasks.front() );
|
||||
tasks.pop( );
|
||||
}
|
||||
|
||||
|
||||
template< class EOT > void peoMoeoPopEval< EOT > :: unpackData()
|
||||
{
|
||||
unpack( num_func );
|
||||
/* Unpacking the solution */
|
||||
unpack( sol );
|
||||
/* Unpacking the @ of that one */
|
||||
unpack( ad_sol );
|
||||
}
|
||||
|
||||
|
||||
template< class EOT > void peoMoeoPopEval< EOT > :: execute()
|
||||
{
|
||||
|
||||
/* Computing the fitness of the solution */
|
||||
funcs[ num_func ]->operator()( sol );
|
||||
}
|
||||
|
||||
|
||||
template< class EOT > void peoMoeoPopEval< EOT > :: packResult()
|
||||
{
|
||||
/* Packing the fitness of the solution */
|
||||
std::vector < double > object;
|
||||
unsigned len;
|
||||
object=sol.objectiveVector();
|
||||
len=object.size();
|
||||
pack (len);
|
||||
for (unsigned i = 0 ; i < len; i ++)
|
||||
pack (object[i]);
|
||||
|
||||
/* Packing the @ of the individual */
|
||||
pack( ad_sol );
|
||||
}
|
||||
|
||||
|
||||
template< class EOT > void peoMoeoPopEval< EOT > :: unpackResult()
|
||||
{
|
||||
/* Unpacking the computed fitness */
|
||||
unsigned len;
|
||||
std::vector < double > object;
|
||||
|
||||
unpack(len);
|
||||
object.resize(len);
|
||||
for (unsigned i = 0 ; i < len; i ++)
|
||||
unpack (object[i]);
|
||||
/* Unpacking the @ of the associated individual */
|
||||
unpack( ad_sol );
|
||||
|
||||
|
||||
/* Associating the fitness the local solution */
|
||||
ad_sol->objectiveVector(object);
|
||||
progression[ ad_sol ].second--;
|
||||
|
||||
/* Notifying the container of the termination of the evaluation */
|
||||
if ( !progression[ ad_sol ].second )
|
||||
{
|
||||
|
||||
progression.erase( ad_sol );
|
||||
}
|
||||
|
||||
total--;
|
||||
if ( !total )
|
||||
{
|
||||
|
||||
getOwner()->setActive();
|
||||
resume();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
template< class EOT > void peoMoeoPopEval< EOT > :: notifySendingData()
|
||||
{}
|
||||
|
||||
|
||||
template< class EOT > void peoMoeoPopEval< EOT > :: notifySendingAllResourceRequests()
|
||||
{
|
||||
getOwner()->setPassive();
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,320 +0,0 @@
|
|||
/*
|
||||
* <peoMultiStart.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 __peoMultiStart_h
|
||||
#define __peoMultiStart_h
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "core/service.h"
|
||||
#include "core/messaging.h"
|
||||
|
||||
//! @class peoMultiStart
|
||||
//! @brief Class allowing the launch of several algorithms
|
||||
//! @see Service
|
||||
//! @version 1.1
|
||||
//! @date january 2008
|
||||
template < typename EntityType > class peoMultiStart : public Service
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! @brief Constructor
|
||||
//! @param AlgorithmType& externalAlgorithm
|
||||
template < typename AlgorithmType > peoMultiStart( AlgorithmType& externalAlgorithm )
|
||||
{
|
||||
singularAlgorithm = new Algorithm< AlgorithmType >( externalAlgorithm );
|
||||
algorithms.push_back( singularAlgorithm );
|
||||
aggregationFunction = new NoAggregationFunction();
|
||||
}
|
||||
|
||||
//! @brief Constructor
|
||||
//! @param AlgorithmReturnType (*externalAlgorithm)( AlgorithmDataType& )
|
||||
template < typename AlgorithmReturnType, typename AlgorithmDataType > peoMultiStart( AlgorithmReturnType (*externalAlgorithm)( AlgorithmDataType& ) )
|
||||
{
|
||||
singularAlgorithm = new FunctionAlgorithm< AlgorithmReturnType, AlgorithmDataType >( externalAlgorithm );
|
||||
algorithms.push_back( singularAlgorithm );
|
||||
aggregationFunction = new NoAggregationFunction();
|
||||
}
|
||||
|
||||
//! @brief Constructor
|
||||
//! @param std::vector< AlgorithmType* >& externalAlgorithms
|
||||
//! @param AggregationFunctionType& externalAggregationFunction
|
||||
template < typename AlgorithmType, typename AggregationFunctionType > peoMultiStart( std::vector< AlgorithmType* >& externalAlgorithms, AggregationFunctionType& externalAggregationFunction )
|
||||
{
|
||||
for ( unsigned int index = 0; index < externalAlgorithms.size(); index++ )
|
||||
{
|
||||
algorithms.push_back( new Algorithm< AlgorithmType >( *externalAlgorithms[ index ] ) );
|
||||
}
|
||||
aggregationFunction = new AggregationAlgorithm< AggregationFunctionType >( externalAggregationFunction );
|
||||
}
|
||||
|
||||
//! @brief Constructor
|
||||
//! @param std::vector< AlgorithmReturnType (*)( AlgorithmDataType& ) >& externalAlgorithms
|
||||
//! @param AggregationFunctionType& externalAggregationFunction
|
||||
template < typename AlgorithmReturnType, typename AlgorithmDataType, typename AggregationFunctionType > peoMultiStart( std::vector< AlgorithmReturnType (*)( AlgorithmDataType& ) >& externalAlgorithms, AggregationFunctionType& externalAggregationFunction )
|
||||
{
|
||||
for ( unsigned int index = 0; index < externalAlgorithms.size(); index++ )
|
||||
{
|
||||
algorithms.push_back( new FunctionAlgorithm< AlgorithmReturnType, AlgorithmDataType >( externalAlgorithms[ index ] ) );
|
||||
}
|
||||
aggregationFunction = new AggregationAlgorithm< AggregationFunctionType >( externalAggregationFunction );
|
||||
}
|
||||
|
||||
//! @brief Destructor
|
||||
~peoMultiStart()
|
||||
{
|
||||
for ( unsigned int index = 0; index < data.size(); index++ ) delete data[ index ];
|
||||
for ( unsigned int index = 0; index < algorithms.size(); index++ ) delete algorithms[ index ];
|
||||
delete aggregationFunction;
|
||||
}
|
||||
|
||||
//! @brief operator on the template type
|
||||
//! @param Type& externalData
|
||||
template < typename Type > void operator()( Type& externalData )
|
||||
{
|
||||
for ( typename Type::iterator externalDataIterator = externalData.begin(); externalDataIterator != externalData.end(); externalDataIterator++ )
|
||||
{
|
||||
data.push_back( new DataType< EntityType >( *externalDataIterator ) );
|
||||
}
|
||||
functionIndex = dataIndex = idx = num_term = 0;
|
||||
requestResourceRequest( data.size() * algorithms.size() );
|
||||
stop();
|
||||
}
|
||||
|
||||
//! @brief operator on the template type
|
||||
//! @param Type& externalDataBegin
|
||||
//! @param Type& externalDataEnd
|
||||
template < typename Type > void operator()( const Type& externalDataBegin, const Type& externalDataEnd )
|
||||
{
|
||||
for ( Type externalDataIterator = externalDataBegin; externalDataIterator != externalDataEnd; externalDataIterator++ )
|
||||
{
|
||||
data.push_back( new DataType< EntityType >( *externalDataIterator ) );
|
||||
}
|
||||
functionIndex = dataIndex = idx = num_term = 0;
|
||||
requestResourceRequest( data.size() * algorithms.size() );
|
||||
stop();
|
||||
}
|
||||
|
||||
//! @brief Function realizing packages of data
|
||||
void packData();
|
||||
//! @brief Function reconstituting packages of data
|
||||
void unpackData();
|
||||
//! @brief Function which executes the algorithm
|
||||
void execute();
|
||||
//! @brief Function realizing packages of the result
|
||||
void packResult();
|
||||
//! @brief Function reconstituting packages of result
|
||||
void unpackResult();
|
||||
//! @brief Function notifySendingData
|
||||
void notifySendingData();
|
||||
//! @brief Function notifySendingAllResourceRequests
|
||||
void notifySendingAllResourceRequests();
|
||||
|
||||
private:
|
||||
|
||||
//! @param AbstractAlgorithm* singularAlgorithm
|
||||
//! @param std::vector< AbstractAlgorithm* > algorithms
|
||||
//! @param AbstractAggregationAlgorithm* aggregationFunction
|
||||
//! @param EntityType entityTypeInstance
|
||||
//! @param std::vector< AbstractDataType* > data
|
||||
//! @param unsigned idx
|
||||
//! @param unsigned num_term
|
||||
//! @param unsigned dataIndex
|
||||
//! @param unsigned functionIndex
|
||||
template < typename Type > struct DataType;
|
||||
struct AbstractDataType
|
||||
{
|
||||
virtual ~AbstractDataType()
|
||||
{ }
|
||||
template < typename Type > operator Type& ()
|
||||
{
|
||||
return ( dynamic_cast< DataType< Type >& >( *this ) ).data;
|
||||
}
|
||||
};
|
||||
|
||||
template < typename Type > struct DataType : public AbstractDataType
|
||||
{
|
||||
DataType( Type& externalData ) : data( externalData )
|
||||
{ }
|
||||
Type& data;
|
||||
};
|
||||
|
||||
struct AbstractAlgorithm
|
||||
{
|
||||
virtual ~AbstractAlgorithm()
|
||||
{ }
|
||||
virtual void operator()( AbstractDataType& dataTypeInstance )
|
||||
{}
|
||||
};
|
||||
|
||||
template < typename AlgorithmType > struct Algorithm : public AbstractAlgorithm
|
||||
{
|
||||
Algorithm( AlgorithmType& externalAlgorithm ) : algorithm( externalAlgorithm )
|
||||
{ }
|
||||
void operator()( AbstractDataType& dataTypeInstance )
|
||||
{
|
||||
algorithm( dataTypeInstance );
|
||||
}
|
||||
AlgorithmType& algorithm;
|
||||
};
|
||||
|
||||
template < typename AlgorithmReturnType, typename AlgorithmDataType > struct FunctionAlgorithm : public AbstractAlgorithm
|
||||
{
|
||||
FunctionAlgorithm( AlgorithmReturnType (*externalAlgorithm)( AlgorithmDataType& ) ) : algorithm( externalAlgorithm )
|
||||
{ }
|
||||
void operator()( AbstractDataType& dataTypeInstance )
|
||||
{
|
||||
algorithm( dataTypeInstance );
|
||||
}
|
||||
AlgorithmReturnType (*algorithm)( AlgorithmDataType& );
|
||||
};
|
||||
|
||||
struct AbstractAggregationAlgorithm
|
||||
{
|
||||
virtual ~AbstractAggregationAlgorithm()
|
||||
{ }
|
||||
virtual void operator()( AbstractDataType& dataTypeInstanceA, AbstractDataType& dataTypeInstanceB )
|
||||
{}
|
||||
};
|
||||
|
||||
template < typename AggregationAlgorithmType > struct AggregationAlgorithm : public AbstractAggregationAlgorithm
|
||||
{
|
||||
AggregationAlgorithm( AggregationAlgorithmType& externalAggregationAlgorithm ) : aggregationAlgorithm( externalAggregationAlgorithm )
|
||||
{ }
|
||||
void operator()( AbstractDataType& dataTypeInstanceA, AbstractDataType& dataTypeInstanceB )
|
||||
{
|
||||
aggregationAlgorithm( dataTypeInstanceA, dataTypeInstanceB );
|
||||
}
|
||||
AggregationAlgorithmType& aggregationAlgorithm;
|
||||
};
|
||||
|
||||
struct NoAggregationFunction : public AbstractAggregationAlgorithm
|
||||
{
|
||||
void operator()( AbstractDataType& dataTypeInstanceA, AbstractDataType& dataTypeInstanceB )
|
||||
{
|
||||
|
||||
static_cast< EntityType& >( dataTypeInstanceA ) = static_cast< EntityType& >( dataTypeInstanceB );
|
||||
}
|
||||
};
|
||||
|
||||
AbstractAlgorithm* singularAlgorithm;
|
||||
std::vector< AbstractAlgorithm* > algorithms;
|
||||
AbstractAggregationAlgorithm* aggregationFunction;
|
||||
EntityType entityTypeInstance;
|
||||
std::vector< AbstractDataType* > data;
|
||||
unsigned idx;
|
||||
unsigned num_term;
|
||||
unsigned dataIndex;
|
||||
unsigned functionIndex;
|
||||
};
|
||||
|
||||
|
||||
template < typename EntityType > void peoMultiStart< EntityType >::packData()
|
||||
{
|
||||
|
||||
pack( functionIndex );
|
||||
pack( idx );
|
||||
pack( ( EntityType& ) *data[ idx++ ] );
|
||||
|
||||
// done with functionIndex for the entire data set - moving to another
|
||||
// function/algorithm starting all over with the entire data set ( idx is set to 0 )
|
||||
if ( idx == data.size() )
|
||||
{
|
||||
|
||||
++functionIndex;
|
||||
idx = 0;
|
||||
}
|
||||
}
|
||||
|
||||
template < typename EntityType > void peoMultiStart< EntityType >::unpackData()
|
||||
{
|
||||
|
||||
unpack( functionIndex );
|
||||
unpack( dataIndex );
|
||||
unpack( entityTypeInstance );
|
||||
}
|
||||
|
||||
template < typename EntityType > void peoMultiStart< EntityType >::execute()
|
||||
{
|
||||
|
||||
// wrapping the unpacked data - the definition of an abstract algorithm imposes
|
||||
// that its internal function operator acts only on abstract data types
|
||||
AbstractDataType* entityWrapper = new DataType< EntityType >( entityTypeInstance );
|
||||
algorithms[ functionIndex ]->operator()( *entityWrapper );
|
||||
|
||||
delete entityWrapper;
|
||||
}
|
||||
|
||||
template < typename EntityType > void peoMultiStart< EntityType >::packResult()
|
||||
{
|
||||
|
||||
pack( dataIndex );
|
||||
pack( entityTypeInstance );
|
||||
}
|
||||
|
||||
template < typename EntityType > void peoMultiStart< EntityType >::unpackResult()
|
||||
{
|
||||
|
||||
unpack( dataIndex );
|
||||
unpack( entityTypeInstance );
|
||||
|
||||
// wrapping the unpacked data - the definition of an abstract algorithm imposes
|
||||
// that its internal function operator acts only on abstract data types
|
||||
AbstractDataType* entityWrapper = new DataType< EntityType >( entityTypeInstance );
|
||||
aggregationFunction->operator()( *data[ dataIndex ], *entityWrapper );
|
||||
delete entityWrapper;
|
||||
|
||||
num_term++;
|
||||
|
||||
if ( num_term == data.size() * algorithms.size() )
|
||||
{
|
||||
|
||||
getOwner()->setActive();
|
||||
resume();
|
||||
}
|
||||
}
|
||||
|
||||
template < typename EntityType > void peoMultiStart< EntityType >::notifySendingData()
|
||||
{}
|
||||
|
||||
template < typename EntityType > void peoMultiStart< EntityType >::notifySendingAllResourceRequests()
|
||||
{
|
||||
|
||||
getOwner()->setPassive();
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,66 +0,0 @@
|
|||
/*
|
||||
* <peoNoAggEvalFunc.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 __peoNoAggEvalFunc_h
|
||||
#define __peoNoAggEvalFunc_h
|
||||
|
||||
#include "peoAggEvalFunc.h"
|
||||
|
||||
//! Class providing a simple interface for associating a fitness value to a specified individual.
|
||||
|
||||
//! The peoNoAggEvalFunc class does nothing more than an association between a fitness value and a specified individual.
|
||||
//! The class is provided as a mean of declaring that no aggregation is required for the evaluation function - the fitness
|
||||
//! value is explicitly specified.
|
||||
template< class EOT > class peoNoAggEvalFunc : public peoAggEvalFunc< EOT >
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
//! Operator which sets as fitness the <b>__fit</b> value for the <b>__sol</b> individual
|
||||
//! @param EOT& __sol
|
||||
//! @param 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 )
|
||||
{
|
||||
|
||||
__sol.fitness( __fit );
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
167
peo/src/peoPSO.h
167
peo/src/peoPSO.h
|
|
@ -1,167 +0,0 @@
|
|||
/* <peoPSO.h>
|
||||
*
|
||||
* (c) OPAC Team, October 2008
|
||||
*
|
||||
* 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
|
||||
* Contact: clive.canape@inria.fr
|
||||
*/
|
||||
|
||||
#ifndef peoPSO_h
|
||||
#define peoPSO_h
|
||||
|
||||
#include <eoPop.h>
|
||||
#include <utils/eoRNG.h>
|
||||
#include <eoFunctor.h>
|
||||
#include <eoMerge.h>
|
||||
#include <eoReduce.h>
|
||||
#include <eoReplacement.h>
|
||||
#include <utils/eoHowMany.h>
|
||||
#include <eoSelectOne.h>
|
||||
|
||||
/*
|
||||
//! @class peoPSOSelect
|
||||
//! @brief Specific class for a selection of a population of a PSO
|
||||
//! @see eoSelectOne
|
||||
//! @version 1.1
|
||||
//! @date october 2007
|
||||
*/
|
||||
template <class POT> class peoPSOSelect: public eoSelectOne<POT>
|
||||
{
|
||||
public:
|
||||
/*
|
||||
//! @brief Constructor
|
||||
//! @param eoTopology < POT > & _topology
|
||||
*/
|
||||
peoPSOSelect(eoTopology < POT > & _topology):topology(_topology)
|
||||
{}
|
||||
|
||||
// //! @brief typedef : creation of Fitness
|
||||
typedef typename PO < POT >::Fitness Fitness;
|
||||
/*
|
||||
//! @brief Virtual operator
|
||||
//! @param eoPop<POT>& _pop
|
||||
//! @return POT&
|
||||
*/
|
||||
virtual const POT& operator()(const eoPop<POT>& _pop)
|
||||
{
|
||||
//return topology.globalBest(_pop);
|
||||
return topology.globalBest();
|
||||
}
|
||||
|
||||
private:
|
||||
// //! @param eoTopology < POT > & topology
|
||||
eoTopology < POT > & topology;
|
||||
};
|
||||
/*
|
||||
//! @class peoGlobalBestVelocity
|
||||
//! @brief Specific class for a replacement thanks to the velocity migration of a population of a PSO
|
||||
//! @see eoReplacement
|
||||
//! @version 1.1
|
||||
//! @date october 2007
|
||||
*/
|
||||
template <class POT>
|
||||
class peoGlobalBestVelocity : public eoReplacement<POT>
|
||||
{
|
||||
public:
|
||||
|
||||
// //! @brief typedef : creation of VelocityType
|
||||
typedef typename POT::ParticleVelocityType VelocityType;
|
||||
/*
|
||||
//! @brief Constructor
|
||||
//! @param double & _c3
|
||||
//! @param eoVelocity < POT > &_velocity
|
||||
*/
|
||||
peoGlobalBestVelocity( const double & _c3, eoVelocity < POT > &_velocity): c3 (_c3),velocity (_velocity)
|
||||
{}
|
||||
/*
|
||||
//! @brief Virtual operator
|
||||
//! @param eoPop<POT>& _dest
|
||||
//! @param eoPop<POT>& _source
|
||||
*/
|
||||
void operator()(eoPop<POT>& _dest, eoPop<POT>& _source)
|
||||
{
|
||||
|
||||
VelocityType newVelocity,r3;
|
||||
r3 = (VelocityType) rng.uniform (1) * c3;
|
||||
for (unsigned i=0;i<_dest.size();i++)
|
||||
for (unsigned j=0;j<_dest[i].size();j++)
|
||||
{
|
||||
newVelocity= _dest[i].velocities[j] + r3 * (_source[0].bestPositions[j] - _dest[i][j]);
|
||||
_dest[i].velocities[j]=newVelocity;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected:
|
||||
/*
|
||||
//! @param double & c3
|
||||
//! @param eoVelocity < POT > & velocity
|
||||
*/
|
||||
const double & c3;
|
||||
eoVelocity < POT > & velocity;
|
||||
};
|
||||
/*
|
||||
//! @class peoWorstPositionReplacement
|
||||
//! @brief Specific class for a replacement of a population of a PSO
|
||||
//! @see eoReplacement
|
||||
//! @version 1.1
|
||||
//! @date october 2007
|
||||
*/
|
||||
template <class POT> class peoWorstPositionReplacement : public eoReplacement<POT>
|
||||
{
|
||||
public:
|
||||
// //! @brief constructor
|
||||
peoWorstPositionReplacement()
|
||||
{}
|
||||
/*
|
||||
//! @brief operator
|
||||
//! @param eoPop<POT>& _dest
|
||||
//! @param eoPop<POT>& _source
|
||||
*/
|
||||
void operator()(eoPop<POT>& _dest, eoPop<POT>& _source)
|
||||
{
|
||||
unsigned ind=0;
|
||||
double best=_dest[0].best();
|
||||
for (unsigned j=1;j<_dest.size();j++)
|
||||
if (_dest[j].best() < best)
|
||||
{
|
||||
ind=j;
|
||||
best=_dest[j].best();
|
||||
}
|
||||
if (_dest[ind].best() < _source[0].best())
|
||||
{
|
||||
_dest[ind].best(_source[0].best());
|
||||
for (unsigned j=0;j<_dest[ind].size();j++)
|
||||
_dest[ind].bestPositions[j]=_source[0].bestPositions[j];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,308 +0,0 @@
|
|||
/*
|
||||
* <peoPopEval.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 __peoPopEval_h
|
||||
#define __peoPopEval_h
|
||||
|
||||
#include <queue>
|
||||
#include <eoEvalFunc.h>
|
||||
#include <typeinfo>
|
||||
#include <string.h>
|
||||
|
||||
#include "core/messaging.h"
|
||||
#include "core/peo_debug.h"
|
||||
#include "peoAggEvalFunc.h"
|
||||
#include "peoNoAggEvalFunc.h"
|
||||
|
||||
//! @class peoPopEval
|
||||
//! @brief Parallel evaluation functor wrapper
|
||||
//! @see Service eoPopEvalFunc
|
||||
//! @version 1.2
|
||||
//! @date 2006
|
||||
template< class EOT > class peoPopEval : public Service, public eoPopEvalFunc<EOT>
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! Constructor function - an EO-derived evaluation functor has to be specified; an internal reference
|
||||
//! is set towards the specified evaluation functor.
|
||||
//!
|
||||
//! @param eoEvalFunc< EOT >& __eval_func - EO-derived evaluation functor to be applied in parallel on each individual of a specified population
|
||||
peoPopEval( eoEvalFunc< EOT >& __eval_func );
|
||||
|
||||
//! Constructor function - a vector of EO-derived evaluation functors has to be specified as well as an aggregation function.
|
||||
//!
|
||||
//! @param const std :: vector< eoEvalFunc < EOT >* >& __funcs - vector of EO-derived partial evaluation functors;
|
||||
//! @param peoAggEvalFunc< EOT >& __merge_eval - aggregation functor for creating a fitness value out of the partial fitness values.
|
||||
peoPopEval( const std :: vector< eoEvalFunc < EOT >* >& __funcs, peoAggEvalFunc< EOT >& __merge_eval );
|
||||
|
||||
//! Operator for applying the evaluation functor (direct or aggregate) for each individual of the specified population.
|
||||
//!
|
||||
//! @param eoPop< EOT >& __pop - population to be evaluated by applying the evaluation functor specified in the constructor.
|
||||
void operator()(eoPop< EOT >& __pop);
|
||||
|
||||
//! @brief Operator ()( eoPop< EOT >& __dummy, eoPop< EOT >& __pop )
|
||||
//! @param eoPop< EOT >& __dummy
|
||||
//! @param eoPop< EOT >& __pop
|
||||
void operator()( eoPop< EOT >& __dummy, eoPop< EOT >& __pop );
|
||||
|
||||
//! Auxiliary function for transferring data between the process requesting an evaluation operation and the process that
|
||||
//! performs the actual evaluation phase. There is no need to explicitly call the function.
|
||||
void packData();
|
||||
|
||||
//! Auxiliary function for transferring data between the process requesting an evaluation operation and the process that
|
||||
//! performs the actual evaluation phase. There is no need to explicitly call the function.
|
||||
void unpackData();
|
||||
|
||||
//! Auxiliary function - it calls the specified evaluation functor(s). There is no need to explicitly call the function.
|
||||
void execute();
|
||||
|
||||
//! Auxiliary function for transferring data between the process requesting an evaluation operation and the process that
|
||||
//! performs the actual evaluation phase. There is no need to explicitly call the function.
|
||||
void packResult();
|
||||
|
||||
//! Auxiliary function for transferring data between the process requesting an evaluation operation and the process that
|
||||
//! performs the actual evaluation phase. There is no need to explicitly call the function.
|
||||
void unpackResult();
|
||||
|
||||
//! Auxiliary function for notifications between the process requesting an evaluation operation and the processes that
|
||||
//! performs the actual evaluation phase. There is no need to explicitly call the function.
|
||||
void notifySendingData();
|
||||
|
||||
//! Auxiliary function for notifications between the process requesting an evaluation operation and the processes that
|
||||
//! performs the actual evaluation phase. There is no need to explicitly call the function.
|
||||
void notifySendingAllResourceRequests();
|
||||
|
||||
private:
|
||||
|
||||
//! @param std :: vector< eoEvalFunc < EOT >* >& funcs
|
||||
//! @param std :: vector< eoEvalFunc < EOT >* > one_func
|
||||
//! @param peoAggEvalFunc< EOT >& merge_eval
|
||||
//! @param peoNoAggEvalFunc< EOT > no_merge_eval
|
||||
//! @param std :: queue< EOT* >tasks
|
||||
//! @param std :: map< EOT*, std :: pair< unsigned, unsigned > > progression
|
||||
//! @param unsigned num_func
|
||||
//! @param EOT sol
|
||||
//! @param EOT *ad_sol
|
||||
//! @param unsigned total
|
||||
const std :: vector< eoEvalFunc < EOT >* >& funcs;
|
||||
std :: vector< eoEvalFunc < EOT >* > one_func;
|
||||
peoAggEvalFunc< EOT >& merge_eval;
|
||||
peoNoAggEvalFunc< EOT > no_merge_eval;
|
||||
std :: queue< EOT* >tasks;
|
||||
std :: map< EOT*, std :: pair< unsigned, unsigned > > progression;
|
||||
unsigned num_func;
|
||||
EOT sol;
|
||||
EOT *ad_sol;
|
||||
unsigned total;
|
||||
};
|
||||
|
||||
|
||||
template< class EOT > peoPopEval< EOT > :: peoPopEval( eoEvalFunc< EOT >& __eval_func ) :
|
||||
|
||||
funcs( one_func ), merge_eval( no_merge_eval )
|
||||
{
|
||||
|
||||
one_func.push_back( &__eval_func );
|
||||
}
|
||||
|
||||
|
||||
template< class EOT > peoPopEval< EOT > :: peoPopEval(
|
||||
|
||||
const std :: vector< eoEvalFunc< EOT >* >& __funcs,
|
||||
peoAggEvalFunc< EOT >& __merge_eval
|
||||
|
||||
) : funcs( __funcs ), merge_eval( __merge_eval )
|
||||
{}
|
||||
|
||||
template< class EOT > void peoPopEval< EOT >::operator()(eoPop< EOT >& __dummy, eoPop< EOT >& __pop )
|
||||
{
|
||||
this->operator()(__pop);
|
||||
}
|
||||
|
||||
template< class EOT > void peoPopEval< EOT >::operator()(eoPop< EOT >& __pop )
|
||||
{
|
||||
if ( __pop.size() && (funcs.size() * __pop.size()) )
|
||||
{
|
||||
for ( unsigned i = 0; i < __pop.size(); i++ )
|
||||
{
|
||||
__pop[ i ].fitness(typename EOT :: Fitness() );
|
||||
progression[ &__pop[ i ] ].first = funcs.size() - 1;
|
||||
progression[ &__pop[ i ] ].second = funcs.size();
|
||||
for ( unsigned j = 0; j < funcs.size(); j++ )
|
||||
{
|
||||
/* Queuing the 'invalid' solution and its associated owner */
|
||||
tasks.push( &__pop[ i ] );
|
||||
}
|
||||
}
|
||||
total = funcs.size() * __pop.size();
|
||||
requestResourceRequest( funcs.size() * __pop.size() );
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template< class EOT > void peoPopEval< EOT > :: packData()
|
||||
{
|
||||
// printDebugMessage ("debut pakc data");
|
||||
pack( progression[ tasks.front() ].first-- );
|
||||
|
||||
/* Packing the contents :-) of the solution */
|
||||
pack( *tasks.front() );
|
||||
|
||||
/* Packing the addresses of both the solution and the owner */
|
||||
pack( tasks.front() );
|
||||
tasks.pop( );
|
||||
}
|
||||
|
||||
|
||||
template< class EOT > void peoPopEval< EOT > :: unpackData()
|
||||
{
|
||||
unpack( num_func );
|
||||
/* Unpacking the solution */
|
||||
unpack( sol );
|
||||
/* Unpacking the @ of that one */
|
||||
unpack( ad_sol );
|
||||
}
|
||||
|
||||
|
||||
template< class EOT > void peoPopEval< EOT > :: execute()
|
||||
{
|
||||
|
||||
/* Computing the fitness of the solution */
|
||||
funcs[ num_func ]->operator()( sol );
|
||||
}
|
||||
|
||||
|
||||
template< class EOT > void peoPopEval< EOT > :: packResult()
|
||||
{
|
||||
/* Packing the fitness of the solution */
|
||||
pack( sol.fitness() );
|
||||
/* Packing the @ of the individual */
|
||||
pack( ad_sol );
|
||||
}
|
||||
|
||||
|
||||
template< class EOT > void peoPopEval< EOT > :: unpackResult()
|
||||
{
|
||||
typename EOT :: Fitness fit;
|
||||
/* Built in types : int, short, long int, long long int,
|
||||
* unsigned int, unsigend short, unsigned long int, unsigned long long int,
|
||||
* float, double, long double
|
||||
*/
|
||||
char types [11] = {'i','s','l','x','j','t','m','y', 'f', 'd','e'};
|
||||
const char* type = typeid(fit).name();
|
||||
int length = strlen(type);
|
||||
int position = 18;
|
||||
if ( length == 1)
|
||||
{
|
||||
position = 0;
|
||||
length = 2;
|
||||
}
|
||||
if ( length > 1 && position < length)
|
||||
{
|
||||
if ( type[position] == types[0])
|
||||
{
|
||||
int __fit; unpack( __fit );fit = __fit;
|
||||
}
|
||||
if ( type[position] == types[1])
|
||||
{
|
||||
short int __fit; unpack( __fit );fit = __fit;
|
||||
}
|
||||
if ( type[position] == types[2])
|
||||
{
|
||||
long int __fit; unpack( __fit );fit = __fit;
|
||||
}
|
||||
if ( type[position] == types[4])
|
||||
{
|
||||
unsigned int __fit; unpack( __fit );fit = __fit;
|
||||
}
|
||||
if ( type[position] == types[5])
|
||||
{
|
||||
unsigned short __fit; unpack( __fit );fit = __fit;
|
||||
}
|
||||
if ( type[position] == types[6])
|
||||
{
|
||||
unsigned long __fit; unpack( __fit );fit = __fit;
|
||||
}
|
||||
if ( type[position] == types[8])
|
||||
{
|
||||
float __fit; unpack( __fit );fit = __fit;
|
||||
}
|
||||
if ( type[position] == types[9])
|
||||
{
|
||||
double __fit; unpack( __fit );fit = __fit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Unpacking the @ of the associated individual */
|
||||
unpack( ad_sol );
|
||||
|
||||
|
||||
/* Associating the fitness the local solution */
|
||||
merge_eval( *ad_sol, fit );
|
||||
|
||||
progression[ ad_sol ].second--;
|
||||
|
||||
/* Notifying the container of the termination of the evaluation */
|
||||
if ( !progression[ ad_sol ].second )
|
||||
{
|
||||
|
||||
progression.erase( ad_sol );
|
||||
}
|
||||
|
||||
total--;
|
||||
if ( !total )
|
||||
{
|
||||
|
||||
getOwner()->setActive();
|
||||
resume();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template< class EOT > void peoPopEval< EOT > :: notifySendingData()
|
||||
{}
|
||||
|
||||
|
||||
template< class EOT > void peoPopEval< EOT > :: notifySendingAllResourceRequests()
|
||||
{
|
||||
getOwner()->setPassive();
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,288 +0,0 @@
|
|||
/*
|
||||
* <peoSyncDataTransfer.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* 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 __peoSyncDataTransfer_h
|
||||
#define __peoSyncDataTransfer_h
|
||||
|
||||
|
||||
#include <queue>
|
||||
#include <cassert>
|
||||
|
||||
#include <utils/eoUpdater.h>
|
||||
|
||||
#include "core/peoAbstractDefs.h"
|
||||
|
||||
#include "core/messaging.h"
|
||||
#include "core/eoPop_mesg.h"
|
||||
#include "core/eoVector_mesg.h"
|
||||
|
||||
#include "core/topology.h"
|
||||
#include "core/thread.h"
|
||||
#include "core/cooperative.h"
|
||||
#include "core/peo_debug.h"
|
||||
|
||||
#include "rmc/mpi/synchron.h"
|
||||
|
||||
|
||||
extern void wakeUpCommunicator();
|
||||
extern int getNodeRank();
|
||||
|
||||
|
||||
class peoSyncDataTransfer : public Cooperative, public eoUpdater
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
template< typename EndPointType >
|
||||
peoSyncDataTransfer(
|
||||
|
||||
EndPointType& __endPoint,
|
||||
Topology& __topology
|
||||
|
||||
) : topology( __topology )
|
||||
{
|
||||
|
||||
source = new MsgTransferQueue< EndPointType >( __endPoint );
|
||||
destination = new MsgTransferQueue< EndPointType >( __endPoint );
|
||||
__topology.add( *this );
|
||||
|
||||
sem_init( &sync, 0, 0 );
|
||||
}
|
||||
|
||||
template< typename EndPointType, typename FunctorType >
|
||||
peoSyncDataTransfer(
|
||||
|
||||
EndPointType& __endPoint,
|
||||
Topology& __topology,
|
||||
FunctorType& externalFunctorRef
|
||||
|
||||
) : topology( __topology )
|
||||
{
|
||||
|
||||
source = new MsgTransferQueue< EndPointType >( __endPoint, externalFunctorRef );
|
||||
destination = new MsgTransferQueue< EndPointType >( __endPoint, externalFunctorRef );
|
||||
__topology.add( *this );
|
||||
|
||||
sem_init( &sync, 0, 0 );
|
||||
}
|
||||
|
||||
template< typename SourceEndPointType, typename DestinationEndPointType >
|
||||
peoSyncDataTransfer(
|
||||
|
||||
SourceEndPointType& __source,
|
||||
DestinationEndPointType& __destination,
|
||||
Topology& __topology
|
||||
|
||||
) : topology( __topology )
|
||||
{
|
||||
|
||||
source = new MsgTransferQueue< SourceEndPointType >( __source );
|
||||
destination = new MsgTransferQueue< DestinationEndPointType >( __destination );
|
||||
__topology.add( *this );
|
||||
|
||||
sem_init( &sync, 0, 0 );
|
||||
}
|
||||
|
||||
template< typename SourceEndPointType, typename DestinationEndPointType, typename FunctorType >
|
||||
peoSyncDataTransfer(
|
||||
|
||||
SourceEndPointType& __source,
|
||||
DestinationEndPointType& __destination,
|
||||
Topology& __topology,
|
||||
FunctorType& externalFunctorRef
|
||||
|
||||
) : topology( __topology )
|
||||
{
|
||||
|
||||
source = new MsgTransferQueue< SourceEndPointType >( __source, externalFunctorRef );
|
||||
destination = new MsgTransferQueue< DestinationEndPointType >( __destination, externalFunctorRef );
|
||||
__topology.add( *this );
|
||||
|
||||
sem_init( &sync, 0, 0 );
|
||||
}
|
||||
|
||||
|
||||
void operator()()
|
||||
{
|
||||
|
||||
standbyTransfer = false;
|
||||
nbTransfersIn = nbTransfersOut = 0;
|
||||
|
||||
topology.setNeighbors( this, in, out );
|
||||
all = topology;
|
||||
|
||||
synchronizeCoopEx();
|
||||
stop();
|
||||
|
||||
// sending data out
|
||||
sendData();
|
||||
// synchronizing
|
||||
sem_wait( &sync );
|
||||
// receiving data in
|
||||
receiveData();
|
||||
|
||||
synchronizeCoopEx();
|
||||
stop();
|
||||
}
|
||||
|
||||
|
||||
void pack()
|
||||
{
|
||||
|
||||
::pack( coop_em.front()->getKey() );
|
||||
source->packMessage();
|
||||
coop_em.pop();
|
||||
}
|
||||
|
||||
void unpack()
|
||||
{
|
||||
|
||||
destination->unpackMessage();
|
||||
}
|
||||
|
||||
|
||||
void packSynchronizeReq()
|
||||
{
|
||||
|
||||
packSynchronRequest( all );
|
||||
}
|
||||
|
||||
|
||||
void notifySending()
|
||||
{
|
||||
|
||||
nbTransfersOut++;
|
||||
|
||||
printDebugMessage( "peoSyncDataTransfer: notified of the completion of a transfer round." );
|
||||
|
||||
getOwner()->setActive();
|
||||
if ( nbTransfersOut == out.size() && nbTransfersIn < in.size() )
|
||||
{
|
||||
getOwner()->setPassive();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void notifyReceiving()
|
||||
{
|
||||
|
||||
nbTransfersIn++;
|
||||
printDebugMessage( "peoSyncIslandMig: notified of incoming data." );
|
||||
|
||||
if ( standbyTransfer )
|
||||
{
|
||||
getOwner()->setActive();
|
||||
if ( nbTransfersOut == out.size() && nbTransfersIn < in.size() )
|
||||
getOwner()->setPassive();
|
||||
}
|
||||
|
||||
if ( nbTransfersIn == in.size() )
|
||||
{
|
||||
|
||||
printDebugMessage( "peoSyncIslandMig: finished collecting incoming data." );
|
||||
sem_post( &sync );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void notifySendingSyncReq()
|
||||
{
|
||||
|
||||
getOwner()->setPassive();
|
||||
printDebugMessage( "peoSyncIslandMig: synchronization request sent." );
|
||||
}
|
||||
|
||||
void notifySynchronized()
|
||||
{
|
||||
|
||||
printDebugMessage( "peoSyncIslandMig: cooperators synchronized." );
|
||||
|
||||
standbyTransfer = true;
|
||||
getOwner()->setActive();
|
||||
resume();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void sendData()
|
||||
{
|
||||
|
||||
for ( unsigned i = 0; i < out.size(); i ++ )
|
||||
{
|
||||
|
||||
source->pushMessage();
|
||||
|
||||
coop_em.push( out[ i ] );
|
||||
send( out[ i ]);
|
||||
|
||||
printDebugMessage( "peoSyncDataTransfer: sending data." );
|
||||
}
|
||||
|
||||
wakeUpCommunicator();
|
||||
}
|
||||
|
||||
void receiveData()
|
||||
{
|
||||
|
||||
assert( !( destination->empty() ) );
|
||||
|
||||
while ( !( destination->empty() ) )
|
||||
{
|
||||
|
||||
printDebugMessage( "peoSyncDataTransfer: received data." );
|
||||
destination->popMessage();
|
||||
printDebugMessage( "peoSyncDataTransfer: done extracting received data." );
|
||||
}
|
||||
}
|
||||
|
||||
Topology& topology; // neighboring topology
|
||||
|
||||
// source and destination end-points
|
||||
AbstractMsgTransferQueue* source;
|
||||
AbstractMsgTransferQueue* destination;
|
||||
|
||||
std :: queue< Cooperative* > coop_em;
|
||||
|
||||
sem_t sync;
|
||||
|
||||
bool standbyTransfer;
|
||||
|
||||
std :: vector< Cooperative* > in, out, all;
|
||||
unsigned nbTransfersIn, nbTransfersOut;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -1,257 +0,0 @@
|
|||
/*
|
||||
* <peoSyncIslandMig.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 __peoSyncIslandMig_h
|
||||
#define __peoSyncIslandMig_h
|
||||
|
||||
|
||||
#include <queue>
|
||||
#include <cassert>
|
||||
|
||||
#include <eoPeriodicContinue.h>
|
||||
|
||||
#include <utils/eoUpdater.h>
|
||||
|
||||
#include <eoContinue.h>
|
||||
#include <eoSelect.h>
|
||||
#include <eoReplacement.h>
|
||||
#include <eoPop.h>
|
||||
#include "peoData.h"
|
||||
|
||||
#include "core/messaging.h"
|
||||
#include "core/eoPop_mesg.h"
|
||||
#include "core/eoVector_mesg.h"
|
||||
|
||||
#include "core/topology.h"
|
||||
#include "core/thread.h"
|
||||
#include "core/cooperative.h"
|
||||
#include "core/peo_debug.h"
|
||||
|
||||
#include "rmc/mpi/synchron.h"
|
||||
|
||||
|
||||
//! @class peoSyncIslandMig
|
||||
//! @brief Specific class for a synchronous migration
|
||||
//! @see Cooperative eoUpdater
|
||||
//! @version 2.0
|
||||
//! @date january 2008
|
||||
template< class TYPESELECT, class TYPEREPLACE > class peoSyncIslandMig : public Cooperative, public eoUpdater
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! @brief Constructor
|
||||
//! @param unsigned __frequency
|
||||
//! @param selector <TYPESELECT> & __select
|
||||
//! @param replacement <TYPEREPLACE> & __replace
|
||||
//! @param Topology& __topology
|
||||
peoSyncIslandMig(
|
||||
unsigned __frequency,
|
||||
selector <TYPESELECT> & __select,
|
||||
replacement <TYPEREPLACE> & __replace,
|
||||
Topology& __topology
|
||||
);
|
||||
|
||||
//! @brief operator
|
||||
void operator()();
|
||||
//! @brief Function realizing packages
|
||||
void pack();
|
||||
//! @brief Function reconstituting packages
|
||||
void unpack();
|
||||
//! @brief Function packSynchronizeReq
|
||||
void packSynchronizeReq();
|
||||
//! @brief Function notifySending
|
||||
void notifySending();
|
||||
//! @brief Function notifyReceiving
|
||||
void notifyReceiving();
|
||||
//! @brief notifySendingSyncReq
|
||||
void notifySendingSyncReq();
|
||||
//! @brief notifySynchronized
|
||||
void notifySynchronized();
|
||||
|
||||
private:
|
||||
|
||||
void emigrate();
|
||||
void immigrate();
|
||||
|
||||
|
||||
private:
|
||||
//! @param eoSyncContinue cont
|
||||
//! @param selector <TYPESELECT> & select
|
||||
//! @param replacement <TYPEREPLACE> & replace
|
||||
//! @param Topology& topology
|
||||
//! @param std :: queue< TYPEREPLACE > imm
|
||||
//! @param std :: queue< TYPESELECT > em
|
||||
//! @param std :: queue< Cooperative* > coop_em
|
||||
//! @param sem_t sync
|
||||
//! @param bool explicitPassive
|
||||
//! @param bool standbyMigration
|
||||
//! @param std :: vector< Cooperative* > in, out, all
|
||||
//! @param unsigned nbMigrations
|
||||
eoSyncContinue cont;
|
||||
selector <TYPESELECT> & select;
|
||||
replacement <TYPEREPLACE> & replace;
|
||||
Topology& topology;
|
||||
std :: queue< TYPEREPLACE > imm;
|
||||
std :: queue< TYPESELECT > em;
|
||||
std :: queue< Cooperative* > coop_em;
|
||||
sem_t sync;
|
||||
bool explicitPassive;
|
||||
bool standbyMigration;
|
||||
std :: vector< Cooperative* > in, out, all;
|
||||
unsigned nbMigrations;
|
||||
};
|
||||
|
||||
|
||||
template< class TYPESELECT, class TYPEREPLACE > peoSyncIslandMig< TYPESELECT,TYPEREPLACE > :: peoSyncIslandMig(
|
||||
|
||||
unsigned __frequency,
|
||||
selector <TYPESELECT> & __select,
|
||||
replacement <TYPEREPLACE> & __replace,
|
||||
Topology& __topology
|
||||
) : cont( __frequency ), select( __select ), replace( __replace ), topology( __topology )
|
||||
{
|
||||
|
||||
__topology.add( *this );
|
||||
sem_init( &sync, 0, 0 );
|
||||
}
|
||||
|
||||
|
||||
template< class TYPESELECT, class TYPEREPLACE > void peoSyncIslandMig< TYPESELECT, TYPEREPLACE > :: pack()
|
||||
{
|
||||
::pack( coop_em.front()->getKey() );
|
||||
::pack(em.front());
|
||||
coop_em.pop();
|
||||
em.pop();
|
||||
}
|
||||
|
||||
template< class TYPESELECT, class TYPEREPLACE > void peoSyncIslandMig< TYPESELECT, TYPEREPLACE > :: unpack()
|
||||
{
|
||||
TYPEREPLACE mig;
|
||||
::unpack(mig);
|
||||
imm.push( mig );
|
||||
explicitPassive = true;
|
||||
}
|
||||
|
||||
template< class TYPESELECT, class TYPEREPLACE > void peoSyncIslandMig< TYPESELECT,TYPEREPLACE > :: packSynchronizeReq()
|
||||
{
|
||||
|
||||
packSynchronRequest( all );
|
||||
}
|
||||
|
||||
template< class TYPESELECT, class TYPEREPLACE > void peoSyncIslandMig< TYPESELECT , TYPEREPLACE > :: emigrate()
|
||||
{
|
||||
|
||||
for ( unsigned i = 0; i < out.size(); i ++ )
|
||||
{
|
||||
|
||||
TYPESELECT mig;
|
||||
select( mig );
|
||||
em.push( mig );
|
||||
coop_em.push( out[ i ] );
|
||||
send( out[ i ] );
|
||||
printDebugMessage( "peoSyncIslandMig: sending some emigrants." );
|
||||
}
|
||||
}
|
||||
|
||||
template< class TYPESELECT, class TYPEREPLACE > void peoSyncIslandMig< TYPESELECT , TYPEREPLACE > :: immigrate()
|
||||
{
|
||||
assert( imm.size() );
|
||||
|
||||
while ( imm.size() )
|
||||
{
|
||||
replace( imm.front() ) ;
|
||||
imm.pop();
|
||||
}
|
||||
|
||||
printDebugMessage( "peoSyncIslandMig: receiving some immigrants." );
|
||||
}
|
||||
|
||||
template< class TYPESELECT, class TYPEREPLACE > void peoSyncIslandMig< TYPESELECT , TYPEREPLACE > :: operator()()
|
||||
{
|
||||
|
||||
if (! cont.check() )
|
||||
{
|
||||
explicitPassive = standbyMigration = false;
|
||||
topology.setNeighbors( this, in, out );
|
||||
all = topology;
|
||||
nbMigrations = 0;
|
||||
synchronizeCoopEx();
|
||||
stop();
|
||||
// sending emigrants
|
||||
emigrate();
|
||||
// synchronizing
|
||||
sem_wait( &sync );
|
||||
// receiving immigrants
|
||||
immigrate();
|
||||
synchronizeCoopEx();
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
template< class TYPESELECT, class TYPEREPLACE > void peoSyncIslandMig< TYPESELECT , TYPEREPLACE > :: notifySending()
|
||||
{
|
||||
if ( !explicitPassive ) getOwner()->setPassive();
|
||||
}
|
||||
|
||||
template< class TYPESELECT, class TYPEREPLACE > void peoSyncIslandMig< TYPESELECT , TYPEREPLACE > :: notifyReceiving()
|
||||
{
|
||||
nbMigrations++;
|
||||
|
||||
if ( nbMigrations == in.size() )
|
||||
{
|
||||
|
||||
if ( standbyMigration ) getOwner()->setActive();
|
||||
sem_post( &sync );
|
||||
}
|
||||
}
|
||||
|
||||
template< class TYPESELECT, class TYPE > void peoSyncIslandMig< TYPESELECT, TYPE > :: notifySendingSyncReq ()
|
||||
{
|
||||
|
||||
getOwner()->setPassive();
|
||||
}
|
||||
|
||||
template< class TYPESELECT, class TYPE > void peoSyncIslandMig< TYPESELECT, TYPE > :: notifySynchronized ()
|
||||
{
|
||||
|
||||
standbyMigration = true;
|
||||
getOwner()->setActive();
|
||||
resume();
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,199 +0,0 @@
|
|||
/*
|
||||
* <peoTransform.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 __peoTransform_h
|
||||
#define __peoTransform_h
|
||||
|
||||
#include "core/thread.h"
|
||||
#include "core/messaging.h"
|
||||
#include "core/peo_debug.h"
|
||||
#include "core/service.h"
|
||||
|
||||
|
||||
extern int getNodeRank();
|
||||
|
||||
//! @class peoTransform
|
||||
//! @brief Class for a parallel transform
|
||||
//! @see Service eoTransform
|
||||
//! @version 1.1
|
||||
//! @date january 2008
|
||||
template< class EOT > class peoTransform : public Service, public eoTransform< EOT >
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! @brief Constructor
|
||||
//! @param eoQuadOp< EOT >& __cross
|
||||
//! @param double __cross_rate
|
||||
//! @param eoMonOp< EOT >& __mut
|
||||
//! @param double __mut_rate
|
||||
peoTransform(
|
||||
eoQuadOp< EOT >& __cross,
|
||||
double __cross_rate,
|
||||
eoMonOp< EOT >& __mut,
|
||||
double __mut_rate
|
||||
);
|
||||
|
||||
//! @brief Operator
|
||||
//! @param eoPop< EOT >& __pop
|
||||
void operator()( eoPop< EOT >& __pop );
|
||||
//! @brief Function realizing packages of data
|
||||
void packData();
|
||||
//! @brief Function reconstituting packages of data
|
||||
void unpackData();
|
||||
//! @brief Function which executes the algorithm
|
||||
void execute();
|
||||
//! @brief Function realizing packages of the result
|
||||
void packResult();
|
||||
//! @brief Function reconstituting packages of result
|
||||
void unpackResult();
|
||||
//! @brief Function notifySendingData
|
||||
void notifySendingData();
|
||||
//! @brief Function notifySendingAllResourceRequests
|
||||
void notifySendingAllResourceRequests();
|
||||
|
||||
private:
|
||||
//! @param eoQuadOp< EOT >& cross
|
||||
//! @param double cross_rate
|
||||
//! @param eoMonOp< EOT >& mut
|
||||
//! @param double mut_rate
|
||||
//! @param unsigned idx
|
||||
//! @param eoPop< EOT >* pop
|
||||
//! @param EOT father
|
||||
//! @param mother
|
||||
//! @param unsigned num_term
|
||||
eoQuadOp< EOT >& cross;
|
||||
double cross_rate;
|
||||
eoMonOp< EOT >& mut;
|
||||
double mut_rate;
|
||||
unsigned idx;
|
||||
eoPop< EOT >* pop;
|
||||
EOT father, mother;
|
||||
unsigned num_term;
|
||||
};
|
||||
|
||||
template< class EOT > peoTransform< EOT > :: peoTransform(
|
||||
|
||||
eoQuadOp< EOT >& __cross,
|
||||
double __cross_rate,
|
||||
eoMonOp < EOT >& __mut,
|
||||
double __mut_rate
|
||||
|
||||
) : cross( __cross ), cross_rate( __cross_rate ), mut( __mut ), mut_rate( __mut_rate )
|
||||
{}
|
||||
|
||||
|
||||
template< class EOT > void peoTransform< EOT > :: packData()
|
||||
{
|
||||
|
||||
pack( idx );
|
||||
pack( pop->operator[]( idx++ ) );
|
||||
pack( pop->operator[]( idx++ ) );
|
||||
}
|
||||
|
||||
|
||||
template< class EOT > void peoTransform< EOT > :: unpackData()
|
||||
{
|
||||
|
||||
unpack( idx );
|
||||
unpack( father );
|
||||
unpack( mother );
|
||||
}
|
||||
|
||||
|
||||
template< class EOT > void peoTransform< EOT > :: execute()
|
||||
{
|
||||
|
||||
if ( rng.uniform() < cross_rate ) cross( mother, father );
|
||||
|
||||
if ( rng.uniform() < mut_rate ) mut( mother );
|
||||
if ( rng.uniform() < mut_rate ) mut( father );
|
||||
}
|
||||
|
||||
|
||||
template< class EOT > void peoTransform< EOT > :: packResult()
|
||||
{
|
||||
|
||||
pack( idx );
|
||||
pack( father );
|
||||
pack( mother );
|
||||
}
|
||||
|
||||
|
||||
template< class EOT > void peoTransform< EOT > :: unpackResult()
|
||||
{
|
||||
|
||||
unsigned sidx;
|
||||
|
||||
unpack( sidx );
|
||||
unpack( pop->operator[]( sidx++ ) );
|
||||
unpack( pop->operator[]( sidx ) );
|
||||
num_term += 2;
|
||||
|
||||
// Can be used with an odd size
|
||||
if ( num_term == 2*(pop->size()/2) )
|
||||
{
|
||||
|
||||
getOwner()->setActive();
|
||||
resume();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template< class EOT > void peoTransform< EOT > :: operator()( eoPop < EOT >& __pop )
|
||||
{
|
||||
|
||||
printDebugMessage( "peoTransform: performing the parallel transformation step." );
|
||||
pop = &__pop;
|
||||
idx = 0;
|
||||
num_term = 0;
|
||||
requestResourceRequest( __pop.size() / 2 );
|
||||
stop();
|
||||
}
|
||||
|
||||
|
||||
template< class EOT > void peoTransform< EOT > :: notifySendingData()
|
||||
{}
|
||||
|
||||
|
||||
template< class EOT > void peoTransform< EOT > :: notifySendingAllResourceRequests()
|
||||
{
|
||||
|
||||
getOwner()->setPassive();
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,174 +0,0 @@
|
|||
/*
|
||||
* <peoWrapper.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 __peoParaAlgorithm_h
|
||||
#define __peoParaAlgorithm_h
|
||||
|
||||
|
||||
#include "core/runner.h"
|
||||
#include "core/peo_debug.h"
|
||||
|
||||
//! @class peoWrapper
|
||||
//! @brief Specific class for wrapping
|
||||
//! @see Runner
|
||||
//! @version 1.1
|
||||
//! @date december 2007
|
||||
class peoWrapper : public Runner
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
//! @brief constructor
|
||||
//! @param AlgorithmType& externalAlgorithm
|
||||
template< typename AlgorithmType > peoWrapper( AlgorithmType& externalAlgorithm )
|
||||
: algorithm( new Algorithm< AlgorithmType, void >( externalAlgorithm ) )
|
||||
{}
|
||||
|
||||
//! @brief constructor
|
||||
//! @param AlgorithmType& externalAlgorithm
|
||||
//! @param AlgorithmDataType& externalData
|
||||
template< typename AlgorithmType, typename AlgorithmDataType > peoWrapper( AlgorithmType& externalAlgorithm, AlgorithmDataType& externalData )
|
||||
: algorithm( new Algorithm< AlgorithmType, AlgorithmDataType >( externalAlgorithm, externalData ) )
|
||||
{}
|
||||
|
||||
//! @brief constructor
|
||||
//! @param AlgorithmReturnType& (*externalAlgorithm)()
|
||||
template< typename AlgorithmReturnType > peoWrapper( AlgorithmReturnType& (*externalAlgorithm)() )
|
||||
: algorithm( new FunctionAlgorithm< AlgorithmReturnType, void >( externalAlgorithm ) )
|
||||
{}
|
||||
|
||||
//! @brief constructor
|
||||
//! @param AlgorithmReturnType& (*externalAlgorithm)( AlgorithmDataType& )
|
||||
//! @param AlgorithmDataType& externalData
|
||||
template< typename AlgorithmReturnType, typename AlgorithmDataType > peoWrapper( AlgorithmReturnType& (*externalAlgorithm)( AlgorithmDataType& ), AlgorithmDataType& externalData )
|
||||
: algorithm( new FunctionAlgorithm< AlgorithmReturnType, AlgorithmDataType >( externalAlgorithm, externalData ) )
|
||||
{}
|
||||
|
||||
//! @brief destructor
|
||||
~peoWrapper()
|
||||
{
|
||||
delete algorithm;
|
||||
}
|
||||
|
||||
//! @brief function run
|
||||
void run()
|
||||
{
|
||||
algorithm->operator()();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
struct AbstractAlgorithm
|
||||
{
|
||||
|
||||
// virtual destructor as we will be using inheritance and polymorphism
|
||||
virtual ~AbstractAlgorithm()
|
||||
{ }
|
||||
|
||||
// operator to be called for executing the algorithm
|
||||
virtual void operator()()
|
||||
{ }
|
||||
};
|
||||
|
||||
template< typename AlgorithmType, typename AlgorithmDataType > struct Algorithm : public AbstractAlgorithm
|
||||
{
|
||||
|
||||
Algorithm( AlgorithmType& externalAlgorithm, AlgorithmDataType& externalData )
|
||||
: algorithm( externalAlgorithm ), algorithmData( externalData )
|
||||
{}
|
||||
|
||||
virtual void operator()()
|
||||
{
|
||||
algorithm( algorithmData );
|
||||
}
|
||||
|
||||
AlgorithmType& algorithm;
|
||||
AlgorithmDataType& algorithmData;
|
||||
};
|
||||
|
||||
template< typename AlgorithmType > struct Algorithm< AlgorithmType, void > : public AbstractAlgorithm
|
||||
{
|
||||
|
||||
Algorithm( AlgorithmType& externalAlgorithm ) : algorithm( externalAlgorithm )
|
||||
{}
|
||||
|
||||
virtual void operator()()
|
||||
{
|
||||
algorithm();
|
||||
}
|
||||
|
||||
AlgorithmType& algorithm;
|
||||
};
|
||||
|
||||
template< typename AlgorithmReturnType, typename AlgorithmDataType > struct FunctionAlgorithm : public AbstractAlgorithm
|
||||
{
|
||||
|
||||
FunctionAlgorithm( AlgorithmReturnType (*externalAlgorithm)( AlgorithmDataType& ), AlgorithmDataType& externalData )
|
||||
: algorithm( externalAlgorithm ), algorithmData( externalData )
|
||||
{}
|
||||
|
||||
virtual void operator()()
|
||||
{
|
||||
algorithm( algorithmData );
|
||||
}
|
||||
|
||||
AlgorithmReturnType (*algorithm)( AlgorithmDataType& );
|
||||
AlgorithmDataType& algorithmData;
|
||||
};
|
||||
|
||||
template< typename AlgorithmReturnType > struct FunctionAlgorithm< AlgorithmReturnType, void > : public AbstractAlgorithm
|
||||
{
|
||||
|
||||
FunctionAlgorithm( AlgorithmReturnType (*externalAlgorithm)() )
|
||||
: algorithm( externalAlgorithm )
|
||||
{}
|
||||
|
||||
virtual void operator()()
|
||||
{
|
||||
algorithm();
|
||||
}
|
||||
|
||||
AlgorithmReturnType (*algorithm)();
|
||||
};
|
||||
|
||||
private:
|
||||
//! @param AbstractAlgorithm* algorithm
|
||||
AbstractAlgorithm* algorithm;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
######################################################################################
|
||||
### 0) Where must cmake go now ?
|
||||
######################################################################################
|
||||
|
||||
add_subdirectory(mpi)
|
||||
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
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)
|
||||
include_directories(${LIBXML2_INCLUDE_DIR})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
######################################################################################
|
||||
### 2) Define your target(s): just the rmc_mpi library here
|
||||
######################################################################################
|
||||
|
||||
set(RMC_MPI_LIB_OUTPUT_PATH ${PEO_BIN_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)
|
||||
install(TARGETS rmc_mpi ARCHIVE DESTINATION local/${LIB} COMPONENT libraries)
|
||||
|
|
@ -1,112 +0,0 @@
|
|||
/*
|
||||
* <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 ();
|
||||
}
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* <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
|
||||
|
|
@ -1,88 +0,0 @@
|
|||
/*
|
||||
* <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 ()
|
||||
{}
|
||||
|
|
@ -1,347 +0,0 @@
|
|||
/*
|
||||
* <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);
|
||||
buffer = new char[len+1];
|
||||
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, buffer, len, MPI_CHAR, MPI_COMM_WORLD);
|
||||
__str.assign( buffer );
|
||||
delete [] buffer;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* <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
|
||||
|
|
@ -1,153 +0,0 @@
|
|||
/*
|
||||
* <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);
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* <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
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* <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 ());
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* <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
|
||||
|
|
@ -1,156 +0,0 @@
|
|||
/*
|
||||
* <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 ()*/ );
|
||||
}
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* <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
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
* <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");
|
||||
}
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* <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);
|
||||
}
|
||||
|
|
@ -1,124 +0,0 @@
|
|||
/*
|
||||
* <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();
|
||||
}
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
* <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
|
||||
|
|
@ -1,208 +0,0 @@
|
|||
/*
|
||||
* <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"
|
||||
|
||||
#include <stdio.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 ();
|
||||
}
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
* <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
|
||||
|
|
@ -1,178 +0,0 @@
|
|||
/*
|
||||
* <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);
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* <send.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 __send_h
|
||||
#define __send_h
|
||||
|
||||
#include "../../core/communicable.h"
|
||||
|
||||
extern void initSending ();
|
||||
|
||||
extern void send (Communicable * __comm, int __to, int __tag);
|
||||
|
||||
extern void sendToAll (Communicable * __comm, int __tag);
|
||||
|
||||
extern void sendMessages ();
|
||||
|
||||
#endif
|
||||
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
* <service.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/service.h"
|
||||
#include "../../core/messaging.h"
|
||||
#include "node.h"
|
||||
#include "tags.h"
|
||||
#include "send.h"
|
||||
#include "scheduler.h"
|
||||
|
||||
void Service :: requestResourceRequest (unsigned __how_many)
|
||||
{
|
||||
|
||||
num_sent_rr = __how_many;
|
||||
for (unsigned i = 0; i < __how_many; i ++)
|
||||
send (this, my_node -> rk_sched, SCHED_REQUEST_TAG);
|
||||
}
|
||||
|
||||
void Service :: packResourceRequest ()
|
||||
{
|
||||
|
||||
SCHED_REQUEST req;
|
||||
req.first = getNodeRank ();
|
||||
req.second = getKey ();
|
||||
|
||||
:: pack (req);
|
||||
}
|
||||
|
|
@ -1,133 +0,0 @@
|
|||
/*
|
||||
* <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 <iostream>
|
||||
#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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
/*
|
||||
* <synchron.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 __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 != syncA.end() && (*itA).runner == (*itB).runner )
|
||||
{
|
||||
itA++;
|
||||
itB++;
|
||||
}
|
||||
|
||||
return ( (itA == syncA.end()) ) ? false : ( (*itA).runner < (*itB).runner );
|
||||
}
|
||||
|
||||
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
|
||||
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
* <tags.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 __tags_h
|
||||
#define __tags_h
|
||||
|
||||
#define RUNNER_STOP_TAG 13
|
||||
|
||||
#define COOP_TAG 14
|
||||
|
||||
#define SCHED_REQUEST_TAG 16
|
||||
#define SCHED_RESULT_TAG 17
|
||||
|
||||
#define TASK_DATA_TAG 18
|
||||
#define TASK_RESULT_TAG 19
|
||||
#define TASK_DONE_TAG 20
|
||||
|
||||
#define SYNCHRONIZE_REQ_TAG 1000
|
||||
#define SYNCHRONIZED_TAG 1001
|
||||
|
||||
#endif
|
||||
|
|
@ -1,152 +0,0 @@
|
|||
/*
|
||||
* <worker.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 <vector>
|
||||
|
||||
#include "tags.h"
|
||||
#include "send.h"
|
||||
#include "node.h"
|
||||
#include "schema.h"
|
||||
#include "worker.h"
|
||||
#include "mess.h"
|
||||
#include "../../core/peo_debug.h"
|
||||
|
||||
static std :: vector <Worker *> key_to_worker (1); /* Vector of registered workers */
|
||||
|
||||
extern void wakeUpCommunicator ();
|
||||
|
||||
Worker * getWorker (WORKER_ID __key)
|
||||
{
|
||||
|
||||
return key_to_worker [__key];
|
||||
}
|
||||
|
||||
Worker :: Worker ()
|
||||
{
|
||||
|
||||
recvAndCompleted = false;
|
||||
taskAssigned = 0;
|
||||
id = key_to_worker.size ();
|
||||
key_to_worker.push_back (this);
|
||||
|
||||
sem_init( &sem_task_done, 0, 0 );
|
||||
}
|
||||
|
||||
void Worker :: packResult ()
|
||||
{
|
||||
|
||||
pack (serv_id);
|
||||
serv -> packResult ();
|
||||
}
|
||||
|
||||
void Worker :: unpackData ()
|
||||
{
|
||||
|
||||
taskAssigned ++;
|
||||
printDebugMessage ("unpacking the ID. of the service.");
|
||||
unpack (serv_id);
|
||||
serv = getService (serv_id);
|
||||
printDebugMessage ("found the service.");
|
||||
serv -> unpackData ();
|
||||
printDebugMessage ("unpacking the data.");
|
||||
setActive ();
|
||||
}
|
||||
|
||||
void Worker :: packTaskDone ()
|
||||
{
|
||||
|
||||
pack (getNodeRank ());
|
||||
pack (id);
|
||||
}
|
||||
|
||||
void Worker :: notifySendingResult ()
|
||||
{
|
||||
|
||||
/* Notifying the scheduler of the termination */
|
||||
recvAndCompleted = true;
|
||||
wakeUp ();
|
||||
}
|
||||
|
||||
void Worker :: notifySendingTaskDone ()
|
||||
{
|
||||
|
||||
sem_post(&sem_task_done);
|
||||
setPassive ();
|
||||
}
|
||||
|
||||
void Worker :: setSource (int __rank)
|
||||
{
|
||||
|
||||
src = __rank;
|
||||
}
|
||||
|
||||
void Worker :: start ()
|
||||
{
|
||||
|
||||
while (true)
|
||||
{
|
||||
|
||||
sleep ();
|
||||
|
||||
if (! atLeastOneActiveRunner () && ! taskAssigned)
|
||||
break;
|
||||
|
||||
if (recvAndCompleted)
|
||||
{
|
||||
send (this, my_node -> rk_sched, TASK_DONE_TAG);
|
||||
recvAndCompleted = false;
|
||||
sem_wait(&sem_task_done);
|
||||
taskAssigned --;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
serv -> execute ();
|
||||
send (this, src, TASK_RESULT_TAG);
|
||||
}
|
||||
}
|
||||
|
||||
printDebugMessage ("Worker finished execution.");
|
||||
setPassive ();
|
||||
|
||||
wakeUpCommunicator();
|
||||
}
|
||||
|
||||
void initWorkersEnv ()
|
||||
{
|
||||
|
||||
key_to_worker.resize (1);
|
||||
}
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
/*
|
||||
* <worker.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 __worker_h
|
||||
#define __worker_h
|
||||
|
||||
#include "../../core/communicable.h"
|
||||
#include "../../core/reac_thread.h"
|
||||
#include "../../core/service.h"
|
||||
|
||||
|
||||
typedef unsigned WORKER_ID;
|
||||
|
||||
class Worker : public Communicable, public ReactiveThread
|
||||
{
|
||||
|
||||
public :
|
||||
|
||||
Worker ();
|
||||
|
||||
void start ();
|
||||
|
||||
void packResult ();
|
||||
|
||||
void unpackData ();
|
||||
|
||||
void packTaskDone ();
|
||||
|
||||
void notifySendingResult ();
|
||||
|
||||
void notifySendingTaskDone ();
|
||||
|
||||
void setSource (int __rank);
|
||||
|
||||
private :
|
||||
|
||||
WORKER_ID id;
|
||||
SERVICE_ID serv_id;
|
||||
Service * serv;
|
||||
int src;
|
||||
|
||||
bool recvAndCompleted;
|
||||
unsigned taskAssigned;
|
||||
|
||||
sem_t sem_task_done;
|
||||
sem_t sem_task_asgn;
|
||||
};
|
||||
|
||||
extern void initWorkersEnv ();
|
||||
|
||||
extern Worker * getWorker (WORKER_ID __key);
|
||||
|
||||
#endif
|
||||
|
|
@ -1,109 +0,0 @@
|
|||
/*
|
||||
* <xml_parser.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 <libxml/xmlreader.h>
|
||||
|
||||
#include "xml_parser.h"
|
||||
|
||||
static xmlTextReaderPtr reader;
|
||||
|
||||
void openXMLDocument (const char * __filename)
|
||||
{
|
||||
|
||||
reader = xmlNewTextReaderFilename (__filename);
|
||||
|
||||
if (! reader)
|
||||
{
|
||||
|
||||
fprintf (stderr, "unable to open '%s'.\n", __filename);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
void closeXMLDocument ()
|
||||
{
|
||||
|
||||
xmlFreeTextReader (reader);
|
||||
}
|
||||
|
||||
std :: string getAttributeValue (const std :: string & __attr)
|
||||
{
|
||||
|
||||
xmlChar * value = xmlTextReaderGetAttribute (reader, (const xmlChar *) __attr.c_str ());
|
||||
|
||||
std :: string str ((const char *) value);
|
||||
|
||||
xmlFree (value);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
static bool isSep (const xmlChar * __text)
|
||||
{
|
||||
|
||||
for (unsigned i = 0; i < strlen ((char *) __text); i ++)
|
||||
if (__text [i] != ' ' && __text [i] != '\t' && __text [i] != '\n')
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
std :: string getNextNode ()
|
||||
{
|
||||
|
||||
xmlChar * name, * value;
|
||||
|
||||
do
|
||||
{
|
||||
xmlTextReaderRead (reader);
|
||||
name = xmlTextReaderName (reader);
|
||||
value = xmlTextReaderValue (reader);
|
||||
}
|
||||
while (! strcmp ((char *) name, "#text") && isSep (value));
|
||||
|
||||
std :: string str;
|
||||
|
||||
if (strcmp ((char *) name, "#text"))
|
||||
str.assign ((char *) name);
|
||||
else
|
||||
str.assign ((char *) value);
|
||||
|
||||
if (name)
|
||||
xmlFree (name);
|
||||
if (value)
|
||||
xmlFree (value);
|
||||
|
||||
return str;
|
||||
}
|
||||
|
|
@ -1,51 +0,0 @@
|
|||
/*
|
||||
* <xml_parser.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 __xml_parser_h
|
||||
#define __xml_parser_h
|
||||
|
||||
#include <string>
|
||||
#include <string.h>
|
||||
|
||||
extern void openXMLDocument (const char * __filename);
|
||||
|
||||
extern void closeXMLDocument ();
|
||||
|
||||
extern std :: string getAttributeValue (const std :: string & __attr);
|
||||
|
||||
extern std :: string getNextNode ();
|
||||
|
||||
#endif
|
||||
|
|
@ -1,64 +0,0 @@
|
|||
######################################################################################
|
||||
### 0) Include headers
|
||||
######################################################################################
|
||||
|
||||
include_directories(${EO_SRC_DIR}/src)
|
||||
include_directories(${MO_SRC_DIR}/src)
|
||||
include_directories(${MOEO_SRC_DIR}/src)
|
||||
include_directories(${PEO_SRC_DIR}/src)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
######################################################################################
|
||||
### 1) Set the compiler for MPI
|
||||
######################################################################################
|
||||
|
||||
set(CMAKE_CXX_COMPILER mpicxx)
|
||||
|
||||
######################################################################################
|
||||
### 2) Define test list
|
||||
######################################################################################
|
||||
|
||||
set(TEST_RUN t-Mpdboot)
|
||||
set(TEST_STOP t-Mpdallexit)
|
||||
set(TEST_LIST
|
||||
t-ParallelEval
|
||||
t-ParallelTransform
|
||||
t-MultiStart
|
||||
t-PSOSelect
|
||||
t-EAAsyncIsland
|
||||
t-EASyncIsland
|
||||
t-PSOGlobalBest
|
||||
t-PSOWorstPosition
|
||||
)
|
||||
|
||||
######################################################################################
|
||||
### 3) Define your targets and link the librairies
|
||||
######################################################################################
|
||||
execute_process(
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/param
|
||||
${CMAKE_CURRENT_BINARY_DIR}/param
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/schema.xml
|
||||
${CMAKE_CURRENT_BINARY_DIR}/schema.xml)
|
||||
|
||||
foreach (test ${TEST_RUN} ${TEST_LIST} ${TEST_STOP})
|
||||
set("T_${test}_SOURCES" "${test}.cpp")
|
||||
add_executable(${test} ${T_${test}_SOURCES})
|
||||
install(TARGETS ${test} RUNTIME DESTINATION local/share${INSTALL_SUB_DIR}/peo/test COMPONENT tests)
|
||||
endforeach (test)
|
||||
|
||||
foreach (testrun ${TEST_RUN})
|
||||
add_test(${testrun} ${testrun})
|
||||
endforeach (testrun)
|
||||
|
||||
foreach (test ${TEST_LIST})
|
||||
add_test(${test} "mpiexec" "-n" "4" "${CMAKE_CURRENT_BINARY_DIR}/${test}" "@param")
|
||||
target_link_libraries(${test} peo xml2 rmc_mpi ga es eoutils eo peo)
|
||||
|
||||
endforeach (test)
|
||||
|
||||
foreach (teststop ${TEST_STOP})
|
||||
add_test(${teststop} ${teststop})
|
||||
endforeach (teststop)
|
||||
|
||||
|
|
@ -1,12 +0,0 @@
|
|||
## miscallenous parameters
|
||||
|
||||
--debug=false
|
||||
|
||||
## deployment schema
|
||||
|
||||
--schema=schema.xml
|
||||
|
||||
## parameters
|
||||
|
||||
--inst=../examples/tsp/benchs/eil101.tsp
|
||||
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<schema>
|
||||
<group scheduler="0">
|
||||
<node name="0" num_workers="0">
|
||||
</node>
|
||||
|
||||
<node name="1" num_workers="0">
|
||||
<runner>1</runner>
|
||||
<runner>2</runner>
|
||||
</node>
|
||||
|
||||
<node name="2" num_workers="1">
|
||||
</node>
|
||||
<node name="3" num_workers="1">
|
||||
</node>
|
||||
</group>
|
||||
</schema>
|
||||
|
||||
|
|
@ -1,119 +0,0 @@
|
|||
/*
|
||||
* <t-EAAsyncIsland.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* 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
|
||||
* peoData 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
|
||||
*
|
||||
*/
|
||||
|
||||
//Test : Asynchronous island with EA
|
||||
#include <peo>
|
||||
#include <es.h>
|
||||
typedef eoReal<double> Indi;
|
||||
|
||||
double f (const Indi & _indi)
|
||||
{
|
||||
double sum=_indi[0]+_indi[1];
|
||||
return (-sum);
|
||||
}
|
||||
int main (int __argc, char *__argv[])
|
||||
{
|
||||
peo :: init( __argc, __argv );
|
||||
if (getNodeRank()==1)
|
||||
std::cout<<"\n\nTest : Asynchronous island with EA\n\n";
|
||||
rng.reseed (10);
|
||||
RingTopology topology;
|
||||
eoGenContinue < Indi > genContPara (10);
|
||||
eoCombinedContinue <Indi> continuatorPara (genContPara);
|
||||
eoCheckPoint<Indi> checkpoint(continuatorPara);
|
||||
peoEvalFunc<Indi> mainEval( f );
|
||||
peoPopEval <Indi> eval(mainEval);
|
||||
eoUniformGenerator < double >uGen (-2., 2.);
|
||||
eoInitFixedLength < Indi > random (2, uGen);
|
||||
eoRankingSelect<Indi> selectionStrategy;
|
||||
eoSelectNumber<Indi> select(selectionStrategy,10);
|
||||
eoSegmentCrossover<Indi> crossover;
|
||||
eoUniformMutation<Indi> mutation(0.01);
|
||||
peoTransform<Indi> transform(crossover,0.8,mutation,0.3);
|
||||
/*p*/
|
||||
eoPop < Indi > pop;
|
||||
pop.append (10, random);
|
||||
eoPlusReplacement<Indi> replace;
|
||||
eoRandomSelect<Indi> mig_select_one;
|
||||
eoSelector <Indi, eoPop<Indi> > mig_select (mig_select_one,2,pop);
|
||||
eoReplace <Indi, eoPop<Indi> > mig_replace (replace,pop);
|
||||
eoPeriodicContinue< Indi > mig_cont( 2 );
|
||||
eoContinuator<Indi> cont(mig_cont, pop);
|
||||
peoAsyncIslandMig<eoPop<Indi>, eoPop<Indi> > mig(cont,mig_select,mig_replace,topology);
|
||||
checkpoint.add(mig);
|
||||
eoEasyEA< Indi > eaAlg( checkpoint, eval, select, transform, replace );
|
||||
peoWrapper parallelEA( eaAlg, pop);
|
||||
eval.setOwner(parallelEA);
|
||||
transform.setOwner(parallelEA);
|
||||
mig.setOwner(parallelEA);
|
||||
eoGenContinue < Indi > genContPara2 (10);
|
||||
eoCombinedContinue <Indi> continuatorPara2 (genContPara2);
|
||||
eoCheckPoint<Indi> checkpoint2(continuatorPara2);
|
||||
peoEvalFunc<Indi> mainEval2( f );
|
||||
peoPopEval <Indi> eval2(mainEval2);
|
||||
eoUniformGenerator < double >uGen2 (-2., 2.);
|
||||
eoInitFixedLength < Indi > random2 (2, uGen2);
|
||||
eoRankingSelect<Indi> selectionStrategy2;
|
||||
eoSelectNumber<Indi> select2(selectionStrategy2,10);
|
||||
eoSegmentCrossover<Indi> crossover2;
|
||||
eoUniformMutation<Indi> mutation2(0.01);
|
||||
peoTransform<Indi> transform2(crossover2,0.8,mutation2,0.3);
|
||||
/*p*/
|
||||
eoPop < Indi > pop2;
|
||||
pop2.append (10, random2);
|
||||
eoPlusReplacement<Indi> replace2;
|
||||
eoRandomSelect<Indi> mig_select_one2;
|
||||
eoSelector <Indi, eoPop<Indi> > mig_select2 (mig_select_one2,2,pop2);
|
||||
eoReplace <Indi, eoPop<Indi> > mig_replace2 (replace2,pop2);
|
||||
eoPeriodicContinue< Indi > mig_cont2( 2 );
|
||||
eoContinuator<Indi> cont2(mig_cont2, pop2);
|
||||
peoAsyncIslandMig<eoPop<Indi>, eoPop<Indi> > mig2(cont2,mig_select2,mig_replace2,topology);
|
||||
checkpoint2.add(mig2);
|
||||
eoEasyEA< Indi > eaAlg2( checkpoint2, eval2, select2, transform2, replace2 );
|
||||
peoWrapper parallelEA2( eaAlg2, pop2);
|
||||
eval2.setOwner(parallelEA2);
|
||||
transform2.setOwner(parallelEA2);
|
||||
mig2.setOwner(parallelEA2);
|
||||
peo :: run();
|
||||
peo :: finalize();
|
||||
if (getNodeRank()==1)
|
||||
{
|
||||
pop.sort();
|
||||
pop2.sort();
|
||||
std::cout << "Final population 1 :\n" << pop << std::endl;
|
||||
std::cout << "Final population 2 :\n" << pop2 << std::endl;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
/*
|
||||
* <t-EASyncIsland.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* 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
|
||||
* peoData 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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
//Test : Synchronous island with EA
|
||||
#include <peo>
|
||||
#include <es.h>
|
||||
typedef eoReal<double> Indi;
|
||||
|
||||
double f (const Indi & _indi)
|
||||
{
|
||||
double sum=_indi[0]+_indi[1];
|
||||
return (-sum);
|
||||
}
|
||||
int main (int __argc, char *__argv[])
|
||||
{
|
||||
peo :: init( __argc, __argv );
|
||||
if (getNodeRank()==1)
|
||||
std::cout<<"\n\nTest : Synchronous island with EA\n\n";
|
||||
rng.reseed (10);
|
||||
RingTopology topology;
|
||||
eoGenContinue < Indi > genContPara (10);
|
||||
eoCombinedContinue <Indi> continuatorPara (genContPara);
|
||||
eoCheckPoint<Indi> checkpoint(continuatorPara);
|
||||
peoEvalFunc<Indi> mainEval( f );
|
||||
peoPopEval <Indi> eval(mainEval);
|
||||
eoUniformGenerator < double >uGen (-2., 2.);
|
||||
eoInitFixedLength < Indi > random (2, uGen);
|
||||
eoRankingSelect<Indi> selectionStrategy;
|
||||
eoSelectNumber<Indi> select(selectionStrategy,10);
|
||||
eoSegmentCrossover<Indi> crossover;
|
||||
eoUniformMutation<Indi> mutation(0.01);
|
||||
peoTransform<Indi> transform(crossover,0.8,mutation,0.3);
|
||||
eoPop < Indi > pop;
|
||||
pop.append (10, random);
|
||||
eoPlusReplacement<Indi> replace;
|
||||
eoRandomSelect<Indi> mig_select_one;
|
||||
eoSelector <Indi, eoPop<Indi> > mig_select (mig_select_one,2,pop);
|
||||
eoReplace <Indi, eoPop<Indi> > mig_replace (replace,pop);
|
||||
peoSyncIslandMig<eoPop<Indi>, eoPop<Indi> > mig(2,mig_select,mig_replace,topology);
|
||||
checkpoint.add(mig);
|
||||
eoEasyEA< Indi > eaAlg( checkpoint, eval, select, transform, replace );
|
||||
peoWrapper parallelEA( eaAlg, pop);
|
||||
eval.setOwner(parallelEA);
|
||||
transform.setOwner(parallelEA);
|
||||
mig.setOwner(parallelEA);
|
||||
eoGenContinue < Indi > genContPara2 (10);
|
||||
eoCombinedContinue <Indi> continuatorPara2 (genContPara2);
|
||||
eoCheckPoint<Indi> checkpoint2(continuatorPara2);
|
||||
peoEvalFunc<Indi> mainEval2( f );
|
||||
peoPopEval <Indi> eval2(mainEval2);
|
||||
eoUniformGenerator < double >uGen2 (-2., 2.);
|
||||
eoInitFixedLength < Indi > random2 (2, uGen2);
|
||||
eoRankingSelect<Indi> selectionStrategy2;
|
||||
eoSelectNumber<Indi> select2(selectionStrategy2,10);
|
||||
eoSegmentCrossover<Indi> crossover2;
|
||||
eoUniformMutation<Indi> mutation2(0.01);
|
||||
peoTransform<Indi> transform2(crossover2,0.8,mutation2,0.3);
|
||||
eoPop < Indi > pop2;
|
||||
pop2.append (10, random2);
|
||||
eoPlusReplacement<Indi> replace2;
|
||||
eoRandomSelect<Indi> mig_select_one2;
|
||||
eoSelector <Indi, eoPop<Indi> > mig_select2 (mig_select_one2,2,pop2);
|
||||
eoReplace <Indi, eoPop<Indi> > mig_replace2 (replace2,pop2);
|
||||
peoSyncIslandMig<eoPop<Indi>, eoPop<Indi> > mig2(2,mig_select2,mig_replace2,topology);
|
||||
checkpoint2.add(mig2);
|
||||
eoEasyEA< Indi > eaAlg2( checkpoint2, eval2, select2, transform2, replace2 );
|
||||
peoWrapper parallelEA2( eaAlg2, pop2);
|
||||
eval2.setOwner(parallelEA2);
|
||||
transform2.setOwner(parallelEA2);
|
||||
mig2.setOwner(parallelEA2);
|
||||
peo :: run();
|
||||
peo :: finalize();
|
||||
if (getNodeRank()==1)
|
||||
{
|
||||
pop.sort();
|
||||
pop2.sort();
|
||||
std::cout << "Final population 1 :\n" << pop << std::endl;
|
||||
std::cout << "Final population 2 :\n" << pop2 << std::endl;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* <t-Mpdallexit.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* 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
|
||||
* peoData 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 <iostream>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main (int __argc, char *__argv[])
|
||||
{
|
||||
int success = system("mpdallexit");
|
||||
}
|
||||
|
|
@ -1,43 +0,0 @@
|
|||
/*
|
||||
* <t-Mpdboot.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* 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
|
||||
* peoData 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 <iostream>
|
||||
#include <stdlib.h>
|
||||
|
||||
int main (int __argc, char *__argv[])
|
||||
{
|
||||
int success = system("mpdboot");
|
||||
}
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
/*
|
||||
* <t-MultiStart.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* 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
|
||||
* peoData 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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Test : multistart
|
||||
|
||||
#include <peo>
|
||||
|
||||
struct Algorithm
|
||||
{
|
||||
void operator()(double & _d)
|
||||
{
|
||||
_d = _d * _d;
|
||||
}
|
||||
};
|
||||
|
||||
int main (int __argc, char * * __argv)
|
||||
{
|
||||
|
||||
peo :: init (__argc, __argv);
|
||||
if (getNodeRank()==1)
|
||||
std::cout<<"\n\nTest : multistart\n\n";
|
||||
std::vector < double > v;
|
||||
if (getNodeRank()==1)
|
||||
std::cout<<"\n\nBefore :";
|
||||
for (unsigned i = 0; i< 10; i++)
|
||||
{
|
||||
v.push_back(i);
|
||||
if (getNodeRank()==1)
|
||||
std::cout<<"\n"<<v[i];
|
||||
}
|
||||
Algorithm algo;
|
||||
peoMultiStart < double > initParallel (algo);
|
||||
peoWrapper parallelAlgo (initParallel, v);
|
||||
initParallel.setOwner(parallelAlgo);
|
||||
peo :: run( );
|
||||
peo :: finalize( );
|
||||
if (getNodeRank()==1)
|
||||
{
|
||||
std::cout<<"\n\nAfter :\n";
|
||||
for (unsigned i = 0; i< 10; i++)
|
||||
std::cout<<v[i]<<"\n";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,122 +0,0 @@
|
|||
/*
|
||||
* <t-PSOGlobalBest.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* 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
|
||||
* peoData 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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Test : PSO Global Best
|
||||
#include <peo>
|
||||
typedef eoRealParticle < double >Indi;
|
||||
double f (const Indi & _indi)
|
||||
{
|
||||
double sum=_indi[0]+_indi[1];
|
||||
return (sum);
|
||||
}
|
||||
int main (int __argc, char *__argv[])
|
||||
{
|
||||
peo :: init( __argc, __argv );
|
||||
if (getNodeRank()==1)
|
||||
std::cout<<"\n\nTest : PSO Global Best\n\n";
|
||||
rng.reseed (10);
|
||||
RingTopology topologyMig;
|
||||
eoGenContinue < Indi > genContPara (10);
|
||||
eoCombinedContinue <Indi> continuatorPara (genContPara);
|
||||
eoCheckPoint<Indi> checkpoint(continuatorPara);
|
||||
peoEvalFunc<Indi, double, const Indi& > plainEval(f);
|
||||
peoPopEval< Indi > eval(plainEval);
|
||||
eoUniformGenerator < double >uGen (0, 1.);
|
||||
eoInitFixedLength < Indi > random (2, uGen);
|
||||
eoUniformGenerator < double >sGen (-1., 1.);
|
||||
eoVelocityInitFixedLength < Indi > veloRandom (2, sGen);
|
||||
eoFirstIsBestInit < Indi > localInit;
|
||||
eoRealVectorBounds bndsFlight(2,0,1.);
|
||||
eoStandardFlight < Indi > flight(bndsFlight);
|
||||
eoPop < Indi > pop;
|
||||
pop.append (10, random);
|
||||
eoLinearTopology<Indi> topology(2);
|
||||
eoRealVectorBounds bnds(2,-1.,1.);
|
||||
eoStandardVelocity < Indi > velocity (topology,1,0.5,2.,bnds);
|
||||
eoInitializer <Indi> init(eval,veloRandom,localInit,topology,pop);
|
||||
eoPeriodicContinue< Indi > mig_cont( 2 );
|
||||
peoPSOSelect<Indi> mig_selec(topology);
|
||||
peoGlobalBestVelocity<Indi> mig_replac (2.,velocity);
|
||||
eoContinuator<Indi> cont(mig_cont, pop);
|
||||
eoSelector <Indi, eoPop<Indi> > mig_select (mig_selec,1,pop);
|
||||
eoReplace <Indi, eoPop<Indi> > mig_replace (mig_replac,pop);
|
||||
eoGenContinue < Indi > genContPara2 (10);
|
||||
eoCombinedContinue <Indi> continuatorPara2 (genContPara2);
|
||||
eoCheckPoint<Indi> checkpoint2(continuatorPara2);
|
||||
peoEvalFunc<Indi, double, const Indi& > plainEval2(f);
|
||||
peoPopEval< Indi > eval2(plainEval2);
|
||||
eoUniformGenerator < double >uGen2 (0, 1.);
|
||||
eoInitFixedLength < Indi > random2 (2, uGen2);
|
||||
eoUniformGenerator < double >sGen2 (-1., 1.);
|
||||
eoVelocityInitFixedLength < Indi > veloRandom2 (2, sGen2);
|
||||
eoFirstIsBestInit < Indi > localInit2;
|
||||
eoRealVectorBounds bndsFlight2(2,0,1.);
|
||||
eoStandardFlight < Indi > flight2(bndsFlight2);
|
||||
eoPop < Indi > pop2;
|
||||
pop2.append (10, random2);
|
||||
eoLinearTopology<Indi> topology2(2);
|
||||
eoRealVectorBounds bnds2(2,-1.,1.);
|
||||
eoStandardVelocity < Indi > velocity2 (topology2,1,0.5,2.,bnds2);
|
||||
eoInitializer <Indi> init2(eval2,veloRandom2,localInit2,topology2,pop2);
|
||||
eoPeriodicContinue< Indi > mig_cont2( 2 );
|
||||
peoPSOSelect<Indi> mig_selec2(topology2);
|
||||
peoGlobalBestVelocity<Indi> mig_replac2 (2.,velocity2);
|
||||
eoContinuator<Indi> cont2(mig_cont2,pop2);
|
||||
eoSelector <Indi, eoPop<Indi> > mig_select2 (mig_selec2,1,pop2);
|
||||
eoReplace <Indi, eoPop<Indi> > mig_replace2 (mig_replac2,pop2);
|
||||
peoAsyncIslandMig< eoPop<Indi>, eoPop<Indi> > mig(cont,mig_select, mig_replace, topologyMig);
|
||||
checkpoint.add( mig );
|
||||
peoAsyncIslandMig< eoPop<Indi>, eoPop<Indi> > mig2(cont2,mig_select2, mig_replace2, topologyMig);
|
||||
checkpoint2.add( mig2 );
|
||||
eoSyncEasyPSO <Indi> psa(init,checkpoint,eval, velocity, flight);
|
||||
peoWrapper parallelPSO( psa, pop);
|
||||
eval.setOwner(parallelPSO);
|
||||
mig.setOwner(parallelPSO);
|
||||
eoSyncEasyPSO <Indi> psa2(init2,checkpoint2,eval2, velocity2, flight2);
|
||||
peoWrapper parallelPSO2( psa2, pop2);
|
||||
eval2.setOwner(parallelPSO2);
|
||||
mig2.setOwner(parallelPSO2);
|
||||
peo :: run();
|
||||
peo :: finalize();
|
||||
if (getNodeRank()==1)
|
||||
{
|
||||
pop.sort();
|
||||
pop2.sort();
|
||||
std::cout << "Final population :\n" << pop << std::endl;
|
||||
std::cout << "Final population :\n" << pop2 << std::endl;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
* <t-PSOSelect.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* 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
|
||||
* peoData 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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
//Test : PSO select
|
||||
#include <peo>
|
||||
typedef eoRealParticle < double >Indi;
|
||||
double f (const Indi & _indi)
|
||||
{
|
||||
double sum=_indi[0]+_indi[1];
|
||||
return (-sum);
|
||||
}
|
||||
|
||||
int main (int __argc, char *__argv[])
|
||||
{
|
||||
std::cout<<"\n\nTest : PSO select\n\n";
|
||||
rng.reseed (10);
|
||||
peoEvalFunc<Indi, double, const Indi& > plainEval(f);
|
||||
eoEvalFuncCounter < Indi > firstEval(plainEval);
|
||||
eoPopLoopEval < Indi > eval(firstEval);
|
||||
eoUniformGenerator < double >uGen (1, 2);
|
||||
eoInitFixedLength < Indi > random (2, uGen);
|
||||
eoUniformGenerator < double >sGen (-1, 1);
|
||||
eoVelocityInitFixedLength < Indi > veloRandom (2, sGen);
|
||||
eoFirstIsBestInit < Indi > localInit;
|
||||
eoRealVectorBounds bndsFlight(2,1,2);
|
||||
eoStandardFlight < Indi > flight(bndsFlight);
|
||||
eoLinearTopology<Indi> topology(6);
|
||||
eoRealVectorBounds bnds(2,-1,1);
|
||||
eoStandardVelocity < Indi > velocity (topology,1,0.5,2.,bnds);
|
||||
eoPop < Indi > empty_pop,pop(20, random);
|
||||
eoInitializer <Indi> init(eval,veloRandom,localInit,topology,pop);
|
||||
init();
|
||||
eval (empty_pop,pop);
|
||||
peoPSOSelect<Indi> mig_selec(topology);
|
||||
pop.sort();
|
||||
std::cout<<"\nBest : "<<pop[0]<<" = "<<mig_selec(pop)<<"\n\n";
|
||||
}
|
||||
|
|
@ -1,122 +0,0 @@
|
|||
/*
|
||||
* <t-PSOWorstPosition.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* 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
|
||||
* peoData 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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Test : PSO Worst Position
|
||||
#include <peo>
|
||||
typedef eoRealParticle < double >Indi;
|
||||
double f (const Indi & _indi)
|
||||
{
|
||||
double sum=_indi[0]+_indi[1];
|
||||
return (sum);
|
||||
}
|
||||
int main (int __argc, char *__argv[])
|
||||
{
|
||||
peo :: init( __argc, __argv );
|
||||
if (getNodeRank()==1)
|
||||
std::cout<<"\n\nTest : PSO Worst Position\n\n";
|
||||
rng.reseed (10);
|
||||
RingTopology topologyMig;
|
||||
eoGenContinue < Indi > genContPara (10);
|
||||
eoCombinedContinue <Indi> continuatorPara (genContPara);
|
||||
eoCheckPoint<Indi> checkpoint(continuatorPara);
|
||||
peoEvalFunc<Indi, double, const Indi& > plainEval(f);
|
||||
peoPopEval< Indi > eval(plainEval);
|
||||
eoUniformGenerator < double >uGen (0, 1.);
|
||||
eoInitFixedLength < Indi > random (2, uGen);
|
||||
eoUniformGenerator < double >sGen (-1., 1.);
|
||||
eoVelocityInitFixedLength < Indi > veloRandom (2, sGen);
|
||||
eoFirstIsBestInit < Indi > localInit;
|
||||
eoRealVectorBounds bndsFlight(2,0,1.);
|
||||
eoStandardFlight < Indi > flight(bndsFlight);
|
||||
eoPop < Indi > pop;
|
||||
pop.append (10, random);
|
||||
eoLinearTopology<Indi> topology(2);
|
||||
eoRealVectorBounds bnds(2,-1.,1.);
|
||||
eoStandardVelocity < Indi > velocity (topology,1,0.5,2.,bnds);
|
||||
eoInitializer <Indi> init(eval,veloRandom,localInit,topology,pop);
|
||||
eoPeriodicContinue< Indi > mig_cont( 2 );
|
||||
peoPSOSelect<Indi> mig_selec(topology);
|
||||
peoWorstPositionReplacement<Indi> mig_replac;
|
||||
eoContinuator<Indi> cont(mig_cont, pop);
|
||||
eoSelector <Indi, eoPop<Indi> > mig_select (mig_selec,1,pop);
|
||||
eoReplace <Indi, eoPop<Indi> > mig_replace (mig_replac,pop);
|
||||
eoGenContinue < Indi > genContPara2 (10);
|
||||
eoCombinedContinue <Indi> continuatorPara2 (genContPara2);
|
||||
eoCheckPoint<Indi> checkpoint2(continuatorPara2);
|
||||
peoEvalFunc<Indi, double, const Indi& > plainEval2(f);
|
||||
peoPopEval< Indi > eval2(plainEval2);
|
||||
eoUniformGenerator < double >uGen2 (0, 1.);
|
||||
eoInitFixedLength < Indi > random2 (2, uGen2);
|
||||
eoUniformGenerator < double >sGen2 (-1., 1.);
|
||||
eoVelocityInitFixedLength < Indi > veloRandom2 (2, sGen2);
|
||||
eoFirstIsBestInit < Indi > localInit2;
|
||||
eoRealVectorBounds bndsFlight2(2,0,1.);
|
||||
eoStandardFlight < Indi > flight2(bndsFlight2);
|
||||
eoPop < Indi > pop2;
|
||||
pop2.append (10, random2);
|
||||
eoLinearTopology<Indi> topology2(2);
|
||||
eoRealVectorBounds bnds2(2,-1.,1.);
|
||||
eoStandardVelocity < Indi > velocity2 (topology2,1,0.5,2.,bnds2);
|
||||
eoInitializer <Indi> init2(eval2,veloRandom2,localInit2,topology2,pop2);
|
||||
eoPeriodicContinue< Indi > mig_cont2( 2 );
|
||||
peoPSOSelect<Indi> mig_selec2(topology2);
|
||||
peoWorstPositionReplacement<Indi> mig_replac2;
|
||||
eoContinuator<Indi> cont2(mig_cont2,pop2);
|
||||
eoSelector <Indi, eoPop<Indi> > mig_select2 (mig_selec2,1,pop2);
|
||||
eoReplace <Indi, eoPop<Indi> > mig_replace2 (mig_replac2,pop2);
|
||||
peoAsyncIslandMig< eoPop<Indi>, eoPop<Indi> > mig(cont,mig_select, mig_replace, topologyMig);
|
||||
checkpoint.add( mig );
|
||||
peoAsyncIslandMig< eoPop<Indi>, eoPop<Indi> > mig2(cont2,mig_select2, mig_replace2, topologyMig);
|
||||
checkpoint2.add( mig2 );
|
||||
eoSyncEasyPSO <Indi> psa(init,checkpoint,eval, velocity, flight);
|
||||
peoWrapper parallelPSO( psa, pop);
|
||||
eval.setOwner(parallelPSO);
|
||||
mig.setOwner(parallelPSO);
|
||||
eoSyncEasyPSO <Indi> psa2(init2,checkpoint2,eval2, velocity2, flight2);
|
||||
peoWrapper parallelPSO2( psa2, pop2);
|
||||
eval2.setOwner(parallelPSO2);
|
||||
mig2.setOwner(parallelPSO2);
|
||||
peo :: run();
|
||||
peo :: finalize();
|
||||
if (getNodeRank()==1)
|
||||
{
|
||||
pop.sort();
|
||||
pop2.sort();
|
||||
std::cout << "Final population :\n" << pop << std::endl;
|
||||
std::cout << "Final population :\n" << pop2 << std::endl;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
* <t-ParallelEval.cpp>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
|
||||
* (C) OPAC Team, LIFL, 2002-2008
|
||||
*
|
||||
* 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
|
||||
* peoData 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
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Test : parallel evaluation
|
||||
#include <peo>
|
||||
#include <es.h>
|
||||
typedef eoReal<double> Indi;
|
||||
double f (const Indi & _indi)
|
||||
{
|
||||
double sum=_indi[0]+_indi[1];
|
||||
return (-sum);
|
||||
}
|
||||
struct Algorithm
|
||||
{
|
||||
Algorithm( peoPopEval < Indi > & _eval): eval( _eval ){}
|
||||
void operator()(eoPop < Indi > & _pop)
|
||||
{
|
||||
eoPop < Indi > empty_pop;
|
||||
eval(empty_pop, _pop);
|
||||
}
|
||||
peoPopEval < Indi > & eval;
|
||||
};
|
||||
|
||||
int main (int __argc, char *__argv[])
|
||||
{
|
||||
peo :: init( __argc, __argv );
|
||||
if (getNodeRank()==1)
|
||||
std::cout<<"\n\nTest : parallel evaluation\n\n";
|
||||
rng.reseed (10);
|
||||
peoEvalFunc<Indi, double, const Indi& > plainEval(f);
|
||||
peoPopEval< Indi > eval(plainEval);
|
||||
eoUniformGenerator < double >uGen (0, 1);
|
||||
eoInitFixedLength < Indi > random (2, uGen);
|
||||
eoPop < Indi > pop(20, random);
|
||||
Algorithm algo ( eval );
|
||||
peoWrapper parallelAlgo( algo, pop);
|
||||
eval.setOwner(parallelAlgo);
|
||||
peo :: run();
|
||||
peo :: finalize();
|
||||
if (getNodeRank()==1)
|
||||
{
|
||||
pop.sort();
|
||||
std::cout<<pop;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue