Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 5 additions & 23 deletions include/osp/auxiliary/misc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,36 +88,18 @@ inline bool isDisjoint(std::vector<intPair> &intervals) {

// computes power of an integer
template<typename T>
T intpow(T base, unsigned exp) {
constexpr T intpow(T base, unsigned exp) {
static_assert(std::is_integral<T>::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<typename T>
unsigned uintpow(T base, unsigned exp) {
static_assert(std::is_integral<T>::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;
Expand Down
6 changes: 3 additions & 3 deletions include/osp/bsp/model/BspArchitecture.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<Graph_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)
Expand Down
2 changes: 1 addition & 1 deletion tests/divisors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <boost/test/unit_test.hpp>

#include "osp/auxiliary/math/divisors.hpp"
Expand Down