blocked_range2d.h Source File

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

- File List
- File Members

# blocked_range2d.h

    00001 /*
    00002     Copyright 2005-2012 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_range2d_H
    00022 #define __TBB_blocked_range2d_H
    00023
    00024 #include "tbb_stddef.h"
    00025 #include "blocked_range.h"
    00026
    00027 namespace tbb {
    00028
    00030
    00031 template<typename RowValue, typename ColValue=RowValue>
    00032 class blocked_range2d {
    00033 public:
    00035     typedef blocked_range<RowValue> row_range_type;
    00036     typedef blocked_range<ColValue> col_range_type;
    00037
    00038 private:
    00039     row_range_type my_rows;
    00040     col_range_type my_cols;
    00041
    00042 public:
    00043
    00044     blocked_range2d( RowValue row_begin, RowValue row_end, typename row_range_type::size_type row_grainsize,
    00045                      ColValue col_begin, ColValue col_end, typename col_range_type::size_type col_grainsize ) :
    00046         my_rows(row_begin,row_end,row_grainsize),
    00047         my_cols(col_begin,col_end,col_grainsize)
    00048     {
    00049     }
    00050
    00051     blocked_range2d( RowValue row_begin, RowValue row_end,
    00052                      ColValue col_begin, ColValue col_end ) :
    00053         my_rows(row_begin,row_end),
    00054         my_cols(col_begin,col_end)
    00055     {
    00056     }
    00057
    00059     bool empty() const {
    00060         // Yes, it is a logical OR here, not AND.
    00061         return my_rows.empty() || my_cols.empty();
    00062     }
    00063
    00065     bool is_divisible() const {
    00066         return my_rows.is_divisible() || my_cols.is_divisible();
    00067     }
    00068
    00069     blocked_range2d( blocked_range2d& r, split ) :
    00070         my_rows(r.my_rows),
    00071         my_cols(r.my_cols)
    00072     {
    00073         if( my_rows.size()*double(my_cols.grainsize()) < my_cols.size()*double(my_rows.grainsize()) ) {
    00074             my_cols.my_begin = col_range_type::do_split(r.my_cols);
    00075         } else {
    00076             my_rows.my_begin = row_range_type::do_split(r.my_rows);
    00077         }
    00078     }
    00079
    00081     const row_range_type& rows() const {return my_rows;}
    00082
    00084     const col_range_type& cols() const {return my_cols;}
    00085 };
    00086
    00087 } // namespace tbb
    00088
    00089 #endif /* __TBB_blocked_range2d_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.