Skip to content

Commit 2c78cd0

Browse files
type fix in bspArch
1 parent d4771f5 commit 2c78cd0

3 files changed

Lines changed: 9 additions & 27 deletions

File tree

include/osp/auxiliary/misc.hpp

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -88,36 +88,18 @@ inline bool isDisjoint(std::vector<intPair> &intervals) {
8888

8989
// computes power of an integer
9090
template<typename T>
91-
T intpow(T base, unsigned exp) {
91+
constexpr T intpow(T base, unsigned exp) {
9292
static_assert(std::is_integral<T>::value);
9393

94-
if (exp == 0) {
94+
if (exp == 0U) {
9595
return 1;
9696
}
97-
if (exp == 1) {
97+
if (exp == 1U) {
9898
return base;
9999
}
100100

101-
T tmp = intpow(base, exp / 2);
102-
if (exp % 2 == 0) {
103-
return tmp * tmp;
104-
}
105-
return base * tmp * tmp;
106-
}
107-
108-
template<typename T>
109-
unsigned uintpow(T base, unsigned exp) {
110-
static_assert(std::is_integral<T>::value);
111-
112-
if (exp == 0) {
113-
return 1;
114-
}
115-
if (exp == 1) {
116-
return base;
117-
}
118-
119-
T tmp = intpow(base, exp / 2);
120-
if (exp % 2 == 0) {
101+
T tmp = intpow(base, exp / 2U);
102+
if (exp % 2U == 0U) {
121103
return tmp * tmp;
122104
}
123105
return base * tmp * tmp;

include/osp/bsp/model/BspArchitecture.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,13 +265,13 @@ class BspArchitecture {
265265
*
266266
* @param base The base value used to calculate the send cost.
267267
*/
268-
void SetExpSendCost(unsigned int base) {
268+
void SetExpSendCost(v_commw_t<Graph_t> base) {
269269

270270
isNuma = true;
271271

272272
unsigned maxPos = 1;
273-
const unsigned two = 2;
274-
for (; uintpow(two, maxPos + 1) <= number_processors - 1; ++maxPos) {
273+
constexpr unsigned two = 2;
274+
for (; intpow(two, maxPos + 1) <= number_processors - 1; ++maxPos) {
275275
}
276276
for (unsigned i = 0; i < number_processors; ++i)
277277
for (unsigned j = i + 1; j < number_processors; ++j)

tests/divisors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616
@author Toni Boehnlein, Benjamin Lozes, Pal Andras Papp, Raphael S. Steiner
1717
*/
1818

19-
#define BOOST_TEST_MODULE IntPower
19+
#define BOOST_TEST_MODULE Divisor
2020
#include <boost/test/unit_test.hpp>
2121

2222
#include "osp/auxiliary/math/divisors.hpp"

0 commit comments

Comments
 (0)