From: cherierm Date: Tue, 19 Aug 2008 15:51:41 +0000 (+0000) Subject: last changes of cpp wrappers examples X-Git-Tag: v3.3~211 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/ed5b6e45b9957b00a2c41f01ce9da418da78cecb last changes of cpp wrappers examples git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@5896 48e7efb5-ca39-0410-a469-dd3cf9ba447f --- diff --git a/examples/cxx/autoDestination/BasicTask.cxx b/examples/cxx/autoDestination/BasicTask.cxx index 21924e8d4f..19cd54a77b 100644 --- a/examples/cxx/autoDestination/BasicTask.cxx +++ b/examples/cxx/autoDestination/BasicTask.cxx @@ -1,3 +1,3 @@ -#include "BasicTask.hpp" - -MSG_IMPLEMENT_DYNAMIC(BasicTask, Task); \ No newline at end of file +#include "BasicTask.hpp" + +MSG_IMPLEMENT_DYNAMIC(BasicTask, Task) diff --git a/examples/cxx/autoDestination/BasicTask.hpp b/examples/cxx/autoDestination/BasicTask.hpp index 14f8e1da8e..bef66e2d54 100644 --- a/examples/cxx/autoDestination/BasicTask.hpp +++ b/examples/cxx/autoDestination/BasicTask.hpp @@ -1,30 +1,31 @@ -#ifndef BASIC_TASK_HPP -#define BASIC_TASK_HPP - -#include -using namespace SimGrid::Msg; - -class BasicTask : public Task -{ - MSG_DECLARE_DYNAMIC(BasicTask); -public: - - // Default constructor. - BasicTask() {} - - // Destructor - virtual ~BasicTask() {} - BasicTask(const char* name, double computeDuration, double messageSize) - throw (InvalidArgumentException, NullPointerException) - :Task(name, computeDuration, messageSize){} - - /*virtual const BasicTask& operator = (const BasicTask& rTask) { - Task::operator=(rTask); - return *this; - }*/ -}; - -typedef BasicTask* BasicTaskPtr; - - -#endif // !BASIC_TASK_HPP \ No newline at end of file +#ifndef BASIC_TASK_HPP +#define BASIC_TASK_HPP + +#include +using namespace SimGrid::Msg; + +class BasicTask : public Task +{ + MSG_DECLARE_DYNAMIC(BasicTask); +public: + + // Default constructor. + BasicTask() {} + + // Destructor + virtual ~BasicTask() + throw (MsgException) {} + BasicTask(const char* name, double computeDuration, double messageSize) + throw (InvalidArgumentException, NullPointerException) + :Task(name, computeDuration, messageSize){} + + /*virtual const BasicTask& operator = (const BasicTask& rTask) { + Task::operator=(rTask); + return *this; + }*/ +}; + +typedef BasicTask* BasicTaskPtr; + + +#endif // !BASIC_TASK_HPP diff --git a/examples/cxx/autoDestination/FinalizeTask.cxx b/examples/cxx/autoDestination/FinalizeTask.cxx index a9cde570c1..0805537c9f 100644 --- a/examples/cxx/autoDestination/FinalizeTask.cxx +++ b/examples/cxx/autoDestination/FinalizeTask.cxx @@ -1,3 +1,3 @@ -#include "FinalizeTask.hpp" - -MSG_IMPLEMENT_DYNAMIC(FinalizeTask, Task); \ No newline at end of file +#include "FinalizeTask.hpp" + +MSG_IMPLEMENT_DYNAMIC(FinalizeTask, Task) diff --git a/examples/cxx/autoDestination/FinalizeTask.hpp b/examples/cxx/autoDestination/FinalizeTask.hpp index 6d95a14682..a181ae33d5 100644 --- a/examples/cxx/autoDestination/FinalizeTask.hpp +++ b/examples/cxx/autoDestination/FinalizeTask.hpp @@ -1,25 +1,23 @@ -#ifndef FINALIZE_TASK_HPP -#define FINALIZE_TASK_HPP - -#include -using namespace SimGrid::Msg; - -class FinalizeTask : public Task -{ - MSG_DECLARE_DYNAMIC(FinalizeTask); -public: - - // Default constructor. - FinalizeTask() - throw (InvalidArgumentException, NullPointerException) - :Task("finalize", 0.0, 0.0){} - - // Destructor - virtual ~FinalizeTask() {} - -}; - - - - -#endif // !FINALIZE_TASK_HPP \ No newline at end of file +#ifndef FINALIZE_TASK_HPP +#define FINALIZE_TASK_HPP + +#include +using namespace SimGrid::Msg; + +class FinalizeTask : public Task +{ + MSG_DECLARE_DYNAMIC(FinalizeTask); +public: + + // Default constructor. + FinalizeTask() + throw (InvalidArgumentException, NullPointerException) + :Task("finalize", 0.0, 0.0){} + + // Destructor + virtual ~FinalizeTask() + throw (MsgException) {} + +}; + +#endif // !FINALIZE_TASK_HPP diff --git a/examples/cxx/autoDestination/Forwarder.cxx b/examples/cxx/autoDestination/Forwarder.cxx index 7953686088..8872e0b3c1 100644 --- a/examples/cxx/autoDestination/Forwarder.cxx +++ b/examples/cxx/autoDestination/Forwarder.cxx @@ -1,60 +1,60 @@ -#include "Forwarder.hpp" -#include "BasicTask.hpp" -#include "FinalizeTask.hpp" - -#include -#include - -#include - -MSG_IMPLEMENT_DYNAMIC(Forwarder, Process); - -int Forwarder::main(int argc, char** argv) -{ - info("Hello"); - - int aliasCount = argc; - - int taskCount = 0; - - Task* taskReceived; - Task* finalizeTask; - BasicTask* basicTask; - - while(true) - { - taskReceived = Task::receive(); - - if(taskReceived->isInstanceOf("FinalizeTask")) - { - info("All tasks have been dispatched. Let's tell everybody the computation is over."); - - for (int i = 0; i < aliasCount; i++) - { - finalizeTask = new FinalizeTask(); - finalizeTask->send(argv[i]); - } - - delete taskReceived; - - break; - } - - basicTask = reinterpret_cast(taskReceived); - - info(TEXT_("Received \"") + TEXT_(basicTask->getName()) + TEXT_("\" ")); - - info(TEXT_("Sending \"") + TEXT_(basicTask->getName()) + TEXT_("\" to \"") + TEXT_(argv[taskCount % aliasCount])); - - basicTask->send(argv[taskCount % aliasCount]); - - taskCount++; - } - - - info("I'm done. See you!"); - - delete this; - - return 0; -} \ No newline at end of file +#include "Forwarder.hpp" +#include "BasicTask.hpp" +#include "FinalizeTask.hpp" + +#include +#include + +#include + +MSG_IMPLEMENT_DYNAMIC(Forwarder, Process) + +int Forwarder::main(int argc, char** argv) +{ + info("Hello"); + + int aliasCount = argc; + + int taskCount = 0; + + Task* taskReceived; + Task* finalizeTask; + BasicTask* basicTask; + + while(true) + { + taskReceived = Task::receive(); + + if(taskReceived->isInstanceOf("FinalizeTask")) + { + info("All tasks have been dispatched. Let's tell everybody the computation is over."); + + for (int i = 0; i < aliasCount; i++) + { + finalizeTask = new FinalizeTask(); + finalizeTask->send(argv[i]); + } + + delete taskReceived; + + break; + } + + basicTask = reinterpret_cast(taskReceived); + + info(TEXT_("Received \"") + TEXT_(basicTask->getName()) + TEXT_("\" ")); + + info(TEXT_("Sending \"") + TEXT_(basicTask->getName()) + TEXT_("\" to \"") + TEXT_(argv[taskCount % aliasCount])); + + basicTask->send(argv[taskCount % aliasCount]); + + taskCount++; + } + + + info("I'm done. See you!"); + + delete this; + + return 0; +} diff --git a/examples/cxx/autoDestination/Forwarder.hpp b/examples/cxx/autoDestination/Forwarder.hpp index 31af15ce3a..767334bfe1 100644 --- a/examples/cxx/autoDestination/Forwarder.hpp +++ b/examples/cxx/autoDestination/Forwarder.hpp @@ -1,24 +1,24 @@ -#ifndef FORWARDER_HPP -#define FORWARDER_HPP - -#include -using namespace SimGrid::Msg; - -class Forwarder : public Process -{ - MSG_DECLARE_DYNAMIC(Forwarder); - - public: - - // Default constructor. - Forwarder(){} - - // Destructor. - virtual ~Forwarder(){} - - int main(int argc, char** argv); - -}; - - -#endif // !FORWARDER_HPP \ No newline at end of file +#ifndef FORWARDER_HPP +#define FORWARDER_HPP + +#include +using namespace SimGrid::Msg; + +class Forwarder : public Process +{ + MSG_DECLARE_DYNAMIC(Forwarder); + + public: + + // Default constructor. + Forwarder(){} + + // Destructor. + virtual ~Forwarder(){} + + int main(int argc, char** argv); + +}; + + +#endif // !FORWARDER_HPP diff --git a/examples/cxx/autoDestination/Main.cxx b/examples/cxx/autoDestination/Main.cxx index dbda264803..696bdc2dfd 100644 --- a/examples/cxx/autoDestination/Main.cxx +++ b/examples/cxx/autoDestination/Main.cxx @@ -1,12 +1,12 @@ -#include - -using namespace SimGrid::Msg; - -int -main(int argc, char* argv[]) -{ - Simulation s; - - return s.execute(argc, argv); - -} +#include + +using namespace SimGrid::Msg; + +int +main(int argc, char* argv[]) +{ + Simulation s; + + return s.execute(argc, argv); + +} diff --git a/examples/cxx/autoDestination/Master.cxx b/examples/cxx/autoDestination/Master.cxx index c36657fc95..323d2d18ff 100644 --- a/examples/cxx/autoDestination/Master.cxx +++ b/examples/cxx/autoDestination/Master.cxx @@ -1,80 +1,80 @@ -#include "Master.hpp" -#include "BasicTask.hpp" -#include "FinalizeTask.hpp" - -#include -#include - -#include - -MSG_IMPLEMENT_DYNAMIC(Master, Process); - -int Master::main(int argc, char** argv) -{ - int taskCount; - double taskComputeSize; - double taskCommunicateSize; - - info("Hello"); - - info(TEXT_("argc=") + TEXT_(argc)); - - for (int i = 0; i< argc; i++) - info(TEXT_("argv:") + TEXT_(argv[i])); - - sscanf(argv[0],"%d", &taskCount); - sscanf(argv[1],"%lg", &taskComputeSize); - sscanf(argv[2],"%lg", &taskCommunicateSize); - - BasicTaskPtr* basicTasks = new BasicTaskPtr[taskCount]; - - for (int i = 0; i < taskCount; i++) - basicTasks[i] = new BasicTask((TEXT_("Task_") + TEXT_(i)), taskComputeSize, taskCommunicateSize); - - int aliasCount = argc - 3; - - char** aliases = (char**) calloc(aliasCount, sizeof(char*)); - - for(int i = 3; i < argc ; i++) - aliases[i - 3] = _strdup(argv[i]); - - info(TEXT_("Got ") + TEXT_(aliasCount) + TEXT_(" alias(es) :")); - - for (int i = 0; i < aliasCount; i++) - info(TEXT_("\t") + TEXT_(aliases[i])); - - info(TEXT_("Got ") + TEXT_(taskCount) + TEXT_(" task to process.")); - - for (int i = 0; i < taskCount; i++) - { - info(TEXT_("Sending \"") + TEXT_(basicTasks[i]->getName()) + TEXT_("\" to \"") + TEXT_(aliases[i % aliasCount]) + TEXT_("\"")); - - /*if((Host::currentHost().getName()).equals((aliases[i % aliasCount].split(":"))[0])) - info("Hey ! It's me ! "); - */ - - basicTasks[i]->send(aliases[i % aliasCount]); - } - - info("Send completed"); - - info("All tasks have been dispatched. Let's tell everybody the computation is over."); - - FinalizeTask* finalizeTask; - - for (int i = 0; i < aliasCount; i++) - { - finalizeTask = new FinalizeTask(); - finalizeTask->send(aliases[i]); - - } - - info("Goodbye now!"); - - delete[] basicTasks; - delete[] aliases; - - delete this; - - return 0; -} \ No newline at end of file +#include "Master.hpp" +#include "BasicTask.hpp" +#include "FinalizeTask.hpp" + +#include +#include + +#include + +MSG_IMPLEMENT_DYNAMIC(Master, Process) + +int Master::main(int argc, char** argv) +{ + int taskCount; + double taskComputeSize; + double taskCommunicateSize; + + info("Hello"); + + info(TEXT_("argc=") + TEXT_(argc)); + + for (int i = 0; i< argc; i++) + info(TEXT_("argv:") + TEXT_(argv[i])); + + sscanf(argv[0],"%d", &taskCount); + sscanf(argv[1],"%lg", &taskComputeSize); + sscanf(argv[2],"%lg", &taskCommunicateSize); + + BasicTaskPtr* basicTasks = new BasicTaskPtr[taskCount]; + + for (int i = 0; i < taskCount; i++) + basicTasks[i] = new BasicTask((TEXT_("Task_") + TEXT_(i)), taskComputeSize, taskCommunicateSize); + + int aliasCount = argc - 3; + + char** aliases = (char**) calloc(aliasCount, sizeof(char*)); + + for(int i = 3; i < argc ; i++) + aliases[i - 3] = _strdup(argv[i]); + + info(TEXT_("Got ") + TEXT_(aliasCount) + TEXT_(" alias(es) :")); + + for (int i = 0; i < aliasCount; i++) + info(TEXT_("\t") + TEXT_(aliases[i])); + + info(TEXT_("Got ") + TEXT_(taskCount) + TEXT_(" task to process.")); + + for (int i = 0; i < taskCount; i++) + { + info(TEXT_("Sending \"") + TEXT_(basicTasks[i]->getName()) + TEXT_("\" to \"") + TEXT_(aliases[i % aliasCount]) + TEXT_("\"")); + + /*if((Host::currentHost().getName()).equals((aliases[i % aliasCount].split(":"))[0])) + info("Hey ! It's me ! "); + */ + + basicTasks[i]->send(aliases[i % aliasCount]); + } + + info("Send completed"); + + info("All tasks have been dispatched. Let's tell everybody the computation is over."); + + FinalizeTask* finalizeTask; + + for (int i = 0; i < aliasCount; i++) + { + finalizeTask = new FinalizeTask(); + finalizeTask->send(aliases[i]); + + } + + info("Goodbye now!"); + + delete[] basicTasks; + delete[] aliases; + + delete this; + + return 0; +} diff --git a/examples/cxx/autoDestination/Master.hpp b/examples/cxx/autoDestination/Master.hpp index dc08c6d27c..40bb39089a 100644 --- a/examples/cxx/autoDestination/Master.hpp +++ b/examples/cxx/autoDestination/Master.hpp @@ -1,23 +1,23 @@ -#ifndef MASTER_HPP -#define MASTER_HPP - -#include -using namespace SimGrid::Msg; - -class Master : public Process -{ - MSG_DECLARE_DYNAMIC(Master); - - public: - - // Default constructor. - Master(){} - - // Destructor. - virtual ~Master(){} - - int main(int argc, char** argv); - -}; - -#endif // !MASTER_HPP \ No newline at end of file +#ifndef MASTER_HPP +#define MASTER_HPP + +#include +using namespace SimGrid::Msg; + +class Master : public Process +{ + MSG_DECLARE_DYNAMIC(Master); + + public: + + // Default constructor. + Master(){} + + // Destructor. + virtual ~Master(){} + + int main(int argc, char** argv); + +}; + +#endif // !MASTER_HPP diff --git a/examples/cxx/autoDestination/Slave.cxx b/examples/cxx/autoDestination/Slave.cxx index 31316d5bd6..74a74246a1 100644 --- a/examples/cxx/autoDestination/Slave.cxx +++ b/examples/cxx/autoDestination/Slave.cxx @@ -1,47 +1,47 @@ -#include "Slave.hpp" -#include "FinalizeTask.hpp" -#include "BasicTask.hpp" - -#include -#include - -#include - -MSG_IMPLEMENT_DYNAMIC(Slave, Process); - -int Slave::main(int argc, char** argv) -{ - info("Hello"); - - Task* receivedTask; - BasicTask* basicTask; - - while(true) - { - receivedTask = Task::receive(); - - if(receivedTask->isInstanceOf("FinalizeTask")) - { - delete receivedTask; - break; - } - - basicTask = reinterpret_cast(receivedTask); - - info(TEXT_("Received \"") + TEXT_(basicTask->getName()) + TEXT_("\" ")); - - info(TEXT_("Processing \"") + TEXT_(basicTask->getName()) + TEXT_("\" ")); - - basicTask->execute(); - - info(TEXT_("\"") + TEXT_(basicTask->getName()) + TEXT_("\" done ")); - - delete basicTask; - } - - info("Received Finalize. I'm done. See you!"); - - delete this; - - return 0; -} \ No newline at end of file +#include "Slave.hpp" +#include "FinalizeTask.hpp" +#include "BasicTask.hpp" + +#include +#include + +#include + +MSG_IMPLEMENT_DYNAMIC(Slave, Process) + +int Slave::main(int argc, char** argv) +{ + info("Hello"); + + Task* receivedTask; + BasicTask* basicTask; + + while(true) + { + receivedTask = Task::receive(); + + if(receivedTask->isInstanceOf("FinalizeTask")) + { + delete receivedTask; + break; + } + + basicTask = reinterpret_cast(receivedTask); + + info(TEXT_("Received \"") + TEXT_(basicTask->getName()) + TEXT_("\" ")); + + info(TEXT_("Processing \"") + TEXT_(basicTask->getName()) + TEXT_("\" ")); + + basicTask->execute(); + + info(TEXT_("\"") + TEXT_(basicTask->getName()) + TEXT_("\" done ")); + + delete basicTask; + } + + info("Received Finalize. I'm done. See you!"); + + delete this; + + return 0; +} diff --git a/examples/cxx/autoDestination/Slave.hpp b/examples/cxx/autoDestination/Slave.hpp index 3e73dfe70a..21c77a156e 100644 --- a/examples/cxx/autoDestination/Slave.hpp +++ b/examples/cxx/autoDestination/Slave.hpp @@ -1,24 +1,25 @@ -#ifndef SLAVE_HPP -#define SLAVE_HPP - -#include -using namespace SimGrid::Msg; - -class Slave : public Process -{ - MSG_DECLARE_DYNAMIC(Slave); - - public: - - // Default constructor. - Slave(){} - - // Destructor. - virtual ~Slave(){} - - int main(int argc, char** argv); - -}; - - -#endif // !SLAVE_HPP \ No newline at end of file +#ifndef SLAVE_HPP +#define SLAVE_HPP + +#include +using namespace SimGrid::Msg; + +class Slave : public Process +{ + MSG_DECLARE_DYNAMIC(Slave); + + public: + + // Default constructor. + Slave(){} + + // Destructor. + virtual ~Slave(){} + + int main(int argc, char** argv); + +}; + + +#endif // !SLAVE_HPP + diff --git a/examples/cxx/basic/BasicTask.cxx b/examples/cxx/basic/BasicTask.cxx index 21924e8d4f..19cd54a77b 100644 --- a/examples/cxx/basic/BasicTask.cxx +++ b/examples/cxx/basic/BasicTask.cxx @@ -1,3 +1,3 @@ -#include "BasicTask.hpp" - -MSG_IMPLEMENT_DYNAMIC(BasicTask, Task); \ No newline at end of file +#include "BasicTask.hpp" + +MSG_IMPLEMENT_DYNAMIC(BasicTask, Task) diff --git a/examples/cxx/basic/BasicTask.hpp b/examples/cxx/basic/BasicTask.hpp index ca3c477026..5dd3eabc7b 100644 --- a/examples/cxx/basic/BasicTask.hpp +++ b/examples/cxx/basic/BasicTask.hpp @@ -1,25 +1,26 @@ -#ifndef BASIC_TASK_HPP -#define BASIC_TASK_HPP - -#include -using namespace SimGrid::Msg; - -class BasicTask : public Task -{ - MSG_DECLARE_DYNAMIC(BasicTask); -public: - - // Default constructor. - BasicTask() {} - - // Destructor - virtual ~BasicTask() {} - BasicTask(const char* name, double computeDuration, double messageSize) - throw (InvalidArgumentException, NullPointerException) - :Task(name, computeDuration, messageSize){} -}; - -typedef BasicTask* BasicTaskPtr; - - -#endif // !BASIC_TASK_HPP \ No newline at end of file +#ifndef BASIC_TASK_HPP +#define BASIC_TASK_HPP + +#include +using namespace SimGrid::Msg; + +class BasicTask : public Task +{ + MSG_DECLARE_DYNAMIC(BasicTask); +public: + + // Default constructor. + BasicTask() {} + + // Destructor + virtual ~BasicTask() + throw(MsgException) {} + BasicTask(const char* name, double computeDuration, double messageSize) + throw (InvalidArgumentException, NullPointerException) + :Task(name, computeDuration, messageSize){} +}; + +typedef BasicTask* BasicTaskPtr; + + +#endif // !BASIC_TASK_HPP diff --git a/examples/cxx/basic/FinalizeTask.cxx b/examples/cxx/basic/FinalizeTask.cxx index a9cde570c1..0805537c9f 100644 --- a/examples/cxx/basic/FinalizeTask.cxx +++ b/examples/cxx/basic/FinalizeTask.cxx @@ -1,3 +1,3 @@ -#include "FinalizeTask.hpp" - -MSG_IMPLEMENT_DYNAMIC(FinalizeTask, Task); \ No newline at end of file +#include "FinalizeTask.hpp" + +MSG_IMPLEMENT_DYNAMIC(FinalizeTask, Task) diff --git a/examples/cxx/basic/FinalizeTask.hpp b/examples/cxx/basic/FinalizeTask.hpp index 6d95a14682..09baf42815 100644 --- a/examples/cxx/basic/FinalizeTask.hpp +++ b/examples/cxx/basic/FinalizeTask.hpp @@ -1,25 +1,26 @@ -#ifndef FINALIZE_TASK_HPP -#define FINALIZE_TASK_HPP - -#include -using namespace SimGrid::Msg; - -class FinalizeTask : public Task -{ - MSG_DECLARE_DYNAMIC(FinalizeTask); -public: - - // Default constructor. - FinalizeTask() - throw (InvalidArgumentException, NullPointerException) - :Task("finalize", 0.0, 0.0){} - - // Destructor - virtual ~FinalizeTask() {} - -}; - - - - -#endif // !FINALIZE_TASK_HPP \ No newline at end of file +#ifndef FINALIZE_TASK_HPP +#define FINALIZE_TASK_HPP + +#include +using namespace SimGrid::Msg; + +class FinalizeTask : public Task +{ + MSG_DECLARE_DYNAMIC(FinalizeTask); +public: + + // Default constructor. + FinalizeTask() + throw (InvalidArgumentException, NullPointerException) + :Task("finalize", 0.0, 0.0){} + + // Destructor + virtual ~FinalizeTask() + throw(MsgException) {} + +}; + + + + +#endif // !FINALIZE_TASK_HPP diff --git a/examples/cxx/basic/Forwarder.cxx b/examples/cxx/basic/Forwarder.cxx index 8767ff7c46..911ff4a83a 100644 --- a/examples/cxx/basic/Forwarder.cxx +++ b/examples/cxx/basic/Forwarder.cxx @@ -1,69 +1,69 @@ -#include "Forwarder.hpp" -#include "BasicTask.hpp" -#include "FinalizeTask.hpp" -#include -#include - -#include - -MSG_IMPLEMENT_DYNAMIC(Forwarder, Process); - - -int Forwarder::main(int argc, char** argv) -{ - info("Hello"); - - int slavesCount = argc; - - Host* slaves = new Host[slavesCount]; - - for (int i = 0; i < argc; i++) - { - try - { - slaves[i] = Host::getByName(argv[i]); - } - catch (HostNotFoundException e) - { - error(TEXT_(e.toString())); - error("Buggy deployment file"); - exit(1); - } - } - - int taskCount = 0; - - while(true) - { - Task* t = Task::get(0); - - if(t->isInstanceOf("FinalizeTask")) - { - info("All tasks have been dispatched. Let's tell everybody the computation is over."); - - for (int cpt = 0; cpt< slavesCount; cpt++) - slaves[cpt].put(0, new FinalizeTask()); - - delete t; - - break; - } - - info(TEXT_("Received \"") + TEXT_(t->getName()) + TEXT_("\" ")); - - info(TEXT_("Sending \"") + TEXT_(t->getName()) + TEXT_("\" to \"") + TEXT_(slaves[taskCount % slavesCount].getName()) + TEXT_("\"")); - - slaves[taskCount % slavesCount].put(0, t); - - taskCount++; - } - - - info("I'm done. See you!"); - - delete[] slaves; - - delete this; - - return 0; -} \ No newline at end of file +#include "Forwarder.hpp" +#include "BasicTask.hpp" +#include "FinalizeTask.hpp" +#include +#include + +#include + +MSG_IMPLEMENT_DYNAMIC(Forwarder, Process) + + +int Forwarder::main(int argc, char** argv) +{ + info("Hello"); + + int slavesCount = argc; + + Host* slaves = new Host[slavesCount]; + + for (int i = 0; i < argc; i++) + { + try + { + slaves[i] = Host::getByName(argv[i]); + } + catch (HostNotFoundException e) + { + error(TEXT_(e.toString())); + error("Buggy deployment file"); + exit(1); + } + } + + int taskCount = 0; + + while(true) + { + Task* t = Task::get(0); + + if(t->isInstanceOf("FinalizeTask")) + { + info("All tasks have been dispatched. Let's tell everybody the computation is over."); + + for (int cpt = 0; cpt< slavesCount; cpt++) + slaves[cpt].put(0, new FinalizeTask()); + + delete t; + + break; + } + + info(TEXT_("Received \"") + TEXT_(t->getName()) + TEXT_("\" ")); + + info(TEXT_("Sending \"") + TEXT_(t->getName()) + TEXT_("\" to \"") + TEXT_(slaves[taskCount % slavesCount].getName()) + TEXT_("\"")); + + slaves[taskCount % slavesCount].put(0, t); + + taskCount++; + } + + + info("I'm done. See you!"); + + delete[] slaves; + + delete this; + + return 0; +} diff --git a/examples/cxx/basic/Forwarder.hpp b/examples/cxx/basic/Forwarder.hpp index 31af15ce3a..767334bfe1 100644 --- a/examples/cxx/basic/Forwarder.hpp +++ b/examples/cxx/basic/Forwarder.hpp @@ -1,24 +1,24 @@ -#ifndef FORWARDER_HPP -#define FORWARDER_HPP - -#include -using namespace SimGrid::Msg; - -class Forwarder : public Process -{ - MSG_DECLARE_DYNAMIC(Forwarder); - - public: - - // Default constructor. - Forwarder(){} - - // Destructor. - virtual ~Forwarder(){} - - int main(int argc, char** argv); - -}; - - -#endif // !FORWARDER_HPP \ No newline at end of file +#ifndef FORWARDER_HPP +#define FORWARDER_HPP + +#include +using namespace SimGrid::Msg; + +class Forwarder : public Process +{ + MSG_DECLARE_DYNAMIC(Forwarder); + + public: + + // Default constructor. + Forwarder(){} + + // Destructor. + virtual ~Forwarder(){} + + int main(int argc, char** argv); + +}; + + +#endif // !FORWARDER_HPP diff --git a/examples/cxx/basic/Main.cxx b/examples/cxx/basic/Main.cxx index 9f399a8be3..7de92928dd 100644 --- a/examples/cxx/basic/Main.cxx +++ b/examples/cxx/basic/Main.cxx @@ -1,12 +1,13 @@ -#include - -using namespace SimGrid::Msg; - -int -main(int argc, char* argv[]) -{ - Simulation s; - - return s.execute(argc, argv); - -} +#include + +using namespace SimGrid::Msg; + +int +main(int argc, char* argv[]) +{ + Simulation s; + + return s.execute(argc, argv); + +} + diff --git a/examples/cxx/basic/Master.cxx b/examples/cxx/basic/Master.cxx index f49f4b99af..51b5eb1255 100644 --- a/examples/cxx/basic/Master.cxx +++ b/examples/cxx/basic/Master.cxx @@ -1,105 +1,106 @@ -#include "Master.hpp" -#include "BasicTask.hpp" -#include "FinalizeTask.hpp" -#include -#include - -#include - -#include -using namespace std; - - -#ifndef BUFFMAX -#define BUFFMAX 260 -#endif - -MSG_IMPLEMENT_DYNAMIC(Master, Process); - -int Master::main(int argc, char** argv) -{ - int channel = 0; - char buff[BUFFMAX + 1] = {0}; - int numberOfTasks; - double taskComputeSize; - double taskCommunicateSize; - StringHelper s; - - if (argc < 3) - { - error("Master needs 3 arguments"); - exit(1); - } - - info("Hello"); - - int slaveCount = 0; - Host* slaves = NULL; - - - info( TEXT_("argc=") + TEXT_(argc)); - - for (int i = 0; i< argc; i++) - info(TEXT_("argv:") + TEXT_(argv[i])); - - sscanf(argv[0],"%d", &numberOfTasks); - - sscanf(argv[1],"%lg", &taskComputeSize); - - sscanf(argv[2],"%lg", &taskCommunicateSize); - - BasicTaskPtr* todo = new BasicTaskPtr[numberOfTasks]; - - for (int i = 0; i < numberOfTasks; i++) - todo[i] = new BasicTask((TEXT_("Task_") + TEXT_(i)), taskComputeSize, taskCommunicateSize); - - slaveCount = argc - 3; - slaves = new Host[slaveCount]; - - for(int i = 3; i < argc ; i++) - { - try - { - slaves[i-3] = Host::getByName(argv[i]); - } - - catch(HostNotFoundException e) - { - cerr << e.toString() <<". Stopping Now!" << endl; - exit(1); - } - } - - info(TEXT_("Got slave(s) :") + TEXT_(slaveCount)); - - for (int i = 0; i < slaveCount; i++) - info(TEXT_("\t") + TEXT_(slaves[i].getName())); - - info(TEXT_("Got ") + TEXT_(numberOfTasks) + TEXT_(" task to process.")); - - for (int i = 0; i < numberOfTasks; i++) - { - info(TEXT_("Sending \"") + TEXT_(todo[i]->getName()) + TEXT_("\" to \"") + TEXT_(slaves[i % slaveCount].getName()) + TEXT_("\"")); - - if(!strcmp(Host::currentHost().getName(), slaves[i % slaveCount].getName())) - info("Hey ! It's me ! "); - - slaves[i % slaveCount].put(channel, todo[i]); - } - - info("Send completed"); - - info("All tasks have been dispatched. Let's tell everybody the computation is over."); - - for (int i = 0; i < slaveCount; i++) - slaves[i].put(channel, new FinalizeTask()); - - delete[] todo; - delete[] slaves; - - info("Goodbye now!"); - - delete this; - - return 0; -} \ No newline at end of file +#include "Master.hpp" +#include "BasicTask.hpp" +#include "FinalizeTask.hpp" +#include +#include + +#include + +#include +using namespace std; + + +#ifndef BUFFMAX +#define BUFFMAX 260 +#endif + +MSG_IMPLEMENT_DYNAMIC(Master, Process) + +int Master::main(int argc, char** argv) +{ + int channel = 0; + + int numberOfTasks; + double taskComputeSize; + double taskCommunicateSize; + StringHelper s; + + if (argc < 3) + { + error("Master needs 3 arguments"); + exit(1); + } + + info("Hello"); + + int slaveCount = 0; + Host* slaves = NULL; + + + info( TEXT_("argc=") + TEXT_(argc)); + + for (int i = 0; i< argc; i++) + info(TEXT_("argv:") + TEXT_(argv[i])); + + sscanf(argv[0],"%d", &numberOfTasks); + + sscanf(argv[1],"%lg", &taskComputeSize); + + sscanf(argv[2],"%lg", &taskCommunicateSize); + + BasicTaskPtr* todo = new BasicTaskPtr[numberOfTasks]; + + for (int i = 0; i < numberOfTasks; i++) + todo[i] = new BasicTask((TEXT_("Task_") + TEXT_(i)), taskComputeSize, taskCommunicateSize); + + slaveCount = argc - 3; + slaves = new Host[slaveCount]; + + for(int i = 3; i < argc ; i++) + { + try + { + slaves[i-3] = Host::getByName(argv[i]); + } + + catch(HostNotFoundException e) + { + cerr << e.toString() <<". Stopping Now!" << endl; + exit(1); + } + } + + info(TEXT_("Got slave(s) :") + TEXT_(slaveCount)); + + for (int i = 0; i < slaveCount; i++) + info(TEXT_("\t") + TEXT_(slaves[i].getName())); + + info(TEXT_("Got ") + TEXT_(numberOfTasks) + TEXT_(" task to process.")); + + for (int i = 0; i < numberOfTasks; i++) + { + info(TEXT_("Sending \"") + TEXT_(todo[i]->getName()) + TEXT_("\" to \"") + TEXT_(slaves[i % slaveCount].getName()) + TEXT_("\"")); + + if(!strcmp(Host::currentHost().getName(), slaves[i % slaveCount].getName())) + info("Hey ! It's me ! "); + + slaves[i % slaveCount].put(channel, todo[i]); + } + + info("Send completed"); + + info("All tasks have been dispatched. Let's tell everybody the computation is over."); + + for (int i = 0; i < slaveCount; i++) + slaves[i].put(channel, new FinalizeTask()); + + delete[] todo; + delete[] slaves; + + info("Goodbye now!"); + + delete this; + + return 0; +} + diff --git a/examples/cxx/basic/Master.hpp b/examples/cxx/basic/Master.hpp index dc08c6d27c..40bb39089a 100644 --- a/examples/cxx/basic/Master.hpp +++ b/examples/cxx/basic/Master.hpp @@ -1,23 +1,23 @@ -#ifndef MASTER_HPP -#define MASTER_HPP - -#include -using namespace SimGrid::Msg; - -class Master : public Process -{ - MSG_DECLARE_DYNAMIC(Master); - - public: - - // Default constructor. - Master(){} - - // Destructor. - virtual ~Master(){} - - int main(int argc, char** argv); - -}; - -#endif // !MASTER_HPP \ No newline at end of file +#ifndef MASTER_HPP +#define MASTER_HPP + +#include +using namespace SimGrid::Msg; + +class Master : public Process +{ + MSG_DECLARE_DYNAMIC(Master); + + public: + + // Default constructor. + Master(){} + + // Destructor. + virtual ~Master(){} + + int main(int argc, char** argv); + +}; + +#endif // !MASTER_HPP diff --git a/examples/cxx/basic/Slave.cxx b/examples/cxx/basic/Slave.cxx index b1a914eec1..3b9c5ea339 100644 --- a/examples/cxx/basic/Slave.cxx +++ b/examples/cxx/basic/Slave.cxx @@ -1,43 +1,43 @@ -#include "Slave.hpp" -#include "FinalizeTask.hpp" -#include -#include - -#include -using namespace std; - -#include - -MSG_IMPLEMENT_DYNAMIC(Slave, Process); - -int Slave::main(int argc, char** argv) -{ - info("Hello");; - - while(true) - { - Task* t = Task::get(0); - - if(t->isInstanceOf("FinalizeTask")) - { - delete t; - break; - } - - info(TEXT_("Received \"") + TEXT_(t->getName()) + TEXT_("\" ")); - - info(TEXT_("Processing \"") + TEXT_(t->getName())); - - t->execute(); - - info(TEXT_("\"") + TEXT_(t->getName()) + TEXT_("\" done ")); - - delete t; - } - - info("Received Finalize. I'm done. See you!"); - - delete this; - - return 0; -} \ No newline at end of file +#include "Slave.hpp" +#include "FinalizeTask.hpp" +#include +#include + +#include +using namespace std; + +#include + +MSG_IMPLEMENT_DYNAMIC(Slave, Process) + +int Slave::main(int argc, char** argv) +{ + info("Hello");; + + while(true) + { + Task* t = Task::get(0); + + if(t->isInstanceOf("FinalizeTask")) + { + delete t; + break; + } + + info(TEXT_("Received \"") + TEXT_(t->getName()) + TEXT_("\" ")); + + info(TEXT_("Processing \"") + TEXT_(t->getName())); + + t->execute(); + + info(TEXT_("\"") + TEXT_(t->getName()) + TEXT_("\" done ")); + + delete t; + } + + info("Received Finalize. I'm done. See you!"); + + delete this; + + return 0; +} diff --git a/examples/cxx/basic/Slave.hpp b/examples/cxx/basic/Slave.hpp index 3e73dfe70a..391e08d9b2 100644 --- a/examples/cxx/basic/Slave.hpp +++ b/examples/cxx/basic/Slave.hpp @@ -1,24 +1,24 @@ -#ifndef SLAVE_HPP -#define SLAVE_HPP - -#include -using namespace SimGrid::Msg; - -class Slave : public Process -{ - MSG_DECLARE_DYNAMIC(Slave); - - public: - - // Default constructor. - Slave(){} - - // Destructor. - virtual ~Slave(){} - - int main(int argc, char** argv); - -}; - - -#endif // !SLAVE_HPP \ No newline at end of file +#ifndef SLAVE_HPP +#define SLAVE_HPP + +#include +using namespace SimGrid::Msg; + +class Slave : public Process +{ + MSG_DECLARE_DYNAMIC(Slave); + + public: + + // Default constructor. + Slave(){} + + // Destructor. + virtual ~Slave(){} + + int main(int argc, char** argv); + +}; + + +#endif // !SLAVE_HPP diff --git a/examples/cxx/comm_time/CommTimeTask.cxx b/examples/cxx/comm_time/CommTimeTask.cxx index 9eddef723a..889d4158d0 100644 --- a/examples/cxx/comm_time/CommTimeTask.cxx +++ b/examples/cxx/comm_time/CommTimeTask.cxx @@ -1,3 +1,3 @@ -#include "CommTimeTask.hpp" - -MSG_IMPLEMENT_DYNAMIC(CommTimeTask, Task); \ No newline at end of file +#include "CommTimeTask.hpp" + +MSG_IMPLEMENT_DYNAMIC(CommTimeTask, Task) diff --git a/examples/cxx/comm_time/CommTimeTask.hpp b/examples/cxx/comm_time/CommTimeTask.hpp index 67ef2a868a..12769d2375 100644 --- a/examples/cxx/comm_time/CommTimeTask.hpp +++ b/examples/cxx/comm_time/CommTimeTask.hpp @@ -1,42 +1,40 @@ -#ifndef COMMTIME_TASK_HPP -#define COMMTIME_TASK_HPP - -#include -using namespace SimGrid::Msg; - -class CommTimeTask : public Task -{ - MSG_DECLARE_DYNAMIC(CommTimeTask); - -public: - - CommTimeTask() - :Task(NULL, 0.0, 0.0){} - - // Default constructor. - CommTimeTask(const char* name, double computeDuration, double messageSize) - throw (InvalidArgumentException, NullPointerException) - :Task(name, computeDuration, messageSize){} - - // Destructor - virtual ~CommTimeTask() {} - - void setTime(double timeVal) - { - this->timeVal = timeVal; - } - - double getTime() - { - return timeVal; - } - -private : - - double timeVal; -}; - - - - -#endif // !COMMTIME_TASK_HPP \ No newline at end of file +#ifndef COMMTIME_TASK_HPP +#define COMMTIME_TASK_HPP + +#include +using namespace SimGrid::Msg; + +class CommTimeTask : public Task +{ + MSG_DECLARE_DYNAMIC(CommTimeTask); + +public: + + CommTimeTask() + :Task(NULL, 0.0, 0.0){} + + // Default constructor. + CommTimeTask(const char* name, double computeDuration, double messageSize) + throw (InvalidArgumentException, NullPointerException) + :Task(name, computeDuration, messageSize){} + + // Destructor + virtual ~CommTimeTask() + throw(MsgException){} + + void setTime(double timeVal) + { + this->timeVal = timeVal; + } + + double getTime() + { + return timeVal; + } + +private : + + double timeVal; +}; + +#endif // !COMMTIME_TASK_HPP diff --git a/examples/cxx/comm_time/FinalizeTask.cxx b/examples/cxx/comm_time/FinalizeTask.cxx index a9cde570c1..0805537c9f 100644 --- a/examples/cxx/comm_time/FinalizeTask.cxx +++ b/examples/cxx/comm_time/FinalizeTask.cxx @@ -1,3 +1,3 @@ -#include "FinalizeTask.hpp" - -MSG_IMPLEMENT_DYNAMIC(FinalizeTask, Task); \ No newline at end of file +#include "FinalizeTask.hpp" + +MSG_IMPLEMENT_DYNAMIC(FinalizeTask, Task) diff --git a/examples/cxx/comm_time/FinalizeTask.hpp b/examples/cxx/comm_time/FinalizeTask.hpp index 6d95a14682..2e29015880 100644 --- a/examples/cxx/comm_time/FinalizeTask.hpp +++ b/examples/cxx/comm_time/FinalizeTask.hpp @@ -1,25 +1,24 @@ -#ifndef FINALIZE_TASK_HPP -#define FINALIZE_TASK_HPP - -#include -using namespace SimGrid::Msg; - -class FinalizeTask : public Task -{ - MSG_DECLARE_DYNAMIC(FinalizeTask); -public: - - // Default constructor. - FinalizeTask() - throw (InvalidArgumentException, NullPointerException) - :Task("finalize", 0.0, 0.0){} - - // Destructor - virtual ~FinalizeTask() {} - -}; - - - - -#endif // !FINALIZE_TASK_HPP \ No newline at end of file +#ifndef FINALIZE_TASK_HPP +#define FINALIZE_TASK_HPP + +#include +using namespace SimGrid::Msg; + +class FinalizeTask : public Task +{ + MSG_DECLARE_DYNAMIC(FinalizeTask); +public: + + // Default constructor. + FinalizeTask() + throw (InvalidArgumentException, NullPointerException) + :Task("finalize", 0.0, 0.0){} + + // Destructor + virtual ~FinalizeTask() + throw(MsgException){} + +}; + +#endif // !FINALIZE_TASK_HPP + diff --git a/examples/cxx/comm_time/Main.cxx b/examples/cxx/comm_time/Main.cxx index 0b9a7f1973..b286b71548 100644 --- a/examples/cxx/comm_time/Main.cxx +++ b/examples/cxx/comm_time/Main.cxx @@ -1,11 +1,11 @@ -#include - -using namespace SimGrid::Msg; - -int -main(int argc, char* argv[]) -{ - Simulation s; - - return s.execute(argc, argv); -} +#include + +using namespace SimGrid::Msg; + +int +main(int argc, char* argv[]) +{ + Simulation s; + + return s.execute(argc, argv); +} diff --git a/examples/cxx/comm_time/Master.cxx b/examples/cxx/comm_time/Master.cxx index 662c3d2236..3b510d13af 100644 --- a/examples/cxx/comm_time/Master.cxx +++ b/examples/cxx/comm_time/Master.cxx @@ -1,84 +1,83 @@ -#include "Master.hpp" -#include "CommTimeTask.hpp" -#include "FinalizeTask.hpp" -#include -#include -#include - -#include - -MSG_IMPLEMENT_DYNAMIC(Master, Process); - -int Master::main(int argc, char** argv) -{ - int channel = 0; - int numberOfTasks; - double taskComputeSize; - double taskCommunicateSize; - - if (argc < 3) - { - error("Master needs 3 arguments"); - exit(1); - } - - info("Hello"); - - int slaveCount = 0; - Host* slaves = NULL; - - sscanf(argv[0],"%d", &numberOfTasks); - - sscanf(argv[1],"%lg", &taskComputeSize); - - sscanf(argv[2],"%lg", &taskCommunicateSize); - - - slaveCount = argc - 3; - slaves = new Host[slaveCount]; - - for(int i = 3; i < argc ; i++) - { - try - { - slaves[i-3] = Host::getByName(argv[i]); - } - - catch(HostNotFoundException e) - { - error(TEXT_(e.toString()) + TEXT_(". Stopping Now!")); - exit(1); - } - } - - info(TEXT_("Got slave(s) :" ) + TEXT_(slaveCount)); - - for (int i = 0; i < slaveCount; i++) - info(TEXT_("\t") + TEXT_(slaves[i].getName())); - - info(TEXT_("Got ") + TEXT_(numberOfTasks) + TEXT_(" task to process.")); - - - for (int i = 0; i < numberOfTasks; i++) - { - CommTimeTask* task = new CommTimeTask(TEXT_("Task_") + TEXT_(i), taskComputeSize, taskCommunicateSize); - task->setTime(getClock()); - slaves[i % slaveCount].put(0, task); - - } - - info("All tasks have been dispatched. Let's tell everybody the computation is over."); - - for (int i = 0; i < slaveCount; i++) - { - info(TEXT_("Finalize host ") + TEXT_(slaves[i].getName()) + TEXT_(" [") + TEXT_(i) + TEXT_("]")); - slaves[i].put(0, new FinalizeTask()); - } - - info("All finalize messages have been dispatched. Goodbye now!"); - - - delete[] slaves; - delete this; - return 0; -} \ No newline at end of file +#include "Master.hpp" +#include "CommTimeTask.hpp" +#include "FinalizeTask.hpp" +#include +#include +#include + +#include + +MSG_IMPLEMENT_DYNAMIC(Master, Process) + +int Master::main(int argc, char** argv) +{ + int numberOfTasks; + double taskComputeSize; + double taskCommunicateSize; + + if (argc < 3) + { + error("Master needs 3 arguments"); + exit(1); + } + + info("Hello"); + + int slaveCount = 0; + Host* slaves = NULL; + + sscanf(argv[0],"%d", &numberOfTasks); + + sscanf(argv[1],"%lg", &taskComputeSize); + + sscanf(argv[2],"%lg", &taskCommunicateSize); + + + slaveCount = argc - 3; + slaves = new Host[slaveCount]; + + for(int i = 3; i < argc ; i++) + { + try + { + slaves[i-3] = Host::getByName(argv[i]); + } + + catch(HostNotFoundException e) + { + error(TEXT_(e.toString()) + TEXT_(". Stopping Now!")); + exit(1); + } + } + + info(TEXT_("Got slave(s) :" ) + TEXT_(slaveCount)); + + for (int i = 0; i < slaveCount; i++) + info(TEXT_("\t") + TEXT_(slaves[i].getName())); + + info(TEXT_("Got ") + TEXT_(numberOfTasks) + TEXT_(" task to process.")); + + + for (int i = 0; i < numberOfTasks; i++) + { + CommTimeTask* task = new CommTimeTask(TEXT_("Task_") + TEXT_(i), taskComputeSize, taskCommunicateSize); + task->setTime(getClock()); + slaves[i % slaveCount].put(0, task); + + } + + info("All tasks have been dispatched. Let's tell everybody the computation is over."); + + for (int i = 0; i < slaveCount; i++) + { + info(TEXT_("Finalize host ") + TEXT_(slaves[i].getName()) + TEXT_(" [") + TEXT_(i) + TEXT_("]")); + slaves[i].put(0, new FinalizeTask()); + } + + info("All finalize messages have been dispatched. Goodbye now!"); + + + delete[] slaves; + delete this; + return 0; +} diff --git a/examples/cxx/comm_time/Master.hpp b/examples/cxx/comm_time/Master.hpp index dc08c6d27c..40bb39089a 100644 --- a/examples/cxx/comm_time/Master.hpp +++ b/examples/cxx/comm_time/Master.hpp @@ -1,23 +1,23 @@ -#ifndef MASTER_HPP -#define MASTER_HPP - -#include -using namespace SimGrid::Msg; - -class Master : public Process -{ - MSG_DECLARE_DYNAMIC(Master); - - public: - - // Default constructor. - Master(){} - - // Destructor. - virtual ~Master(){} - - int main(int argc, char** argv); - -}; - -#endif // !MASTER_HPP \ No newline at end of file +#ifndef MASTER_HPP +#define MASTER_HPP + +#include +using namespace SimGrid::Msg; + +class Master : public Process +{ + MSG_DECLARE_DYNAMIC(Master); + + public: + + // Default constructor. + Master(){} + + // Destructor. + virtual ~Master(){} + + int main(int argc, char** argv); + +}; + +#endif // !MASTER_HPP diff --git a/examples/cxx/comm_time/Slave.cxx b/examples/cxx/comm_time/Slave.cxx index e1b41e8801..bc97e99284 100644 --- a/examples/cxx/comm_time/Slave.cxx +++ b/examples/cxx/comm_time/Slave.cxx @@ -1,45 +1,45 @@ -#include "Slave.hpp" -#include "FinalizeTask.hpp" -#include "CommTimeTask.hpp" -#include -#include -#include - -#include - -MSG_IMPLEMENT_DYNAMIC(Slave, Process); - -int Slave::main(int argc, char** argv) -{ - info("Hello"); - - while(true) - { - double time1 = getClock(); - Task* t = Task::get(0); - double time2 = getClock(); - - if(t->isInstanceOf("FinalizeTask")) - { - delete t; - break; - } - - CommTimeTask* task = reinterpret_cast(t); - - if(time1 < task->getTime()) - time1 = task->getTime(); - - //info(TEXT_("Processing \"") + TEXT_(task->getName()) + TEXT_("\" ") + TEXT_(getHost().getName()) + TEXT_(" (Communication time : ") + TEXT_((time2 - time1)) + TEXT_(")")); - - task->execute(); - - delete task; - } - - info(TEXT_("Received Finalize. I'm done. See you!")); - - delete this; - return 0; - -} \ No newline at end of file +#include "Slave.hpp" +#include "FinalizeTask.hpp" +#include "CommTimeTask.hpp" +#include +#include +#include + +#include + +MSG_IMPLEMENT_DYNAMIC(Slave, Process) + +int Slave::main(int argc, char** argv) +{ + info("Hello"); + + while(true) + { + double time1 = getClock(); + Task* t = Task::get(0); + double time2 = getClock(); + + if(t->isInstanceOf("FinalizeTask")) + { + delete t; + break; + } + + CommTimeTask* task = reinterpret_cast(t); + + if(time1 < task->getTime()) + time1 = task->getTime(); + + info(TEXT_("Processing \"") + TEXT_(task->getName()) + TEXT_("\" ") + TEXT_(getHost().getName()) + TEXT_(" (Communication time : ") + TEXT_((time2 - time1)) + TEXT_(")")); + + task->execute(); + + delete task; + } + + info(TEXT_("Received Finalize. I'm done. See you!")); + + delete this; + return 0; + +} diff --git a/examples/cxx/comm_time/Slave.hpp b/examples/cxx/comm_time/Slave.hpp index 3e73dfe70a..c3e861b4fc 100644 --- a/examples/cxx/comm_time/Slave.hpp +++ b/examples/cxx/comm_time/Slave.hpp @@ -1,24 +1,23 @@ -#ifndef SLAVE_HPP -#define SLAVE_HPP - -#include -using namespace SimGrid::Msg; - -class Slave : public Process -{ - MSG_DECLARE_DYNAMIC(Slave); - - public: - - // Default constructor. - Slave(){} - - // Destructor. - virtual ~Slave(){} - - int main(int argc, char** argv); - -}; - - -#endif // !SLAVE_HPP \ No newline at end of file +#ifndef SLAVE_HPP +#define SLAVE_HPP + +#include +using namespace SimGrid::Msg; + +class Slave : public Process +{ + MSG_DECLARE_DYNAMIC(Slave); + + public: + + // Default constructor. + Slave(){} + + // Destructor. + virtual ~Slave(){} + + int main(int argc, char** argv); + +}; + +#endif // !SLAVE_HPP diff --git a/examples/cxx/explicitDestination/BasicTask.cxx b/examples/cxx/explicitDestination/BasicTask.cxx index 21924e8d4f..19cd54a77b 100644 --- a/examples/cxx/explicitDestination/BasicTask.cxx +++ b/examples/cxx/explicitDestination/BasicTask.cxx @@ -1,3 +1,3 @@ -#include "BasicTask.hpp" - -MSG_IMPLEMENT_DYNAMIC(BasicTask, Task); \ No newline at end of file +#include "BasicTask.hpp" + +MSG_IMPLEMENT_DYNAMIC(BasicTask, Task) diff --git a/examples/cxx/explicitDestination/BasicTask.hpp b/examples/cxx/explicitDestination/BasicTask.hpp index 14f8e1da8e..01093d7ef3 100644 --- a/examples/cxx/explicitDestination/BasicTask.hpp +++ b/examples/cxx/explicitDestination/BasicTask.hpp @@ -1,30 +1,31 @@ -#ifndef BASIC_TASK_HPP -#define BASIC_TASK_HPP - -#include -using namespace SimGrid::Msg; - -class BasicTask : public Task -{ - MSG_DECLARE_DYNAMIC(BasicTask); -public: - - // Default constructor. - BasicTask() {} - - // Destructor - virtual ~BasicTask() {} - BasicTask(const char* name, double computeDuration, double messageSize) - throw (InvalidArgumentException, NullPointerException) - :Task(name, computeDuration, messageSize){} - - /*virtual const BasicTask& operator = (const BasicTask& rTask) { - Task::operator=(rTask); - return *this; - }*/ -}; - -typedef BasicTask* BasicTaskPtr; - - -#endif // !BASIC_TASK_HPP \ No newline at end of file +#ifndef BASIC_TASK_HPP +#define BASIC_TASK_HPP + +#include +using namespace SimGrid::Msg; + +class BasicTask : public Task +{ + MSG_DECLARE_DYNAMIC(BasicTask); +public: + + // Default constructor. + BasicTask() {} + + // Destructor + virtual ~BasicTask() + throw(MsgException){} + BasicTask(const char* name, double computeDuration, double messageSize) + throw (InvalidArgumentException, NullPointerException) + :Task(name, computeDuration, messageSize){} + + /*virtual const BasicTask& operator = (const BasicTask& rTask) { + Task::operator=(rTask); + return *this; + }*/ +}; + +typedef BasicTask* BasicTaskPtr; + + +#endif // !BASIC_TASK_HPP diff --git a/examples/cxx/explicitDestination/FinalizeTask.cxx b/examples/cxx/explicitDestination/FinalizeTask.cxx index a9cde570c1..0805537c9f 100644 --- a/examples/cxx/explicitDestination/FinalizeTask.cxx +++ b/examples/cxx/explicitDestination/FinalizeTask.cxx @@ -1,3 +1,3 @@ -#include "FinalizeTask.hpp" - -MSG_IMPLEMENT_DYNAMIC(FinalizeTask, Task); \ No newline at end of file +#include "FinalizeTask.hpp" + +MSG_IMPLEMENT_DYNAMIC(FinalizeTask, Task) diff --git a/examples/cxx/explicitDestination/FinalizeTask.hpp b/examples/cxx/explicitDestination/FinalizeTask.hpp index 6d95a14682..53c75db7f2 100644 --- a/examples/cxx/explicitDestination/FinalizeTask.hpp +++ b/examples/cxx/explicitDestination/FinalizeTask.hpp @@ -1,25 +1,23 @@ -#ifndef FINALIZE_TASK_HPP -#define FINALIZE_TASK_HPP - -#include -using namespace SimGrid::Msg; - -class FinalizeTask : public Task -{ - MSG_DECLARE_DYNAMIC(FinalizeTask); -public: - - // Default constructor. - FinalizeTask() - throw (InvalidArgumentException, NullPointerException) - :Task("finalize", 0.0, 0.0){} - - // Destructor - virtual ~FinalizeTask() {} - -}; - - - - -#endif // !FINALIZE_TASK_HPP \ No newline at end of file +#ifndef FINALIZE_TASK_HPP +#define FINALIZE_TASK_HPP + +#include +using namespace SimGrid::Msg; + +class FinalizeTask : public Task +{ + MSG_DECLARE_DYNAMIC(FinalizeTask); +public: + + // Default constructor. + FinalizeTask() + throw (InvalidArgumentException, NullPointerException) + :Task("finalize", 0.0, 0.0){} + + // Destructor + virtual ~FinalizeTask() + throw(MsgException){} + +}; + +#endif // !FINALIZE_TASK_HPP diff --git a/examples/cxx/explicitDestination/Forwarder.cxx b/examples/cxx/explicitDestination/Forwarder.cxx index f7220cd970..651533a11b 100644 --- a/examples/cxx/explicitDestination/Forwarder.cxx +++ b/examples/cxx/explicitDestination/Forwarder.cxx @@ -1,61 +1,61 @@ -#include "Forwarder.hpp" -#include "BasicTask.hpp" -#include "FinalizeTask.hpp" - -#include -#include - -#include - - -MSG_IMPLEMENT_DYNAMIC(Forwarder, Process); - - -int Forwarder::main(int argc, char** argv) -{ - info("Hello"); - - int aliasCount = argc; - - int taskCount = 0; - - Task* taskReceived; - Task* finalizeTask; - BasicTask* basicTask; - - while(true) - { - taskReceived = Task::receive(Host::currentHost().getName()); - - if(taskReceived->isInstanceOf("FinalizeTask")) - { - info("All tasks have been dispatched. Let's tell everybody the computation is over."); - - for (int i = 0; i < aliasCount; i++) - { - finalizeTask = new FinalizeTask(); - finalizeTask->send(argv[i]); - } - - delete taskReceived; - - break; - } - - basicTask = reinterpret_cast(taskReceived); - - info(TEXT_("Received \"") + TEXT_(basicTask->getName()) + TEXT_("\" ")); - - info(TEXT_("Sending \"") + TEXT_(basicTask->getName()) + TEXT_("\" to \"") + TEXT_(argv[taskCount % aliasCount]) + TEXT_("\"")); - - basicTask->send(argv[taskCount % aliasCount]); - - taskCount++; - } - - - info("I'm done. See you!"); - - delete this; - return 0; -} \ No newline at end of file +#include "Forwarder.hpp" +#include "BasicTask.hpp" +#include "FinalizeTask.hpp" + +#include +#include + +#include + + +MSG_IMPLEMENT_DYNAMIC(Forwarder, Process) + + +int Forwarder::main(int argc, char** argv) +{ + info("Hello"); + + int aliasCount = argc; + + int taskCount = 0; + + Task* taskReceived; + Task* finalizeTask; + BasicTask* basicTask; + + while(true) + { + taskReceived = Task::receive(Host::currentHost().getName()); + + if(taskReceived->isInstanceOf("FinalizeTask")) + { + info("All tasks have been dispatched. Let's tell everybody the computation is over."); + + for (int i = 0; i < aliasCount; i++) + { + finalizeTask = new FinalizeTask(); + finalizeTask->send(argv[i]); + } + + delete taskReceived; + + break; + } + + basicTask = reinterpret_cast(taskReceived); + + info(TEXT_("Received \"") + TEXT_(basicTask->getName()) + TEXT_("\" ")); + + info(TEXT_("Sending \"") + TEXT_(basicTask->getName()) + TEXT_("\" to \"") + TEXT_(argv[taskCount % aliasCount]) + TEXT_("\"")); + + basicTask->send(argv[taskCount % aliasCount]); + + taskCount++; + } + + + info("I'm done. See you!"); + + delete this; + return 0; +} diff --git a/examples/cxx/explicitDestination/Forwarder.hpp b/examples/cxx/explicitDestination/Forwarder.hpp index 31af15ce3a..767334bfe1 100644 --- a/examples/cxx/explicitDestination/Forwarder.hpp +++ b/examples/cxx/explicitDestination/Forwarder.hpp @@ -1,24 +1,24 @@ -#ifndef FORWARDER_HPP -#define FORWARDER_HPP - -#include -using namespace SimGrid::Msg; - -class Forwarder : public Process -{ - MSG_DECLARE_DYNAMIC(Forwarder); - - public: - - // Default constructor. - Forwarder(){} - - // Destructor. - virtual ~Forwarder(){} - - int main(int argc, char** argv); - -}; - - -#endif // !FORWARDER_HPP \ No newline at end of file +#ifndef FORWARDER_HPP +#define FORWARDER_HPP + +#include +using namespace SimGrid::Msg; + +class Forwarder : public Process +{ + MSG_DECLARE_DYNAMIC(Forwarder); + + public: + + // Default constructor. + Forwarder(){} + + // Destructor. + virtual ~Forwarder(){} + + int main(int argc, char** argv); + +}; + + +#endif // !FORWARDER_HPP diff --git a/examples/cxx/explicitDestination/Main.cxx b/examples/cxx/explicitDestination/Main.cxx index dbda264803..696bdc2dfd 100644 --- a/examples/cxx/explicitDestination/Main.cxx +++ b/examples/cxx/explicitDestination/Main.cxx @@ -1,12 +1,12 @@ -#include - -using namespace SimGrid::Msg; - -int -main(int argc, char* argv[]) -{ - Simulation s; - - return s.execute(argc, argv); - -} +#include + +using namespace SimGrid::Msg; + +int +main(int argc, char* argv[]) +{ + Simulation s; + + return s.execute(argc, argv); + +} diff --git a/examples/cxx/explicitDestination/Master.cxx b/examples/cxx/explicitDestination/Master.cxx index cd83fe6b75..c436a29ffd 100644 --- a/examples/cxx/explicitDestination/Master.cxx +++ b/examples/cxx/explicitDestination/Master.cxx @@ -1,84 +1,84 @@ -#include "Master.hpp" -#include "BasicTask.hpp" -#include "FinalizeTask.hpp" - -#include -#include - -#include - -MSG_IMPLEMENT_DYNAMIC(Master, Process); - -int Master::main(int argc, char** argv) -{ - int taskCount; - double taskComputeSize; - double taskCommunicateSize; - - info("Hello"); - - - info(TEXT_("argc=") + TEXT_(argc)); - - for (int i = 0; i< argc; i++) - info(TEXT_("argv:") + TEXT_(argv[i])); - - sscanf(argv[0],"%d", &taskCount); - - sscanf(argv[1],"%lg", &taskComputeSize); - - sscanf(argv[2],"%lg", &taskCommunicateSize); - - BasicTaskPtr* basicTasks = new BasicTaskPtr[taskCount]; - - for (int i = 0; i < taskCount; i++) - basicTasks[i] = new BasicTask(TEXT_("Task_") + TEXT_(i), taskComputeSize, taskCommunicateSize); - - int aliasCount = argc - 3; - - char** aliases = (char**) calloc(aliasCount, sizeof(char*)); - - for(int i = 3; i < argc ; i++) - aliases[i - 3] = _strdup(argv[i]); - - info(TEXT_("Got ") + TEXT_(aliasCount) + TEXT_(" alias(es) :")); - - for (int i = 0; i < aliasCount; i++) - info(TEXT_("\t") + TEXT_(aliases[i])); - - info(TEXT_("Got ") + TEXT_(taskCount) + TEXT_(" task to process.")); - - for (int i = 0; i < taskCount; i++) - { - info(TEXT_("Sending \"") + TEXT_(basicTasks[i]->getName()) + TEXT_("\" to \"") + TEXT_(aliases[i % aliasCount]) + TEXT_("\"")); - - - /*if((Host::currentHost().getName()).equals((aliases[i % aliasCount].split(":"))[0])) - info("Hey ! It's me ! "); - */ - - basicTasks[i]->send(aliases[i % aliasCount]); - } - - info("Send completed"); - - info("All tasks have been dispatched. Let's tell everybody the computation is over."); - - FinalizeTask* finalizeTask; - - for (int i = 0; i < aliasCount; i++) - { - finalizeTask = new FinalizeTask(); - finalizeTask->send(aliases[i]); - - } - - info("Goodbye now!"); - - delete[] basicTasks; - delete[] aliases; - - delete this; - - return 0; -} \ No newline at end of file +#include "Master.hpp" +#include "BasicTask.hpp" +#include "FinalizeTask.hpp" + +#include +#include + +#include + +MSG_IMPLEMENT_DYNAMIC(Master, Process) + +int Master::main(int argc, char** argv) +{ + int taskCount; + double taskComputeSize; + double taskCommunicateSize; + + info("Hello"); + + + info(TEXT_("argc=") + TEXT_(argc)); + + for (int i = 0; i< argc; i++) + info(TEXT_("argv:") + TEXT_(argv[i])); + + sscanf(argv[0],"%d", &taskCount); + + sscanf(argv[1],"%lg", &taskComputeSize); + + sscanf(argv[2],"%lg", &taskCommunicateSize); + + BasicTaskPtr* basicTasks = new BasicTaskPtr[taskCount]; + + for (int i = 0; i < taskCount; i++) + basicTasks[i] = new BasicTask(TEXT_("Task_") + TEXT_(i), taskComputeSize, taskCommunicateSize); + + int aliasCount = argc - 3; + + char** aliases = (char**) calloc(aliasCount, sizeof(char*)); + + for(int i = 3; i < argc ; i++) + aliases[i - 3] = _strdup(argv[i]); + + info(TEXT_("Got ") + TEXT_(aliasCount) + TEXT_(" alias(es) :")); + + for (int i = 0; i < aliasCount; i++) + info(TEXT_("\t") + TEXT_(aliases[i])); + + info(TEXT_("Got ") + TEXT_(taskCount) + TEXT_(" task to process.")); + + for (int i = 0; i < taskCount; i++) + { + info(TEXT_("Sending \"") + TEXT_(basicTasks[i]->getName()) + TEXT_("\" to \"") + TEXT_(aliases[i % aliasCount]) + TEXT_("\"")); + + + /*if((Host::currentHost().getName()).equals((aliases[i % aliasCount].split(":"))[0])) + info("Hey ! It's me ! "); + */ + + basicTasks[i]->send(aliases[i % aliasCount]); + } + + info("Send completed"); + + info("All tasks have been dispatched. Let's tell everybody the computation is over."); + + FinalizeTask* finalizeTask; + + for (int i = 0; i < aliasCount; i++) + { + finalizeTask = new FinalizeTask(); + finalizeTask->send(aliases[i]); + + } + + info("Goodbye now!"); + + delete[] basicTasks; + delete[] aliases; + + delete this; + + return 0; +} diff --git a/examples/cxx/explicitDestination/Master.hpp b/examples/cxx/explicitDestination/Master.hpp index dc08c6d27c..40bb39089a 100644 --- a/examples/cxx/explicitDestination/Master.hpp +++ b/examples/cxx/explicitDestination/Master.hpp @@ -1,23 +1,23 @@ -#ifndef MASTER_HPP -#define MASTER_HPP - -#include -using namespace SimGrid::Msg; - -class Master : public Process -{ - MSG_DECLARE_DYNAMIC(Master); - - public: - - // Default constructor. - Master(){} - - // Destructor. - virtual ~Master(){} - - int main(int argc, char** argv); - -}; - -#endif // !MASTER_HPP \ No newline at end of file +#ifndef MASTER_HPP +#define MASTER_HPP + +#include +using namespace SimGrid::Msg; + +class Master : public Process +{ + MSG_DECLARE_DYNAMIC(Master); + + public: + + // Default constructor. + Master(){} + + // Destructor. + virtual ~Master(){} + + int main(int argc, char** argv); + +}; + +#endif // !MASTER_HPP diff --git a/examples/cxx/explicitDestination/Slave.cxx b/examples/cxx/explicitDestination/Slave.cxx index c7ebc3138d..6bd3dd6285 100644 --- a/examples/cxx/explicitDestination/Slave.cxx +++ b/examples/cxx/explicitDestination/Slave.cxx @@ -1,45 +1,45 @@ -#include "Slave.hpp" -#include "FinalizeTask.hpp" -#include "BasicTask.hpp" - -#include -#include - -#include -using namespace std; - -MSG_IMPLEMENT_DYNAMIC(Slave, Process); - -int Slave::main(int argc, char** argv) -{ - info("Hello"); - - Task* receivedTask; - BasicTask* basicTask; - - while(true) - { - receivedTask = Task::receive(Host::currentHost().getName()); - - if(receivedTask->isInstanceOf("FinalizeTask")) - { - delete receivedTask; - break; - } - - basicTask = reinterpret_cast(receivedTask); - - info(TEXT_("Received \"") + TEXT_(basicTask->getName()) + TEXT_("\" ")); - - info(TEXT_("Processing \"") + TEXT_(basicTask->getName()) + TEXT_("\" ")); - basicTask->execute(); - info(TEXT_("\"") + TEXT_(basicTask->getName()) + TEXT_("\" done ")); - - delete basicTask; - } - - info("Received Finalize. I'm done. See you!"); - - delete this; - return 0; -} \ No newline at end of file +#include "Slave.hpp" +#include "FinalizeTask.hpp" +#include "BasicTask.hpp" + +#include +#include + +#include +using namespace std; + +MSG_IMPLEMENT_DYNAMIC(Slave, Process) + +int Slave::main(int argc, char** argv) +{ + info("Hello"); + + Task* receivedTask; + BasicTask* basicTask; + + while(true) + { + receivedTask = Task::receive(Host::currentHost().getName()); + + if(receivedTask->isInstanceOf("FinalizeTask")) + { + delete receivedTask; + break; + } + + basicTask = reinterpret_cast(receivedTask); + + info(TEXT_("Received \"") + TEXT_(basicTask->getName()) + TEXT_("\" ")); + + info(TEXT_("Processing \"") + TEXT_(basicTask->getName()) + TEXT_("\" ")); + basicTask->execute(); + info(TEXT_("\"") + TEXT_(basicTask->getName()) + TEXT_("\" done ")); + + delete basicTask; + } + + info("Received Finalize. I'm done. See you!"); + + delete this; + return 0; +} diff --git a/examples/cxx/explicitDestination/Slave.hpp b/examples/cxx/explicitDestination/Slave.hpp index 3e73dfe70a..391e08d9b2 100644 --- a/examples/cxx/explicitDestination/Slave.hpp +++ b/examples/cxx/explicitDestination/Slave.hpp @@ -1,24 +1,24 @@ -#ifndef SLAVE_HPP -#define SLAVE_HPP - -#include -using namespace SimGrid::Msg; - -class Slave : public Process -{ - MSG_DECLARE_DYNAMIC(Slave); - - public: - - // Default constructor. - Slave(){} - - // Destructor. - virtual ~Slave(){} - - int main(int argc, char** argv); - -}; - - -#endif // !SLAVE_HPP \ No newline at end of file +#ifndef SLAVE_HPP +#define SLAVE_HPP + +#include +using namespace SimGrid::Msg; + +class Slave : public Process +{ + MSG_DECLARE_DYNAMIC(Slave); + + public: + + // Default constructor. + Slave(){} + + // Destructor. + virtual ~Slave(){} + + int main(int argc, char** argv); + +}; + + +#endif // !SLAVE_HPP diff --git a/examples/cxx/ping_pong/Main.cxx b/examples/cxx/ping_pong/Main.cxx index dbda264803..ee113ef517 100644 --- a/examples/cxx/ping_pong/Main.cxx +++ b/examples/cxx/ping_pong/Main.cxx @@ -1,12 +1,13 @@ -#include - -using namespace SimGrid::Msg; - -int -main(int argc, char* argv[]) -{ - Simulation s; - - return s.execute(argc, argv); - -} +#include + +using namespace SimGrid::Msg; + +int +main(int argc, char* argv[]) +{ + Simulation s; + + return s.execute(argc, argv); + +} + diff --git a/examples/cxx/ping_pong/PingPongTask.cxx b/examples/cxx/ping_pong/PingPongTask.cxx index fe452e6abf..93d1133c2b 100644 --- a/examples/cxx/ping_pong/PingPongTask.cxx +++ b/examples/cxx/ping_pong/PingPongTask.cxx @@ -1,3 +1,3 @@ -#include "PingPongTask.hpp" - -MSG_IMPLEMENT_DYNAMIC(PingPongTask, Task); \ No newline at end of file +#include "PingPongTask.hpp" + +MSG_IMPLEMENT_DYNAMIC(PingPongTask, Task) diff --git a/examples/cxx/ping_pong/PingPongTask.hpp b/examples/cxx/ping_pong/PingPongTask.hpp index 53cc4d84d1..405c1cba67 100644 --- a/examples/cxx/ping_pong/PingPongTask.hpp +++ b/examples/cxx/ping_pong/PingPongTask.hpp @@ -1,40 +1,41 @@ -#ifndef PINGPONG_TASK_HPP -#define PINGPONG_TASK_HPP - -#include -using namespace SimGrid::Msg; - -class PingPongTask : public Task -{ - MSG_DECLARE_DYNAMIC(PingPongTask); - -public: - - PingPongTask() - :Task(NULL, 0.0, 0.0){} - - // Default constructor. - PingPongTask(const char* name, double computeDuration, double messageSize) - throw (InvalidArgumentException, NullPointerException) - :Task(name, computeDuration, messageSize){} - - // Destructor - virtual ~PingPongTask() {} - - void setTime(double timeVal) - { - this->timeVal = timeVal; - } - - double getTime() - { - return timeVal; - } - -private : - - double timeVal; -}; - - -#endif // !PINGPONG_TASK_HPP \ No newline at end of file +#ifndef PINGPONG_TASK_HPP +#define PINGPONG_TASK_HPP + +#include +using namespace SimGrid::Msg; + +class PingPongTask : public Task +{ + MSG_DECLARE_DYNAMIC(PingPongTask); + +public: + + PingPongTask() + :Task(NULL, 0.0, 0.0){} + + // Default constructor. + PingPongTask(const char* name, double computeDuration, double messageSize) + throw (InvalidArgumentException, NullPointerException) + :Task(name, computeDuration, messageSize){} + + // Destructor + virtual ~PingPongTask() + throw(MsgException){} + + void setTime(double timeVal) + { + this->timeVal = timeVal; + } + + double getTime() + { + return timeVal; + } + +private : + + double timeVal; +}; + + +#endif // !PINGPONG_TASK_HPP diff --git a/examples/cxx/ping_pong/Receiver.cxx b/examples/cxx/ping_pong/Receiver.cxx index 41ad22013c..cf58070e0d 100644 --- a/examples/cxx/ping_pong/Receiver.cxx +++ b/examples/cxx/ping_pong/Receiver.cxx @@ -1,46 +1,46 @@ -#include "Receiver.hpp" -#include "PingPongTask.hpp" -#include -#include -#include - -#include - -MSG_IMPLEMENT_DYNAMIC(Receiver, Process); - -const double commSizeLat = 1; -const double commSizeBw = 100000000; - -int Receiver::main(int argc, char** argv) -{ - info("Hello"); - double communicationTime=0; - double time = getClock(); - StringHelper bw; - - info("Try to get a task"); - - PingPongTask* task = reinterpret_cast(Task::get(0)); - - double timeGot = getClock(); - double timeSent = task->getTime(); - - delete task; - - info(TEXT_("Got at time ") + TEXT_(timeGot)); - info(TEXT_("Was sent at time ") + TEXT_(timeSent)); - - time = timeSent; - - communicationTime = timeGot - time; - - info(TEXT_( "Communication time : ") + TEXT_(communicationTime)); - - info(TEXT_(" --- BW ") + bw.append(commSizeBw/communicationTime,"%07lf") + TEXT_(" ----")); - - info("Goodbye!"); - - delete this; - - return 0; -} \ No newline at end of file +#include "Receiver.hpp" +#include "PingPongTask.hpp" +#include +#include +#include + +#include + +MSG_IMPLEMENT_DYNAMIC(Receiver, Process) + +const double commSizeLat = 1; +const double commSizeBw = 100000000; + +int Receiver::main(int argc, char** argv) +{ + info("Hello"); + double communicationTime=0; + double time = getClock(); + StringHelper bw; + + info("Try to get a task"); + + PingPongTask* task = reinterpret_cast(Task::get(0)); + + double timeGot = getClock(); + double timeSent = task->getTime(); + + delete task; + + info(TEXT_("Got at time ") + TEXT_(timeGot)); + info(TEXT_("Was sent at time ") + TEXT_(timeSent)); + + time = timeSent; + + communicationTime = timeGot - time; + + info(TEXT_( "Communication time : ") + TEXT_(communicationTime)); + + info(TEXT_(" --- BW ") + bw.append(commSizeBw/communicationTime,"%07lf") + TEXT_(" ----")); + + info("Goodbye!"); + + delete this; + + return 0; +} diff --git a/examples/cxx/ping_pong/Receiver.hpp b/examples/cxx/ping_pong/Receiver.hpp index 5fbf04e4d9..e4af2de025 100644 --- a/examples/cxx/ping_pong/Receiver.hpp +++ b/examples/cxx/ping_pong/Receiver.hpp @@ -1,24 +1,25 @@ -#ifndef RECEIVER_HPP -#define RECEIVER_HPP - -#include -using namespace SimGrid::Msg; - -class Receiver : public Process -{ - MSG_DECLARE_DYNAMIC(Receiver); - - public: - - // Default constructor. - Receiver(){} - - // Destructor. - virtual ~Receiver(){} - - int main(int argc, char** argv); - -}; - - -#endif // !RECEIVER_HPP \ No newline at end of file +#ifndef RECEIVER_HPP +#define RECEIVER_HPP + +#include +using namespace SimGrid::Msg; + +class Receiver : public Process +{ + MSG_DECLARE_DYNAMIC(Receiver); + + public: + + // Default constructor. + Receiver(){} + + // Destructor. + virtual ~Receiver(){} + + int main(int argc, char** argv); + +}; + + +#endif // !RECEIVER_HPP + diff --git a/examples/cxx/ping_pong/Sender.cxx b/examples/cxx/ping_pong/Sender.cxx index 8c3f364c86..41cbd7bc54 100644 --- a/examples/cxx/ping_pong/Sender.cxx +++ b/examples/cxx/ping_pong/Sender.cxx @@ -1,62 +1,63 @@ -#include "Sender.hpp" -#include "PingPongTask.hpp" -#include -#include -#include - -#include -using namespace std; - -const double commSizeLat = 1; -const double commSizeBw = 100000000; - -MSG_IMPLEMENT_DYNAMIC(Sender, Process); - -int Sender::main(int argc, char** argv) -{ - info("Hello"); - - int hostCount = argc; - - info(TEXT_("Host count : ") + TEXT_(hostCount)); - - Host* hostTable = new Host[hostCount]; - double time; - double computeDuration = 0; - PingPongTask* task; - - for(int pos = 0; pos < argc ; pos++) - { - try - { - hostTable[pos] = Host::getByName(argv[pos]); - } - catch(HostNotFoundException e) - { - error(TEXT_(e.toString()) + TEXT_(". Stopping Now!")); - exit(1); - } - } - - for (int pos = 0; pos < hostCount; pos++) - { - time = getClock(); - - info(TEXT_("Sender time : ") + TEXT_(time)); - - task = new PingPongTask("no name",computeDuration,commSizeLat); - task->setTime(time); - - hostTable[pos].put(0,task); - } - - info("Goodbye!"); - - - delete[] hostTable; - - delete this; - - return 0; - -} \ No newline at end of file +#include "Sender.hpp" +#include "PingPongTask.hpp" +#include +#include +#include + +#include +using namespace std; + +const double commSizeLat = 1; +const double commSizeBw = 100000000; + +MSG_IMPLEMENT_DYNAMIC(Sender, Process) + +int Sender::main(int argc, char** argv) +{ + info("Hello"); + + int hostCount = argc; + + info(TEXT_("Host count : ") + TEXT_(hostCount)); + + Host* hostTable = new Host[hostCount]; + double time; + double computeDuration = 0; + PingPongTask* task; + + for(int pos = 0; pos < argc ; pos++) + { + try + { + hostTable[pos] = Host::getByName(argv[pos]); + } + catch(HostNotFoundException e) + { + error(TEXT_(e.toString()) + TEXT_(". Stopping Now!")); + exit(1); + } + } + + for (int pos = 0; pos < hostCount; pos++) + { + time = getClock(); + + info(TEXT_("Sender time : ") + TEXT_(time)); + + task = new PingPongTask("no name",computeDuration,commSizeLat); + task->setTime(time); + + hostTable[pos].put(0,task); + } + + info("Goodbye!"); + + + delete[] hostTable; + + delete this; + + return 0; + +} + diff --git a/examples/cxx/ping_pong/Sender.hpp b/examples/cxx/ping_pong/Sender.hpp index 3569645c01..0c7a647b3e 100644 --- a/examples/cxx/ping_pong/Sender.hpp +++ b/examples/cxx/ping_pong/Sender.hpp @@ -1,24 +1,25 @@ -#ifndef SENDER_HPP -#define SENDER_HPP - -#include -using namespace SimGrid::Msg; - -class Sender : public Process -{ - MSG_DECLARE_DYNAMIC(Sender); - - public: - - // Default constructor. - Sender(){} - - // Destructor. - virtual ~Sender(){} - - int main(int argc, char** argv); - -}; - - -#endif // !SENDER_HPP \ No newline at end of file +#ifndef SENDER_HPP +#define SENDER_HPP + +#include +using namespace SimGrid::Msg; + +class Sender : public Process +{ + MSG_DECLARE_DYNAMIC(Sender); + + public: + + // Default constructor. + Sender(){} + + // Destructor. + virtual ~Sender(){} + + int main(int argc, char** argv); + +}; + + +#endif // !SENDER_HPP + diff --git a/examples/cxx/suspend/DreamMaster.cxx b/examples/cxx/suspend/DreamMaster.cxx index 62ed58f119..aac7b71ebd 100644 --- a/examples/cxx/suspend/DreamMaster.cxx +++ b/examples/cxx/suspend/DreamMaster.cxx @@ -1,54 +1,54 @@ -#include "DreamMaster.hpp" -#include "LazyGuy.hpp" -#include -#include -#include - -#include - - -MSG_IMPLEMENT_DYNAMIC(DreamMaster, Process); - -int DreamMaster::main(int argc, char** argv) -{ - - info("Hello"); - - info("Let's create a lazy guy."); - - - LazyGuy* lazy; - - try - { - Host currentHost = Host::currentHost(); - - info(TEXT_("Current host name : ") + TEXT_(currentHost.getName())); - - lazy = new LazyGuy(currentHost,"LazyGuy"); - - info("Let's wait a little bit..."); - - Process::sleep(10.0); - - info("Let's wake the lazy guy up! >:) "); - - lazy->resume(); - - - } - catch(HostNotFoundException e) - { - error(TEXT_(e.toString()) + TEXT_(". Stopping Now!")); - exit(1); - } - - //lazy->migrate(currentHost); - - info("OK, goodbye now."); - - delete this; - - return 0; - -} \ No newline at end of file +#include "DreamMaster.hpp" +#include "LazyGuy.hpp" +#include +#include +#include + +#include + + +MSG_IMPLEMENT_DYNAMIC(DreamMaster, Process) + +int DreamMaster::main(int argc, char** argv) +{ + + info("Hello"); + + info("Let's create a lazy guy."); + + + LazyGuy* lazy; + + try + { + Host currentHost = Host::currentHost(); + + info(TEXT_("Current host name : ") + TEXT_(currentHost.getName())); + + lazy = new LazyGuy(currentHost,"LazyGuy"); + + info("Let's wait a little bit..."); + + Process::sleep(10.0); + + info("Let's wake the lazy guy up! >:) "); + + lazy->resume(); + + + } + catch(HostNotFoundException e) + { + error(TEXT_(e.toString()) + TEXT_(". Stopping Now!")); + exit(1); + } + + //lazy->migrate(currentHost); + + info("OK, goodbye now."); + + delete this; + + return 0; + +} diff --git a/examples/cxx/suspend/DreamMaster.hpp b/examples/cxx/suspend/DreamMaster.hpp index 8729ea3252..f4c47b8ded 100644 --- a/examples/cxx/suspend/DreamMaster.hpp +++ b/examples/cxx/suspend/DreamMaster.hpp @@ -1,24 +1,24 @@ -#ifndef DREAMMASTER_HPP -#define DREAMMASTER_HPP - -#include -using namespace SimGrid::Msg; - -class DreamMaster : public Process -{ - MSG_DECLARE_DYNAMIC(DreamMaster); - - public: - - // Default constructor. - DreamMaster(){} - - // Destructor. - virtual ~DreamMaster(){} - - int main(int argc, char** argv); - -}; - - -#endif // !DREAMMASTER_HPP \ No newline at end of file +#ifndef DREAMMASTER_HPP +#define DREAMMASTER_HPP + +#include +using namespace SimGrid::Msg; + +class DreamMaster : public Process +{ + MSG_DECLARE_DYNAMIC(DreamMaster); + + public: + + // Default constructor. + DreamMaster(){} + + // Destructor. + virtual ~DreamMaster(){} + + int main(int argc, char** argv); + +}; + + +#endif // !DREAMMASTER_HPP diff --git a/examples/cxx/suspend/LazyGuy.cxx b/examples/cxx/suspend/LazyGuy.cxx index 7db90b7ed4..0b390a9fff 100644 --- a/examples/cxx/suspend/LazyGuy.cxx +++ b/examples/cxx/suspend/LazyGuy.cxx @@ -1,24 +1,25 @@ -#include "LazyGuy.hpp" -#include - -#include - -MSG_IMPLEMENT_DYNAMIC(LazyGuy, Process); - -int LazyGuy::main(int argc, char** argv) -{ - info("Hello !"); - - info("Nobody's watching me ? Let's go to sleep."); - - Process::currentProcess().suspend(); - - info("Uuuh ? Did somebody call me ?"); - - info("Mmmh, goodbye now."); - - - delete this; - - return 0; -} \ No newline at end of file +#include "LazyGuy.hpp" +#include + +#include + +// Not needed : DreamMaster directly constructs the object +// MSG_IMPLEMENT_DYNAMIC(LazyGuy, Process) + +int LazyGuy::main(int argc, char** argv) +{ + info("Hello !"); + + info("Nobody's watching me ? Let's go to sleep."); + + Process::currentProcess().suspend(); + + info("Uuuh ? Did somebody call me ?"); + + info("Mmmh, goodbye now."); + + delete this; + + return 0; +} + diff --git a/examples/cxx/suspend/LazyGuy.hpp b/examples/cxx/suspend/LazyGuy.hpp index 13077c6dbe..e7ffdcbeb0 100644 --- a/examples/cxx/suspend/LazyGuy.hpp +++ b/examples/cxx/suspend/LazyGuy.hpp @@ -1,28 +1,30 @@ -#ifndef LAZYGUY_HPP -#define LAZYGUY_HPP - -#include -using namespace SimGrid::Msg; - -class LazyGuy : public Process -{ - MSG_DECLARE_DYNAMIC(LazyGuy); - - public: - - // Default constructor. - LazyGuy(){} - - // Destructor. - virtual ~LazyGuy(){} - - LazyGuy(const Host& rHost,const char* name) - throw(NullPointerException) - :Process(rHost, name){} - - int main(int argc, char** argv); - -}; - - -#endif // !LAZYGUY_HPP \ No newline at end of file +#ifndef LAZYGUY_HPP +#define LAZYGUY_HPP + +#include +using namespace SimGrid::Msg; + +class LazyGuy : public Process +{ + // Not needed : DreamMaster directly constructs the object + // MSG_DECLARE_DYNAMIC(LazyGuy); + + public: + + // Default constructor. + LazyGuy(){} + + // Destructor. + virtual ~LazyGuy(){} + + LazyGuy(const Host& rHost,const char* name) + throw(NullPointerException) + :Process(rHost, name){} + + int main(int argc, char** argv); + +}; + + +#endif // !LAZYGUY_HPP + diff --git a/examples/cxx/suspend/Main.cxx b/examples/cxx/suspend/Main.cxx index dbda264803..5cf20506fb 100644 --- a/examples/cxx/suspend/Main.cxx +++ b/examples/cxx/suspend/Main.cxx @@ -1,12 +1,14 @@ -#include - -using namespace SimGrid::Msg; - -int -main(int argc, char* argv[]) -{ - Simulation s; - - return s.execute(argc, argv); - -} +#include + +using namespace SimGrid::Msg; + +int +main(int argc, char* argv[]) +{ + Simulation s; + + return s.execute(argc, argv); + +} + +