20 #ifndef MIRTK_Parallel_H 21 #define MIRTK_Parallel_H 23 #include "mirtk/CommonExport.h" 25 #include "mirtk/Stream.h" 26 #include "mirtk/Memory.h" 28 #ifndef MIRTK_COMMON_WITH_TBB_MALLOC 29 # define MIRTK_COMMON_WITH_TBB_MALLOC 0 36 # define MIRTK_UNDEF_NOMINMAX 38 # include <tbb/task_scheduler_init.h> 39 # include <tbb/blocked_range.h> 40 # include <tbb/blocked_range2d.h> 41 # include <tbb/blocked_range3d.h> 42 # include <tbb/parallel_for.h> 43 # include <tbb/parallel_reduce.h> 44 # include <tbb/concurrent_queue.h> 45 # if MIRTK_COMMON_WITH_TBB_MALLOC 46 # include <tbb/scalable_allocator.h> 47 # include <tbb/cache_aligned_allocator.h> 49 # include <tbb/mutex.h> 50 # ifdef MIRTK_UNDEF_NOMINMAX 51 # undef MIRTK_UNDEF_NOMINMAX 65 MIRTK_Common_EXPORT
extern bool use_gpu;
104 using tbb::task_scheduler_init;
105 using tbb::blocked_range;
106 using tbb::blocked_range2d;
107 using tbb::blocked_range3d;
108 using tbb::parallel_for;
109 using tbb::parallel_reduce;
110 using tbb::concurrent_queue;
114 #if MIRTK_COMMON_WITH_TBB_MALLOC 115 using tbb::scalable_allocator;
116 using tbb::cache_aligned_allocator;
126 MIRTK_Common_EXPORT
extern UniquePtr<task_scheduler_init> tbb_scheduler;
137 using scalable_allocator = std::allocator<T>;
140 using cache_aligned_allocator = std::allocator<T>;
154 template <
typename T>
162 T begin()
const {
return _lbound; }
163 T end()
const {
return _ubound; }
167 template <
typename T>
196 template <
typename T>
231 template <
class Range,
class Body>
237 template <
class Range,
class Body>
248 #endif // MIRTK_Parallel_H Dummy type used to distinguish split constructor from copy constructor.
MIRTK_Common_EXPORT int tbb_debug
Debugging level of TBB code.
void ParseParallelOption(int &, int &, char *[])
Parse parallelization option.
Helper for initialization of task scheduler.
bool IsParallelOption(const char *)
Check if given option is a parallelization option.
MIRTK_Common_EXPORT int debug_gpu
Debugging level of GPU code.
MIRTK_Common_EXPORT bool use_gpu
Enable/disable GPU acceleration.
void PrintParallelOptions(ostream &)
Print parallelization command-line options.
void parallel_reduce(const Range &range, Body &body)
parallel_reduce dummy template function which executes the body serially
void parallel_for(const Range &range, const Body &body)
parallel_for dummy template function which executes the body serially