## Python* API for Intel® Threading Building Blocks (Intel® TBB).

## Overview

It is a preview Python* module which unlocks opportunities for additional performance in multi-threaded and multiprocess Python programs by enabling threading composability between two or more thread-enabled libraries like Numpy, Scipy, Sklearn, Dask, Joblib, and etc.

The biggest improvement can be achieved when a task pool like the ThreadPool or Pool from the Python standard library or libraries like Dask or Joblib (used either in multi-threading or multi-processing mode) execute tasks calling compute-intensive functions of Numpy/Scipy/Sklearn/PyDAAL which in turn are parallelized using Intel® Math Kernel Library or/and Intel® TBB.

The module implements Pool class with the standard interface using Intel® TBB which can be used to replace Python's ThreadPool. Thanks to the monkey-patching technique implemented in class Monkey, no source code change is needed in order to enable threading composability in Python programs.

For more information and examples, please refer to online blog.

## Directories

rml
  The folder contains sources for building the plugin with cross-process dynamic thread scheduler implementation.
tbb
  The folder contains Python module sources.

## Files

setup.py
  Standard Python setup script.
Makefile
  Internal Makefile for building, installing, and testing. See below.
TBB.py
  Alternative entry point for Python module.

## Build and install

For accessing targets defined in python/Makefile, please use src/Makefile instead and build runtime libraries before working with Python.

`make -C ../src python_all`
  Install and test as described below.
`make -C ../src python_install`
  Install module into Python environment.
`make -C ../src python_test`
  Test installed Intel® TBB module for Python.
`make -C ../src python_release`
  Recompile Python module. Result is located in Intel® TBB build directory.
`make -C ../src python_clean`
  Remove any intermediate files produced by the commands above. Does not remove installed module.

## Command-line interface

`python -m tbb -h`
  Print documentation on command-line interface
`pydoc tbb`
  Read built-in documentation for Python interfaces.
`python-tbb your_script.py`
`python -m tbb your_script.py`
  Run your_script.py in context of `with tbb.Monkey():` when Intel® TBB is enabled. By default only multi-threading will be covered.
`python -m tbb --ipc your_script.py`
  Run your_script.py in context of `with tbb.Monkey():` when Intel® TBB enabled in both multi-threading and multi-processing modes.

## System Requirements

The Python module was not tested on older versions of Python thus we require at least Python versions 2.7 and 3.5 or higher.
SWIG must be of version 3.0.6 or higher
OS versions: Microsoft* Windows* Server 2012, Microsoft* Windows* 10, Ubuntu* 14.04 LTS, Red Hat* Enterprise Linux* 7.

Up to parent directory

Copyright © 2016-2018 Intel Corporation. All Rights Reserved.

Intel is a registered trademark or trademark 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.