1 // Copyright (c) 2014 Hartmut Kaiser 2 // 3 // Distributed under the Boost Software License, Version 1.0. (See accompanying 4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6 #if !defined(HPX_UTIL_CALCULATE_FANOUT_APR_23_2014_0124PM) 7 #define HPX_UTIL_CALCULATE_FANOUT_APR_23_2014_0124PM 8 9 #include <cstddef> 10 11 namespace hpx { namespace util 12 { 13 inline std::size_t calculate_fanout(std::size_t size,std::size_t local_fanout)14 calculate_fanout(std::size_t size, std::size_t local_fanout) 15 { 16 if (size == 0 || local_fanout == 0) 17 return 1; 18 if (size <= local_fanout) 19 return size; 20 21 std::size_t fanout = 1; 22 size -= local_fanout; 23 while (fanout < size) 24 { 25 fanout *= local_fanout; 26 } 27 return fanout; 28 } 29 }} 30 31 #endif 32