A
lgorithmique
N
umérique
D
istribuée
Private GIT Repository
projects
/
loba.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Happy new year.
[loba.git]
/
main.cpp
diff --git
a/main.cpp
b/main.cpp
index f31e847d13244248afeccc28aef47a5b00c17510..af47c6498a9be603b0e8e292c2cc4cfcf5520321 100644
(file)
--- a/
main.cpp
+++ b/
main.cpp
@@
-4,7
+4,8
@@
#include <cstring> // strchr
#include <iostream>
#include <stdexcept>
#include <cstring> // strchr
#include <iostream>
#include <stdexcept>
-#include <msg/msg.h>
+#include <unistd.h>
+#include <simgrid/msg.h>
#include <xbt/log.h>
// Creates log categories
#include <xbt/log.h>
// Creates log categories
@@
-23,6
+24,7
@@
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(main);
#include "misc.h"
#include "options.h"
#include "process.h"
#include "misc.h"
#include "options.h"
#include "process.h"
+#include "simgrid_features.h"
#include "statistics.h"
#include "synchro.h"
#include "timer.h"
#include "statistics.h"
#include "synchro.h"
#include "timer.h"
@@
-149,6
+151,15
@@
static bool check_for_lost_load()
return res;
}
return res;
}
+static void check_file_access(const std::string& name)
+{
+ if (access(name.c_str(), R_OK) != 0) {
+ std::cerr << "ERROR: cannot access to file \""
+ << name << "\" for reading: " << strerror(errno) << "\n";
+ exit(EXIT_FAILURE_ARGS);
+ }
+}
+
static void signal_handler(int /*sig*/)
{
if (!opt::exit_request) {
static void signal_handler(int /*sig*/)
{
if (!opt::exit_request) {
@@
-171,19
+182,19
@@
static void install_signal_handler()
sigemptyset(&action.sa_mask);
action.sa_flags = SA_RESTART;
if (sigaction(SIGINT, &action, NULL) == -1) {
sigemptyset(&action.sa_mask);
action.sa_flags = SA_RESTART;
if (sigaction(SIGINT, &action, NULL) == -1) {
- std::cerr << "sigaction: " << strerror(errno) << "\n";
+ std::cerr << "
ERROR:
sigaction: " << strerror(errno) << "\n";
exit(EXIT_FAILURE_OTHER);
}
}
#define PR_VALUE(descr, format, ...) \
XBT_INFO("| %.*s: " format, DATA_DESCR_WIDTH, \
exit(EXIT_FAILURE_OTHER);
}
}
#define PR_VALUE(descr, format, ...) \
XBT_INFO("| %.*s: " format, DATA_DESCR_WIDTH, \
- descr "
.
................................................", \
+ descr "
................................................", \
__VA_ARGS__)
#define PR_STATS(descr, st) \
XBT_INFO("| %.*s: %g / %g / %g", DATA_DESCR_WIDTH, \
__VA_ARGS__)
#define PR_STATS(descr, st) \
XBT_INFO("| %.*s: %g / %g / %g", DATA_DESCR_WIDTH, \
- descr " (sum/avg/dev)
.
..................................", \
+ descr " (sum/avg/dev)
..................................", \
st.get_sum(), st.get_mean(), st.get_stddev())
int main(int argc, char* argv[])
st.get_sum(), st.get_mean(), st.get_stddev())
int main(int argc, char* argv[])
@@
-192,7
+203,7
@@
int main(int argc, char* argv[])
double simulated_time = -1.0;
timestamp elapsed_time(timestamp::wallclock_time);
timestamp simulation_time(timestamp::cpu_time);
double simulated_time = -1.0;
timestamp elapsed_time(timestamp::wallclock_time);
timestamp simulation_time(timestamp::cpu_time);
-
MSG
_error_t res;
+
msg
_error_t res;
elapsed_time.start();
simulation_time.start();
elapsed_time.start();
simulation_time.start();
@@
-209,7
+220,7
@@
int main(int argc, char* argv[])
}
// Initialize some MSG internal data.
}
// Initialize some MSG internal data.
- MSG_
global_
init(&argc, argv);
+ MSG_init(&argc, argv);
install_signal_handler();
// Parse global parameters
install_signal_handler();
// Parse global parameters
@@
-223,7
+234,6
@@
int main(int argc, char* argv[])
"Compiled on " << version::date << "\n\n";
if (!parse_res || opt::help_requested)
opt::usage();
"Compiled on " << version::date << "\n\n";
if (!parse_res || opt::help_requested)
opt::usage();
- MSG_clean();
exit(parse_res ? EXIT_NO_FAILURE : EXIT_FAILURE_ARGS);
}
XBT_INFO("%s v%s (%s)", opt::program_name.c_str(), version::num.c_str(),
exit(parse_res ? EXIT_NO_FAILURE : EXIT_FAILURE_ARGS);
}
XBT_INFO("%s v%s (%s)", opt::program_name.c_str(), version::num.c_str(),
@@
-236,6
+246,7
@@
int main(int argc, char* argv[])
// Create the platform and the application.
XBT_DEBUG("Loading platform file...");
// Create the platform and the application.
XBT_DEBUG("Loading platform file...");
+ check_file_access(opt::platform_file);
MSG_create_environment(opt::platform_file.c_str());
XBT_DEBUG("Creating hostdata...");
hostdata::create();
MSG_create_environment(opt::platform_file.c_str());
XBT_DEBUG("Creating hostdata...");
hostdata::create();
@@
-264,6
+275,7
@@
int main(int argc, char* argv[])
}
MY_launch_application(); // it is already opt::* aware...
} else {
}
MY_launch_application(); // it is already opt::* aware...
} else {
+ check_file_access(opt::deployment_file);
MSG_launch_application(opt::deployment_file.c_str());
}
MSG_launch_application(opt::deployment_file.c_str());
}
@@
-295,11
+307,6
@@
int main(int argc, char* argv[])
// Clean the MSG simulation.
hostdata::destroy();
// Clean the MSG simulation.
hostdata::destroy();
- res = MSG_clean();
- if (res != MSG_OK) {
- XBT_ERROR("MSG_clean() failed with status %#x", res);
- exit_status |= EXIT_FAILURE_CLEAN;
- }
// Report final simulation status.
if (simulated_time >= 0.0) {
// Report final simulation status.
if (simulated_time >= 0.0) {