Intel(R) Threading Building Blocks Doxygen Documentation
version 4.2.3
|
Go to the documentation of this file.
17 #ifndef _TBB_task_stream_H
18 #define _TBB_task_stream_H
35 template<
typename T,
typename mutex_t >
64 return (val & (
one<<pos)) != 0;
77 for(
int level = 0; level < Levels; level++) {
84 const unsigned max_lanes =
sizeof(
population_t) * CHAR_BIT;
86 N = n_lanes>=max_lanes ? max_lanes : n_lanes>2 ? 1<<(
__TBB_Log2(n_lanes-1)+1) : 2;
87 __TBB_ASSERT(
N==max_lanes ||
N>=n_lanes && ((
N-1)&
N)==0,
"number of lanes miscalculated");
89 for(
int level = 0; level < Levels; level++) {
96 for(
int level = 0; level < Levels; level++)
105 idx = random.
get() & (
N-1);
107 if(
lock.try_acquire(
lanes[level][idx].my_mutex) ) {
108 lanes[level][idx].my_queue.push_back(source);
116 task*
pop(
int level,
unsigned& last_used_lane ) {
119 unsigned idx = (last_used_lane+1)&(
N-1);
133 last_used_lane = idx;
147 for(
int level = 0; level < Levels; level++)
148 for(
unsigned i=0; i<
N; ++i) {
151 for(lane_t::queue_base_t::iterator it=lane.
my_queue.begin();
152 it!=lane.
my_queue.end(); ++it, ++result)
156 tbb::task::destroy(*t);
population_t population[Levels]
unsigned short get()
Get a random number.
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
void clear_one_bit(population_t &dest, int pos)
bool empty(int level)
Checks existence of a task.
Base class for user-defined tasks.
intptr_t drain()
Destroys all remaining tasks in every lane. Returns the number of destroyed tasks.
A fast random number generator.
Represents acquisition of a mutex.
Essentially, this is just a pair of a queue and a mutex to protect the queue.
bool is_bit_set(population_t val, int pos)
void __TBB_AtomicAND(volatile void *operand, uintptr_t addend)
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void * lock
padded< lane_t > * lanes[Levels]
std::deque< T, tbb_allocator< T > > queue_base_t
Base class for types that should not be copied or assigned.
void __TBB_AtomicOR(volatile void *operand, uintptr_t addend)
intptr_t __TBB_Log2(uintptr_t x)
void initialize(unsigned n_lanes)
Pads type T to fill out to a multiple of cache line size.
queue_and_mutex< task *, spin_mutex > lane_t
The container for "fairness-oriented" aka "enqueued" tasks.
task * pop(int level, unsigned &last_used_lane)
Try finding and popping a task.
void push(task *source, int level, FastRandom &random)
Push a task into a lane.
void set_one_bit(population_t &dest, int pos)
Copyright © 2005-2020 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.