- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

# blocked_range3d.h

    00001 /*
    00002     Copyright 2005-2012 Intel Corporation.  All Rights Reserved.
    00003
    00004     This file is part of Threading Building Blocks.
    00005
    00006     Threading Building Blocks is free software; you can redistribute it
    00007     and/or modify it under the terms of the GNU General Public License
    00008     version 2 as published by the Free Software Foundation.
    00009
    00010     Threading Building Blocks is distributed in the hope that it will be
    00011     useful, but WITHOUT ANY WARRANTY; without even the implied warranty
    00012     of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00013     GNU General Public License for more details.
    00014
    00015     You should have received a copy of the GNU General Public License
    00016     along with Threading Building Blocks; if not, write to the Free Software
    00017     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    00018
    00019     As a special exception, you may use this file as part of a free software
    00020     library without restriction.  Specifically, if other files instantiate
    00021     templates or use macros or inline functions from this file, or you compile
    00022     this file and link it with other files to produce an executable, this
    00023     file does not by itself cause the resulting executable to be covered by
    00024     the GNU General Public License.  This exception does not however
    00025     invalidate any other reasons why the executable file might be covered by
    00026     the GNU General Public License.
    00027 */
    00028
    00029 #ifndef __TBB_blocked_range3d_H
    00030 #define __TBB_blocked_range3d_H
    00031
    00032 #include "tbb_stddef.h"
    00033 #include "blocked_range.h"
    00034
    00035 namespace tbb {
    00036
    00038
    00039 template<typename PageValue, typename RowValue=PageValue, typename ColValue=RowValue>
    00040 class blocked_range3d {
    00041 public:
    00043     typedef blocked_range<PageValue> page_range_type;
    00044     typedef blocked_range<RowValue>  row_range_type;
    00045     typedef blocked_range<ColValue>  col_range_type;
    00046
    00047 private:
    00048     page_range_type my_pages;
    00049     row_range_type  my_rows;
    00050     col_range_type  my_cols;
    00051
    00052 public:
    00053
    00054     blocked_range3d( PageValue page_begin, PageValue page_end,
    00055                      RowValue  row_begin,  RowValue row_end,
    00056                      ColValue  col_begin,  ColValue col_end ) :
    00057         my_pages(page_begin,page_end),
    00058         my_rows(row_begin,row_end),
    00059         my_cols(col_begin,col_end)
    00060     {
    00061     }
    00062
    00063     blocked_range3d( PageValue page_begin, PageValue page_end, typename page_range_type::size_type page_grainsize,
    00064                      RowValue  row_begin,  RowValue row_end,   typename row_range_type::size_type row_grainsize,
    00065                      ColValue  col_begin,  ColValue col_end,   typename col_range_type::size_type col_grainsize ) :
    00066         my_pages(page_begin,page_end,page_grainsize),
    00067         my_rows(row_begin,row_end,row_grainsize),
    00068         my_cols(col_begin,col_end,col_grainsize)
    00069     {
    00070     }
    00071
    00073     bool empty() const {
    00074         // Yes, it is a logical OR here, not AND.
    00075         return my_pages.empty() || my_rows.empty() || my_cols.empty();
    00076     }
    00077
    00079     bool is_divisible() const {
    00080         return  my_pages.is_divisible() || my_rows.is_divisible() || my_cols.is_divisible();
    00081     }
    00082
    00083     blocked_range3d( blocked_range3d& r, split ) :
    00084         my_pages(r.my_pages),
    00085         my_rows(r.my_rows),
    00086         my_cols(r.my_cols)
    00087     {
    00088         if( my_pages.size()*double(my_rows.grainsize()) < my_rows.size()*double(my_pages.grainsize()) ) {
    00089             if ( my_rows.size()*double(my_cols.grainsize()) < my_cols.size()*double(my_rows.grainsize()) ) {
    00090                 my_cols.my_begin = col_range_type::do_split(r.my_cols);
    00091             } else {
    00092                 my_rows.my_begin = row_range_type::do_split(r.my_rows);
    00093             }
    00094         } else {
    00095             if ( my_pages.size()*double(my_cols.grainsize()) < my_cols.size()*double(my_pages.grainsize()) ) {
    00096                 my_cols.my_begin = col_range_type::do_split(r.my_cols);
    00097             } else {
    00098                     my_pages.my_begin = page_range_type::do_split(r.my_pages);
    00099             }
    00100         }
    00101     }
    00102
    00104     const page_range_type& pages() const {return my_pages;}
    00105
    00107     const row_range_type& rows() const {return my_rows;}
    00108
    00110     const col_range_type& cols() const {return my_cols;}
    00111
    00112 };
    00113
    00114 } // namespace tbb
    00115
    00116 #endif /* __TBB_blocked_range3d_H */

Copyright © 2005-2012 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.