From 95fcf20e6ef0f0cb449faddd00b5500bede028af Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 14 Nov 2017 18:31:24 +0100 Subject: [PATCH] Use std::min/std::max instead of MIN/MAX in C++ files. --- examples/s4u/app-bittorrent/s4u-peer.cpp | 5 +++-- examples/s4u/app-bittorrent/s4u-tracker.cpp | 3 ++- src/simdag/sd_task.cpp | 3 ++- src/simix/smx_network.cpp | 2 +- src/smpi/colls/allgatherv/allgatherv-mpich-rdb.cpp | 3 ++- src/smpi/colls/allreduce/allreduce-mvapich-rs.cpp | 4 +++- src/smpi/colls/gather/gather-mvapich.cpp | 12 +++++------- src/smpi/colls/reduce/reduce-binomial.cpp | 3 ++- src/smpi/colls/reduce/reduce-mvapich-knomial.cpp | 6 ++++-- src/smpi/colls/reduce/reduce-mvapich-two-level.cpp | 14 +++++++------- .../colls/reduce_scatter/reduce_scatter-mpich.cpp | 7 ++++--- src/surf/StorageImpl.cpp | 3 ++- src/surf/cpu_cas01.cpp | 3 ++- src/surf/cpu_ti.cpp | 3 ++- src/surf/fair_bottleneck.cpp | 6 +++--- src/surf/lagrange.cpp | 2 +- src/surf/maxmin.cpp | 10 +++++----- src/surf/ptask_L07.cpp | 4 ++-- src/surf/surf_c_bindings.cpp | 5 +++-- teshsuite/surf/lmm_usage/lmm_usage.cpp | 9 +++++---- 20 files changed, 60 insertions(+), 47 deletions(-) diff --git a/examples/s4u/app-bittorrent/s4u-peer.cpp b/examples/s4u/app-bittorrent/s4u-peer.cpp index 3225496027..8f9bc799cc 100644 --- a/examples/s4u/app-bittorrent/s4u-peer.cpp +++ b/examples/s4u/app-bittorrent/s4u-peer.cpp @@ -3,6 +3,7 @@ /* 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 #include #include @@ -20,7 +21,7 @@ XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_bt_peer, "Messages specific for the peers"); #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 @@ -163,7 +164,7 @@ void Peer::sendRequestTo(Connection* remote_peer, unsigned int piece) 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_ diff --git a/examples/s4u/app-bittorrent/s4u-tracker.cpp b/examples/s4u/app-bittorrent/s4u-tracker.cpp index d45095179c..129667980e 100644 --- a/examples/s4u/app-bittorrent/s4u-tracker.cpp +++ b/examples/s4u/app-bittorrent/s4u-tracker.cpp @@ -5,6 +5,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "s4u-tracker.hpp" +#include #include XBT_LOG_NEW_DEFAULT_CATEGORY(s4u_bt_tracker, "Messages specific for the tracker"); @@ -48,7 +49,7 @@ void Tracker::operator()() TrackerAnswer* ta = new TrackerAnswer(TRACKER_QUERY_INTERVAL); std::set::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 { diff --git a/src/simdag/sd_task.cpp b/src/simdag/sd_task.cpp index 84b9b74997..42b7142230 100644 --- a/src/simdag/sd_task.cpp +++ b/src/simdag/sd_task.cpp @@ -882,7 +882,8 @@ void SD_task_build_MxN_1D_block_matrix(SD_task_t task, int src_nb, int dst_nb){ 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]); } } diff --git a/src/simix/smx_network.cpp b/src/simix/smx_network.cpp index 30bd46ebce..fde74d4aef 100644 --- a/src/simix/smx_network.cpp +++ b/src/simix/smx_network.cpp @@ -690,7 +690,7 @@ void SIMIX_comm_copy_data(smx_activity_t synchro) /* 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) diff --git a/src/smpi/colls/allgatherv/allgatherv-mpich-rdb.cpp b/src/smpi/colls/allgatherv/allgatherv-mpich-rdb.cpp index c094c7d9a3..9174ad8731 100644 --- a/src/smpi/colls/allgatherv/allgatherv-mpich-rdb.cpp +++ b/src/smpi/colls/allgatherv/allgatherv-mpich-rdb.cpp @@ -8,6 +8,7 @@ #include "../colls_private.hpp" #include "smpi_status.hpp" +#include namespace simgrid{ namespace smpi{ @@ -48,7 +49,7 @@ int Coll_allgatherv_mpich_rdb::allgatherv ( 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); diff --git a/src/smpi/colls/allreduce/allreduce-mvapich-rs.cpp b/src/smpi/colls/allreduce/allreduce-mvapich-rs.cpp index 1711f3b432..32b254865c 100644 --- a/src/smpi/colls/allreduce/allreduce-mvapich-rs.cpp +++ b/src/smpi/colls/allreduce/allreduce-mvapich-rs.cpp @@ -22,6 +22,8 @@ */ #include "../colls_private.hpp" +#include + namespace simgrid{ namespace smpi{ int Coll_allreduce_mvapich2_rs::allreduce(void *sendbuf, @@ -53,7 +55,7 @@ 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); diff --git a/src/smpi/colls/gather/gather-mvapich.cpp b/src/smpi/colls/gather/gather-mvapich.cpp index 79b703569f..2ebd387a9f 100644 --- a/src/smpi/colls/gather/gather-mvapich.cpp +++ b/src/smpi/colls/gather/gather-mvapich.cpp @@ -36,6 +36,7 @@ */ #include "../colls_private.hpp" +#include #define MPIR_Gather_MV2_Direct Coll_gather_ompi_basic_linear::gather #define MPIR_Gather_MV2_two_level_Direct Coll_gather_ompi_basic_linear::gather @@ -223,12 +224,9 @@ int Coll_gather_mvapich2_two_level::gather(void *sendbuf, 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; @@ -291,10 +289,10 @@ int Coll_gather_mvapich2_two_level::gather(void *sendbuf, * 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; diff --git a/src/smpi/colls/reduce/reduce-binomial.cpp b/src/smpi/colls/reduce/reduce-binomial.cpp index d36c30f2f6..07abde4fdc 100644 --- a/src/smpi/colls/reduce/reduce-binomial.cpp +++ b/src/smpi/colls/reduce/reduce-binomial.cpp @@ -5,6 +5,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "../colls_private.hpp" +#include //#include namespace simgrid{ @@ -47,7 +48,7 @@ int Coll_reduce_binomial::reduce(void *sendbuf, void *recvbuf, int count, /* 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)) { diff --git a/src/smpi/colls/reduce/reduce-mvapich-knomial.cpp b/src/smpi/colls/reduce/reduce-mvapich-knomial.cpp index d5788fb0bf..90619c286f 100644 --- a/src/smpi/colls/reduce/reduce-mvapich-knomial.cpp +++ b/src/smpi/colls/reduce/reduce-mvapich-knomial.cpp @@ -39,6 +39,8 @@ */ #include "../colls_private.hpp" +#include + extern int mv2_reduce_intra_knomial_factor; extern int mv2_reduce_inter_knomial_factor; @@ -150,7 +152,7 @@ int Coll_reduce_mvapich2_knomial::reduce ( 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); } @@ -177,7 +179,7 @@ int Coll_reduce_mvapich2_knomial::reduce ( tmp_buf = static_cast(xbt_malloc(sizeof(void *)*expected_recv_count)); requests = static_cast(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); } diff --git a/src/smpi/colls/reduce/reduce-mvapich-two-level.cpp b/src/smpi/colls/reduce/reduce-mvapich-two-level.cpp index 3c3adc17a6..7a14eb4d38 100644 --- a/src/smpi/colls/reduce/reduce-mvapich-two-level.cpp +++ b/src/smpi/colls/reduce/reduce-mvapich-two-level.cpp @@ -36,6 +36,8 @@ */ #include "../colls_private.hpp" +#include + #define MV2_INTRA_SHMEM_REDUCE_MSG 2048 #define mv2_g_shmem_coll_max_msg_size (1 << 17) @@ -117,15 +119,14 @@ int Coll_reduce_mvapich2_two_level::reduce( void *sendbuf, 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); } @@ -150,7 +151,7 @@ int Coll_reduce_mvapich2_two_level::reduce( void *sendbuf, 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); @@ -189,8 +190,7 @@ int Coll_reduce_mvapich2_two_level::reduce( void *sendbuf, } 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) { @@ -214,7 +214,7 @@ int Coll_reduce_mvapich2_two_level::reduce( void *sendbuf, *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, diff --git a/src/smpi/colls/reduce_scatter/reduce_scatter-mpich.cpp b/src/smpi/colls/reduce_scatter/reduce_scatter-mpich.cpp index 995f078dc3..8061733e42 100644 --- a/src/smpi/colls/reduce_scatter/reduce_scatter-mpich.cpp +++ b/src/smpi/colls/reduce_scatter/reduce_scatter-mpich.cpp @@ -5,6 +5,7 @@ * under the terms of the license (GNU LGPL) which comes with this package. */ #include "../colls_private.hpp" +#include static inline int MPIU_Mirror_permutation(unsigned int x, int bits) { @@ -64,7 +65,7 @@ int Coll_reduce_scatter_mpich_pair::reduce_scatter(void *sendbuf, void *recvbuf, } /* 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); @@ -295,13 +296,13 @@ int Coll_reduce_scatter_mpich_rdb::reduce_scatter(void *sendbuf, void *recvbuf, /* 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); diff --git a/src/surf/StorageImpl.cpp b/src/surf/StorageImpl.cpp index a4ddf1b116..51d1368a93 100644 --- a/src/surf/StorageImpl.cpp +++ b/src/surf/StorageImpl.cpp @@ -7,6 +7,7 @@ #include "StorageImpl.hpp" #include "surf_private.hpp" +#include #include #include #include @@ -60,7 +61,7 @@ StorageModel::~StorageModel() 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) diff --git a/src/surf/cpu_cas01.cpp b/src/surf/cpu_cas01.cpp index e9655c4ecf..99707a2730 100644 --- a/src/surf/cpu_cas01.cpp +++ b/src/surf/cpu_cas01.cpp @@ -8,6 +8,7 @@ #include "cpu_ti.hpp" #include "maxmin_private.hpp" #include "simgrid/sg_config.h" +#include XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu_cas, surf_cpu, "Logging specific to the SURF CPU IMPROVED module"); @@ -173,7 +174,7 @@ CpuAction* CpuCas01::execution_start(double size, int requestedCores) 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()); diff --git a/src/surf/cpu_ti.cpp b/src/surf/cpu_ti.cpp index 0611e46a0d..942cfd235d 100644 --- a/src/surf/cpu_ti.cpp +++ b/src/surf/cpu_ti.cpp @@ -6,6 +6,7 @@ #include "cpu_ti.hpp" #include "src/surf/trace_mgr.hpp" +#include #ifndef SURF_MODEL_CPUTI_H_ #define SURF_MODEL_CPUTI_H_ @@ -604,7 +605,7 @@ CpuAction *CpuTi::execution_start(double size) 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(model()), 1.0, isOff(), this); diff --git a/src/surf/fair_bottleneck.cpp b/src/surf/fair_bottleneck.cpp index a61385c690..84be37fc03 100644 --- a/src/surf/fair_bottleneck.cpp +++ b/src/surf/fair_bottleneck.cpp @@ -115,10 +115,10 @@ void bottleneck_solve(lmm_system_t sys) 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; @@ -141,7 +141,7 @@ void bottleneck_solve(lmm_system_t sys) } 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) { diff --git a/src/surf/lagrange.cpp b/src/surf/lagrange.cpp index 2a25fdc3d3..447273bede 100644 --- a/src/surf/lagrange.cpp +++ b/src/surf/lagrange.cpp @@ -276,7 +276,7 @@ void lagrange_solve(lmm_system_t sys) 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); diff --git a/src/surf/maxmin.cpp b/src/surf/maxmin.cpp index cb02c9cbe9..1135631596 100644 --- a/src/surf/maxmin.cpp +++ b/src/surf/maxmin.cpp @@ -487,7 +487,7 @@ void lmm_expand_add(lmm_system_t sys, lmm_constraint_t cnst, lmm_variable_t var, 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) { @@ -662,7 +662,7 @@ void lmm_print(lmm_system_t sys) 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); @@ -673,7 +673,7 @@ void lmm_print(lmm_system_t sys) 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) + "')"; @@ -793,7 +793,7 @@ void lmm_solve(lmm_system_t sys) 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); } } @@ -853,7 +853,7 @@ void lmm_solve(lmm_system_t sys) 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) || diff --git a/src/surf/ptask_L07.cpp b/src/surf/ptask_L07.cpp index 9e252ee753..c62664e6e0 100644 --- a/src/surf/ptask_L07.cpp +++ b/src/surf/ptask_L07.cpp @@ -183,7 +183,7 @@ L07Action::L07Action(Model *model, int host_nb, sg_host_t *host_list, std::vector 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()); @@ -409,7 +409,7 @@ void L07Action::updateBound() std::vector 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]); } } } diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index 8bbd64268e..cac3a8698d 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -6,6 +6,7 @@ #include "simgrid/s4u/Engine.hpp" #include "src/instr/instr_private.hpp" #include "src/plugins/vm/VirtualMachineImpl.hpp" +#include XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_kernel); @@ -75,9 +76,9 @@ double surf_solve(double max_date) 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); diff --git a/teshsuite/surf/lmm_usage/lmm_usage.cpp b/teshsuite/surf/lmm_usage/lmm_usage.cpp index ac869f5653..71c2fd4c58 100644 --- a/teshsuite/surf/lmm_usage/lmm_usage.cpp +++ b/teshsuite/surf/lmm_usage/lmm_usage.cpp @@ -12,6 +12,7 @@ #include "xbt/log.h" #include "xbt/module.h" #include "xbt/sysdep.h" +#include #include XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example"); @@ -145,10 +146,10 @@ static void test1(method_t method) 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); -- 2.20.1