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