- oneTBB enables you to specify logical paralleism instead of threads. Most threading packages require you to specify threads. Programming directly in terms of threads can be tedious and lead to inefficient programs, because threads are low-level, heavy constructs that are close to the hardware. Direct programming with threads forces you to efficiently map logical tasks onto threads. In contrast, the oneTBB run-time library automatically maps logical parallelism onto threads in a way that makes efficient use of processor resources.
- oneTBB targets threading for performance. Most general-purpose threading packages support many different kinds of threading, such as threading for asynchronous events in graphical user interfaces. As a result, general-purpose packages tend to be low-level tools that provide a foundation, not a solution. Instead, oneTBB focuses on the particular goal of parallelizing computationally intensive work, delivering higher-level, simpler solutions.
- oneTBB is compatible with other threading packages.Because the library is not designed to address all threading problems, it can coexist seamlessly with other threading packages.
- oneTBB emphasizes scalable, data parallel programming. Breaking a program up into separate functional blocks, and assigning a separate thread to each block is a solution that typically does not scale well since typically the number of functional blocks is fixed. In contrast, oneTBB emphasizesdata-parallelprogramming, enabling multiple threads to work on different parts of a collection. Data-parallel programming scales well to larger numbers of processors by dividing the collection into smaller pieces. With data-parallel programming, program performance increases as you add processors.
- oneTBB relies on generic programming. Traditional libraries specify interfaces in terms of specific types or base classes. Instead, oneAPI Threading Building Blocks uses generic programming. The essence of generic programming is writing the best possible algorithms with the fewest constraints. The C++ Standard Template Library (STL) is a good example of generic programming in which the interfaces are specified byrequirementson types. For example, C++ STL has a template functionsortthat sorts a sequence abstractly defined in terms of iterators on the sequence. The requirements on the iterators are:
- Provide random access
- The expression*i<*jis true if the item pointed to by iteratorishould precede the item pointed to by iteratorj, and false otherwise.
- The expressionswap(*i,*j)swaps two elements.