Stxxl  1.4.0
mng/test_block_alloc_strategy.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002  *  mng/test_block_alloc_strategy.cpp
00003  *
00004  *  instantiate all block allocation strategies
00005  *
00006  *  Part of the STXXL. See http://stxxl.sourceforge.net
00007  *
00008  *  Copyright © 2008 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
00009  *
00010  *  Distributed under the Boost Software License, Version 1.0.
00011  *  (See accompanying file LICENSE_1_0.txt or copy at
00012  *  http://www.boost.org/LICENSE_1_0.txt)
00013  **************************************************************************/
00014 
00015 #include <stxxl/mng>
00016 #include <stxxl/bits/mng/block_alloc_interleaved.h>
00017 #include <stxxl/bits/common/error_handling.h>
00018 
00019 template <typename strategy>
00020 void test_strategy()
00021 {
00022     STXXL_MSG(STXXL_PRETTY_FUNCTION_NAME);
00023     strategy s0;
00024     strategy s2(1, 3);
00025     stxxl::offset_allocator<strategy> o(1, s0);
00026     typedef typename stxxl::interleaved_alloc_traits<strategy>::strategy interleaved;
00027     interleaved itl(23, strategy(1, 3));
00028     for (int i = 0; i < 16; ++i)
00029         STXXL_MSG(s0(i) << " " << s2(i) << " " << o(i) << " " << itl(i));
00030 
00031     int firstdisk = 0;
00032     int ndisks = 4;
00033     int nruns = 10;
00034     int runsize = 15;
00035     std::cout << "firstdisk=" << firstdisk << "  ndisks=" << ndisks << "  nruns=" << nruns << "  runsize=" << runsize;
00036     interleaved itl2(nruns, strategy(firstdisk, firstdisk + ndisks));
00037     for (int i = 0; i < nruns * runsize; ++i) {
00038         if (i % nruns == 0)
00039             std::cout << std::endl;
00040         std::cout << itl2(i) << " ";
00041     }
00042     std::cout << std::endl;
00043 }
00044 
00045 int main()
00046 {
00047     stxxl::config * cfg = stxxl::config::get_instance();
00048 
00049     // instantiate the allocation strategies
00050     STXXL_MSG("Number of disks: " << cfg->disks_number());
00051     for (unsigned i = 0; i < cfg->disks_number(); ++i)
00052         STXXL_MSG(cfg->disk_path(i) << ", " << cfg->disk_size(i) << ", " << cfg->disk_io_impl(i));
00053     test_strategy<stxxl::striping>();
00054     test_strategy<stxxl::FR>();
00055     test_strategy<stxxl::SR>();
00056     test_strategy<stxxl::RC>();
00057     STXXL_MSG("Regular disks: [" << cfg->regular_disk_range().first << "," << cfg->regular_disk_range().second << ")");
00058     if (cfg->regular_disk_range().first != cfg->regular_disk_range().second)
00059         test_strategy<stxxl::RC_disk>();
00060     STXXL_MSG("Flash devices: [" << cfg->flash_range().first << "," << cfg->flash_range().second << ")");
00061     if (cfg->flash_range().first != cfg->flash_range().second)
00062         test_strategy<stxxl::RC_flash>();
00063     test_strategy<stxxl::single_disk>();
00064 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines