20 #ifndef GALOIS_RUNTIME_RANGE_H
21 #define GALOIS_RUNTIME_RANGE_H
25 #include <boost/iterator/counting_iterator.hpp>
27 #include "galois/config.h"
58 std::pair<block_iterator, block_iterator>
block_pair()
const {
63 std::pair<local_iterator, local_iterator>
local_pair()
const {
64 return std::make_pair(container->local_begin(), container->local_end());
79 template <
typename IterTy>
95 std::pair<block_iterator, block_iterator>
block_pair()
const {
100 std::pair<local_iterator, local_iterator>
local_pair()
const {
111 template <
typename IterTy>
121 template <
typename IterTy>
123 IterTy global_begin, global_end;
124 const uint32_t* thread_beginnings;
134 : global_begin(b), global_end(e), thread_beginnings(thread_ranges) {}
146 std::pair<block_iterator, block_iterator>
block_pair()
const {
153 assert(local_begin <= local_end);
155 if (thread_beginnings[total_threads] == *global_end && *global_begin == 0) {
156 return std::make_pair(local_begin, local_end);
171 if (local_begin < global_begin) {
174 if (local_end > global_end) {
178 if (left >= right || right <= left) {
179 left = right = global_end;
193 return std::make_pair(left, right);
197 std::pair<local_iterator, local_iterator>
local_pair()
const {
218 template <
typename IterTy>
220 const uint32_t* thread_ranges) {
233 template <
typename I,
bool IS_INTEGER = false>
234 class IteratorRangeMaker {
239 IteratorRangeMaker(
const I& beg,
const I& end) : m_beg(beg), m_end(end) {}
241 template <
typename Arg>
247 template <
typename I>
248 class IteratorRangeMaker<I, true> {
253 IteratorRangeMaker(
const I& beg,
const I& end) : m_beg(beg), m_end(end) {}
255 template <
typename Arg>
258 boost::counting_iterator<I>(m_end));
262 template <
typename T>
263 class InitListRangeMaker {
264 std::initializer_list<T> m_list;
267 explicit InitListRangeMaker(
const std::initializer_list<T>& l) : m_list(l) {}
269 template <
typename Arg>
275 template <
typename C,
bool HAS_LOCAL_RANGE = true>
276 class ContainerRangeMaker {
280 explicit ContainerRangeMaker(C& cont) : m_cont(cont) {}
282 template <
typename Arg>
288 template <
typename C>
289 class ContainerRangeMaker<C, false> {
294 explicit ContainerRangeMaker(C& cont) : m_cont(cont) {}
296 template <
typename Arg>
302 template <
typename C>
305 template <
typename T>
306 using CallExprType =
typename std::remove_reference<decltype(
307 std::declval<T>().local_begin())>::type;
309 template <
typename T>
310 static std::true_type go(
typename std::add_pointer<CallExprType<T>>::type);
312 template <
typename T>
313 static std::false_type go(...);
316 constexpr
static const bool value =
317 std::is_same<decltype(go<C>(
nullptr)), std::true_type>::value;
322 template <
typename C>
324 return internal::ContainerRangeMaker<C, internal::HasLocalIter<C>::value>(
328 template <
typename T>
329 auto iterate(std::initializer_list<T> initList) {
330 return internal::InitListRangeMaker<T>(initList);
333 template <
typename I>
335 return internal::IteratorRangeMaker<I, std::is_integral<I>::value>(beg, end);
StandardRange(IterTy b, IterTy e)
Definition: Range.h:90
iterator local_iterator
Definition: Range.h:128
SpecificRange(IterTy b, IterTy e, const uint32_t *thread_ranges)
Definition: Range.h:133
std::pair< IterTy, IterTy > block_range(IterTy b, IterTy e, unsigned id, unsigned num)
Returns a continuous block from the range based on the number of divisions and the id of the block re...
Definition: gstl.h:244
local_iterator local_begin() const
Definition: Range.h:104
iterator local_iterator
Definition: Range.h:85
LocalRange(T &c)
Definition: Range.h:50
local_iterator local_begin() const
Definition: Range.h:201
iterator end() const
Definition: Range.h:93
LocalRange< T > makeLocalRange(T &obj)
Definition: Range.h:75
block_iterator block_end() const
Definition: Range.h:205
iterator end() const
Definition: Range.h:53
T::iterator iterator
Definition: Range.h:45
SpecificRange< IterTy > makeSpecificRange(IterTy begin, IterTy end, const uint32_t *thread_ranges)
Creates a SpecificRange object.
Definition: Range.h:219
local_iterator local_end() const
Definition: Range.h:68
std::iterator_traits< iterator >::value_type value_type
Definition: Range.h:48
iterator block_iterator
Definition: Range.h:129
local_iterator local_begin() const
Definition: Range.h:67
block_iterator block_begin() const
Definition: Range.h:204
iterator end() const
Definition: Range.h:137
iterator begin() const
Definition: Range.h:92
std::pair< block_iterator, block_iterator > block_pair() const
Definition: Range.h:146
static unsigned getTID()
Definition: ThreadPool.h:204
IterTy iterator
Definition: Range.h:127
unsigned int activeThreads
Definition: Threads.cpp:26
block_iterator block_end() const
Definition: Range.h:108
iterator block_iterator
Definition: Range.h:47
block_iterator block_end() const
Definition: Range.h:71
local_iterator local_end() const
Definition: Range.h:105
void operator()(void)
Definition: Executor_ParaMeter.h:417
SpecificRange is a range type where a threads range is specified by an an int array that tells you wh...
Definition: Range.h:122
T & get_container() const
Definition: Range.h:56
std::pair< local_iterator, local_iterator > local_pair() const
Definition: Range.h:197
StandardRange< IterTy > makeStandardRange(IterTy begin, IterTy end)
Definition: Range.h:112
iterator begin() const
Definition: Range.h:52
local_iterator local_end() const
Definition: Range.h:202
T container_type
Definition: Range.h:44
IterTy iterator
Definition: Range.h:84
block_iterator block_begin() const
Definition: Range.h:107
std::iterator_traits< IterTy >::value_type value_type
Definition: Range.h:131
T::local_iterator local_iterator
Definition: Range.h:46
auto iterate(C &cont)
Definition: Range.h:323
std::pair< local_iterator, local_iterator > local_pair() const
Definition: Range.h:63
block_iterator block_begin() const
Definition: Range.h:70
T value_type
Definition: Executor_ParaMeter.h:111
std::pair< block_iterator, block_iterator > block_pair() const
Definition: Range.h:95
std::pair< local_iterator, local_iterator > local_pair() const
Definition: Range.h:100
std::iterator_traits< IterTy >::value_type value_type
Definition: Range.h:88
iterator block_iterator
Definition: Range.h:86
iterator begin() const
Definition: Range.h:136
std::pair< block_iterator, block_iterator > block_pair() const
Definition: Range.h:58