std::string mbox = "mb42";
std::string msg = "GaBuZoMeu";
explicit Sender() = default; /* Sending the default message */
- explicit Sender(std::string arg) { /* Sending the specified message */ msg= arg; }
+ explicit Sender(std::string arg) : msg(arg) { /* Sending the specified message */}
explicit Sender(std::vector<std::string> args)
{
/* This constructor is used when we start the actor from the deployment file */
void Node::fixFingers()
{
XBT_DEBUG("Fixing fingers");
- int id = findSuccessor(id_ + powers2[next_finger_to_fix]);
+ int id = findSuccessor(id_ + (1U << next_finger_to_fix));
if (id != -1) {
if (id != fingers_[next_finger_to_fix]) {
setFinger(next_finger_to_fix, id);
XBT_VERB("My finger table:");
XBT_VERB("Start | Succ");
for (int i = 0; i < nb_bits; i++) {
- XBT_VERB(" %3d | %3d", (id_ + powers2[i]) % nb_keys, fingers_[i]);
+ XBT_VERB(" %3u | %3d", (id_ + (1U << i)) % nb_keys, fingers_[i]);
}
XBT_VERB("Predecessor: %d", pred_id_);
int nb_bits = 24;
int nb_keys = 0;
int timeout = 50;
-int* powers2 = nullptr;
-
-/* Global initialization of the Chord simulation. */
-static void chord_init()
-{
- // compute the powers of 2 once for all
- powers2 = new int[nb_bits];
- int pow = 1;
- for (int i = 0; i < nb_bits; i++) {
- powers2[i] = pow;
- pow = pow << 1;
- }
- nb_keys = pow;
- XBT_DEBUG("Sets nb_keys to %d", nb_keys);
-
- HostChord::EXTENSION_ID = simgrid::s4u::Host::extension_create<HostChord>();
-
- std::vector<simgrid::s4u::Host*> list = simgrid::s4u::Engine::get_instance()->get_all_hosts();
- for (auto const& host : list)
- host->extension_set(new HostChord(host));
-}
-
-static void chord_exit()
-{
- delete[] powers2;
-}
int main(int argc, char* argv[])
{
e.load_platform(options[0]);
- chord_init(); // FIXME: inline me
+ /* Global initialization of the Chord simulation. */
+ nb_keys = 1U << nb_bits;
+ XBT_DEBUG("Sets nb_keys to %d", nb_keys);
+
+ HostChord::EXTENSION_ID = simgrid::s4u::Host::extension_create<HostChord>();
+ for (auto const& host : simgrid::s4u::Engine::get_instance()->get_all_hosts())
+ host->extension_set(new HostChord(host));
e.register_actor<Node>("node");
e.load_deployment(options[1]);
e.run();
XBT_INFO("Simulated time: %g", e.get_clock());
-
- chord_exit();
-
return 0;
}
extern int nb_bits;
extern int nb_keys;
extern int timeout;
-extern int* powers2;
class HostChord {
RngStream stream_;
}
namespace s4u {
-XBT_PUBLIC void getStorageList(std::map<std::string, Storage*>* whereTo);
+XBT_ATTRIB_DEPRECATED_v322(
+ "simgrid::s4u::getStorageList() is deprecated in favor of Engine::getAllStorages(). Please switch before v3.22")
+ XBT_PUBLIC void getStorageList(std::map<std::string, Storage*>* whereTo);
class XBT_PUBLIC Storage : public simgrid::xbt::Extendable<Storage> {
friend s4u::Engine;
int root = 0;
MPI_Datatype datatype1 = MPI_DEFAULT_TYPE;
MPI_Datatype datatype2 = MPI_DEFAULT_TYPE;
-
- virtual void parse(simgrid::xbt::ReplayAction& action, std::string name) = 0;
};
class BcastArgParser : public CollCommParser {
"lib"+name+".dylib" /* mac osx */}) {
File fileOut = new File(tempDir.toFile().getAbsolutePath() + File.separator + filename);
+ boolean done = false;
try ( // Try-with-resources. These stream will be autoclosed when needed.
InputStream in = NativeLib.class.getClassLoader().getResourceAsStream(path+filename);
OutputStream out = new FileOutputStream(fileOut);
while ((bytesRead = in.read(buffer)) != -1) // Read until EOF
out.write(buffer, 0, bytesRead);
- out.close(); // Windows cannot open it twice, so close it first. Shame.
-
+ done = true;
+ }
+ if (done) {
/* load that shit */
System.load(fileOut.getAbsolutePath());
/* It loaded! we're good */
return true;
-
}
}
sg_platf_init();
sg_platf_begin();
- storage_register_callbacks();
-
return 0;
}
/********** Tracing **********/
/* instr_routing.c */
-void instr_routing_define_callbacks();
xbt_graph_t instr_routing_platform_graph();
void instr_routing_platform_graph_export_graphviz(xbt_graph_t g, const char* filename);
// - enabled (with --cfg=tracing:yes)
// - already configured (TRACE_global_init already called)
if (TRACE_is_enabled()) {
+ instr_routing_define_callbacks();
XBT_DEBUG("Tracing starts");
/* init the tracing module to generate the right output */
bool TRACE_actor_is_enabled()
{
- return trace_actor_enabled && TRACE_is_enabled();
+ return trace_actor_enabled && trace_enabled;
}
bool TRACE_vm_is_enabled()
{
- return trace_vm_enabled && TRACE_is_enabled();
+ return trace_vm_enabled && trace_enabled;
}
bool TRACE_disable_link()
{
- return trace_disable_link && TRACE_is_enabled();
+ return trace_disable_link && trace_enabled;
}
bool TRACE_disable_speed()
{
- return trace_disable_power && TRACE_is_enabled();
+ return trace_disable_power && trace_enabled;
}
bool TRACE_buffer ()
{
- return trace_buffer && TRACE_is_enabled();
+ return trace_buffer && trace_enabled;
}
bool TRACE_disable_destroy ()
{
- return trace_disable_destroy && TRACE_is_enabled();
+ return trace_disable_destroy && trace_enabled;
}
bool TRACE_basic ()
{
- return trace_basic && TRACE_is_enabled();
+ return trace_basic && trace_enabled;
}
bool TRACE_display_sizes ()
{
- return trace_display_sizes && trace_smpi_enabled && TRACE_is_enabled();
+ return trace_display_sizes && trace_smpi_enabled && trace_enabled;
}
std::string TRACE_get_comment()
extern XBT_PRIVATE std::set<std::string> trivaNodeTypes;
extern XBT_PRIVATE std::set<std::string> trivaEdgeTypes;
XBT_PRIVATE long long int instr_new_paje_id();
+XBT_PRIVATE void instr_routing_define_callbacks();
void instr_new_variable_type(std::string new_typename, std::string color);
void instr_new_user_variable_type(std::string father_type, std::string new_typename, std::string color);
void instr_new_user_state_type(std::string father_type, std::string new_typename);
namespace s4u {
-void XBT_ATTRIB_DEPRECATED_v322(
- "simgrid::s4u::getStorageList() is deprecated in favor of Engine::getAllStorages(). Please switch before v3.22")
- getStorageList(std::map<std::string, Storage*>* whereTo)
+void getStorageList(std::map<std::string, Storage*>* whereTo)
{
for (auto const& s : simgrid::s4u::Engine::get_instance()->get_all_storages())
whereTo->insert({s->get_name(), s});
/*
* Callbacks
*/
-static void sg_instr_AS_begin(simgrid::s4u::NetZone& netzone)
+static void instr_netzone_on_creation(simgrid::s4u::NetZone& netzone)
{
std::string id = netzone.get_name();
}
}
-static void sg_instr_AS_end(simgrid::s4u::NetZone& /*netzone*/)
+static void instr_netzone_on_seal(simgrid::s4u::NetZone& /*netzone*/)
{
if (TRACE_needs_platform()){
currentContainer.pop_back();
}
}
-static void instr_routing_parse_start_link(simgrid::s4u::Link& link)
+static void instr_link_on_creation(simgrid::s4u::Link& link)
{
if (currentContainer.empty()) // No ongoing parsing. Are you creating the loopback?
return;
}
}
-static void sg_instr_new_host(simgrid::s4u::Host& host)
+static void instr_host_on_creation(simgrid::s4u::Host& host)
{
container_t container = new simgrid::instr::HostContainer(host, currentContainer.back());
container_t root = simgrid::instr::Container::getRoot();
}
}
-static void sg_instr_new_router(simgrid::kernel::routing::NetPoint * netpoint)
+static void instr_netpoint_on_creation(simgrid::kernel::routing::NetPoint* netpoint)
{
if (netpoint->is_router() && TRACE_is_enabled() && TRACE_needs_platform())
new simgrid::instr::RouterContainer(netpoint->get_cname(), currentContainer.back());
}
-static void instr_routing_parse_end_platform ()
+static void instr_on_platform_created()
{
currentContainer.clear();
std::set<std::string>* filter = new std::set<std::string>;
TRACE_paje_dump_buffer(true);
}
-void instr_routing_define_callbacks ()
+void instr_routing_define_callbacks()
{
- // always need the callbacks to ASes (we need only the root AS), to create the rootContainer and the rootType properly
- if (not TRACE_is_enabled())
- return;
+ // always need the callbacks to zones (we need only the root zone), to create the rootContainer and the rootType
+ // properly
if (TRACE_needs_platform()) {
- simgrid::s4u::Link::onCreation.connect(instr_routing_parse_start_link);
- simgrid::s4u::onPlatformCreated.connect(instr_routing_parse_end_platform);
- simgrid::s4u::Host::onCreation.connect(sg_instr_new_host);
+ simgrid::s4u::Host::onCreation.connect(instr_host_on_creation);
+ simgrid::s4u::Link::onCreation.connect(instr_link_on_creation);
+ simgrid::s4u::onPlatformCreated.connect(instr_on_platform_created);
}
- simgrid::s4u::NetZone::onCreation.connect(sg_instr_AS_begin);
- simgrid::s4u::NetZone::onSeal.connect(sg_instr_AS_end);
- simgrid::kernel::routing::NetPoint::onCreation.connect(sg_instr_new_router);
+ simgrid::s4u::NetZone::onCreation.connect(instr_netzone_on_creation);
+ simgrid::s4u::NetZone::onSeal.connect(instr_netzone_on_seal);
+ simgrid::kernel::routing::NetPoint::onCreation.connect(instr_netpoint_on_creation);
}
/*
* user categories support
Action* NetworkCm02Model::communicate(s4u::Host* src, s4u::Host* dst, double size, double rate)
{
- bool failed = false;
double latency = 0.0;
std::vector<LinkImpl*> back_route;
std::vector<LinkImpl*> route;
"You're trying to send data from %s to %s but there is no connecting path between these two hosts.",
src->get_cname(), dst->get_cname());
- failed = std::any_of(route.begin(), route.end(), [](LinkImpl* link) { return link->is_off(); });
+ bool failed = std::any_of(route.begin(), route.end(), [](LinkImpl* link) { return link->is_off(); });
if (cfg_crosstraffic) {
dst->routeTo(src, back_route, nullptr);
- failed = std::any_of(back_route.begin(), back_route.end(), [](LinkImpl* const& link) { return link->is_off(); });
+ if (not failed)
+ failed = std::any_of(back_route.begin(), back_route.end(), [](LinkImpl* const& link) { return link->is_off(); });
}
NetworkCm02Action *action = new NetworkCm02Action(this, size, failed);
/** Module management function: creates all internal data structures */
void sg_platf_init()
-{ /* Do nothing: just for symmetry of user code */
+{
+ simgrid::s4u::onPlatformCreated.connect(check_disk_attachment);
}
/** Module management function: frees all internal data structures */
*************/
extern std::map<std::string, simgrid::surf::StorageType*> storage_types;
-static void check_disk_attachment()
+void check_disk_attachment()
{
for (auto const& s : simgrid::s4u::Engine::get_instance()->get_all_storages()) {
simgrid::kernel::routing::NetPoint* host_elm = sg_netpoint_by_name_or_null(s->getImpl()->getHost().c_str());
}
}
-void storage_register_callbacks()
-{
- simgrid::s4u::onPlatformCreated.connect(check_disk_attachment);
- instr_routing_define_callbacks();
-}
-
/*********
* Model *
*********/
*/
XBT_PRIVATE int __surf_is_absolute_file_path(const char* file_path);
-XBT_PUBLIC void storage_register_callbacks();
-
+XBT_PRIVATE void check_disk_attachment();
XBT_PRIVATE void parse_after_config();
#endif
if (not after_config_done) {
TRACE_start();
- /* Register classical callbacks */
- storage_register_callbacks();
-
after_config_done = 1;
}
}
echo "Build mode $build_mode on $(uname -np)" >&2
case "$build_mode" in
"Debug")
+ INSTALL="/builds/simgrid_install"
;;
"ModelChecker")
+ INSTALL="/builds/mc_simgrid_install"
;;
"DynamicAnalysis")
+ INSTALL=""
;;
*)
echo "XX pwd: "$(pwd)
echo "XX"
set -x
-if [ "$build_mode" = "ModelChecker" ] ; then
- INSTALL="-DCMAKE_INSTALL_PREFIX=/builds/mc_simgrid_install"
-elif [ "$build_mode" = "Debug" ] ; then
- INSTALL="-DCMAKE_INSTALL_PREFIX=/builds/simgrid_install"
-fi
if cmake --version | grep -q 3\.11 ; then
# -DCMAKE_DISABLE_SOURCE_CHANGES=ON is broken with java on CMake 3.11
MAY_DISABLE_SOURCE_CHANGE="-DCMAKE_DISABLE_SOURCE_CHANGES=ON"
fi
-cmake -G"$GENERATOR" $INSTALL \
+cmake -G"$GENERATOR" ${INSTALL:+-DCMAKE_INSTALL_PREFIX=$INSTALL} \
-Denable_debug=ON -Denable_documentation=OFF -Denable_coverage=OFF \
-Denable_model-checking=$(onoff test "$build_mode" = "ModelChecker") \
-Denable_smpi_ISP_testsuite=$(onoff test "$build_mode" = "ModelChecker") \
mv CTestResults.xml $WORKSPACE
fi
-if test "$(uname)" != "Msys" && test "${build_mode}" = "Debug" -o "${build_mode}" = "ModelChecker" ; then
+if test -n "$INSTALL"; then
echo "XX"
echo "XX Test done. Install everything since it's a regular build, not on a Windows."
echo "XX"
- test "${build_mode}" = "Debug" && rm -rf /builds/simgrid_install
- test "${build_mode}" = "ModelChecker" && rm -rf /builds/mc_simgrid_install
+ rm -rf "$INSTALL"
make install
fi