{
/* creates variability for tasks smaller than 1% of CPU power.
* unrealistic, for learning purposes */
- double factor = 1.0;
- double speed = host->get_speed();
- if (flops < speed / 100) {
- factor = 0.5;
- }
+ double factor = (flops < host->get_speed() / 100) ? 0.5 : 1.0;
XBT_INFO("Host %s, task with %lf flops, new factor %lf", host->get_cname(), flops, factor);
return factor;
}
} else {
auto i = buffer.begin();
for (auto const& event : buffer) {
- double head_timestamp = event->timestamp_;
- if (head_timestamp > last_timestamp_to_dump)
+ if (event->timestamp_ > last_timestamp_to_dump)
break;
event->print();
delete event;
// to check if variables were previously set to 0, otherwise paje won't simulate them
static std::set<std::string, std::less<>> platform_variables;
- // create a key considering the resource and variable
- std::string key = std::string(resource) + get_name();
-
- // check if key exists: if it doesn't, set the variable to zero and mark this in the global map.
- if (platform_variables.find(key) == platform_variables.end()) {
+ // create a key considering the resource and variable, and check if key exists in the global map:
+ // if it doesn't, set the variable to zero.
+ if (platform_variables.emplace(std::string(resource) + get_name()).second)
set_event(now, 0);
- platform_variables.insert(key);
- }
add_event(now, value);
sub_event(now + delta, value);
int j = static_cast<int>(ancestors_a2.size()) - 1;
while (i >= 0 && j >= 0) {
simgrid::instr::Container* a1p = ancestors_a1.at(i);
- const simgrid::instr::Container* a2p = ancestors_a2.at(j);
- if (a1p == a2p) {
- p = a1p;
- } else {
+ if (a1p != ancestors_a2.at(j))
break;
- }
+ p = a1p;
i--;
j--;
}
actor::ActorImpl* EngineImpl::get_actor_by_pid(aid_t pid)
{
auto item = actor_list_.find(pid);
- if (item != actor_list_.end())
- return item->second;
-
- return nullptr; // Not found
+ return item == actor_list_.end() ? nullptr : item->second;
}
void EngineImpl::remove_daemon(actor::ActorImpl* actor)
}
alloc[selected_resource].insert(player_idx);
}
- bool is_stable = (alloc == last_alloc);
- if (is_stable)
+ if (alloc == last_alloc) // considered stable
return true;
std::vector<int> alloc_by_player = alloc_map_to_vector(alloc);
engine->add_model(vm_model, {cpu_pm_model});
std::shared_ptr<simgrid::kernel::resource::CpuModel> cpu_model_vm;
- auto cpu_optim = simgrid::config::get_value<std::string>("cpu/optim");
- if (cpu_optim == "TI") {
+ if (simgrid::config::get_value<std::string>("cpu/optim") == "TI") {
cpu_model_vm = std::make_shared<simgrid::kernel::resource::CpuTiModel>("VmCpu_TI");
} else {
cpu_model_vm = std::make_shared<simgrid::kernel::resource::CpuCas01Model>("VmCpu_Cas01");
/** @brief Retrieves the next occurring event, or nullptr if none happens before date */
Event* FutureEvtSet::pop_leq(double date, double* value, resource::Resource** resource)
{
- double event_date = next_date();
- if (event_date > date || heap_.empty())
+ if (next_date() > date || heap_.empty())
return nullptr;
Event* event = heap_.top().second;
NetPoint* ClusterBase::get_gateway(unsigned long position)
{
- NetPoint* res = nullptr;
- auto it = gateways_.find(position);
- if (it != gateways_.end()) {
- res = it->second;
- }
- return res;
+ auto it = gateways_.find(position);
+ return it == gateways_.end() ? nullptr : it->second;
}
void ClusterBase::fill_leaf_from_cb(unsigned long position, const std::vector<unsigned long>& dimensions,
void ModelChecker::resume()
{
- int res = checker_side_.get_channel().send(MessageType::CONTINUE);
- if (res)
+ if (checker_side_.get_channel().send(MessageType::CONTINUE) != 0)
throw xbt::errno_error();
remote_process_->clear_cache();
}
return true;
/* Start comparison */
- bool differ = type ? heap_area_differ_with_type(process, state, area1, area2, snapshot1, snapshot2, previous, type,
- size, check_ignore, pointer_level)
- : heap_area_differ_without_type(process, state, area1, area2, snapshot1, snapshot2, previous, size,
- check_ignore);
- if (differ)
+ if (type ? heap_area_differ_with_type(process, state, area1, area2, snapshot1, snapshot2, previous, type, size,
+ check_ignore, pointer_level)
+ : heap_area_differ_without_type(process, state, area1, area2, snapshot1, snapshot2, previous, size,
+ check_ignore))
return true;
if (match_pairs)
xbt_assert(elf != nullptr && elf_kind(elf) == ELF_K_ELF, "%s is not an ELF file", info->file_name.c_str());
// Remember if this is a `ET_EXEC` (fixed location) or `ET_DYN`:
- Elf64_Half type = get_type(elf);
- if (type == ET_EXEC)
+ if (get_type(elf) == ET_EXEC)
info->flags |= simgrid::mc::ObjectInformation::Executable;
// Read DWARF debug information in the file:
return MPI_ERR_TYPE;
} else {
size_t size = datatype->size();
- if (size == 0) {
- *count = 0;
- } else if (status->count % size != 0) {
- *count = MPI_UNDEFINED;
- } else {
- *count = simgrid::smpi::Status::get_count(status, datatype);
- }
+ *count = (size == 0) ? 0
+ : (status->count % size != 0) ? MPI_UNDEFINED
+ : simgrid::smpi::Status::get_count(status, datatype);
return MPI_SUCCESS;
}
}
int bsend_buf_size = 0;
void* bsend_buf = nullptr;
smpi_process()->bsend_buffer(&bsend_buf, &bsend_buf_size);
- int size = datatype->get_extent() * count;
- if (bsend_buf == nullptr || bsend_buf_size < size + MPI_BSEND_OVERHEAD)
+ if (bsend_buf == nullptr || bsend_buf_size < datatype->get_extent() * count + MPI_BSEND_OVERHEAD)
return MPI_ERR_BUFFER;
TRACE_smpi_comm_in(my_proc_id, __func__,
new simgrid::instr::Pt2PtTIData("bsend", MPI_COMM_WORLD->group()->rank(dst_traced),
int bsend_buf_size = 0;
void* bsend_buf = nullptr;
smpi_process()->bsend_buffer(&bsend_buf, &bsend_buf_size);
- int size = datatype->get_extent() * count;
- if (bsend_buf == nullptr || bsend_buf_size < size + MPI_BSEND_OVERHEAD)
+ if (bsend_buf == nullptr || bsend_buf_size < datatype->get_extent() * count + MPI_BSEND_OVERHEAD)
return MPI_ERR_BUFFER;
TRACE_smpi_comm_in(my_proc_id, __func__,
new simgrid::instr::Pt2PtTIData("ibsend", MPI_COMM_WORLD->group()->rank(trace_dst),
status->count = 0;
return MPI_SUCCESS;
}
- MPI_Offset total = max - min;
- if (total == tot && (datatype->flags() & DT_FLAG_CONTIGUOUS)) {
+ if (max - min == tot && (datatype->flags() & DT_FLAG_CONTIGUOUS)) {
// contiguous. Just have each proc perform its read
if (status != MPI_STATUS_IGNORE)
status->count = count * datatype->size();
mailbox = process->mailbox();
XBT_DEBUG("Is there a corresponding recv already posted in the large mailbox %s?", mailbox->get_cname());
- simgrid::kernel::activity::ActivityImplPtr action = mailbox->iprobe(1, &match_send, static_cast<void*>(this));
- if (action == nullptr) {
+ if (not mailbox->iprobe(1, &match_send, static_cast<void*>(this))) {
if ((flags_ & MPI_REQ_SSEND) == 0) {
mailbox = process->mailbox_small();
XBT_DEBUG("No, nothing in the large mailbox, message is to be sent on the small one %s",
mailbox = process->mailbox_small();
XBT_DEBUG("SSEND : Is there a corresponding recv already posted in the small mailbox %s?",
mailbox->get_cname());
- action = mailbox->iprobe(1, &match_send, static_cast<void*>(this));
- if (action == nullptr) {
+ if (not mailbox->iprobe(1, &match_send, static_cast<void*>(this))) {
XBT_DEBUG("No, we are first, send to large mailbox");
mailbox = process->mailbox();
}
*count = 0;
for (int i = 0; i < incount; i++) {
if (requests[i] != MPI_REQUEST_NULL && not (requests[i]->flags_ & MPI_REQ_FINISHED)) {
- int ret = test(&requests[i], pstat, &flag);
- if(ret!=MPI_SUCCESS)
+ if (test(&requests[i], pstat, &flag) != MPI_SUCCESS)
error = 1;
if(flag) {
indices[*count] = i;
VirtualMachineImpl* HostImpl::get_vm_by_name_or_null(const std::string& name) const
{
auto vm_it = vms_.find(name);
- if (vm_it != vms_.end())
- return vm_it->second;
- return nullptr;
+ return vm_it == vms_.end() ? nullptr : vm_it->second;
}
std::vector<s4u::VirtualMachine*> HostImpl::get_vms() const
XBT_DEBUG("Quotient: %g reduced_amount: %f reduced_a: %f", quotient, reduced_amount, reduced_a);
/* Now solve for new_amount which is <= trace_total */
- double reduced_b;
XBT_DEBUG("Solve integral: [%.2f, amount=%.2f]", reduced_a, reduced_amount);
- double amount_till_end = integrate(reduced_a, last_time_);
- if (amount_till_end > reduced_amount) {
- reduced_b = profile_->solve_simple(reduced_a, reduced_amount);
- } else {
- reduced_b = last_time_ + profile_->solve_simple(0.0, reduced_amount - amount_till_end);
- }
+ double amount_till_end = integrate(reduced_a, last_time_);
+ double reduced_b = amount_till_end > reduced_amount
+ ? profile_->solve_simple(reduced_a, reduced_amount)
+ : last_time_ + profile_->solve_simple(0.0, reduced_amount - amount_till_end);
/* Re-map to the original b and amount */
return last_time_ * floor(a / last_time_) + (quotient * last_time_) + reduced_b;
for (ActiveComm* comm : root->active_comms_up_) {
// compute inbound penalty
double my_penalty_in = 1.0;
- int nb_comms = comm->destination->nb_active_comms_down_; // total number of incoming comms
- if (nb_comms != 1)
+ if (comm->destination->nb_active_comms_down_ != 1) // total number of incoming comms
my_penalty_in = (comm->destination->active_comms_down_)[root] // number of comm sent to dest by root node
* Be_ * comm->destination->active_comms_down_.size(); // number of different nodes sending to dest
const lmm::Constraint* cnst = action.get_variable()->get_constraint(i);
while (cnst != nullptr) {
i++;
- const Resource* constraint_id = cnst->get_id();
- if (not constraint_id->is_on()) {
+ if (not cnst->get_id()->is_on()) {
XBT_DEBUG("Action (%p) Failed!!", &action);
action.finish(Action::State::FAILED);
break;
std::string val = name.substr(pos + 1);
name.erase(pos);
- const std::string path("path");
- if (name.compare(0, path.length(), path) != 0)
+ if (name.rfind("path", 0) != 0)
XBT_INFO("Configuration change: Set '%s' to '%s'", name.c_str(), val.c_str());
set_as_string(name.c_str(), val);