blocked_range3d.h

00001 /*
00002     Copyright 2005-2009 Intel Corporation.  All Rights Reserved.
00003 
00004     The source code contained or described herein and all documents related
00005     to the source code ("Material") are owned by Intel Corporation or its
00006     suppliers or licensors.  Title to the Material remains with Intel
00007     Corporation or its suppliers and licensors.  The Material is protected
00008     by worldwide copyright laws and treaty provisions.  No part of the
00009     Material may be used, copied, reproduced, modified, published, uploaded,
00010     posted, transmitted, distributed, or disclosed in any way without
00011     Intel's prior express written permission.
00012 
00013     No license under any patent, copyright, trade secret or other
00014     intellectual property right is granted to or conferred upon you by
00015     disclosure or delivery of the Materials, either expressly, by
00016     implication, inducement, estoppel or otherwise.  Any license under such
00017     intellectual property rights must be express and approved by Intel in
00018     writing.
00019 */
00020 
00021 #ifndef __TBB_blocked_range3d_H
00022 #define __TBB_blocked_range3d_H
00023 
00024 #include "tbb_stddef.h"
00025 #include "blocked_range.h"
00026 
00027 namespace tbb {
00028 
00030 
00031 template<typename PageValue, typename RowValue=PageValue, typename ColValue=RowValue>
00032 class blocked_range3d {
00033 public:
00035     typedef blocked_range<PageValue> page_range_type;
00036     typedef blocked_range<RowValue>  row_range_type;
00037     typedef blocked_range<ColValue>  col_range_type;
00038  
00039 private:
00040     page_range_type my_pages;
00041     row_range_type  my_rows;
00042     col_range_type  my_cols;
00043 
00044 public:
00045 
00046     blocked_range3d( PageValue page_begin, PageValue page_end,
00047                      RowValue  row_begin,  RowValue row_end,
00048                      ColValue  col_begin,  ColValue col_end ) : 
00049         my_pages(page_begin,page_end),
00050         my_rows(row_begin,row_end),
00051         my_cols(col_begin,col_end)
00052     {
00053     }
00054 
00055     blocked_range3d( PageValue page_begin, PageValue page_end, typename page_range_type::size_type page_grainsize, 
00056                      RowValue  row_begin,  RowValue row_end,   typename row_range_type::size_type row_grainsize,
00057                      ColValue  col_begin,  ColValue col_end,   typename col_range_type::size_type col_grainsize ) :  
00058         my_pages(page_begin,page_end,page_grainsize),
00059         my_rows(row_begin,row_end,row_grainsize),
00060         my_cols(col_begin,col_end,col_grainsize)
00061     {
00062     }
00063 
00065     bool empty() const {
00066         // Yes, it is a logical OR here, not AND.
00067         return my_pages.empty() || my_rows.empty() || my_cols.empty();
00068     }
00069 
00071     bool is_divisible() const {
00072         return  my_pages.is_divisible() || my_rows.is_divisible() || my_cols.is_divisible();
00073     }
00074 
00075     blocked_range3d( blocked_range3d& r, split ) : 
00076         my_pages(r.my_pages),
00077         my_rows(r.my_rows),
00078         my_cols(r.my_cols)
00079     {
00080         if( my_pages.size()*double(my_rows.grainsize()) < my_rows.size()*double(my_pages.grainsize()) ) {
00081             if ( my_rows.size()*double(my_cols.grainsize()) < my_cols.size()*double(my_rows.grainsize()) ) {
00082                 my_cols.my_begin = col_range_type::do_split(r.my_cols);
00083             } else {
00084                 my_rows.my_begin = row_range_type::do_split(r.my_rows);
00085             }
00086         } else {
00087             if ( my_pages.size()*double(my_cols.grainsize()) < my_cols.size()*double(my_pages.grainsize()) ) {
00088                 my_cols.my_begin = col_range_type::do_split(r.my_cols);
00089             } else {
00090                     my_pages.my_begin = page_range_type::do_split(r.my_pages);
00091             }
00092         }
00093     }
00094 
00096     const page_range_type& pages() const {return my_pages;}
00097 
00099     const row_range_type& rows() const {return my_rows;}
00100 
00102     const col_range_type& cols() const {return my_cols;}
00103 
00104 };
00105 
00106 } // namespace tbb 
00107 
00108 #endif /* __TBB_blocked_range3d_H */

Copyright © 2005-2009 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.