Stxxl  1.4.0
include/stxxl/bits/algo/async_schedule.h
Go to the documentation of this file.
00001 /***************************************************************************
00002  *  include/stxxl/bits/algo/async_schedule.h
00003  *
00004  *  Part of the STXXL. See http://stxxl.sourceforge.net
00005  *
00006  *  Copyright (C) 2002 Roman Dementiev <dementiev@mpi-sb.mpg.de>
00007  *  Copyright (C) 2009 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
00008  *
00009  *  Distributed under the Boost Software License, Version 1.0.
00010  *  (See accompanying file LICENSE_1_0.txt or copy at
00011  *  http://www.boost.org/LICENSE_1_0.txt)
00012  **************************************************************************/
00013 
00014 // Implements the "prudent prefetching" as described in
00015 // D. Hutchinson, P. Sanders, J. S. Vitter: Duality between prefetching
00016 // and queued writing on parallel disks, 2005
00017 // DOI: 10.1137/S0097539703431573
00018 
00019 
00020 #ifndef STXXL_ASYNC_SCHEDULE_HEADER
00021 #define STXXL_ASYNC_SCHEDULE_HEADER
00022 
00023 #include <stxxl/bits/common/types.h>
00024 
00025 
00026 __STXXL_BEGIN_NAMESPACE
00027 
00028 void compute_prefetch_schedule(
00029     const int_type * first,
00030     const int_type * last,
00031     int_type * out_first,
00032     int_type m,
00033     int_type D);
00034 
00035 inline void compute_prefetch_schedule(
00036     int_type * first,
00037     int_type * last,
00038     int_type * out_first,
00039     int_type m,
00040     int_type D)
00041 {
00042     compute_prefetch_schedule(static_cast<const int_type *>(first), last, out_first, m, D);
00043 }
00044 
00045 template <typename run_type>
00046 void compute_prefetch_schedule(
00047     const run_type & input,
00048     int_type * out_first,
00049     int_type m,
00050     int_type D)
00051 {
00052     const int_type L = input.size();
00053     int_type * disks = new int_type[L];
00054     for (int_type i = 0; i < L; ++i)
00055         disks[i] = input[i].bid.storage->get_physical_device_id();
00056     compute_prefetch_schedule(disks, disks + L, out_first, m, D);
00057     delete[] disks;
00058 }
00059 
00060 template <typename bid_iterator_type>
00061 void compute_prefetch_schedule(
00062     bid_iterator_type input_begin,
00063     bid_iterator_type input_end,
00064     int_type * out_first,
00065     int_type m,
00066     int_type D)
00067 {
00068     const int_type L = input_end - input_begin;
00069     int_type * disks = new int_type[L];
00070     int_type i = 0;
00071     for (bid_iterator_type it = input_begin; it != input_end; ++it, ++i)
00072         disks[i] = it->storage->get_physical_device_id();
00073     compute_prefetch_schedule(disks, disks + L, out_first, m, D);
00074     delete[] disks;
00075 }
00076 
00077 __STXXL_END_NAMESPACE
00078 
00079 #endif // !STXXL_ASYNC_SCHEDULE_HEADER
00080 // vim: et:ts=4:sw=4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines