Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/oneapi/tbb/blocked_range3d.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     Copyright (c) 2005-2021 Intel Corporation
0003 
0004     Licensed under the Apache License, Version 2.0 (the "License");
0005     you may not use this file except in compliance with the License.
0006     You may obtain a copy of the License at
0007 
0008         http://www.apache.org/licenses/LICENSE-2.0
0009 
0010     Unless required by applicable law or agreed to in writing, software
0011     distributed under the License is distributed on an "AS IS" BASIS,
0012     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0013     See the License for the specific language governing permissions and
0014     limitations under the License.
0015 */
0016 
0017 #ifndef __TBB_blocked_range3d_H
0018 #define __TBB_blocked_range3d_H
0019 
0020 #include <cstddef>
0021 
0022 #include "detail/_config.h"
0023 #include "detail/_namespace_injection.h"
0024 
0025 #include "blocked_range.h"
0026 
0027 namespace tbb {
0028 namespace detail {
0029 namespace d1 {
0030 
0031 //! A 3-dimensional range that models the Range concept.
0032 /** @ingroup algorithms */
0033 template<typename PageValue, typename RowValue = PageValue, typename ColValue = RowValue>
0034     __TBB_requires(blocked_range_value<PageValue> &&
0035                    blocked_range_value<RowValue> &&
0036                    blocked_range_value<ColValue>)
0037 class blocked_range3d {
0038 public:
0039     //! Type for size of an iteration range
0040     using page_range_type = blocked_range<PageValue>;
0041     using row_range_type = blocked_range<RowValue>;
0042     using col_range_type = blocked_range<ColValue>;
0043 
0044 private:
0045     page_range_type my_pages;
0046     row_range_type  my_rows;
0047     col_range_type  my_cols;
0048 
0049 public:
0050 
0051     blocked_range3d( PageValue page_begin, PageValue page_end,
0052                      RowValue  row_begin,  RowValue row_end,
0053                      ColValue  col_begin,  ColValue col_end ) :
0054         my_pages(page_begin,page_end),
0055         my_rows(row_begin,row_end),
0056         my_cols(col_begin,col_end)
0057     {}
0058 
0059     blocked_range3d( PageValue page_begin, PageValue page_end, typename page_range_type::size_type page_grainsize,
0060                      RowValue  row_begin,  RowValue row_end,   typename row_range_type::size_type row_grainsize,
0061                      ColValue  col_begin,  ColValue col_end,   typename col_range_type::size_type col_grainsize ) :
0062         my_pages(page_begin,page_end,page_grainsize),
0063         my_rows(row_begin,row_end,row_grainsize),
0064         my_cols(col_begin,col_end,col_grainsize)
0065     {}
0066 
0067     //! True if range is empty
0068     bool empty() const {
0069         // Range is empty if at least one dimension is empty.
0070         return my_pages.empty() || my_rows.empty() || my_cols.empty();
0071     }
0072 
0073     //! True if range is divisible into two pieces.
0074     bool is_divisible() const {
0075         return  my_pages.is_divisible() || my_rows.is_divisible() || my_cols.is_divisible();
0076     }
0077 
0078     blocked_range3d( blocked_range3d& r, split split_obj ) :
0079         my_pages(r.my_pages),
0080         my_rows(r.my_rows),
0081         my_cols(r.my_cols)
0082     {
0083         do_split(r, split_obj);
0084     }
0085 
0086     blocked_range3d( blocked_range3d& r, proportional_split& proportion ) :
0087         my_pages(r.my_pages),
0088         my_rows(r.my_rows),
0089         my_cols(r.my_cols)
0090     {
0091         do_split(r, proportion);
0092     }
0093 
0094     //! The pages of the iteration space
0095     const page_range_type& pages() const { return my_pages; }
0096 
0097     //! The rows of the iteration space
0098     const row_range_type& rows() const { return my_rows; }
0099 
0100     //! The columns of the iteration space
0101     const col_range_type& cols() const { return my_cols; }
0102 
0103 private:
0104     template <typename Split>
0105     void do_split( blocked_range3d& r, Split& split_obj) {
0106         if ( my_pages.size()*double(my_rows.grainsize()) < my_rows.size()*double(my_pages.grainsize()) ) {
0107             if ( my_rows.size()*double(my_cols.grainsize()) < my_cols.size()*double(my_rows.grainsize()) ) {
0108                 my_cols.my_begin = col_range_type::do_split(r.my_cols, split_obj);
0109             } else {
0110                 my_rows.my_begin = row_range_type::do_split(r.my_rows, split_obj);
0111             }
0112         } else {
0113             if ( my_pages.size()*double(my_cols.grainsize()) < my_cols.size()*double(my_pages.grainsize()) ) {
0114                 my_cols.my_begin = col_range_type::do_split(r.my_cols, split_obj);
0115             } else {
0116                 my_pages.my_begin = page_range_type::do_split(r.my_pages, split_obj);
0117             }
0118         }
0119     }
0120 };
0121 
0122 } // namespace d1
0123 } // namespace detail
0124 
0125 inline namespace v1 {
0126 using detail::d1::blocked_range3d;
0127 } // namespace v1
0128 } // namespace tbb
0129 
0130 #endif /* __TBB_blocked_range3d_H */