From 2c78cd0309911928035698f274c96708379f1d37 Mon Sep 17 00:00:00 2001 From: Raphael Steiner Date: Fri, 21 Nov 2025 13:11:58 +0100 Subject: [PATCH] type fix in bspArch --- include/osp/auxiliary/misc.hpp | 28 ++++------------------- include/osp/bsp/model/BspArchitecture.hpp | 6 ++--- tests/divisors.cpp | 2 +- 3 files changed, 9 insertions(+), 27 deletions(-) diff --git a/include/osp/auxiliary/misc.hpp b/include/osp/auxiliary/misc.hpp index 7a0cd95e..56a95955 100644 --- a/include/osp/auxiliary/misc.hpp +++ b/include/osp/auxiliary/misc.hpp @@ -88,36 +88,18 @@ inline bool isDisjoint(std::vector &intervals) { // computes power of an integer template -T intpow(T base, unsigned exp) { +constexpr T intpow(T base, unsigned exp) { static_assert(std::is_integral::value); - if (exp == 0) { + if (exp == 0U) { return 1; } - if (exp == 1) { + if (exp == 1U) { return base; } - T tmp = intpow(base, exp / 2); - if (exp % 2 == 0) { - return tmp * tmp; - } - return base * tmp * tmp; -} - -template -unsigned uintpow(T base, unsigned exp) { - static_assert(std::is_integral::value); - - if (exp == 0) { - return 1; - } - if (exp == 1) { - return base; - } - - T tmp = intpow(base, exp / 2); - if (exp % 2 == 0) { + T tmp = intpow(base, exp / 2U); + if (exp % 2U == 0U) { return tmp * tmp; } return base * tmp * tmp; diff --git a/include/osp/bsp/model/BspArchitecture.hpp b/include/osp/bsp/model/BspArchitecture.hpp index 72762ce1..48f73f8a 100644 --- a/include/osp/bsp/model/BspArchitecture.hpp +++ b/include/osp/bsp/model/BspArchitecture.hpp @@ -265,13 +265,13 @@ class BspArchitecture { * * @param base The base value used to calculate the send cost. */ - void SetExpSendCost(unsigned int base) { + void SetExpSendCost(v_commw_t base) { isNuma = true; unsigned maxPos = 1; - const unsigned two = 2; - for (; uintpow(two, maxPos + 1) <= number_processors - 1; ++maxPos) { + constexpr unsigned two = 2; + for (; intpow(two, maxPos + 1) <= number_processors - 1; ++maxPos) { } for (unsigned i = 0; i < number_processors; ++i) for (unsigned j = i + 1; j < number_processors; ++j) diff --git a/tests/divisors.cpp b/tests/divisors.cpp index ca5ae86d..74eb43d7 100644 --- a/tests/divisors.cpp +++ b/tests/divisors.cpp @@ -16,7 +16,7 @@ limitations under the License. @author Toni Boehnlein, Benjamin Lozes, Pal Andras Papp, Raphael S. Steiner */ -#define BOOST_TEST_MODULE IntPower +#define BOOST_TEST_MODULE Divisor #include #include "osp/auxiliary/math/divisors.hpp"