Style for PEO

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@906 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
canape 2008-01-25 16:14:06 +00:00
commit b74a446baa
82 changed files with 1946 additions and 1663 deletions

View file

@ -1,4 +1,4 @@
/*
/*
* <mess.cpp>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -42,62 +42,69 @@
#include "node.h"
#define MPI_BUF_SIZE 1024*64
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 () {
void initBuffers ()
{
pos_buf = 0;
act_buf.clear ();
act_req.clear ();
}
void cleanBuffers () {
void cleanBuffers ()
{
for (unsigned i = 0; i < act_req.size ();) {
for (unsigned i = 0; i < act_req.size ();)
{
MPI_Status stat ;
int flag ;
MPI_Status stat ;
int flag ;
MPI_Test (act_req [i], & flag, & stat) ;
if (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 () ;
delete[] act_buf [i] ;
delete act_req [i] ;
act_req [i] = act_req.back () ;
act_req.pop_back () ;
act_buf [i] = act_buf.back () ;
act_buf.pop_back () ;
act_req [i] = act_req.back () ;
act_req.pop_back () ;
}
else
i ++;
}
else
i ++;
}
}
void waitBuffers () {
void waitBuffers ()
{
printDebugMessage ("waiting the termination of the asynchronous operations to complete");
for (unsigned i = 0; i < act_req.size (); i ++) {
for (unsigned i = 0; i < act_req.size (); i ++)
{
MPI_Status stat ;
MPI_Status stat ;
MPI_Wait (act_req [i], & stat) ;
MPI_Wait (act_req [i], & stat) ;
delete[] act_buf [i] ;
delete act_req [i] ;
}
delete[] act_buf [i] ;
delete act_req [i] ;
}
}
bool probeMessage (int & __src, int & __tag) {
bool probeMessage (int & __src, int & __tag)
{
int flag;
@ -111,19 +118,22 @@ bool probeMessage (int & __src, int & __tag) {
return flag;
}
void waitMessage () {
void waitMessage ()
{
MPI_Status stat;
MPI_Status stat;
MPI_Probe (MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, & stat);
}
void initMessage () {
void initMessage ()
{
pos_buf = 0;
}
void sendMessage (int __to, int __tag) {
void sendMessage (int __to, int __tag)
{
cleanBuffers ();
act_buf.push_back (new char [pos_buf]);
@ -132,13 +142,15 @@ void sendMessage (int __to, int __tag) {
MPI_Isend (act_buf.back (), pos_buf, MPI_PACKED, __to, __tag, MPI_COMM_WORLD, act_req.back ());
}
void sendMessageToAll (int __tag) {
void sendMessageToAll (int __tag)
{
for (int i = 0; i < getNumberOfNodes (); i ++)
sendMessage (i, __tag);
}
void receiveMessage (int __from, int __tag) {
void receiveMessage (int __from, int __tag)
{
MPI_Status stat;
MPI_Request req;
@ -147,80 +159,93 @@ void receiveMessage (int __from, int __tag) {
MPI_Wait (& req, & stat);
}
void synchronizeNodes () {
void synchronizeNodes ()
{
MPI_Barrier ( MPI_COMM_WORLD );
}
/* Char */
void pack (const char & __c) {
void pack (const char & __c)
{
MPI_Pack ((void *) & __c, 1, MPI_CHAR, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
}
/* Boolean */
void pack (const bool & __b, int __nitem){
void pack (const bool & __b, int __nitem)
{
MPI_Pack ((void *) & __b, __nitem, MPI_INT, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
}
/* Float */
void pack (const float & __f, int __nitem) {
void pack (const float & __f, int __nitem)
{
MPI_Pack ((void *) & __f, __nitem, MPI_FLOAT, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
}
/* Double */
void pack (const double & __d, int __nitem) {
void pack (const double & __d, int __nitem)
{
MPI_Pack ((void *) & __d, __nitem, MPI_DOUBLE, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
}
/* Integer */
void pack (const int & __i, int __nitem) {
void pack (const int & __i, int __nitem)
{
MPI_Pack ((void *) & __i, __nitem, MPI_INT, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
}
/* Unsigned int. */
void pack (const unsigned int & __ui, int __nitem) {
void pack (const unsigned int & __ui, int __nitem)
{
MPI_Pack ((void *) & __ui, __nitem, MPI_UNSIGNED, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
}
/* Short int. */
void pack (const short & __sh, int __nitem) {
void pack (const short & __sh, int __nitem)
{
MPI_Pack ((void *) & __sh, __nitem, MPI_SHORT, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
}
/* Unsigned short */
void pack (const unsigned short & __ush, int __nitem) {
void pack (const unsigned short & __ush, int __nitem)
{
MPI_Pack ((void *) & __ush, __nitem, MPI_UNSIGNED_SHORT, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
}
/* Long */
void pack (const long & __l, int __nitem) {
void pack (const long & __l, int __nitem)
{
MPI_Pack ((void *) & __l, __nitem, MPI_LONG, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
}
/* Unsigned long */
void pack (const unsigned long & __ul, int __nitem) {
void pack (const unsigned long & __ul, int __nitem)
{
MPI_Pack ((void *) & __ul, __nitem, MPI_UNSIGNED_LONG, mpi_buf, MPI_BUF_SIZE, & pos_buf, MPI_COMM_WORLD);
}
/* String */
void pack (const char * __str) {
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) {
void pack (const std::string & __str)
{
size_t size = __str.size() + 1;
char * buffer = new char[ size ];
@ -230,79 +255,91 @@ void pack (const std::string & __str) {
}
/* Char */
void unpack (char & __c) {
void unpack (char & __c)
{
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __c, 1, MPI_CHAR, MPI_COMM_WORLD);
}
/* Boolean */
extern void unpack (bool & __b, int __nitem ){
extern void unpack (bool & __b, int __nitem )
{
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __b, __nitem, MPI_INT, MPI_COMM_WORLD);
}
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __b, __nitem, MPI_INT, MPI_COMM_WORLD);
}
/* Float */
void unpack (float & __f, int __nitem) {
void unpack (float & __f, int __nitem)
{
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __f, __nitem, MPI_FLOAT, MPI_COMM_WORLD);
}
/* Double */
void unpack (double & __d, int __nitem) {
void unpack (double & __d, int __nitem)
{
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __d, __nitem, MPI_DOUBLE, MPI_COMM_WORLD);
}
/* Integer */
void unpack (int & __i, int __nitem) {
void unpack (int & __i, int __nitem)
{
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __i, __nitem, MPI_INT, MPI_COMM_WORLD);
}
/* Unsigned int. */
void unpack (unsigned int & __ui, int __nitem) {
void unpack (unsigned int & __ui, int __nitem)
{
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __ui, __nitem, MPI_UNSIGNED, MPI_COMM_WORLD);
}
/* Short int. */
void unpack (short & __sh, int __nitem) {
void unpack (short & __sh, int __nitem)
{
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __sh, __nitem, MPI_SHORT, MPI_COMM_WORLD);
}
/* Unsigned short */
void unpack (unsigned short & __ush, int __nitem) {
void unpack (unsigned short & __ush, int __nitem)
{
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __ush, __nitem, MPI_UNSIGNED_SHORT, MPI_COMM_WORLD);
}
/* Long */
void unpack (long & __l, int __nitem) {
void unpack (long & __l, int __nitem)
{
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __l, __nitem, MPI_LONG, MPI_COMM_WORLD);
}
/* Unsigned long */
void unpack (unsigned long & __ul, int __nitem) {
void unpack (unsigned long & __ul, int __nitem)
{
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & __ul, __nitem, MPI_UNSIGNED_LONG, MPI_COMM_WORLD);
}
/* String */
void unpack (char * __str) {
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);
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, __str, len, MPI_CHAR, MPI_COMM_WORLD);
}
void unpack (std::string & __str) {
void unpack (std::string & __str)
{
char * buffer;
int len;
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, & len, 1, MPI_INT, MPI_COMM_WORLD);
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, buffer, len, MPI_CHAR, MPI_COMM_WORLD);
__str.assign( buffer );
MPI_Unpack (mpi_buf, MPI_BUF_SIZE, & pos_buf, buffer, len, MPI_CHAR, MPI_COMM_WORLD);
__str.assign( buffer );
}