/* 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. */
+#include <algorithm>
#include <climits>
#include <xbt/ex.hpp>
#define BLOCK_SIZE 16384
/** Number of blocks asked by each request */
-#define BLOCKS_REQUESTED 2
+#define BLOCKS_REQUESTED 2UL
#define ENABLE_END_GAME_MODE 1
#define SLEEP_DURATION 1
xbt_assert(remote_peer->hasPiece(piece));
int block_index = getFirstMissingBlockFrom(piece);
if (block_index != -1) {
- int block_length = MIN(BLOCKS_REQUESTED, PIECES_BLOCKS - block_index);
+ int block_length = std::min(BLOCKS_REQUESTED, PIECES_BLOCKS - block_index);
XBT_DEBUG("Sending a REQUEST to %s for piece %u (%d,%d)", remote_peer->mailbox_->getCname(), piece, block_index,
block_length);
remote_peer->mailbox_
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "s4u-tracker.hpp"
+#include <algorithm>
#include <xbt/RngStream.h>
XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_bt_tracker, "Messages specific for the tracker");
TrackerAnswer* ta = new TrackerAnswer(TRACKER_QUERY_INTERVAL);
std::set<int>::iterator next_peer;
int nb_known_peers = known_peers.size();
- int max_tries = MIN(MAXIMUM_PEERS, nb_known_peers);
+ int max_tries = std::min(MAXIMUM_PEERS, nb_known_peers);
int tried = 0;
while (tried < max_tries) {
do {
XBT_VERB("(%d->%d): (%.2f, %.2f)-> (%.2f, %.2f)", i, j, src_start, src_end, dst_start, dst_end);
task->bytes_amount[i*(src_nb+dst_nb)+src_nb+j]=0.0;
if ((src_end > dst_start) && (dst_end > src_start)) { /* There is something to send */
- task->bytes_amount[i*(src_nb+dst_nb)+src_nb+j] = MIN(src_end, dst_end)- MAX(src_start, dst_start);
+ task->bytes_amount[i * (src_nb + dst_nb) + src_nb + j] =
+ std::min(src_end, dst_end) - std::max(src_start, dst_start);
XBT_VERB("==> %.2f", task->bytes_amount[i*(src_nb+dst_nb)+src_nb+j]);
}
}
/* Copy at most dst_buff_size bytes of the message to receiver's buffer */
if (comm->dst_buff_size)
- buff_size = MIN(buff_size, *(comm->dst_buff_size));
+ buff_size = std::min(buff_size, *(comm->dst_buff_size));
/* Update the receiver's buffer size to the copied amount */
if (comm->dst_buff_size)
#include "../colls_private.hpp"
#include "smpi_status.hpp"
+#include <algorithm>
namespace simgrid{
namespace smpi{
recvtype->extent(&recvtype_true_lb, &recvtype_true_extent);
- tmp_buf_rl= (void*)smpi_get_tmp_sendbuffer(total_count*(MAX(recvtype_true_extent,recvtype_extent)));
+ tmp_buf_rl = (void*)smpi_get_tmp_sendbuffer(total_count * std::max(recvtype_true_extent, recvtype_extent));
/* adjust for potential negative lower bound in datatype */
tmp_buf = (void *)((char*)tmp_buf_rl - recvtype_true_lb);
*/
#include "../colls_private.hpp"
+#include <algorithm>
+
namespace simgrid{
namespace smpi{
int Coll_allreduce_mvapich2_rs::allreduce(void *sendbuf,
datatype->extent(&true_lb, &true_extent);
extent = datatype->get_extent();
- tmp_buf_free= smpi_get_tmp_recvbuffer(count * (MAX(extent, true_extent)));
+ tmp_buf_free = smpi_get_tmp_recvbuffer(count * std::max(extent, true_extent));
/* adjust for potential negative lower bound in datatype */
tmp_buf = (void *) ((char *) tmp_buf_free - true_lb);
*/
#include "../colls_private.hpp"
+#include <algorithm>
#define MPIR_Gather_MV2_Direct Coll_gather_ompi_basic_linear::gather
#define MPIR_Gather_MV2_two_level_Direct Coll_gather_ompi_basic_linear::gather
if (local_rank == 0) {
/* Node leader, allocate tmp_buffer */
if (rank == root) {
- tmp_buf = smpi_get_tmp_recvbuffer(recvcnt * MAX(recvtype_extent,
- recvtype_true_extent) * local_size);
+ tmp_buf = smpi_get_tmp_recvbuffer(recvcnt * std::max(recvtype_extent, recvtype_true_extent) * local_size);
} else {
- tmp_buf = smpi_get_tmp_sendbuffer(sendcnt * MAX(sendtype_extent,
- sendtype_true_extent) *
- local_size);
+ tmp_buf = smpi_get_tmp_sendbuffer(sendcnt * std::max(sendtype_extent, sendtype_true_extent) * local_size);
}
if (tmp_buf == NULL) {
mpi_errno = MPI_ERR_OTHER;
* is the same as leader_root */
if (rank == root) {
leader_gather_buf =
- smpi_get_tmp_recvbuffer(recvcnt * MAX(recvtype_extent, recvtype_true_extent) * comm_size);
+ smpi_get_tmp_recvbuffer(recvcnt * std::max(recvtype_extent, recvtype_true_extent) * comm_size);
} else {
leader_gather_buf =
- smpi_get_tmp_sendbuffer(sendcnt * MAX(sendtype_extent, sendtype_true_extent) * comm_size);
+ smpi_get_tmp_sendbuffer(sendcnt * std::max(sendtype_extent, sendtype_true_extent) * comm_size);
}
if (leader_gather_buf == NULL) {
mpi_errno = MPI_ERR_OTHER;
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "../colls_private.hpp"
+#include <algorithm>
//#include <star-reduction.c>
namespace simgrid{
/* If I'm not the root, then my recvbuf may not be valid, therefore
I have to allocate a temporary one */
if (rank != root) {
- recvbuf = (void *) smpi_get_tmp_recvbuffer(count*(MAX(extent,true_extent)));
+ recvbuf = (void*)smpi_get_tmp_recvbuffer(count * std::max(extent, true_extent));
recvbuf = (void *)((char*)recvbuf - true_lb);
}
if ((rank != root) || (sendbuf != MPI_IN_PLACE)) {
*/
#include "../colls_private.hpp"
+#include <algorithm>
+
extern int mv2_reduce_intra_knomial_factor;
extern int mv2_reduce_inter_knomial_factor;
is_commutative = (op==MPI_OP_NULL || op->is_commutative());
if (rank != root) {
- recvbuf=(void *)smpi_get_tmp_recvbuffer(count*(MAX(extent,true_extent)));
+ recvbuf = (void*)smpi_get_tmp_recvbuffer(count * std::max(extent, true_extent));
recvbuf = (void *)((char*)recvbuf - true_lb);
}
tmp_buf = static_cast<void**>(xbt_malloc(sizeof(void *)*expected_recv_count));
requests = static_cast<MPI_Request*>(xbt_malloc(sizeof(MPI_Request)*expected_recv_count));
for(k=0; k < expected_recv_count; k++ ) {
- tmp_buf[k] = smpi_get_tmp_sendbuffer(count*(MAX(extent,true_extent)));
+ tmp_buf[k] = smpi_get_tmp_sendbuffer(count * std::max(extent, true_extent));
tmp_buf[k] = (void *)((char*)tmp_buf[k] - true_lb);
}
*/
#include "../colls_private.hpp"
+#include <algorithm>
+
#define MV2_INTRA_SHMEM_REDUCE_MSG 2048
#define mv2_g_shmem_coll_max_msg_size (1 << 17)
datatype->extent(&true_lb,
&true_extent);
extent =datatype->get_extent();
- stride = count * MAX(extent, true_extent);
+ stride = count * std::max(extent, true_extent);
if (local_size == total_size) {
/* First handle the case where there is only one node */
if (stride <= MV2_INTRA_SHMEM_REDUCE_MSG &&
is_commutative == 1) {
if (local_rank == 0 ) {
- tmp_buf=(void *)smpi_get_tmp_sendbuffer( count *
- (MAX(extent, true_extent)));
+ tmp_buf = (void*)smpi_get_tmp_sendbuffer(count * std::max(extent, true_extent));
tmp_buf = (void *) ((char *) tmp_buf - true_lb);
}
out_buf = NULL;
}
- if (count * (MAX(extent, true_extent)) < SHMEM_COLL_BLOCK_SIZE) {
+ if (count * (std::max(extent, true_extent)) < SHMEM_COLL_BLOCK_SIZE) {
mpi_errno = MPIR_Reduce_shmem_MV2(in_buf, out_buf, count, datatype, op, 0, shmem_comm);
} else {
mpi_errno = MPIR_Reduce_intra_knomial_wrapper_MV2(in_buf, out_buf, count, datatype, op, 0, shmem_comm);
}
leader_comm_size = leader_comm->size();
leader_comm_rank = leader_comm->rank();
- tmp_buf=(void *)smpi_get_tmp_sendbuffer(count *
- (MAX(extent, true_extent)));
+ tmp_buf = (void*)smpi_get_tmp_sendbuffer(count * std::max(extent, true_extent));
tmp_buf = (void *) ((char *) tmp_buf - true_lb);
}
if (sendbuf != MPI_IN_PLACE) {
*this step*/
if (MV2_Reduce_intra_function == & MPIR_Reduce_shmem_MV2)
{
- if (is_commutative == 1 && (count * (MAX(extent, true_extent)) < SHMEM_COLL_BLOCK_SIZE)) {
+ if (is_commutative == 1 && (count * (std::max(extent, true_extent)) < SHMEM_COLL_BLOCK_SIZE)) {
mpi_errno = MV2_Reduce_intra_function(in_buf, out_buf, count, datatype, op, intra_node_root, shmem_comm);
} else {
mpi_errno = MPIR_Reduce_intra_knomial_wrapper_MV2(in_buf, out_buf, count,
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "../colls_private.hpp"
+#include <algorithm>
static inline int MPIU_Mirror_permutation(unsigned int x, int bits)
{
}
/* allocate temporary buffer to store incoming data */
- tmp_recvbuf = (void*)smpi_get_tmp_recvbuffer(recvcounts[rank]*(MAX(true_extent,extent))+1);
+ tmp_recvbuf = (void*)smpi_get_tmp_recvbuffer(recvcounts[rank] * std::max(true_extent, extent) + 1);
/* adjust for potential negative lower bound in datatype */
tmp_recvbuf = (void *)((char*)tmp_recvbuf - true_lb);
/* noncommutative and (non-pof2 or block irregular), use recursive doubling. */
/* need to allocate temporary buffer to receive incoming data*/
- tmp_recvbuf= (void *) smpi_get_tmp_recvbuffer( total_count*(MAX(true_extent,extent)));
+ tmp_recvbuf= (void*)smpi_get_tmp_recvbuffer(total_count * std::max(true_extent, extent));
/* adjust for potential negative lower bound in datatype */
tmp_recvbuf = (void *)((char*)tmp_recvbuf - true_lb);
/* need to allocate another temporary buffer to accumulate
results */
- tmp_results = (void *)smpi_get_tmp_sendbuffer( total_count*(MAX(true_extent,extent)));
+ tmp_results = (void*)smpi_get_tmp_sendbuffer(total_count * std::max(true_extent, extent));
/* adjust for potential negative lower bound in datatype */
tmp_results = (void *)((char*)tmp_results - true_lb);
#include "StorageImpl.hpp"
#include "surf_private.hpp"
+#include <algorithm>
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/split.hpp>
StorageImpl::StorageImpl(Model* model, std::string name, lmm_system_t maxminSystem, double bread, double bwrite,
std::string type_id, std::string content_name, sg_size_t size, std::string attach)
- : Resource(model, name.c_str(), lmm_constraint_new(maxminSystem, this, MAX(bread, bwrite)))
+ : Resource(model, name.c_str(), lmm_constraint_new(maxminSystem, this, std::max(bread, bwrite)))
, piface_(this)
, typeId_(type_id)
, size_(size)
#include "cpu_ti.hpp"
#include "maxmin_private.hpp"
#include "simgrid/sg_config.h"
+#include <algorithm>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu_cas, surf_cpu, "Logging specific to the SURF CPU IMPROVED module");
CpuAction *CpuCas01::sleep(double duration)
{
if (duration > 0)
- duration = MAX(duration, sg_surf_precision);
+ duration = std::max(duration, sg_surf_precision);
XBT_IN("(%s,%g)", getCname(), duration);
CpuCas01Action* action = new CpuCas01Action(model(), 1.0, isOff(), speed_.scale * speed_.peak, constraint());
#include "cpu_ti.hpp"
#include "src/surf/trace_mgr.hpp"
+#include <algorithm>
#ifndef SURF_MODEL_CPUTI_H_
#define SURF_MODEL_CPUTI_H_
CpuAction *CpuTi::sleep(double duration)
{
if (duration > 0)
- duration = MAX(duration, sg_surf_precision);
+ duration = std::max(duration, sg_surf_precision);
XBT_IN("(%s,%g)", getCname(), duration);
CpuTiAction* action = new CpuTiAction(static_cast<CpuTiModel*>(model()), 1.0, isOff(), this);
double min_inc = DBL_MAX;
for (s_lmm_element_t const& elm : var->cnsts) {
if (elm.consumption_weight > 0)
- min_inc = MIN(min_inc, elm.constraint->usage / elm.consumption_weight);
+ min_inc = std::min(min_inc, elm.constraint->usage / elm.consumption_weight);
}
if (var->bound > 0)
- min_inc = MIN(min_inc, var->bound - var->value);
+ min_inc = std::min(min_inc, var->bound - var->value);
var->mu = min_inc;
XBT_DEBUG("Updating variable %p maximum increment: %g", var, var->mu);
var->value += var->mu;
} else {
XBT_DEBUG("\tNon-Shared variable. Update constraint usage of %p (%g) with variable %p by %g",
cnst, cnst->usage, elem->variable, elem->variable->mu);
- cnst->usage = MIN(cnst->usage, elem->consumption_weight * elem->variable->mu);
+ cnst->usage = std::min(cnst->usage, elem->consumption_weight * elem->variable->mu);
}
}
if (not cnst->sharing_policy) {
else {
tmp = new_value(var);
- overall_modification = MAX(overall_modification, fabs(var->value - tmp));
+ overall_modification = std::max(overall_modification, fabs(var->value - tmp));
var->value = tmp;
XBT_DEBUG("New value of var (%p) = %e, overall_modification = %e", var, var->value, overall_modification);
if (cnst->sharing_policy)
elem.consumption_weight += value;
else
- elem.consumption_weight = MAX(elem.consumption_weight, value);
+ elem.consumption_weight = std::max(elem.consumption_weight, value);
//We need to check that increasing value of the element does not cross the concurrency limit
if (var->sharing_weight) {
if(cnst->sharing_policy)
sum += elem->consumption_weight * elem->variable->value;
else
- sum = MAX(sum, elem->consumption_weight * elem->variable->value);
+ sum = std::max(sum, elem->consumption_weight * elem->variable->value);
}
//TODO: Adding disabled elements only for test compatibility, but do we really want them to be printed?
elem_list = &(cnst->disabled_element_set);
if(cnst->sharing_policy)
sum += elem->consumption_weight * elem->variable->value;
else
- sum = MAX(sum, elem->consumption_weight * elem->variable->value);
+ sum = std::max(sum, elem->consumption_weight * elem->variable->value);
}
buf = buf + "0) <= " + std::to_string(cnst->bound) + " ('" + std::to_string(cnst->id_int) + "')";
if (min_bound < 0)
min_bound = var->bound * var->sharing_weight;
else
- min_bound = MIN(min_bound, (var->bound * var->sharing_weight));
+ min_bound = std::min(min_bound, (var->bound * var->sharing_weight));
XBT_DEBUG("Updated min_bound=%f", min_bound);
}
}
if (elem2->variable->value > 0)
continue;
if (elem2->consumption_weight > 0)
- cnst->usage = MAX(cnst->usage, elem2->consumption_weight / elem2->variable->sharing_weight);
+ cnst->usage = std::max(cnst->usage, elem2->consumption_weight / elem2->variable->sharing_weight);
}
//If the constraint is saturated, remove it from the set of active constraints (light_tab)
if (not double_positive(cnst->usage, sg_maxmin_precision) ||
std::vector<LinkImpl*> route;
hostList_->at(i)->routeTo(hostList_->at(j), route, &lat);
- latency = MAX(latency, lat);
+ latency = std::max(latency, lat);
for (auto const& link : route)
affected_links.insert(link->getCname());
std::vector<LinkImpl*> route;
hostList_->at(i)->routeTo(hostList_->at(j), route, &lat);
- lat_current = MAX(lat_current, lat * communicationAmount_[i * hostNb + j]);
+ lat_current = std::max(lat_current, lat * communicationAmount_[i * hostNb + j]);
}
}
}
#include "simgrid/s4u/Engine.hpp"
#include "src/instr/instr_private.hpp"
#include "src/plugins/vm/VirtualMachineImpl.hpp"
+#include <algorithm>
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_kernel);
if (not surf_network_model->nextOccuringEventIsIdempotent()) { // NS3, I see you
if (next_event_date != -1.0) {
- time_delta = MIN(next_event_date - NOW, time_delta);
+ time_delta = std::min(next_event_date - NOW, time_delta);
} else {
- time_delta = MAX(next_event_date - NOW, time_delta); // Get the positive component
+ time_delta = std::max(next_event_date - NOW, time_delta); // Get the positive component
}
XBT_DEBUG("Run the NS3 network at most %fs", time_delta);
#include "xbt/log.h"
#include "xbt/module.h"
#include "xbt/sysdep.h"
+#include <algorithm>
#include <cmath>
XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example");
lagrange_solve(Sys);
double max_deviation = 0.0;
- max_deviation = MAX(max_deviation, fabs(lmm_variable_getvalue(R_1) - x));
- max_deviation = MAX(max_deviation, fabs(lmm_variable_getvalue(R_3) - x));
- max_deviation = MAX(max_deviation, fabs(lmm_variable_getvalue(R_2) - (b - a + x)));
- max_deviation = MAX(max_deviation, fabs(lmm_variable_getvalue(R_1_2_3) - (a - x)));
+ max_deviation = std::max(max_deviation, fabs(lmm_variable_getvalue(R_1) - x));
+ max_deviation = std::max(max_deviation, fabs(lmm_variable_getvalue(R_3) - x));
+ max_deviation = std::max(max_deviation, fabs(lmm_variable_getvalue(R_2) - (b - a + x)));
+ max_deviation = std::max(max_deviation, fabs(lmm_variable_getvalue(R_1_2_3) - (a - x)));
if (max_deviation > 0.00001) { // Legacy value used in lagrange.c
XBT_WARN("Max Deviation from optimal solution : %g", max_deviation);