Stxxl  1.3.2
sort_base.h
1 /***************************************************************************
2  * include/stxxl/bits/algo/sort_base.h
3  *
4  * Part of the STXXL. See http://stxxl.sourceforge.net
5  *
6  * Copyright (C) 2009 Andreas Beckmann <[email protected]>
7  *
8  * Distributed under the Boost Software License, Version 1.0.
9  * (See accompanying file LICENSE_1_0.txt or copy at
10  * http://www.boost.org/LICENSE_1_0.txt)
11  **************************************************************************/
12 
13 #ifndef STXXL_SORT_BASE_HEADER
14 #define STXXL_SORT_BASE_HEADER
15 
16 #include <cmath>
17 #include <stxxl/bits/common/types.h>
18 
19 
20 #ifndef STXXL_NO_WARN_RECURSIVE_SORT
21 #define STXXL_WARNMSG_RECURSIVE_SORT STXXL_ERRMSG
22 #else
23 #define STXXL_WARNMSG_RECURSIVE_SORT STXXL_VERBOSE
24 #endif
25 
26 #ifndef STXXL_SORT_OPTIMAL_PREFETCHING
27 #define STXXL_SORT_OPTIMAL_PREFETCHING 1
28 #endif
29 
30 #ifndef STXXL_CHECK_ORDER_IN_SORTS
31 #define STXXL_CHECK_ORDER_IN_SORTS 0
32 #endif
33 
34 #ifndef STXXL_L2_SIZE
35 #define STXXL_L2_SIZE (512 * 1024)
36 #endif
37 
38 __STXXL_BEGIN_NAMESPACE
39 
40 // Optimal merging: merge r = pow(nruns,1/ceil(log(nruns)/log(m))) runs at once
41 inline unsigned_type optimal_merge_factor(unsigned_type num_runs, unsigned_type max_concurrent_runs)
42 {
43  return unsigned_type(ceil(pow(num_runs, 1. / ceil(log(double(num_runs)) / log(double(max_concurrent_runs))))));
44 }
45 
46 __STXXL_END_NAMESPACE
47 
48 #endif // !STXXL_SORT_BASE_HEADER
49 // vim: et:ts=4:sw=4