A
lgorithmique
N
umérique
D
istribuée
Public GIT Repository
projects
/
simgrid.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into fix/execute_benched
[simgrid.git]
/
teshsuite
/
s4u
/
comm-pt2pt
/
comm-pt2pt.cpp
diff --git
a/teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp
b/teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp
index
5fe7bd6
..
6b70db2
100644
(file)
--- a/
teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp
+++ b/
teshsuite/s4u/comm-pt2pt/comm-pt2pt.cpp
@@
-3,6
+3,13
@@
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
+/* We want this test to be exhaustive in term of:
+ * - communication involved (regular, asynchronous, detached, with a permanent receiver declared)
+ * - whether the send or the receive was posted first
+ *
+ * FIXME: Missing elements: timeouts, host/actor failures, link failures
+ */
+
#include "simgrid/s4u.hpp"
#include <cstring>
#include "simgrid/s4u.hpp"
#include <cstring>
@@
-32,118
+39,117
@@
static void usage(const char* binaryName, const char* defaultSend, const char* d
" j irecv on permanent mailbox (after a little delay)\n"
" J irecv on permanent mailbox (after a little delay)\n"
"\n"
" j irecv on permanent mailbox (after a little delay)\n"
" J irecv on permanent mailbox (after a little delay)\n"
"\n"
- "Example 1: %s examples/platforms/cluster.xml r
ipd rrrr # testing fancy
functions\n"
- "Default specs: %s %s (all possible pair
)
",
+ "Example 1: %s examples/platforms/cluster.xml r
RiIdD rrrrrr # testing all send
functions\n"
+ "Default specs: %s %s (all possible pair
s)\n
",
binaryName, binaryName, defaultSend, defaultRecv);
exit(1);
}
binaryName, binaryName, defaultSend, defaultRecv);
exit(1);
}
-static void
receiv
er(std::vector<std::string> args)
+static void
send
er(std::vector<std::string> args)
{
{
- XBT_INFO("
Receiv
er spec: %s", args[0].c_str());
+ XBT_INFO("
Send
er spec: %s", args[0].c_str());
for (unsigned int test = 1; test <= args[0].size(); test++) {
this_actor::sleep_until(test * 5 - 5);
for (unsigned int test = 1; test <= args[0].size(); test++) {
this_actor::sleep_until(test * 5 - 5);
-
char* mboxName = bprintf("Test #%u", test
);
- simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::byName(mboxName);
+
std::string* mboxName = new std::string("Test #" + std::to_string(test)
);
+ simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::byName(mboxName
->c_str()
);
switch (args[0][test - 1]) {
case 'r':
switch (args[0][test - 1]) {
case 'r':
- XBT_INFO("Test %
d
: r (regular send)", test);
-
simgrid::s4u::this_actor::send(mbox,
(void*)mboxName, 42.0);
+ XBT_INFO("Test %
u
: r (regular send)", test);
+
mbox->put(
(void*)mboxName, 42.0);
break;
case 'R':
break;
case 'R':
- XBT_INFO("Test %
d
: R (sleep + regular send)", test);
+ XBT_INFO("Test %
u
: R (sleep + regular send)", test);
simgrid::s4u::this_actor::sleep_for(0.5);
simgrid::s4u::this_actor::sleep_for(0.5);
-
simgrid::s4u::this_actor::send(mbox,
(void*)mboxName, 42.0);
+
mbox->put(
(void*)mboxName, 42.0);
break;
case 'i':
break;
case 'i':
- XBT_INFO("Test %
d
: i (asynchronous isend)", test);
-
simgrid::s4u::this_actor::isend(mbox,
(void*)mboxName, 42.0)->wait();
+ XBT_INFO("Test %
u
: i (asynchronous isend)", test);
+
mbox->put_async(
(void*)mboxName, 42.0)->wait();
break;
case 'I':
break;
case 'I':
- XBT_INFO("Test %
d
: I (sleep + isend)", test);
+ XBT_INFO("Test %
u
: I (sleep + isend)", test);
simgrid::s4u::this_actor::sleep_for(0.5);
simgrid::s4u::this_actor::sleep_for(0.5);
-
simgrid::s4u::this_actor::isend(mbox,
(void*)mboxName, 42.0)->wait();
+
mbox->put_async(
(void*)mboxName, 42.0)->wait();
break;
case 'd':
break;
case 'd':
- XBT_INFO("Test %
d
: d (detached send)", test);
-
simgrid::s4u::this_actor::dsend(mbox, (void*)mboxName, 42.0
);
+ XBT_INFO("Test %
u
: d (detached send)", test);
+
mbox->put_init((void*)mboxName, 42.0)->detach(
);
break;
case 'D':
break;
case 'D':
- XBT_INFO("Test %
d
: D (sleep + detached send)", test);
+ XBT_INFO("Test %
u
: D (sleep + detached send)", test);
simgrid::s4u::this_actor::sleep_for(0.5);
simgrid::s4u::this_actor::sleep_for(0.5);
-
simgrid::s4u::this_actor::dsend(mbox, (void*)mboxName, 42.0
);
+
mbox->put_init((void*)mboxName, 42.0)->detach(
);
break;
default:
break;
default:
- xbt_die("Unknown sender spec for test %
d
: '%c'", test, args[0][test - 1]);
+ xbt_die("Unknown sender spec for test %
u
: '%c'", test, args[0][test - 1]);
}
}
- XBT_INFO("Test %
d
OK", test);
+ XBT_INFO("Test %
u
OK", test);
}
simgrid::s4u::this_actor::sleep_for(0.5);
// FIXME: we should test what happens when the process ends before the end of remote comm instead of hiding it
}
}
simgrid::s4u::this_actor::sleep_for(0.5);
// FIXME: we should test what happens when the process ends before the end of remote comm instead of hiding it
}
-static void
send
er(std::vector<std::string> args)
+static void
receiv
er(std::vector<std::string> args)
{
{
- XBT_INFO("
Send
er spec: %s", args[0].c_str());
+ XBT_INFO("
Receiv
er spec: %s", args[0].c_str());
for (unsigned int test = 1; test <= args[0].size(); test++) {
this_actor::sleep_until(test * 5 - 5);
for (unsigned int test = 1; test <= args[0].size(); test++) {
this_actor::sleep_until(test * 5 - 5);
-
char* mboxName = bprintf("Test #%u",
test);
- simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::byName(mboxName);
+
std::string mboxName = "Test #" + std::to_string(
test);
+ simgrid::s4u::MailboxPtr mbox = simgrid::s4u::Mailbox::byName(mboxName
.c_str()
);
void* received = nullptr;
switch (args[0][test - 1]) {
case 'r':
void* received = nullptr;
switch (args[0][test - 1]) {
case 'r':
- XBT_INFO("Test %
d
: r (regular receive)", test);
- received =
simgrid::s4u::this_actor::recv(mbox
);
+ XBT_INFO("Test %
u
: r (regular receive)", test);
+ received =
mbox->get(
);
break;
case 'R':
break;
case 'R':
- XBT_INFO("Test %
d
: R (sleep + regular receive)", test);
+ XBT_INFO("Test %
u
: R (sleep + regular receive)", test);
simgrid::s4u::this_actor::sleep_for(0.5);
simgrid::s4u::this_actor::sleep_for(0.5);
- received =
simgrid::s4u::this_actor::recv(mbox
);
+ received =
mbox->get(
);
break;
case 'i':
break;
case 'i':
- XBT_INFO("Test %
d
: i (asynchronous irecv)", test);
-
simgrid::s4u::this_actor::irecv(mbox,
&received)->wait();
+ XBT_INFO("Test %
u
: i (asynchronous irecv)", test);
+
mbox->get_async(
&received)->wait();
break;
case 'I':
break;
case 'I':
- XBT_INFO("Test %
d
: I (sleep + asynchronous irecv)", test);
+ XBT_INFO("Test %
u
: I (sleep + asynchronous irecv)", test);
simgrid::s4u::this_actor::sleep_for(0.5);
simgrid::s4u::this_actor::sleep_for(0.5);
-
simgrid::s4u::this_actor::irecv(mbox,
&received)->wait();
+
mbox->get_async(
&received)->wait();
break;
case 'p':
break;
case 'p':
- XBT_INFO("Test %
d
: p (regular receive on permanent mailbox)", test);
+ XBT_INFO("Test %
u
: p (regular receive on permanent mailbox)", test);
mbox->setReceiver(Actor::self());
mbox->setReceiver(Actor::self());
- received =
simgrid::s4u::this_actor::recv(mbox
);
+ received =
mbox->get(
);
break;
case 'P':
break;
case 'P':
- XBT_INFO("Test %
d
: P (sleep + regular receive on permanent mailbox)", test);
+ XBT_INFO("Test %
u
: P (sleep + regular receive on permanent mailbox)", test);
simgrid::s4u::this_actor::sleep_for(0.5);
mbox->setReceiver(Actor::self());
simgrid::s4u::this_actor::sleep_for(0.5);
mbox->setReceiver(Actor::self());
- received =
simgrid::s4u::this_actor::recv(mbox
);
+ received =
mbox->get(
);
break;
case 'j':
break;
case 'j':
- XBT_INFO("Test %
d
: j (irecv on permanent mailbox)", test);
+ XBT_INFO("Test %
u
: j (irecv on permanent mailbox)", test);
mbox->setReceiver(Actor::self());
mbox->setReceiver(Actor::self());
-
simgrid::s4u::this_actor::irecv(mbox,
&received)->wait();
+
mbox->get_async(
&received)->wait();
break;
case 'J':
break;
case 'J':
- XBT_INFO("Test %
d
: J (sleep + irecv on permanent mailbox)", test);
+ XBT_INFO("Test %
u
: J (sleep + irecv on permanent mailbox)", test);
simgrid::s4u::this_actor::sleep_for(0.5);
mbox->setReceiver(Actor::self());
simgrid::s4u::this_actor::sleep_for(0.5);
mbox->setReceiver(Actor::self());
-
simgrid::s4u::this_actor::irecv(mbox,
&received)->wait();
+
mbox->get_async(
&received)->wait();
break;
default:
break;
default:
- xbt_die("Unknown receiver spec for test %
d
: '%c'", test, args[0][test - 1]);
+ xbt_die("Unknown receiver spec for test %
u
: '%c'", test, args[0][test - 1]);
}
}
-
- xbt_assert(strcmp(static_cast<char*>(received), mboxName) == 0);
- xbt_free(received);
- xbt_free(mboxName);
- XBT_INFO("Test %d OK", test);
+ std::string* receivedStr = static_cast<std::string*>(received);
+ xbt_assert(*receivedStr == mboxName);
+ delete receivedStr;
+ XBT_INFO("Test %u OK", test);
}
simgrid::s4u::this_actor::sleep_for(0.5);
}
}
simgrid::s4u::this_actor::sleep_for(0.5);
}
@@
-152,8
+158,8
@@
int main(int argc, char* argv[])
{
std::string specSend;
std::string specRecv;
{
std::string specSend;
std::string specRecv;
- for (char s : {'r', 'R', 'i', 'I', '
p', 'P', 'j', 'J
'})
- for (char r : {'r', 'R', 'i', 'I', '
d', 'D
'}) {
+ for (char s : {'r', 'R', 'i', 'I', '
d', 'D
'})
+ for (char r : {'r', 'R', 'i', 'I', '
p', 'P', 'j', 'J
'}) {
specSend += s;
specRecv += r;
}
specSend += s;
specRecv += r;
}
@@
-184,5
+190,6
@@
int main(int argc, char* argv[])
e->run();
XBT_INFO("Simulation time %g", e->getClock());
e->run();
XBT_INFO("Simulation time %g", e->getClock());
+ delete e;
return 0;
}
return 0;
}