STXXL  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
async_schedule.h
Go to the documentation of this file.
1 /***************************************************************************
2  * include/stxxl/bits/algo/async_schedule.h
3  *
4  * Part of the STXXL. See http://stxxl.sourceforge.net
5  *
6  * Copyright (C) 2002 Roman Dementiev <[email protected]>
7  * Copyright (C) 2009 Andreas Beckmann <[email protected]>
8  *
9  * Distributed under the Boost Software License, Version 1.0.
10  * (See accompanying file LICENSE_1_0.txt or copy at
11  * http://www.boost.org/LICENSE_1_0.txt)
12  **************************************************************************/
13 
14 #ifndef STXXL_ALGO_ASYNC_SCHEDULE_HEADER
15 #define STXXL_ALGO_ASYNC_SCHEDULE_HEADER
16 
17 // Implements the "prudent prefetching" as described in
18 // D. Hutchinson, P. Sanders, J. S. Vitter: Duality between prefetching
19 // and queued writing on parallel disks, 2005
20 // DOI: 10.1137/S0097539703431573
21 
23 #include <stxxl/bits/namespace.h>
24 
26 
28  const int_type* first,
29  const int_type* last,
30  int_type* out_first,
31  int_type m,
32  int_type D);
33 
35  int_type* first,
36  int_type* last,
37  int_type* out_first,
38  int_type m,
39  int_type D)
40 {
41  compute_prefetch_schedule(static_cast<const int_type*>(first), last, out_first, m, D);
42 }
43 
44 template <typename run_type>
46  const run_type& input,
47  int_type* out_first,
48  int_type m,
49  int_type D)
50 {
51  const int_type L = input.size();
52  int_type* disks = new int_type[L];
53  for (int_type i = 0; i < L; ++i)
54  disks[i] = input[i].bid.storage->get_physical_device_id();
55  compute_prefetch_schedule(disks, disks + L, out_first, m, D);
56  delete[] disks;
57 }
58 
59 template <typename bid_iterator_type>
61  bid_iterator_type input_begin,
62  bid_iterator_type input_end,
63  int_type* out_first,
64  int_type m,
65  int_type D)
66 {
67  const int_type L = input_end - input_begin;
68  int_type* disks = new int_type[L];
69  int_type i = 0;
70  for (bid_iterator_type it = input_begin; it != input_end; ++it, ++i)
71  disks[i] = it->storage->get_physical_device_id();
72  compute_prefetch_schedule(disks, disks + L, out_first, m, D);
73  delete[] disks;
74 }
75 
77 
78 #endif // !STXXL_ALGO_ASYNC_SCHEDULE_HEADER
79 // vim: et:ts=4:sw=4
choose_int_types< my_pointer_size >::int_type int_type
Definition: types.h:66
#define STXXL_BEGIN_NAMESPACE
Definition: namespace.h:16
void compute_prefetch_schedule(const int_type *first, const int_type *last, int_type *out_first, int_type m, int_type D)
#define STXXL_END_NAMESPACE
Definition: namespace.h:17