File indexing completed on 2024-11-15 09:58:26
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef __TBB_blocked_range3d_H
0018 #define __TBB_blocked_range3d_H
0019
0020 #include "tbb_stddef.h"
0021 #include "blocked_range.h"
0022
0023 namespace tbb {
0024
0025
0026
0027 template<typename PageValue, typename RowValue=PageValue, typename ColValue=RowValue>
0028 class blocked_range3d {
0029 public:
0030
0031 typedef blocked_range<PageValue> page_range_type;
0032 typedef blocked_range<RowValue> row_range_type;
0033 typedef blocked_range<ColValue> col_range_type;
0034
0035 private:
0036 page_range_type my_pages;
0037 row_range_type my_rows;
0038 col_range_type my_cols;
0039
0040 public:
0041
0042 blocked_range3d( PageValue page_begin, PageValue page_end,
0043 RowValue row_begin, RowValue row_end,
0044 ColValue col_begin, ColValue col_end ) :
0045 my_pages(page_begin,page_end),
0046 my_rows(row_begin,row_end),
0047 my_cols(col_begin,col_end)
0048 {}
0049
0050 blocked_range3d( PageValue page_begin, PageValue page_end, typename page_range_type::size_type page_grainsize,
0051 RowValue row_begin, RowValue row_end, typename row_range_type::size_type row_grainsize,
0052 ColValue col_begin, ColValue col_end, typename col_range_type::size_type col_grainsize ) :
0053 my_pages(page_begin,page_end,page_grainsize),
0054 my_rows(row_begin,row_end,row_grainsize),
0055 my_cols(col_begin,col_end,col_grainsize)
0056 {}
0057
0058
0059 bool empty() const {
0060
0061 return my_pages.empty() || my_rows.empty() || my_cols.empty();
0062 }
0063
0064
0065 bool is_divisible() const {
0066 return my_pages.is_divisible() || my_rows.is_divisible() || my_cols.is_divisible();
0067 }
0068
0069 blocked_range3d( blocked_range3d& r, split ) :
0070 my_pages(r.my_pages),
0071 my_rows(r.my_rows),
0072 my_cols(r.my_cols)
0073 {
0074 split split_obj;
0075 do_split(r, split_obj);
0076 }
0077
0078 #if __TBB_USE_PROPORTIONAL_SPLIT_IN_BLOCKED_RANGES
0079
0080 static const bool is_splittable_in_proportion = true;
0081
0082 blocked_range3d( blocked_range3d& r, proportional_split& proportion ) :
0083 my_pages(r.my_pages),
0084 my_rows(r.my_rows),
0085 my_cols(r.my_cols)
0086 {
0087 do_split(r, proportion);
0088 }
0089 #endif
0090
0091
0092 const page_range_type& pages() const {return my_pages;}
0093
0094
0095 const row_range_type& rows() const {return my_rows;}
0096
0097
0098 const col_range_type& cols() const {return my_cols;}
0099
0100 private:
0101
0102 template <typename Split>
0103 void do_split( blocked_range3d& r, Split& split_obj)
0104 {
0105 if ( my_pages.size()*double(my_rows.grainsize()) < my_rows.size()*double(my_pages.grainsize()) ) {
0106 if ( my_rows.size()*double(my_cols.grainsize()) < my_cols.size()*double(my_rows.grainsize()) ) {
0107 my_cols.my_begin = col_range_type::do_split(r.my_cols, split_obj);
0108 } else {
0109 my_rows.my_begin = row_range_type::do_split(r.my_rows, split_obj);
0110 }
0111 } else {
0112 if ( my_pages.size()*double(my_cols.grainsize()) < my_cols.size()*double(my_pages.grainsize()) ) {
0113 my_cols.my_begin = col_range_type::do_split(r.my_cols, split_obj);
0114 } else {
0115 my_pages.my_begin = page_range_type::do_split(r.my_pages, split_obj);
0116 }
0117 }
0118 }
0119 };
0120
0121 }
0122
0123 #endif