Jean-Emile Dartois <jean-emile.dartois@b-com.com>
Jean-Emile Dartois <jean-emile.dartois@b-com.com> <jedartois@gmail.com>
Darina Dimitrova <dimitrov@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
-Bruno Donassolo <donassbr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
+Bruno Donassolo <bruno.donassolo@inria.fr> <donassbr@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Yann Duplouy <yann.duplouy@inria.fr> <duplouy@crans.org>
Pierre-François Dutot <dutot@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Julien Emmanuel <julien.emmanuel@inria.fr>
#include "xbt/string.hpp"
#include "xbt/sysdep.h"
-#include <cstdlib> /* abort */
-
jclass jxbt_get_class(JNIEnv * env, const char *name)
{
jclass cls = env->FindClass(name);
default_function = code;
}
-void EngineImpl::add_model_ptask(resource::Model::Type type, resource::Model* model, bool is_default)
+void EngineImpl::add_model(resource::Model::Type type, std::shared_ptr<resource::Model> model, bool is_default)
{
if (is_default)
- models_by_type_[type].insert(models_by_type_[type].begin(), model);
+ models_by_type_[type].insert(models_by_type_[type].begin(), model.get());
else
- models_by_type_[type].push_back(model);
+ models_by_type_[type].push_back(model.get());
+
+ models_.push_back(std::move(model));
}
-void EngineImpl::add_model(resource::Model::Type type, std::shared_ptr<resource::Model> model, bool is_default)
+resource::Model* EngineImpl::get_default_model(resource::Model::Type type) const
{
- add_model_ptask(type, model.get(), is_default);
- models_.push_back(std::move(model));
+ resource::Model* model = nullptr;
+ if (models_by_type_.find(type) != models_by_type_.end() and models_by_type_.at(type).size() > 0)
+ return models_by_type_.at(type)[0];
+ return model;
}
-resource::Model* EngineImpl::get_default_model(resource::Model::Type type)
+const std::vector<resource::Model*>& EngineImpl::get_model_list(resource::Model::Type type)
{
- if (models_by_type_[type].size() > 0)
- return models_by_type_[type][0];
- else
- return nullptr;
+ return models_by_type_[type];
}
} // namespace kernel
* @param is_default Is this the default model for this type of resource in this exp
*/
void add_model(resource::Model::Type type, std::shared_ptr<resource::Model> model, bool is_default = false);
- /**
- * @brief Add a model (specific for ptask)
- *
- * Ptask is special. The CPU and NETWORK models need to be in the managed
- * resources by surf_solve (model_by_type) but cannot be in the list of
- * all models (old all_existing_models global variable)
- *
- * This methods does this job while we cannot handle ptask as the remaining models
- */
- void add_model_ptask(resource::Model::Type type, resource::Model* model, bool is_default);
/** @brief Get current default model for a resource type */
- resource::Model* get_default_model(resource::Model::Type type);
+ resource::Model* get_default_model(resource::Model::Type type) const;
/** @brief Get list of models created for a resource type */
- const std::vector<resource::Model*>& get_model_list(resource::Model::Type type) { return models_by_type_[type]; }
+ const std::vector<resource::Model*>& get_model_list(resource::Model::Type type);
+
/** @brief Get list of all models managed by this engine */
- const std::vector<std::shared_ptr<resource::Model>>& get_all_models() { return models_; }
+ const std::vector<std::shared_ptr<resource::Model>>& get_all_models() const { return models_; }
routing::NetZoneImpl* netzone_root_ = nullptr;
static EngineImpl* get_instance() { return simgrid::s4u::Engine::get_instance()->pimpl; }
#include "src/kernel/activity/MutexImpl.hpp"
#include "src/kernel/activity/SynchroRaw.hpp"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_mutex, simix_synchro, "Mutex kernel-space implementation");
-
#if SIMGRID_HAVE_MC
#include "simgrid/modelchecker.h"
#include "src/mc/mc_safety.hpp"
#define MC_CHECK_NO_DPOR() (void)0
#endif
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(simix_mutex, simix_synchro, "Mutex kernel-space implementation");
+
namespace simgrid {
namespace kernel {
namespace activity {
#include <array>
#include <boost/core/demangle.hpp>
+#include <cerrno>
+#include <cstring>
#include <libunwind.h>
#endif
void MC_init_dot_output()
{
dot_output = fopen(_sg_mc_dot_output_file.get().c_str(), "w");
-
- if (dot_output == nullptr) {
- perror("Error open dot output file");
- xbt_abort();
- }
+ xbt_assert(dot_output != nullptr, "Error open dot output file: %s", strerror(errno));
fprintf(dot_output,
"digraph graphname{\n fixedsize=true; rankdir=TB; ranksep=.25; edge [fontsize=12]; node [fontsize=10, shape=circle,width=.5 ]; graph [resolution=20, fontsize=10];\n");
#include <xbt/log.h>
#include <cerrno>
-#include <unistd.h>
+#include <cstring>
#include <sys/socket.h>
#include <sys/types.h>
+#include <unistd.h>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_Channel, mc, "MC interprocess communication");
{
XBT_DEBUG("Send %s", to_c_str(*(MessageType*)message));
while (::send(this->socket_, message, size, 0) == -1) {
- if (errno != EINTR)
+ if (errno != EINTR) {
+ XBT_ERROR("Channel::send failure: %s", strerror(errno));
return errno;
+ }
}
return 0;
}
ssize_t res = recv(this->socket_, message, size, block ? 0 : MSG_DONTWAIT);
if (res != -1)
XBT_DEBUG("Receive %s", to_c_str(*(MessageType*)message));
+ else
+ XBT_ERROR("Channel::receive failure: %s", strerror(errno));
return res;
}
}
#include <sys/mman.h> // PROT_*
#include <algorithm>
+#include <cerrno>
+#include <cstring>
#include <memory>
#include <string>
} else if (res == 0)
return -1;
else if (errno != EINTR) {
- perror("pread_whole");
+ XBT_ERROR("pread_whole: %s", strerror(errno));
return -1;
}
}
offset += res;
} else if (res == 0)
return -1;
- else if (errno != EINTR)
+ else if (errno != EINTR) {
+ XBT_ERROR("pwrite_whole: %s", strerror(errno));
return -1;
+ }
}
return real_count;
}
}
/* Sanity checks */
- if ((a < 0.0) || (amount < 0.0)) {
- XBT_CRITICAL("Error, invalid parameters [a = %.2f, amount = %.2f]. "
- "You probably have a task executing with negative computation amount. Check your code.",
- a, amount);
- xbt_abort();
- }
+ xbt_assert(a >= 0.0 && amount >= 0.0,
+ "Error, invalid parameters [a = %.2f, amount = %.2f]. "
+ "You probably have a task executing with negative computation amount. Check your code.",
+ a, amount);
/* At this point, a and amount are positive */
if (amount < EPSILON)
auto* maxmin_system = new simgrid::kernel::lmm::FairBottleneck(true /* selective update */);
set_maxmin_system(maxmin_system);
- net_model_ = std::make_unique<NetworkL07Model>(this, maxmin_system);
- auto engine = simgrid::kernel::EngineImpl::get_instance();
- engine->add_model_ptask(simgrid::kernel::resource::Model::Type::NETWORK, net_model_.get(), true);
+ auto net_model = std::make_shared<NetworkL07Model>(this, maxmin_system);
+ auto engine = simgrid::kernel::EngineImpl::get_instance();
+ engine->add_model(simgrid::kernel::resource::Model::Type::NETWORK, std::move(net_model), true);
- cpu_model_ = std::make_unique<CpuL07Model>(this, maxmin_system);
- engine->add_model_ptask(simgrid::kernel::resource::Model::Type::CPU_PM, cpu_model_.get(), true);
+ auto cpu_model = std::make_shared<CpuL07Model>(this, maxmin_system);
+ engine->add_model(simgrid::kernel::resource::Model::Type::CPU_PM, std::move(cpu_model), true);
}
HostL07Model::~HostL07Model() {}
void update_actions_state(double now, double delta) override;
kernel::resource::CpuAction* execute_parallel(const std::vector<s4u::Host*>& host_list, const double* flops_amount,
const double* bytes_amount, double rate) override;
-
-private:
- std::unique_ptr<NetworkL07Model> net_model_;
- std::unique_ptr<CpuL07Model> cpu_model_;
};
class CpuL07Model : public kernel::resource::CpuModel {
CpuL07Model(const CpuL07Model&) = delete;
CpuL07Model& operator=(const CpuL07Model&) = delete;
~CpuL07Model() override;
+ /* this action is done by HostL07Model which shares the LMM system with the CPU model
+ * Overriding to an empty function here allows us to handle the Cpu07Model as a regular
+ * method in surf_presolve */
+ void update_actions_state(double now, double delta) override{};
kernel::resource::Cpu* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate) override;
HostL07Model* hostModel_;
s4u::Link::SharingPolicy policy) override;
kernel::resource::Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
+ /* this action is done by HostL07Model which shares the LMM system with the CPU model
+ * Overriding to an empty function here allows us to handle the Cpu07Model as a regular
+ * method in surf_presolve */
+ void update_actions_state(double now, double delta) override{};
HostL07Model* hostModel_;
};
XBT_DEBUG("Next TRACE event: %f", next_event_date);
for (auto* model : engine->get_model_list(simgrid::kernel::resource::Model::Type::NETWORK)) {
+ /* Skip all idempotent models, they were already treated above
+ * NS3 is the one to handled here */
if (model->next_occurring_event_is_idempotent())
continue;
- // NS3, I see you
if (next_event_date != -1.0) {
time_delta = std::min(next_event_date - NOW, time_delta);
} else {
#include "memory_map.hpp"
+// abort with a message if `expr' is false
+#define CHECK(expr) \
+ if (not(expr)) { \
+ fprintf(stderr, "CHECK FAILED: %s:%d: %s\n", __FILE__, __LINE__, #expr); \
+ abort(); \
+ } else \
+ ((void)0)
+
namespace simgrid {
namespace xbt {
char *endptr;
memreg.start_addr = std::strtoull(tok, &endptr, 16);
/* Make sure that the entire string was an hex number */
- if (*endptr != '\0')
- abort();
+ CHECK(*endptr == '\0');
tok = strtok_r(nullptr, "-", &saveptr);
- if (tok == nullptr)
- abort();
+ CHECK(tok != nullptr);
memreg.end_addr = std::strtoull(tok, &endptr, 16);
/* Make sure that the entire string was an hex number */
- if (*endptr != '\0')
- abort();
+ CHECK(*endptr == '\0');
/* Get the permissions flags */
- if (std::strlen(lfields[1]) < 4)
- abort();
+ CHECK(std::strlen(lfields[1]) >= 4);
memreg.prot = 0;
for (i = 0; i < 3; i++){
/* Get the offset value */
memreg.offset = std::strtoull(lfields[2], &endptr, 16);
/* Make sure that the entire string was an hex number */
- if (*endptr != '\0')
- abort();
+ CHECK(*endptr == '\0');
/* Get the device major:minor bytes */
tok = strtok_r(lfields[3], ":", &saveptr);
- if (tok == nullptr)
- abort();
+ CHECK(tok != nullptr);
memreg.dev_major = (char) strtoul(tok, &endptr, 16);
/* Make sure that the entire string was an hex number */
- if (*endptr != '\0')
- abort();
+ CHECK(*endptr == '\0');
tok = strtok_r(nullptr, ":", &saveptr);
- if (tok == nullptr)
- abort();
+ CHECK(tok != nullptr);
memreg.dev_minor = (char) std::strtoul(tok, &endptr, 16);
/* Make sure that the entire string was an hex number */
- if (*endptr != '\0')
- abort();
+ CHECK(*endptr == '\0');
/* Get the inode number and make sure that the entire string was a long int */
memreg.inode = strtoul(lfields[4], &endptr, 10);
- if (*endptr != '\0')
- abort();
+ CHECK(*endptr == '\0');
/* And finally get the pathname */
if (lfields[5])
abort();
} else if (behavior == Behavior::SEGV) {
#ifndef __clang_analyzer__
- int* A = 0;
+ int* A = nullptr;
if (x == 3 && y == 4)
*A = 1;
#endif