Compare commits

..
Author SHA1 Message Date
tbbdev 9afd759b72 Commit oneTBB source code 627cac6d 2024-02-13 05:49:20 -06:00
tbbdev bc3abe7578 Commit oneTBB source code 144b1846 2024-01-31 10:28:52 -06:00
Olga Malysheva 8b829acc65 Update documentation for oneTBB 2021.11.0 (#1268)
Signed-off-by: Olga Malysheva <olga.malysheva@intel.com>
2023-11-17 17:23:05 +01:00
tbbdev 457fff98bd Commit oneTBB source code cb6cc0ec 2023-09-14 10:56:12 -05:00
Olga Malysheva be2fb93722 Update documentation for oneTBB 2021.10.0 (#1147)
* Update documentation for oneTBB 2021.10.0

Signed-off-by: Olga Malysheva <olga.malysheva@intel.com>
2023-07-24 18:32:00 +02:00
tbbdev 9cb1b454fa Commit oneTBB source code 95f9511 2023-05-26 14:08:52 -05:00
Olga Malysheva a00cc3b8b5 Update documentation for oneTBB 2021.9 (#1060) 2023-04-06 19:14:50 +02:00
tbbdev 3eb1ff7047 Commit oneTBB source code 3b16143 2023-03-10 08:33:18 -06:00
Olga Malysheva c949771482 Update documentation for oneTBB 2021.8 (#998)
Signed-off-by: Olga Malysheva <olga.malysheva@intel.com>
2022-12-22 16:39:46 +01:00
tbbdev bd619c54a6 Commit oneTBB source code 6bfd29b 2022-10-28 08:38:07 -05:00
Olga Malysheva 7673da272f Update documentation (#934) 2022-10-07 16:34:12 +02:00
tbbdev b2b28c5b63 Commit oneTBB 2021.7 source code 32326067 2022-08-11 14:28:08 +02:00
c8504c4ec8 Update documentation for oneTBB 2021.6 (#836)
* Update pull_request_template.md (#751)

Signed-off-by: Alexandra Epanchinzeva alexandra.epanchinzeva@intel.com
(cherry picked from commit 4eda0f93a7)

* Update CONTRIBUTING.md (#765)

(cherry picked from commit e274a9e4b3)

* Documentation update for unpreview `task_handle` and related stuff (#755)

* Unpreview task_handle and related stuff

Signed-off-by: Anton Potapov <anton.potapov@intel.com>
Co-authored-by: Alexandra <alexandra.epanchinzeva@intel.com>
(cherry picked from commit fd76f45215)

* Update conf.py (#774)

(cherry picked from commit 6666292fbf)

* Actualize documentation about proportional splitting constructor in Range (#728)

Actualize documentation about proportional splitting

Signed-off-by: Fedotov, Aleksei <aleksei.fedotov@intel.com>
(cherry picked from commit e5cbe500d2)

* Update doc structure and add new files (#791)

(cherry picked from commit ce0d258e72)

* Instruction for building the docs locally  (#778)

(cherry picked from commit e386960a77)

* Document a way to flow graph can be attached to arbitrary task_arena (#785)

* Document a way to flow graph can be attached to arbitrary task_arena

task_arena interface provides mechanisms to guide tasks execution within the arena by
setting the preferred computation units or restricting part of computation units. In some
cases, you may want to use mechanisms within a flow graph.

Signed-off-by: Serov, Vladimir <vladimir.serov@intel.com>
Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com>
Co-authored-by: Alexandra Epanchinzeva <alexandra.epanchinzeva@intel.com>
(cherry picked from commit a938322524)

* Add topic about "Lazy Initiliazation" pattern to Design patterns (#790)

New topic about Lazy initialization pattern and how it can be implemented using oneapi::tbb::collaborative_call_once has been added.

Signed-off-by: Ilya Isaev <ilya.isaev@intel.com>
(cherry picked from commit 1da8f0d33b)

* Update Get Started Guide (#803)

(cherry picked from commit 05023723ff)

* Update intro_gsg.rst (#808)

(cherry picked from commit 2c4f282e86)

* Update conf.py (#810)

(cherry picked from commit 0a0a5926ee)

* TBB DOC : Dev Guide: Task Scheduler Bypass and How Does Task Scheduler Works (#521)

* TBB DOC : Dev Guide: Task Scheduler Bypass and How Task Scheduler
Works

Signed-off-by: Anton Potapov <anton.potapov@intel.com>
Co-authored-by: Alexandra <alexandra.epanchinzeva@intel.com>

(cherry picked from commit ed9d4b5e9a)

* Update intro_gsg.rst (#811)

(cherry picked from commit efea9935d1)

* Update conf.py (#812)

(cherry picked from commit 3859d1111f)

* Update examples.rst (#816)

(cherry picked from commit 4aa0b0b2db)

* Update layout.html (#815)

(cherry picked from commit 3e352b4812)

* Update RELEASE_NOTES.md for oneTBB 2021.6 (#835)

(cherry picked from commit faaf43c4ab)

Co-authored-by: Alexandra <alexandra.epanchinzeva@intel.com>
Co-authored-by: Anton Potapov <potapov.slash.co@gmail.com>
Co-authored-by: Aleksei Fedotov <aleksei.fedotov@intel.com>
Co-authored-by: Vladimir Serov <vladimir.serov@intel.com>
Co-authored-by: Ilya Isaev <ilya.isaev@intel.com>
Co-authored-by: Anton Potapov <anton.potapov@intel.com>
2022-08-09 13:59:37 -05:00
tbbdev 4533e4ff0f Commit oneTBB source code e0cc5187 2022-01-25 12:24:52 +03:00
Olga Malysheva 3df08fe234 Update documentation for 2021.5 release. (#690)
Signed-off-by: Olga Malysheva <Olga.Malysheva@intel.com>
2021-12-17 16:40:54 +03:00
Ilya Isaev e109790634 vars.bat: fix issue with no TBB in PATH (#624)
Signed-off-by: Ilya Isaev <ilya.isaev@intel.com>
2021-10-19 16:34:44 +03:00
tbbdev 5a5c793a6c Restore files from 70bf10c 2021-10-13 21:02:17 +03:00
Ilya Isaev 544840c8b0 Add TBB_DLL_PATH variable (#617)
Applying 155a9af commit from master
Signed-off-by: Ilya Isaev <ilya.isaev@intel.com>
2021-10-13 15:57:28 +03:00
tbbdev ba0cc2e0f9 Commit oneTBB source code 70bf10c 2021-10-13 14:10:41 +03:00
Olga Malysheva 4e021eafc0 Complete documentation update (#599)
Signed-off-by: Olga Malysheva <Olga.Malysheva@intel.com>
2021-10-04 12:50:18 +03:00
Anton Potapov 84da9e9ad6 - Updating documentation for 2021.4 (#583)
Signed-off-by: Anton Potapov <anton.potapov@intel.com>
2021-09-27 12:07:02 +03:00
tbbdev df3096075a Commit oneTBB source code 357c9b2 2021-09-01 11:20:23 +03:00
tbbdev 261fe22630 Commit oneTBB 2021.3.0 source code 2021-06-30 11:19:55 +03:00
tbbdev 2dba207286 Commit oneTBB 2021.2.0 source code 2021-01-27 23:03:49 +03:00
tbbdev 46fb877ef1 Commit oneTBB 2021.1.1 source code 2020-12-08 14:00:57 +03:00
tbbdev 978af3d9d7 Committing oneTBB 2021.1-beta10 source code 2020-10-27 16:11:20 +03:00
tbbdev 8632c27846 Committing oneTBB 2021.1-beta09 source code 2020-09-24 16:00:30 +03:00
tbbdev 05b1dd0789 Committing oneTBB 2021.1-beta08 source code 2020-08-06 18:38:19 +03:00
tbbdev 88b4c2782a Committing oneTBB 2021.1-beta05 source code 2020-04-01 16:58:36 +03:00
331 changed files with 13515 additions and 4302 deletions
+1 -1
View File
@@ -1 +1 @@
5.0.0
7.0.0
+27
View File
@@ -0,0 +1,27 @@
# Copyright (c) 2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# PR template regexp's for issue labeler
bug fix:
- '\[(x|X)\]\sbug\sfix'
enhancement:
- '\[(x|X)\]\snew\sfeature'
tests:
- '\[(x|X)\]\stests'
infrastructure:
- '\[(x|X)\]\sinfrastructure'
documentation:
- '\[(x|X)\]\sdocumentation'
allocator:
- '\[(x|X)\]\sallocator'
+18
View File
@@ -0,0 +1,18 @@
# Copyright (c) 2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
allocator:
- 'src/tbbmalloc/**/*'
- 'src/tbbmalloc_proxy/**/*'
- 'test/tbbmalloc/**/*'
+11 -8
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2021-2022 Intel Corporation
# Copyright (c) 2021-2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -25,6 +25,8 @@ on:
- synchronize
- reopened
permissions: read-all
env:
BUILD_CONCURRENCY: 2
MACOS_BUILD_CONCURRENCY: 3
@@ -57,7 +59,7 @@ jobs:
needs: [codespell]
env:
BUILD_TYPE: oss
runs-on: [ubuntu-20.04]
runs-on: [ubuntu-22.04]
timeout-minutes: 10
steps:
- uses: actions/checkout@v2
@@ -65,6 +67,7 @@ jobs:
run: |
pip3 install -U Jinja2
pip3 install git+https://github.com/executablebooks/sphinx-book-theme.git
pip3 install sphinx-tabs
echo GITHUB_SHA_SHORT=${GITHUB_SHA::8} >> $GITHUB_ENV
mkdir html
- name: Build documentation
@@ -126,8 +129,8 @@ jobs:
cat years.diff
exit 1
fi
python_module_test_ubuntu18-04:
runs-on: [ubuntu-18.04]
python_module_test_ubuntu_latest:
runs-on: [ubuntu-latest]
timeout-minutes: 15
steps:
- uses: actions/checkout@v2
@@ -146,7 +149,7 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
- os: ubuntu-latest
c_compiler: gcc
cxx_compiler: g++
std: 14
@@ -184,7 +187,7 @@ jobs:
fail-fast: false
matrix:
include:
- os: macos-10.15
- os: macos-12
c_compiler: clang
cxx_compiler: clang++
std: 14
@@ -246,7 +249,7 @@ jobs:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
- os: ubuntu-latest
c_compiler: gcc
cxx_compiler: g++
std: 14
@@ -284,7 +287,7 @@ jobs:
fail-fast: false
matrix:
include:
- os: macos-10.15
- os: macos-12
c_compiler: clang
cxx_compiler: clang++
std: 14
+35
View File
@@ -0,0 +1,35 @@
# Copyright (c) 2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: "Issue Labeler"
on:
issues:
types: [opened, edited]
pull_request:
types: [opened, edited]
jobs:
triage:
runs-on: ubuntu-latest
permissions:
pull-requests: write
issues: write
contents: read
steps:
- uses: github/issue-labeler@v3.2 #May not be the latest version
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: .github/issue_labeler.yml
enable-versioned-regex: 0
sync-labels: 1
+26
View File
@@ -0,0 +1,26 @@
# Copyright (c) 2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: "Pull Request Labeler"
on:
- pull_request_target
jobs:
triage:
permissions:
contents: read
pull-requests: write
runs-on: ubuntu-latest
steps:
- uses: actions/labeler@v4
+4 -4
View File
@@ -36,7 +36,7 @@ cc_library(
"include/oneapi/tbb/detail/*.h",
]),
copts = ["-w"] + select({
"@bazel_tools//platforms:windows": [""],
"@platforms//os:windows": [""],
"//conditions:default": ["-mwaitpkg"],
}),
defines =
@@ -47,7 +47,7 @@ cc_library(
],
}) +
select({
"@bazel_tools//platforms:osx": ["_XOPEN_SOURCE"],
"@platforms//os:osx": ["_XOPEN_SOURCE"],
"//conditions:default": [],
}),
includes = [
@@ -55,8 +55,8 @@ cc_library(
],
linkopts =
select({
"@bazel_tools//platforms:windows": [],
"@bazel_tools//platforms:linux": [
"@platforms//os:windows": [],
"@platforms//os:linux": [
"-ldl",
"-pthread",
"-lrt",
+1 -1
View File
@@ -33,7 +33,7 @@ example
_WORKSPACE.bazel_:
```python
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
load("@platforms//tools/build_defs/repo:git.bzl", "git_repository")
git_repository(
name = "oneTBB",
+91 -48
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2022 Intel Corporation
# Copyright (c) 2020-2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -12,10 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.5)
# Enable CMake policies
if (POLICY CMP0068)
# RPATH settings do not affect install_name on macOS since CMake 3.9
cmake_policy(SET CMP0068 NEW)
endif()
if (POLICY CMP0091)
# The NEW behavior for this policy is to not place MSVC runtime library flags in the default
# CMAKE_<LANG>_FLAGS_<CONFIG> cache entries and use CMAKE_MSVC_RUNTIME_LIBRARY abstraction instead.
@@ -38,12 +43,6 @@ if (APPLE)
endif()
endif()
# Until CMake 3.4.0 FindThreads.cmake requires C language enabled.
# Enable C language before CXX to avoid possible override of CMAKE_SIZEOF_VOID_P.
if (CMAKE_VERSION VERSION_LESS 3.4)
enable_language(C)
endif()
file(READ include/oneapi/tbb/version.h _tbb_version_info)
string(REGEX REPLACE ".*#define TBB_VERSION_MAJOR ([0-9]+).*" "\\1" _tbb_ver_major "${_tbb_version_info}")
string(REGEX REPLACE ".*#define TBB_VERSION_MINOR ([0-9]+).*" "\\1" _tbb_ver_minor "${_tbb_version_info}")
@@ -104,15 +103,19 @@ option(TBBMALLOC_BUILD "Enable tbbmalloc build" ON)
cmake_dependent_option(TBBMALLOC_PROXY_BUILD "Enable tbbmalloc_proxy build" ON "TBBMALLOC_BUILD" OFF)
option(TBB_CPF "Enable preview features of the library" OFF)
option(TBB_FIND_PACKAGE "Enable search for external oneTBB using find_package instead of build from sources" OFF)
option(TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH "Disable HWLOC automatic search by pkg-config tool" OFF)
option(TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH "Disable HWLOC automatic search by pkg-config tool" ${CMAKE_CROSSCOMPILING})
option(TBB_ENABLE_IPO "Enable Interprocedural Optimization (IPO) during the compilation" ON)
option(TBB_FUZZ_TESTING "Enable fuzz testing" OFF)
option(TBB_INSTALL "Enable installation" ON)
if (NOT DEFINED BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON)
endif()
if (NOT BUILD_SHARED_LIBS)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
message(WARNING "You are building oneTBB as a static library. This is highly discouraged and such configuration is not supported. Consider building a dynamic library to avoid unforeseen issues.")
endif()
@@ -123,6 +126,14 @@ if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
endif()
if (CMAKE_BUILD_TYPE)
string(TOLOWER ${CMAKE_BUILD_TYPE} _tbb_build_type)
if (_tbb_build_type STREQUAL "debug")
set(TBB_ENABLE_IPO OFF)
endif()
unset(_tbb_build_type)
endif()
# -------------------------------------------------------------------
# Files and folders naming
set(CMAKE_DEBUG_POSTFIX _debug)
@@ -171,10 +182,22 @@ foreach(output_type LIBRARY ARCHIVE PDB RUNTIME)
endif()
endforeach()
if (CMAKE_CONFIGURATION_TYPES)
# We can't use generator expressions in a cmake variable name.
set(TBB_TEST_WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${TBB_OUTPUT_DIR_BASE}_$<LOWER_CASE:$<CONFIG>>)
else()
set(TBB_TEST_WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif()
# -------------------------------------------------------------------
# -------------------------------------------------------------------
# Common dependencies
#force -pthread during compilation for Emscripten
if (EMSCRIPTEN AND NOT EMSCRIPTEN_WITHOUT_PTHREAD)
set(THREADS_HAVE_PTHREAD_ARG TRUE)
endif()
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
# -------------------------------------------------------------------
@@ -216,47 +239,50 @@ else()
if (TBB_BUILD)
add_subdirectory(src/tbb)
endif()
if (NOT "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "mips")
if (TBBMALLOC_BUILD)
add_subdirectory(src/tbbmalloc)
if(TBBMALLOC_PROXY_BUILD AND NOT "${MSVC_CXX_ARCHITECTURE_ID}" MATCHES "ARM64")
add_subdirectory(src/tbbmalloc_proxy)
endif()
endif()
if (APPLE OR NOT BUILD_SHARED_LIBS)
message(STATUS "TBBBind build targets are disabled due to unsupported environment")
else()
add_subdirectory(src/tbbbind)
if (TBBMALLOC_BUILD)
add_subdirectory(src/tbbmalloc)
if(TBBMALLOC_PROXY_BUILD AND NOT "${MSVC_CXX_ARCHITECTURE_ID}" MATCHES "ARM64")
add_subdirectory(src/tbbmalloc_proxy)
endif()
endif()
if (NOT BUILD_SHARED_LIBS)
message(STATUS "TBBBind build targets are disabled due to unsupported environment")
else()
add_subdirectory(src/tbbbind)
endif()
if (TBB_INSTALL)
# -------------------------------------------------------------------
# Installation instructions
include(CMakePackageConfigHelpers)
# -------------------------------------------------------------------
# Installation instructions
include(CMakePackageConfigHelpers)
install(DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT devel)
install(DIRECTORY include/
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
COMPONENT devel)
install(EXPORT ${PROJECT_NAME}Targets
NAMESPACE TBB::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
COMPONENT devel)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
"include(\${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}Targets.cmake)\n")
if (NOT BUILD_SHARED_LIBS)
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
"include(CMakeFindDependencyMacro)\nfind_dependency(Threads)\n")
endif()
install(EXPORT ${PROJECT_NAME}Targets
NAMESPACE TBB::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
COMPONENT devel)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
"include(\${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}Targets.cmake)\n")
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
COMPATIBILITY AnyNewerVersion)
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
COMPATIBILITY AnyNewerVersion)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
COMPONENT devel)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
COMPONENT devel)
install(FILES "README.md"
DESTINATION ${CMAKE_INSTALL_DOCDIR}
COMPONENT devel)
# -------------------------------------------------------------------
install(FILES "README.md"
DESTINATION ${CMAKE_INSTALL_DOCDIR}
COMPONENT devel)
# -------------------------------------------------------------------
endif()
endif()
if (TBB_TEST)
@@ -279,10 +305,27 @@ endif()
if (ANDROID_PLATFORM)
if ("${ANDROID_STL}" STREQUAL "c++_shared")
configure_file(
"${ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libs/${ANDROID_ABI}/libc++_shared.so"
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libc++_shared.so"
COPYONLY)
if (${ANDROID_NDK_MAJOR} GREATER_EQUAL "25")
if(ANDROID_ABI STREQUAL "arm64-v8a")
set(ANDROID_TOOLCHAIN_NAME "aarch64-linux-android")
elseif(ANDROID_ABI STREQUAL "x86_64")
set(ANDROID_TOOLCHAIN_NAME "x86_64-linux-android")
elseif(ANDROID_ABI STREQUAL "armeabi-v7a")
set(ANDROID_TOOLCHAIN_NAME "arm-linux-androideabi")
elseif(ANDROID_ABI STREQUAL "x86")
set(ANDROID_TOOLCHAIN_NAME "i686-linux-android")
endif()
configure_file(
"${ANDROID_TOOLCHAIN_ROOT}/sysroot/usr/lib/${ANDROID_TOOLCHAIN_NAME}/libc++_shared.so"
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libc++_shared.so"
COPYONLY)
else()
configure_file(
"${ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libs/${ANDROID_ABI}/libc++_shared.so"
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libc++_shared.so"
COPYONLY)
endif()
endif()
# This custom target may be implemented without separate CMake script, but it requires
# ADB(Android Debug Bridge) executable file availability, so to incapsulate this requirement
-5
View File
@@ -29,11 +29,6 @@ The DCO is an attestation attached to every contribution made by every developer
As a contributor, you’ll want to be familiar with the oneTBB project and the repository layout. You should also know how to use it as explained in the [oneTBB documentation](https://oneapi-src.github.io/oneTBB/) and how to set up your build development environment to configure, build, and test oneTBB as explained in the [oneTBB Build System Description](cmake/README.md).
## Issues
If you face a problem, first check out open [oneTBB GitHub issues](https://github.com/oneapi-src/oneTBB/issues) to see if the issue you’d like to address is already reported. You may find users that have encountered the bug you’re finding or have similar ideas for changes or additions.
You can use issues to report a problem, make a feature request, or add comments on an existing issue.
## Pull Requests
You can find all [open oneTBB pull requests](https://github.com/oneapi-src/oneTBB/pulls) on GitHub.
+14 -1
View File
@@ -61,7 +61,7 @@ You can use the ``install`` components for partial installation.
The following install components are supported:
- `runtime` - oneTBB runtime package (core shared libraries and `.dll` files on Windows* OS).
- `devel` - oneTBB development package (header files, CMake integration files, library symbolic links, and `.lib` files on Windows* OS).
- `tbb4py` - [oneTBB Module for Python](#onetbb-python-module-support).
- `tbb4py` - [oneTBB Module for Python](https://github.com/oneapi-src/oneTBB/blob/master/python/README.md).
If you want to install specific components after configuration and build, run:
@@ -77,6 +77,19 @@ cmake <options> ..
cpack
```
## Installation from vcpkg
You can download and install oneTBB using the [vcpkg](https://github.com/Microsoft/vcpkg) dependency manager:
```sh
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh #.\bootstrap-vcpkg.bat(for Windows)
./vcpkg integrate install
./vcpkg install tbb
```
The oneTBB port in vcpkg is kept up to date by Microsoft* team members and community contributors. If the version is out of date, create an issue or pull request on the [vcpkg repository](https://github.com/Microsoft/vcpkg).
## Example of Installation
### Single-configuration generators
+24
View File
@@ -0,0 +1,24 @@
# Copyright (c) 2021-2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# DISCLAIMER: Bazel support is community-based. The maintainers do not
# use Bazel internally. The Bazel build can have security risks or
# optimization gaps.
module(
name = "onetbb",
compatibility_level = 1,
)
bazel_dep(name = "platforms", version = "0.0.8")
+7 -3
View File
@@ -20,22 +20,27 @@ Refer to oneTBB [examples](examples) and [samples](https://github.com/oneapi-src
oneTBB is a part of [oneAPI](https://oneapi.io). The current branch implements version 1.1 of oneAPI Specification.
> **_NOTE:_** Threading Building Blocks (TBB) is now called oneAPI Threading Building Blocks (oneTBB) to highlight that the tool is a part of the oneAPI ecosystem.
## Release Information
Here are [Release Notes](RELEASE_NOTES.md) and [System Requirements](SYSTEM_REQUIREMENTS.md).
See [Release Notes](RELEASE_NOTES.md) and [System Requirements](SYSTEM_REQUIREMENTS.md).
## Documentation
* [oneTBB Specification](https://spec.oneapi.com/versions/latest/elements/oneTBB/source/nested-index.html)
* [oneTBB Developer Guide and Reference](https://oneapi-src.github.io/oneTBB)
* [Migrating from TBB to oneTBB](https://oneapi-src.github.io/oneTBB/main/tbb_userguide/Migration_Guide.html)
* [README for the CMake build system](cmake/README.md)
* [oneTBB Testing Approach](https://oneapi-src.github.io/oneTBB/main/intro/testing_approach.html)
* [Basic support for the Bazel build system](Bazel.md)
* [oneTBB Discussions](https://github.com/oneapi-src/oneTBB/discussions)
* [WASM Support](WASM_Support.md)
## Installation
See [Installation from Sources](INSTALL.md) to learn how to install oneTBB.
## Support
Please report issues and suggestions via [GitHub issues](https://github.com/oneapi-src/oneTBB/issues). See our [documentation](./CONTRIBUTING.md##Issues) to learn how to work with them.
See our [documentation](./SUPPORT.md) to learn how to request help.
## How to Contribute
We welcome community contributions, so check our [Contributing Guidelines](CONTRIBUTING.md)
@@ -45,7 +50,6 @@ to learn more.
oneAPI Threading Building Blocks is licensed under [Apache License, Version 2.0](LICENSE.txt).
By its terms, contributions submitted to the project are also done under that license.
## Engineering team contacts
* [Email us.](mailto:inteltbbdevelopers@intel.com)
+10 -24
View File
@@ -18,36 +18,22 @@
This document contains changes of oneTBB compared to the last release.
## Table of Contents <!-- omit in toc -->
- [New Features](#new_features)
- [Known Limitations](#known-limitations)
- [Fixed Issues](#fixed-issues)
- [Open-source Contributions Integrated](#open-source-contributions-integrated)
## :white_check_mark: New Features
- Improved support and use of the latest C++ standards for parallel_sort that allows using this algorithm with user-defined and standard library-defined objects with modern semantics.
- The following features are now fully functional: task_arena extensions, collaborative_call_once, adaptive mutexes, heterogeneous overloads for concurrent_hash_map, and task_scheduler_handle.
- Added support for Windows* Server 2022 and Python 3.10.
## :rotating_light: Known Limitations
- An application using Parallel STL algorithms in libstdc++ versions 9 and 10 may fail to compile due to incompatible interface changes between earlier versions of Threading Building Blocks (TBB) and oneAPI Threading Building Blocks (oneTBB). Disable support for Parallel STL algorithms by defining PSTL_USE_PARALLEL_POLICIES (in libstdc++ 9) or _GLIBCXX_USE_TBB_PAR_BACKEND (in libstdc++ 10) macro to zero before inclusion of the first standard header file in each translation unit.
- On Linux* OS, if oneAPI Threading Building Blocks (oneTBB) or Threading Building Blocks (TBB) are installed in a system folder like /usr/lib64, the application may fail to link due to the order in which the linker searches for libraries. Use the -L linker option to specify the correct location of oneTBB library. This issue does not affect the program execution.
- The oneapi::tbb::info namespace interfaces might unexpectedly change the process affinity mask on Windows* OS systems (see https://github.com/open-mpi/hwloc/issues/366 for details) when using hwloc version lower than 2.5.
- The ``oneapi::tbb::info`` namespace interfaces might unexpectedly change the process affinity mask on Windows* OS systems (see https://github.com/open-mpi/hwloc/issues/366 for details) when using hwloc version lower than 2.5.
- Using a hwloc version other than 1.11, 2.0, or 2.5 may cause an undefined behavior on Windows OS. See https://github.com/open-mpi/hwloc/issues/477 for details.
- The NUMA topology may be detected incorrectly on Windows OS machines where the number of NUMA node threads exceeds the size of 1 processor group.
- The NUMA topology may be detected incorrectly on Windows* OS machines where the number of NUMA node threads exceeds the size of 1 processor group.
- On Windows OS on ARM64*, when compiling an application using oneTBB with the Microsoft* Compiler, the compiler issues a warning C4324 that a structure was padded due to the alignment specifier. Consider suppressing the warning by specifying /wd4324 to the compiler command line.
- oneTBB does not support fork(), to work-around the issue, consider using task_scheduler_handle to join oneTBB worker threads before using fork().
- C++ exception handling mechanism on Windows* OS on ARM64* might corrupt memory if an exception is thrown from any oneTBB parallel algorithm (see Windows* OS on ARM64* compiler issue: https://developercommunity.visualstudio.com/t/ARM64-incorrect-stack-unwinding-for-alig/1544293).
- Using ``TBBConfig.cmake`` in 32-bit environment may cause incorrect linkage with 64-bit oneTBB library. As a workaround, set ``CMAKE_PREFIX_PATH``:
- On Linux* OS: to ``TBBROOT/lib32/``
- On Windows* OS: to ``TBBROOT/lib32/;TBBROOT/bin32/``
> **_NOTE:_** To see known limitations that impact all versions of oneTBB, refer to [oneTBB Documentation](https://oneapi-src.github.io/oneTBB/main/intro/limitations.html).
## :hammer: Fixed Issues
- Memory allocator crash on a system with an incomplete /proc/meminfo (GitHub* [#584](https://github.com/oneapi-src/oneTBB/issues/584)).
- Incorrect blocking of task stealing (GitHub* #[478](https://github.com/oneapi-src/oneTBB/issues/478)).
- Hang due to incorrect decrement of a limiter_node (GitHub* [#634](https://github.com/oneapi-src/oneTBB/issues/634)).
- Memory corruption in some rare cases when passing big messages in a flow graph (GitHub* [#639](https://github.com/oneapi-src/oneTBB/issues/639)).
- Possible deadlock in a throwable flow graph node with a lightweight policy. The lightweight policy is now ignored for functors that can throw exceptions (GitHub* [#420](https://github.com/oneapi-src/oneTBB/issues/420)).
- Crash when obtaining a range from empty ordered and unordered containers (GitHub* [#641](https://github.com/oneapi-src/oneTBB/issues/641)).
- Deadlock in a concurrent_vector resize() that could happen when the new size is less than the previous size (GitHub* [#733](https://github.com/oneapi-src/oneTBB/issues/733)).
## :octocat: Open-source Contributions Integrated
- Improved aligned memory allocation. Contributed by Andrey Semashev (https://github.com/oneapi-src/oneTBB/pull/671).
- Optimized usage of atomic_fence on IA-32 and Intel(R) 64 architectures. Contributed by Andrey Semashev (https://github.com/oneapi-src/oneTBB/pull/328).
- Fixed incorrect definition of the assignment operator in containers. Contributed by Andrey Semashev (https://github.com/oneapi-src/oneTBB/issues/372).
- Fixed ``tbb::this_task_arena()`` behavior for specific ``tbb::task_arena{1,0}``.
- Restored performance on systems with a high number of CPU cores that support ``_tpause``.
+7
View File
@@ -0,0 +1,7 @@
# Security Policy
Intel is committed to rapidly addressing security vulnerabilities affecting our customers and providing clear guidance on the solution,
impact, severity and mitigation.
## Reporting a Vulnerability
Please report any security vulnerabilities in this project
[utilizing the guidelines here](https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html).
+35
View File
@@ -0,0 +1,35 @@
<!--
******************************************************************************
* 
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/-->
# oneTBB Support
We are committed to providing support and assistance to help you make the most out of oneTBB.
Use the following methods if you face any challenges.
## Issues
If you have a problem, check out the [GitHub Issues](https://github.com/oneapi-src/oneTBB/issues) to see if the issue you want to address is already reported.
You may find users that have encountered the same bug or have similar ideas for changes or updates.
You can use issues to report a problem, make a feature request, or add comments on an existing issue.
## Discussions
Visit the [GitHub Discussions](https://github.com/oneapi-src/oneTBB/discussions) to engage with the community, ask questions, or help others.
## Email
Reach out to us privately via [email](mailto:inteltbbdevelopers@intel.com).
+41 -20
View File
@@ -21,14 +21,15 @@ This document provides details about hardware, operating system, and software pr
- [Supported Hardware](#supported-hardware)
- [Software](#software)
- [Supported Operating Systems](#supported-operating-systems)
- [Community-Supported Platforms](#community-supported-platforms)
- [Supported Compilers](#supported-compilers)
- [Limitations](#limitations)
## Supported Hardware
- Intel(R) Celeron(R) processor family
- Intel(R) Core* processor family
- Intel(R) Xeon(R) processor family
- Intel(R) Xeon Phi* processor family
- Intel(R) Atom* processor family
- Non-Intel(R) processors compatible with the processors listed above
@@ -36,30 +37,50 @@ This document provides details about hardware, operating system, and software pr
## Software
### Supported Operating Systems
- Systems with Microsoft* Windows* operating systems
- Systems with Microsoft* Windows* operating systems:
- Microsoft* Windows* 10
- Microsoft* Windows* Server 2016
- Microsoft* Windows* 11
- Microsoft* Windows* Server 2019
- Systems with Linux* operating systems
- Clear Linux*
- Amazon* Linux 2
- CentOS* 8
- Debian* 10
- Fedora* 34
- Red Hat* Enterprise Linux* 7, 8
- Microsoft* Windows* Server 2022
- Systems with Linux* operating systems:
- Oracle Linux* 8
- Amazon* Linux 2, 2022
- Debian* 9, 10, 11
- Fedora* 36, 37, 38
- Rocky* Linux* 8, 9
- Red Hat* Enterprise Linux* 8, 9
- SuSE* Linux* Enterprise Server 15
- Ubuntu* 18.04 LTS, 20.04, 21.04, 22.04
- Systems with macOS* operating systems
- macOS* 10.15, 11.x
- Systems with Android* operating systems
- Ubuntu* 20.04, 22.04
- Systems with macOS* operating systems:
- macOS* 12.x, 13.x
- Systems with Android* operating systems:
- Android* 9
### Community-Supported Platforms
- MinGW*
- FreeBSD*
- Microsoft* Windows* on ARM*/ARM64*
- macOS* on ARM64*
### Supported Compilers
- Intel* oneAPI DPC++/C++ Compiler
- Intel* C++ Compiler 19.0 and 19.1 version
- Microsoft* Visual C++ 14.1 (Microsoft* Visual Studio* 2017, Windows* OS only)
- Intel® C++ Compiler Classic 2021.1 - 2021.9
- Microsoft* Visual C++ 14.2 (Microsoft* Visual Studio* 2019, Windows* OS only)
- For each supported Linux* operating system, the standard gcc version provided with that operating system is supported
- GNU Compilers (gcc) 4.8.5 - 11.1.1
- GNU C Library (glibc) version 2.17 - 2.33
- Clang* 6.0.0 - 12.0.0
- Microsoft* Visual C++ 14.3 (Microsoft* Visual Studio* 2022, Windows* OS only)
- For each supported Linux* operating system, the standard gcc version provided with that operating system is supported:
- GNU Compilers (gcc) 8.x – 12.x
- GNU C Library (glibc) version 2.28 – 2.36
- Clang* 6.0.0 - 13.0.0
## Limitations
There are some cases where we cannot provide support for your platforms. It includes:
1. The platform is out of official support (met end of life). When you use an unsupported platform, you can face a security risk that can be difficult to resolve.
2. We do not have the infrastructure to test a platform. Therefore we cannot guarantee that oneTBB works correctly on that platform.
3. Changes affect more code than just platform-specific macros.
4. The platform is incompatible with oneTBB. Some platforms may have limitations that prevent oneTBB from working correctly. We cannot provide support in these cases as the issue is beyond our control.
5. The platform is modified or customized. If you made significant updates to your platform, it might be hard for us to find the root cause of the issue. Therefore, we may not be able to provide support as the modification could affect the oneTBB functionality.
We understand that these limitations can be frustrating. Thus, we suggest creating a branch specifically for the unsupported platform, allowing other users to contribute to or use your implementation.
+60
View File
@@ -0,0 +1,60 @@
<!--
******************************************************************************
* 
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/-->
# WASM Support
oneTBB extends its capabilities by offering robust support for ``WASM``.
``WASM`` stands for WebAssembly, a low-level binary format for executing code in web browsers.
It is designed to be a portable target for compilers and efficient to parse and execute.
Using oneTBB with WASM, you can take full advantage of parallelism and concurrency while working on web-based applications, interactive websites, and a variety of other WASM-compatible platforms.
oneTBB offers WASM support through the integration with [Emscripten*](https://emscripten.org/docs/introducing_emscripten/index.html), a powerful toolchain for compiling C and C++ code into WASM-compatible runtimes.
## Build
**Prerequisites:** Download and install Emscripten*. See the [instructions](https://emscripten.org/docs/getting_started/downloads.html).
To build the system, run:
```
mkdir build && cd build
emcmake cmake .. -DCMAKE_CXX_COMPILER=em++ -DCMAKE_C_COMPILER=emcc -DTBB_STRICT=OFF -DCMAKE_CXX_FLAGS=-Wno-unused-command-line-argument -DTBB_DISABLE_HWLOC_AUTOMATIC_SEARCH=ON -DBUILD_SHARED_LIBS=ON -DTBB_EXAMPLES=ON -DTBB_TEST=ON
```
To compile oneTBB without ``pthreads``, set the flag ``-DEMSCRIPTEN_WITHOUT_PTHREAD=true`` in the command above. By default, oneTBB uses the ``pthreads``.
```
cmake --build . <options>
cmake --install . <options>
```
Where:
* ``emcmake`` - a tool that sets up the environment for Emscripten*.
* ``-DCMAKE_CXX_COMPILER=em++`` - specifies the C++ compiler as Emscripten* C++ compiler.
* ``-DCMAKE_C_COMPILER=emcc`` - specifies the C compiler as Emscripten* C compiler.
> **_NOTE:_** See [CMake documentation](https://github.com/oneapi-src/oneTBB/blob/master/cmake/README.md) to learn about other options.
## Run Test
To run tests, use:
```
ctest
```
+75 -57
View File
@@ -1,30 +1,31 @@
# Build system description
# Build System Description
The project uses CMake build configuration.
The project uses CMake* build configuration.
The following controls are available during the configure stage:
```
TBB_TEST:BOOL - Enable testing (ON by default)
TBB_STRICT:BOOL - Treat compiler warnings as errors (ON by default)
TBB_SANITIZE:STRING - Sanitizer parameter, passed to compiler/linker
TBB_SIGNTOOL:FILEPATH - Tool for digital signing, used in post install step for libraries if provided.
TBB_SIGNTOOL:FILEPATH - Tool for digital signing, used in post-install step for libraries if provided.
TBB_SIGNTOOL_ARGS:STRING - Additional arguments for TBB_SIGNTOOL, used if TBB_SIGNTOOL is set.
TBB_BUILD:BOOL - Enable Intel(R) oneAPI Threading Building Blocks (oneTBB) build (ON by default)
TBBMALLOC_BUILD:BOOL - Enable Intel(R) oneAPI Threading Building Blocks (oneTBB) memory allocator build (ON by default)
TBBMALLOC_PROXY_BUILD:BOOL - Enable Intel(R) oneAPI Threading Building Blocks (oneTBB) memory allocator proxy build (requires TBBMALLOC_BUILD. ON by default)
TBB4PY_BUILD:BOOL - Enable Intel(R) oneAPI Threading Building Blocks (oneTBB) Python module build (OFF by default)
TBB_CPF:BOOL - Enable preview features of the library (OFF by default)
TBB_INSTALL:BOOL - Enable installation (ON by default)
TBB_INSTALL_VARS:BOOL - Enable auto-generated vars installation(packages generated by `cpack` and `make install` will also include the vars script)(OFF by default)
TBB_VALGRIND_MEMCHECK:BOOL - Enable scan for memory leaks using Valgrind (OFF by default)
TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH - Disable HWLOC automatic search by pkg-config tool (OFF by default)
TBB_ENABLE_IPO - Enable Interprocedural Optimization (IPO) during the compilation (ON by default)
```
## Configure, build, and test
## Configure, Build, and Test
### Preparation
To perform out-of-source build, create a build directory and go there:
To perform an out-of-source build, create a build directory and go there:
```bash
mkdir /tmp/my-build
@@ -39,14 +40,16 @@ cmake <options> <repo_root>
Some useful options:
- `-G <generator>` - specify particular project generator. See `cmake --help` for details.
- `-DCMAKE_BUILD_TYPE=Debug` - specify for Debug build. It is not applicable for multiconfig generators, e.g. for Visual Studio* generator.
- `-DCMAKE_BUILD_TYPE=Debug` - specify for Debug build. It is not applicable for multi-config generators, e.g., Microsoft* Visual Studio* generator.
#### TBBBind library configuration
#### TBBBind Library Configuration
The TBBbind library has three versions: `tbbbind`, `tbbbind_2_0`, and `tbbbind_2_5`. Each of these versions is linked with corresponding HWLOC library version:
- `tbbbind` links with HWLOC 1.11.x
- `tbbbind_2_0` links with HWLOC 2.1–2.4
- `tbbbind_2_5` links with HWLOC 2.5 and later
> **_TIP:_** It is recommended to install the HWLOC* library. See [oneTBB documentation](https://oneapi-src.github.io/oneTBB/GSG/next_steps.html#hybrid-cpu-and-numa-support) for details.
The TBBbind library has three versions: `tbbbind`, `tbbbind_2_0`, and `tbbbind_2_5`. Each of these versions is linked with the corresponding HWLOC* library version:
- `tbbbind` links with `HWLOC 1.11.x`
- `tbbbind_2_0` links with `HWLOC 2.1–2.4`
- `tbbbind_2_5` links with `HWLOC 2.5` and later
The search for a suitable version of the HWLOC library is enabled by default. If you want to use a specific version of the library, you can specify the path to it manually using the following CMake variables:
@@ -63,17 +66,17 @@ The search for a suitable version of the HWLOC library is enabled by default. If
Windows* OS requires an additional variable for correct TBBBind library building:
- `CMAKE_HWLOC_<HWLOC_VER>_DLL_PATH` - path to the corresponding HWLOC version `.dll` file.
`HWLOC_VER` substring used earlier can be replaced with one of the three values:
The `HWLOC_VER` substring used earlier can be replaced with one of the three values:
- `1_11` for the `tbbbind` library configuration
- `2` for the `tbbbind_2_0` library configuration
- `2_5` for the `tbbbind_2_5` library configuration
If you specify variables for several TBBBind versions, the building process for all of these versions is performed during single build session.
If you specify variables for several TBBBind versions, the building process for all of these versions is performed during a single build session.
---
**TIP**
Specify the `TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH` to disable HWLOC libraries automatic search.
Specify the `TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH` to turn off the HWLOC library's automatic search.
---
@@ -85,24 +88,24 @@ cmake --build . <options>
```
Some useful options:
- `--target <target>` - specific target, "all" is default.
- `--config <Release|Debug>` - build configuration, applicable only for multiconfig generators, e.g. Visual Studio* generator.
- `--target <target>` - specific target, "all" is the default.
- `--config <Release|Debug>` - build configuration, applicable only for multi-config generators, e.g., Visual Studio* generator.
The binaries are placed to `./<compiler-id>_<compiler-ver>_cxx<stdver>_<build-type>`. For example, `./gnu_4.8_cxx11_release`.
#### Build for 32-bit
#### Build For 32-bit
* **Intel(R) Compiler**. Source Intel(R) C++ Compiler with `ia32` and build as usual.
* **MSVC**. Use switch for [generator](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html) (e.g. `-A Win32` for [VS2019](https://cmake.org/cmake/help/latest/generator/Visual%20Studio%2016%202019.html)) during the configuration stage and then build as usual.
* **MSVC**. Use switch for [generator](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html) (e.g., `-A Win32` for [VS2019](https://cmake.org/cmake/help/latest/generator/Visual%20Studio%2016%202019.html)) during the configuration stage and then build as usual.
* **GCC/Clang**. Specify `-m32` during the configuration. It can be `CXXFLAGS=-m32 cmake ..` or `cmake -DCMAKE_CXX_FLAGS=-m32 ..`
* For any other compiler, which builds for 64-bit by default, specify 32-bit compiler key during the configuration as above.
* For any other compiler, which builds for 64-bit by default, specify a 32-bit compiler key during the configuration as above.
#### Windows* OS specific builds
#### Windows* OS-Specific Builds
---
**NOTE**
Following builds require CMake version 3.15 or higher.
The following builds require CMake version 3.15 or higher.
---
@@ -123,12 +126,12 @@ cmake -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ..
```bash
cmake -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug -DCMAKE_BUILD_TYPE=Debug ..
```
* **Windows* OS 10 Universal Windows application build**. Set `CMAKE_SYSTEM_NAME` to `WindowsStore` and `CMAKE_SYSTEM_VERSION` to `10.0`.
* **Windows OS 10 Universal Windows application build**. Set `CMAKE_SYSTEM_NAME` to `WindowsStore` and `CMAKE_SYSTEM_VERSION` to `10.0`.
---
**NOTE**
Set `TBB_NO_APPCONTAINER` to `ON` in order to apply `/APPCONTAINER:NO` option during the compilation (used for testing).
Set `TBB_NO_APPCONTAINER` to `ON` to apply the `/APPCONTAINER:NO` option during the compilation (used for testing).
---
@@ -136,16 +139,31 @@ Set `TBB_NO_APPCONTAINER` to `ON` in order to apply `/APPCONTAINER:NO` option du
cmake -DCMAKE_SYSTEM_NAME:STRING=WindowsStore -DCMAKE_SYSTEM_VERSION:STRING=10.0 ..
```
* **Universal Windows* OS Driver build**. Set `TBB_WINDOWS_DRIVER` to `ON` and use static linkage with CRT.
* **Universal Windows OS Driver build**. Set `TBB_WINDOWS_DRIVER` to `ON` and use static linkage with CRT.
```bash
cmake -DTBB_WINDOWS_DRIVER=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ..
```
#### Example
```bash
cmake -DCMAKE_CXX_COMPILER=icpc -DCMAKE_C_COMPILER=icc -DTBB_TEST=off -DCMAKE_HWLOC_1_11_LIBRARY_PATH=<path_to_hwloc_library_file>/libhwloc.so.15
-DCMAKE_HWLOC_1_11_INCLUDE_PATH=<path_to_hwloc_header_directory> -DCMAKE_INSTALL_PREFIX=<path_to_install_oneTBB>/oneTBB_install ..
make -j8 && make install
```
---
**NOTE**
The library path points to a file, while the include path points to a directory and not to ``hwloc.h``.
---
### Test
#### Build test
To build a test, use the default target 'all':
To build a test, use the default target ``all``:
```
cmake --build .
```
@@ -155,14 +173,14 @@ Or use a specific test target:
cmake --build . --target <test> # e.g. test_version
```
#### Run test
#### Run Test
You can run a test by using CTest:
```bash
ctest
```
Or by using 'test' target:
Or by using the ``test`` target:
```bash
cmake --build . --target test # currently does not work on Windows* OS
```
@@ -170,7 +188,7 @@ cmake --build . --target test # currently does not work on Windows* OS
## Installation
See [Installation from Sources](../INSTALL.md) to learn how to install oneTBB.
## Sanitizers - сonfigure, build, and run
## Sanitizers - Configure, Build, and Run
```bash
mkdir build
@@ -180,7 +198,7 @@ make -j
ctest -V
```
## Valgrind memcheck - configure, build, and run
## Valgrind Memcheck - Configure, Build, and Run
### Prerequisites
* Valgrind tool executable
@@ -192,9 +210,9 @@ cmake -DTBB_VALGRIND_MEMCHECK=ON ..
make -j memcheck-<test name> # or memcheck-all to scan all tests
```
## Test specification
## Test Specification
Use Doxygen to generate oneTBB test specification:
Use Doxygen* to generate oneTBB test specification:
```bash
mkdir build
@@ -203,12 +221,12 @@ cmake -DTBB_TEST_SPEC=ON ..
make test_spec
```
## TBBConfig - integration of binary packages
## TBBConfig - Integration of Binary Packages
It is a configuration module that is used for integration of prebuilt oneTBB. It consists of two files (TBBConfig.cmake and TBBConfigVersion.cmake) and can be used via [find_package](https://cmake.org/cmake/help/latest/command/find_package.html) function.
It is a configuration module that is used for the integration of prebuilt oneTBB. It consists of two files (``TBBConfig.cmake`` and ``TBBConfigVersion.cmake``) and can be used via the [find_package](https://cmake.org/cmake/help/latest/command/find_package.html) function.
How to use this module in your CMake project:
1. Let CMake know where to search for TBBConfig, e.g. specify location of TBBConfig.cmake in `TBB_DIR` (for more details about search paths see [find_package](https://cmake.org/cmake/help/latest/command/find_package.html)).
To use this module in your CMake project:
1. Let CMake know where to search for TBBConfig, e.g. specify the location of ``TBBConfig.cmake`` in `TBB_DIR` (for more details about search paths, see [find_package](https://cmake.org/cmake/help/latest/command/find_package.html)).
2. Use [find_package](https://cmake.org/cmake/help/latest/command/find_package.html) to find oneTBB.
3. Use provided variables and/or imported targets (described below) to work with the found oneTBB.
@@ -223,14 +241,14 @@ target_link_libraries(foo TBB::tbb)
oneTBB components can be passed to [find_package](https://cmake.org/cmake/help/latest/command/find_package.html) after keyword ``COMPONENTS`` or ``REQUIRED``.
Use basic names of components (`tbb`, `tbbmalloc`, etc.).
If components are not specified then the default set is used: `tbb`, `tbbmalloc` and ``tbbmalloc_proxy``.
If components are not specified, then the default set is used: `tbb`, `tbbmalloc`, and ``tbbmalloc_proxy``.
If `tbbmalloc_proxy` is requested, `tbbmalloc` component will also be added and set as dependency for `tbbmalloc_proxy`.
If `tbbmalloc_proxy` is requested, the `tbbmalloc` component is also added and set as a dependency for `tbbmalloc_proxy`.
TBBConfig creates [imported targets](https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#imported-targets>) as
shared libraries using the following format: `TBB::<component>` (for example, `TBB::tbb`, `TBB::tbbmalloc`).
shared libraries using the following format: `TBB::<component>`. For example, `TBB::tbb` or `TBB::tbbmalloc`.
Set `TBB_FIND_RELEASE_ONLY` to `TRUE` before calling `find_package` in order to search only for release oneTBB version. This variable helps to avoid simultaneous linkage of release and debug oneTBB versions when CMake configuration is `Debug` but a third-party component depends on release oneTBB version.
To search only for release oneTBB version, set `TBB_FIND_RELEASE_ONLY` to `TRUE` before calling `find_package`. This variable helps to avoid simultaneous linkage of release and debug oneTBB versions when CMake configuration is `Debug,` but a third-party component depends on the release oneTBB version.
Variables set during TBB configuration:
@@ -241,14 +259,14 @@ Variable | Description
`TBB_VERSION` | oneTBB version (format: `<major>.<minor>.<patch>.<tweak>`)
`TBB_IMPORTED_TARGETS` | All created oneTBB imported targets (not supported for builds from source code)
Starting from [oneTBB 2021.1](https://github.com/oneapi-src/oneTBB/releases/tag/v2021.1) GitHub release TBBConfig files in the binary packages are located under `<tbb-root>/lib/cmake/TBB`.
Starting from [oneTBB 2021.1](https://github.com/oneapi-src/oneTBB/releases/tag/v2021.1), GitHub* release TBBConfig files in the binary packages are located under `<tbb-root>/lib/cmake/TBB`.
For example, `TBB_DIR` should be set to `<tbb-root>/lib/cmake/TBB`.
TBBConfig files are automatically created during the build from source code and can be installed together with the library.
Also oneTBB provides a helper function that creates TBBConfig files from predefined templates: see `tbb_generate_config` in `cmake/config_generation.cmake`.
Also, oneTBB provides a helper function that creates TBBConfig files from predefined templates. See `tbb_generate_config` in `cmake/config_generation.cmake`.
## oneTBB Python Module support
`TBB4PY_BUILD` Cmake option provides ability to build Python module for oneTBB.
## oneTBB Python Module Support
The `TBB4PY_BUILD` Cmake option provides the ability to build a Python module for oneTBB.
### Targets:
- `irml` - build IPC RML server
@@ -258,30 +276,30 @@ Also oneTBB provides a helper function that creates TBBConfig files from predefi
- Python version 3.5 or newer
- SWIG version 3.0.6 or newer
## CMake files
## CMake Files
### Compile/link options
### Compile and Link Options
Compile and link options may be specific for certain compilers. This part is handled in `cmake/compilers/*` files.
Options in TBB CMake are handled via variables in two ways for convenience:
* by options group
* by specific option
* by the specific option
#### Options group
#### Options Group
Naming convention is the following: `TBB_<SCOPE>_<STAGE>_<CATEGORY>`, where
Naming convention is the following: `TBB_<SCOPE>_<STAGE>_<CATEGORY>`, where:
* `<SCOPE>` could be
* `<SCOPE>` can be:
* `LIB` - options applied during libraries build.
* `TEST` - options applied during test build.
* `BENCH` - options applied during benchmarks build.
* `COMMON` - options applied during all (libraries, test, benchmarks) builds.
* `<STAGE>` could be
* `<STAGE>` can be:
* `COMPILE` - options applied during the compilation.
* `LINK` - options applied during the linkage.
* `<CATEGORY>` could be
* `<CATEGORY>` can be:
* `FLAGS` - list of flags
* `LIBS` - list of libraries
@@ -289,17 +307,17 @@ Naming convention is the following: `TBB_<SCOPE>_<STAGE>_<CATEGORY>`, where
Variable | Description
--- | ---
`TBB_COMMON_COMPILE_FLAGS` | Applied to libraries, tests and benchmarks as compile options
`TBB_COMMON_COMPILE_FLAGS` | Applied to libraries, tests, and benchmarks as compile options
`TBB_LIB_LINK_FLAGS` | Applied to libraries as link options
`TBB_LIB_LINK_LIBS ` | Applied to libraries as link libraries
`TBB_TEST_COMPILE_FLAGS` | Applied to tests as compile options
Please specify the `LINK` options prefixed with dash(-) for MSVC(Visual Studio) compiler with CMake < 3.13 to avoid issues caused by `target_link_libraries` CMake command usage.
Specify the `LINK` options prefixed with a dash(-) for MSVC(Visual Studio) compiler with CMake < 3.13 to avoid issues caused by `target_link_libraries` CMake command usage.
#### Specific options
#### Specific Options
If the option used only in part of the places (library, tests, benchmarks) as well as adding this option to the group of other options is not possible,
If the option is used only in part of the places (library, tests, benchmarks) and adding this option to the group of other options is not possible,
then the option must be named using common sense.
Warnings supperssions should be added into `TBB_WARNING_SUPPRESS` variable which is applied during the compilation of libraries, tests and benchmarks.
Additional warnings should be added into `TBB_WARNING_TEST_FLAGS` variable which is applied during the compilation of tests.
Warning suppressions should be added to the `TBB_WARNING_SUPPRESS` variable, which is applied during the compilation of libraries, tests, and benchmarks.
Additional warnings should be added to the `TBB_WARNING_TEST_FLAGS` variable, which is applied during the compilation of tests.
+8 -2
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021 Intel Corporation
# Copyright (c) 2020-2022 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -32,9 +32,15 @@ if (NOT TBB_STRICT AND COMMAND tbb_remove_compile_flag)
endif()
# Enable Intel(R) Transactional Synchronization Extensions (-mrtm) and WAITPKG instructions support (-mwaitpkg) on relevant processors
if (NOT "${CMAKE_OSX_ARCHITECTURES}" MATCHES "^arm64$" AND CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64|amd64|AMD64)") # OSX systems are 64-bit only
if (CMAKE_OSX_ARCHITECTURES)
set(_tbb_target_architectures "${CMAKE_OSX_ARCHITECTURES}")
else()
set(_tbb_target_architectures "${CMAKE_SYSTEM_PROCESSOR}")
endif()
if ("${_tbb_target_architectures}" MATCHES "(x86_64|amd64|AMD64)") # OSX systems are 64-bit only
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -mrtm $<$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},12.0>>:-mwaitpkg>)
endif()
unset(_tbb_target_architectures)
# TBB malloc settings
set(TBBMALLOC_LIB_COMPILE_FLAGS -fno-rtti -fno-exceptions)
+21 -5
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021 Intel Corporation
# Copyright (c) 2020-2024 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -12,6 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
if (EMSCRIPTEN)
set(TBB_EMSCRIPTEN 1)
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -fexceptions)
set(TBB_TEST_LINK_FLAGS ${TBB_COMMON_LINK_FLAGS} -fexceptions -sINITIAL_MEMORY=65536000 -sALLOW_MEMORY_GROWTH=1 -sEXIT_RUNTIME=1)
if (NOT EMSCRIPTEN_WITHOUT_PTHREAD)
set_property(TARGET Threads::Threads PROPERTY INTERFACE_LINK_LIBRARIES "-pthread")
endif()
endif()
if (MINGW)
set(TBB_LINK_DEF_FILE_FLAG "")
set(TBB_DEF_FILE_PREFIX "")
@@ -27,6 +36,7 @@ elseif (MSVC)
else()
set(TBB_LINK_DEF_FILE_FLAG -Wl,--version-script=)
set(TBB_DEF_FILE_PREFIX lin${TBB_ARCH})
set(TBB_TEST_COMPILE_FLAGS ${TBB_TEST_COMPILE_FLAGS} $<$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},10.0>>:-ffp-model=precise>)
endif()
# Depfile options (e.g. -MD) are inserted automatically in some cases.
@@ -44,15 +54,21 @@ if (NOT TBB_STRICT AND COMMAND tbb_remove_compile_flag)
endif()
# Enable Intel(R) Transactional Synchronization Extensions (-mrtm) and WAITPKG instructions support (-mwaitpkg) on relevant processors
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(AMD64|amd64|i.86|x86)")
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(AMD64|amd64|i.86|x86)" AND NOT EMSCRIPTEN)
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -mrtm $<$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},12.0>>:-mwaitpkg>)
endif()
# Clang flags to prevent compiler from optimizing out security checks
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -Wformat -Wformat-security -Werror=format-security -fPIC $<$<NOT:$<BOOL:${EMSCRIPTEN}>>:-fstack-protector-strong>)
# -z switch is not supported on MacOS
if (NOT APPLE)
set(TBB_LIB_LINK_FLAGS ${TBB_LIB_LINK_FLAGS} -Wl,-z,relro,-z,now)
endif()
set(TBB_COMMON_LINK_LIBS ${CMAKE_DL_LIBS})
if (ANDROID_PLATFORM)
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} $<$<NOT:$<CONFIG:Debug>>:-D_FORTIFY_SOURCE=2>)
endif()
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} $<$<NOT:$<CONFIG:Debug>>:-D_FORTIFY_SOURCE=2>)
if (MINGW)
list(APPEND TBB_COMMON_COMPILE_FLAGS -U__STRICT_ANSI__)
+14 -4
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2022 Intel Corporation
# Copyright (c) 2020-2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -40,9 +40,7 @@ if (CMAKE_SYSTEM_PROCESSOR MATCHES "(AMD64|amd64|i.86|x86)")
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -mrtm $<$<AND:$<NOT:$<CXX_COMPILER_ID:Intel>>,$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},11.0>>>:-mwaitpkg>)
endif()
if (NOT MINGW)
set(TBB_COMMON_LINK_LIBS dl)
endif()
set(TBB_COMMON_LINK_LIBS ${CMAKE_DL_LIBS})
# Ignore -Werror set through add_compile_options() or added to CMAKE_CXX_FLAGS if TBB_STRICT is disabled.
if (NOT TBB_STRICT AND COMMAND tbb_remove_compile_flag)
@@ -52,6 +50,7 @@ endif()
if (NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL Intel)
# gcc 6.0 and later have -flifetime-dse option that controls elimination of stores done outside the object lifetime
set(TBB_DSE_FLAG $<$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},6.0>>:-flifetime-dse=1>)
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} $<$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},8.0>>:-fstack-clash-protection>)
endif()
# Workaround for heavy tests and too many symbols in debug (rellocation truncated to fit: R_MIPS_CALL16)
@@ -68,6 +67,17 @@ if (MINGW AND CMAKE_SYSTEM_PROCESSOR MATCHES "i.86")
list (APPEND TBB_COMMON_COMPILE_FLAGS -msse2)
endif ()
# Gnu flags to prevent compiler from optimizing out security checks
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -fno-strict-overflow -fno-delete-null-pointer-checks -fwrapv)
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -Wformat -Wformat-security -Werror=format-security
-fstack-protector-strong )
# -z switch is not supported on MacOS and MinGW
if (NOT APPLE AND NOT MINGW)
set(TBB_LIB_LINK_FLAGS ${TBB_LIB_LINK_FLAGS} -Wl,-z,relro,-z,now,-z,noexecstack)
endif()
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} $<$<NOT:$<CONFIG:Debug>>:-D_FORTIFY_SOURCE=2> )
# TBB malloc settings
set(TBBMALLOC_LIB_COMPILE_FLAGS -fno-rtti -fno-exceptions)
set(TBB_OPENMP_FLAG -fopenmp)
+3 -5
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021 Intel Corporation
# Copyright (c) 2020-2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -26,10 +26,8 @@ elseif (APPLE)
set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:-ipo>)
else()
include(${CMAKE_CURRENT_LIST_DIR}/GNU.cmake)
set(TBB_LIB_LINK_FLAGS ${TBB_LIB_LINK_FLAGS} -static-intel -Wl,-z,relro,-z,now,)
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -fstack-protector -Wformat -Wformat-security
$<$<NOT:$<CONFIG:Debug>>:-qno-opt-report-embed -D_FORTIFY_SOURCE=2>
$<$<EQUAL:${TBB_ARCH},32>:-falign-stack=maintain-16-byte>)
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} $<$<EQUAL:${TBB_ARCH},32>:-falign-stack=maintain-16-byte>)
set(TBB_LIB_LINK_FLAGS ${TBB_LIB_LINK_FLAGS} -static-intel)
set(TBB_OPENMP_FLAG -qopenmp)
set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:-ipo>)
endif()
+3 -1
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021 Intel Corporation
# Copyright (c) 2020-2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -14,10 +14,12 @@
if (WIN32)
include(${CMAKE_CURRENT_LIST_DIR}/MSVC.cmake)
set(TBB_OPENMP_FLAG /Qopenmp)
set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:/Qipo>)
set(TBB_IPO_LINK_FLAGS $<$<NOT:$<CONFIG:Debug>>:/INCREMENTAL:NO>)
else()
include(${CMAKE_CURRENT_LIST_DIR}/Clang.cmake)
set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:-ipo>)
set(TBB_OPENMP_FLAG -qopenmp)
endif()
set(TBB_IPO_LINK_FLAGS ${TBB_IPO_LINK_FLAGS} ${TBB_IPO_COMPILE_FLAGS})
+8 -2
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021 Intel Corporation
# Copyright (c) 2020-2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -33,7 +33,13 @@ if (MSVC_VERSION LESS_EQUAL 1900)
set(TBB_TEST_COMPILE_FLAGS ${TBB_TEST_COMPILE_FLAGS} /wd4503)
endif()
set(TBB_LIB_COMPILE_FLAGS -D_CRT_SECURE_NO_WARNINGS /GS)
set(TBB_COMMON_COMPILE_FLAGS /volatile:iso /FS /EHsc)
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} /volatile:iso /FS /EHsc)
set(TBB_LIB_LINK_FLAGS ${TBB_LIB_LINK_FLAGS} /DYNAMICBASE /NXCOMPAT)
if (TBB_ARCH EQUAL 32)
set(TBB_LIB_LINK_FLAGS ${TBB_LIB_LINK_FLAGS} /SAFESEH )
endif()
# Ignore /WX set through add_compile_options() or added to CMAKE_CXX_FLAGS if TBB_STRICT is disabled.
if (NOT TBB_STRICT AND COMMAND tbb_remove_compile_flag)
+41 -30
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021 Intel Corporation
# Copyright (c) 2020-2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@ function(tbb_generate_config)
set(options HANDLE_SUBDIRS)
set(oneValueArgs INSTALL_DIR
SYSTEM_NAME
LIB_REL_PATH INC_REL_PATH DLL_REL_PATH
LIB_REL_PATH INC_REL_PATH
VERSION
TBB_BINARY_VERSION
TBBMALLOC_BINARY_VERSION
@@ -35,7 +35,6 @@ function(tbb_generate_config)
file(MAKE_DIRECTORY ${config_install_dir})
file(TO_CMAKE_PATH "${tbb_gen_cfg_LIB_REL_PATH}" TBB_LIB_REL_PATH)
file(TO_CMAKE_PATH "${tbb_gen_cfg_DLL_REL_PATH}" TBB_DLL_REL_PATH)
file(TO_CMAKE_PATH "${tbb_gen_cfg_INC_REL_PATH}" TBB_INC_REL_PATH)
set(TBB_VERSION ${tbb_gen_cfg_VERSION})
@@ -54,45 +53,61 @@ set(_tbbbind_bin_version ${tbb_gen_cfg_TBBBIND_BINARY_VERSION})
if (tbb_gen_cfg_SYSTEM_NAME STREQUAL "Linux")
set(TBB_LIB_PREFIX "lib")
set(TBB_LIB_EXT "so.\${_\${_tbb_component}_bin_version}")
set(TBB_IMPLIB_RELEASE "")
set(TBB_IMPLIB_DEBUG "")
if (tbb_gen_cfg_HANDLE_SUBDIRS)
set(TBB_HANDLE_SUBDIRS "
if (CMAKE_SIZEOF_VOID_P STREQUAL \"8\")
set(_tbb_subdir intel64/gcc4.8)
else ()
set(_tbb_subdir ia32/gcc4.8)
endif()
set (TBB_HANDLE_IMPLIB "
set (_tbb_release_dll \${_tbb_release_lib})
set (_tbb_debug_dll \${_tbb_debug_lib})
")
if (tbb_gen_cfg_HANDLE_SUBDIRS)
set(TBB_HANDLE_SUBDIRS "set(_tbb_subdir gcc4.8)")
set(_libdir_for_pc_file "\${prefix}/lib/intel64/gcc4.8")
set(_tbb_pc_extra_libdir "-L\${prefix}/lib")
configure_file(${_tbb_gen_cfg_path}/../integration/pkg-config/tbb.pc.in ${config_install_dir}/tbb.pc @ONLY)
set(_libdir_for_pc_file "\${prefix}/lib/ia32/gcc4.8")
set(_tbb_pc_extra_libdir "-L\${prefix}/lib32")
configure_file(${_tbb_gen_cfg_path}/../integration/pkg-config/tbb.pc.in ${config_install_dir}/tbb32.pc @ONLY)
endif()
elseif (tbb_gen_cfg_SYSTEM_NAME STREQUAL "Darwin")
set(TBB_LIB_PREFIX "lib")
set(TBB_LIB_EXT "\${_\${_tbb_component}_bin_version}.dylib")
set(TBB_IMPLIB_RELEASE "")
set(TBB_IMPLIB_DEBUG "")
set (TBB_HANDLE_IMPLIB "
set (_tbb_release_dll \${_tbb_release_lib})
set (_tbb_debug_dll \${_tbb_debug_lib})
")
set(_libdir_for_pc_file "\${prefix}/lib")
configure_file(${_tbb_gen_cfg_path}/../integration/pkg-config/tbb.pc.in ${config_install_dir}/tbb.pc @ONLY)
elseif (tbb_gen_cfg_SYSTEM_NAME STREQUAL "Windows")
set(TBB_LIB_PREFIX "")
set(TBB_LIB_EXT "dll")
set(TBB_LIB_EXT "lib")
set(TBB_COMPILE_DEFINITIONS "
INTERFACE_COMPILE_DEFINITIONS \"__TBB_NO_IMPLICIT_LINKAGE=1\"")
# .lib - installed to TBB_LIB_REL_PATH (e.g. <prefix>/lib) and are passed as IMPORTED_IMPLIB_<CONFIG> property to target
# .dll - installed to <prefix>/bin or <prefix>/redist and are passed as IMPORTED_LOCATION_<CONFIG> property to target
set (TBB_HANDLE_IMPLIB "
find_file(_tbb_release_dll
NAMES \${_tbb_component}\${_bin_version}.dll
PATHS \${_tbb_root}
PATH_SUFFIXES \"redist/\${_tbb_intel_arch}/\${_tbb_subdir}\" \"bin\${_tbb_arch_suffix}/\${_tbb_subdir}\" \"bin\${_tbb_arch_suffix}/\" \"bin\"
NO_DEFAULT_PATH
)
# .lib files installed to TBB_LIB_REL_PATH (e.g. <prefix>/lib);
# .dll files installed to TBB_DLL_REL_PATH (e.g. <prefix>/bin);
# Expand TBB_LIB_REL_PATH here in IMPORTED_IMPLIB property and
# redefine it with TBB_DLL_REL_PATH value to properly fill IMPORTED_LOCATION property in TBBConfig.cmake.in template.
set(TBB_IMPLIB_RELEASE "
IMPORTED_IMPLIB_RELEASE \"\${_tbb_root}/${TBB_LIB_REL_PATH}/\${_tbb_subdir}/\${_tbb_component}\${_bin_version}.lib\"")
set(TBB_IMPLIB_DEBUG "
IMPORTED_IMPLIB_DEBUG \"\${_tbb_root}/${TBB_LIB_REL_PATH}/\${_tbb_subdir}/\${_tbb_component}\${_bin_version}_debug.lib\"")
set(TBB_LIB_REL_PATH ${TBB_DLL_REL_PATH})
if (EXISTS \"\${_tbb_debug_lib}\")
find_file(_tbb_debug_dll
NAMES \${_tbb_component}\${_bin_version}_debug.dll
PATHS \${_tbb_root}
PATH_SUFFIXES \"redist/\${_tbb_intel_arch}/\${_tbb_subdir}\" \"bin\${_tbb_arch_suffix}/\${_tbb_subdir}\" \"bin\${_tbb_arch_suffix}/\" \"bin\"
NO_DEFAULT_PATH
)
endif()
")
set(TBB_IMPLIB_RELEASE "
IMPORTED_IMPLIB_RELEASE \"\${_tbb_release_lib}\"")
set(TBB_IMPLIB_DEBUG "
IMPORTED_IMPLIB_DEBUG \"\${_tbb_debug_lib}\"")
if (tbb_gen_cfg_HANDLE_SUBDIRS)
set(TBB_HANDLE_SUBDIRS "
@@ -100,19 +115,15 @@ set(_tbb_subdir vc14)
if (WINDOWS_STORE)
set(_tbb_subdir \${_tbb_subdir}_uwp)
endif()
if (CMAKE_SIZEOF_VOID_P STREQUAL \"8\")
set(_tbb_subdir intel64/\${_tbb_subdir})
else ()
set(_tbb_subdir ia32/\${_tbb_subdir})
endif()
")
set(_tbb_pc_lib_name ${_tbb_pc_lib_name}${TBB_BINARY_VERSION})
set(_libdir_for_pc_file "\${prefix}/lib/intel64/vc14")
set(_tbb_pc_extra_libdir "-L\${prefix}/lib")
configure_file(${_tbb_gen_cfg_path}/../integration/pkg-config/tbb.pc.in ${config_install_dir}/tbb.pc @ONLY)
set(_libdir_for_pc_file "\${prefix}/lib/ia32/vc14")
set(_tbb_pc_extra_libdir "-L\${prefix}/lib32")
configure_file(${_tbb_gen_cfg_path}/../integration/pkg-config/tbb.pc.in ${config_install_dir}/tbb32.pc @ONLY)
endif()
+1 -3
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021 Intel Corporation
# Copyright (c) 2020-2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -46,8 +46,6 @@ endforeach()
unset(HWLOC_TARGET_NAME)
if (NOT HWLOC_TARGET_EXPLICITLY_DEFINED AND
# No hwloc auto detection for cross compilation
NOT CMAKE_CROSSCOMPILING AND
NOT TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH
)
find_package(PkgConfig QUIET)
+11 -3
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021 Intel Corporation
# Copyright (c) 2020-2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -31,10 +31,18 @@ endif()
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/memcheck)
function(_tbb_run_memcheck test_target)
function(_tbb_run_memcheck test_target subdir)
set(target_name memcheck-${test_target})
if(${subdir} STREQUAL "tbbmalloc")
# Valgring intercepts all allocation symbols with its own by default,
# so it disables using tbbmalloc. In case of tbbmalloc tests
# intercept allocation symbols only in the default system libraries,
# but not in any other shared library or the executable
# defining public malloc or operator new related functions.
set(option "--soname-synonyms=somalloc=nouserintercepts")
endif()
add_custom_target(${target_name}
COMMAND ${VALGRIND_EXE} --leak-check=full --show-leak-kinds=all --log-file=${CMAKE_BINARY_DIR}/memcheck/${target_name}.log -v $<TARGET_FILE:${test_target}>)
COMMAND ${VALGRIND_EXE} ${option} --leak-check=full --show-leak-kinds=all --log-file=${CMAKE_BINARY_DIR}/memcheck/${target_name}.log -v $<TARGET_FILE:${test_target}>)
add_dependencies(memcheck-all ${target_name})
endfunction()
+5 -2
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021 Intel Corporation
# Copyright (c) 2020-2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -18,4 +18,7 @@ set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
set(CPACK_PACKAGE_VERSION "${TBB_VERSION}")
string(TOLOWER ${CPACK_PACKAGE_NAME}-${PROJECT_VERSION}-${CMAKE_SYSTEM_NAME}_${TBB_OUTPUT_DIR_BASE}_${CMAKE_BUILD_TYPE} CPACK_PACKAGE_FILE_NAME)
set(CPACK_GENERATOR ZIP)
include(CPack)
# Note: this is an internal non-documented variable set by CPack
if (NOT CPack_CMake_INCLUDED)
include(CPack)
endif()
+31
View File
@@ -0,0 +1,31 @@
# Copyright (c) 2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
include(CheckSymbolExists)
if (UNIX)
set(CMAKE_REQUIRED_FLAGS -Wno-deprecated-declarations)
if (APPLE)
set(CMAKE_REQUIRED_DEFINITIONS -D_XOPEN_SOURCE)
endif()
check_symbol_exists("getcontext" "ucontext.h" _tbb_have_ucontext)
if (NOT _tbb_have_ucontext)
set(TBB_RESUMABLE_TASKS_USE_THREADS "__TBB_RESUMABLE_TASKS_USE_THREADS=1")
endif()
unset(_tbb_have_ucontext)
unset(CMAKE_REQUIRED_DEFINITIONS)
unset(CMAKE_REQUIRED_FLAGS)
endif()
+2 -1
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021 Intel Corporation
# Copyright (c) 2020-2022 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -39,4 +39,5 @@ set(TBB_TESTS_ENVIRONMENT ${TBB_TESTS_ENVIRONMENT}
"LSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/cmake/suppressions/lsan.suppressions")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TBB_SANITIZE_OPTION}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TBB_SANITIZE_OPTION}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${TBB_SANITIZE_OPTION}")
+3 -4
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021 Intel Corporation
# Copyright (c) 2020-2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@ set(TBB_ROOT_REL_PATH "../../..")
# Paths relative to TBB root directory
set(INC_REL_PATH "include")
set(LIB_REL_PATH "lib")
set(DLL_REL_PATH "redist")
# Parse version info
file(READ ${CMAKE_CURRENT_LIST_DIR}/../../include/oneapi/tbb/version.h _tbb_version_info)
@@ -45,6 +44,6 @@ set(COMMON_ARGS
)
tbb_generate_config(INSTALL_DIR ${INSTALL_DIR}/linux SYSTEM_NAME Linux HANDLE_SUBDIRS ${COMMON_ARGS})
tbb_generate_config(INSTALL_DIR ${INSTALL_DIR}/windows SYSTEM_NAME Windows HANDLE_SUBDIRS DLL_REL_PATH ${DLL_REL_PATH} ${COMMON_ARGS})
tbb_generate_config(INSTALL_DIR ${INSTALL_DIR}/darwin SYSTEM_NAME Darwin ${COMMON_ARGS})
tbb_generate_config(INSTALL_DIR ${INSTALL_DIR}/windows SYSTEM_NAME Windows HANDLE_SUBDIRS ${COMMON_ARGS})
tbb_generate_config(INSTALL_DIR ${INSTALL_DIR}/darwin SYSTEM_NAME Darwin ${COMMON_ARGS})
message(STATUS "TBBConfig files were created in ${INSTALL_DIR}")
+1
View File
@@ -1,3 +1,4 @@
# TSAN suppression for known issues.
# Possible data race during ittnotify initialization. Low impact.
race:__itt_nullify_all_pointers
race:__itt_init_ittlib
+37 -7
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2017-2021 Intel Corporation
# Copyright (c) 2017-2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -43,14 +43,38 @@ if (NOT _tbbmalloc_proxy_ix EQUAL -1)
set(TBB_FIND_REQUIRED_tbbmalloc ${TBB_FIND_REQUIRED_tbbmalloc_proxy})
endif()
unset(_tbbmalloc_proxy_ix)
if (CMAKE_SIZEOF_VOID_P STREQUAL "8")
set(_tbb_intel_arch intel64)
else ()
set(_tbb_intel_arch ia32)
set(_tbb_arch_suffix 32)
endif()
@TBB_HANDLE_SUBDIRS@
foreach (_tbb_component ${TBB_FIND_COMPONENTS})
unset(_tbb_release_dll CACHE)
unset(_tbb_debug_dll CACHE)
unset(_tbb_release_lib CACHE)
unset(_tbb_debug_lib CACHE)
set(TBB_${_tbb_component}_FOUND 0)
@TBB_HANDLE_BIN_VERSION@
get_filename_component(_tbb_release_lib "${_tbb_root}/@TBB_LIB_REL_PATH@/${_tbb_subdir}/@TBB_LIB_PREFIX@${_tbb_component}${_bin_version}.@TBB_LIB_EXT@" ABSOLUTE)
find_library(_tbb_release_lib
NAMES @TBB_LIB_PREFIX@${_tbb_component}${_bin_version}.@TBB_LIB_EXT@
PATHS ${_tbb_root}
PATH_SUFFIXES "@TBB_LIB_REL_PATH@/${_tbb_intel_arch}/${_tbb_subdir}" "@TBB_LIB_REL_PATH@${_tbb_arch_suffix}/${_tbb_subdir}" "@TBB_LIB_REL_PATH@${_tbb_arch_suffix}" "@TBB_LIB_REL_PATH@"
NO_DEFAULT_PATH
)
if (NOT TBB_FIND_RELEASE_ONLY)
get_filename_component(_tbb_debug_lib "${_tbb_root}/@TBB_LIB_REL_PATH@/${_tbb_subdir}/@TBB_LIB_PREFIX@${_tbb_component}${_bin_version}_debug.@TBB_LIB_EXT@" ABSOLUTE)
find_library(_tbb_debug_lib
NAMES @TBB_LIB_PREFIX@${_tbb_component}${_bin_version}_debug.@TBB_LIB_EXT@
PATHS ${_tbb_root}
PATH_SUFFIXES "@TBB_LIB_REL_PATH@/${_tbb_intel_arch}/${_tbb_subdir}" "@TBB_LIB_REL_PATH@${_tbb_arch_suffix}/${_tbb_subdir}" "@TBB_LIB_REL_PATH@${_tbb_arch_suffix}" "@TBB_LIB_REL_PATH@"
NO_DEFAULT_PATH
)
endif()
if (EXISTS "${_tbb_release_lib}" OR EXISTS "${_tbb_debug_lib}")
@@ -63,15 +87,17 @@ foreach (_tbb_component ${TBB_FIND_COMPONENTS})
unset(_tbb_current_realpath)
unset(_tbb_include_dir)
if (EXISTS "${_tbb_release_lib}")
@TBB_HANDLE_IMPLIB@
if (EXISTS "${_tbb_release_dll}")
set_target_properties(TBB::${_tbb_component} PROPERTIES
IMPORTED_LOCATION_RELEASE "${_tbb_release_lib}"@TBB_IMPLIB_RELEASE@)
IMPORTED_LOCATION_RELEASE "${_tbb_release_dll}"@TBB_IMPLIB_RELEASE@)
set_property(TARGET TBB::${_tbb_component} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
endif()
if (EXISTS "${_tbb_debug_lib}")
if (EXISTS "${_tbb_debug_dll}")
set_target_properties(TBB::${_tbb_component} PROPERTIES
IMPORTED_LOCATION_DEBUG "${_tbb_debug_lib}"@TBB_IMPLIB_DEBUG@)
IMPORTED_LOCATION_DEBUG "${_tbb_debug_dll}"@TBB_IMPLIB_DEBUG@)
set_property(TARGET TBB::${_tbb_component} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
endif()
@@ -93,6 +119,10 @@ foreach (_tbb_component ${TBB_FIND_COMPONENTS})
endif()
endforeach()
list(REMOVE_DUPLICATES TBB_IMPORTED_TARGETS)
unset(_tbb_release_dll)
unset(_tbb_debug_dll)
unset(_tbb_release_lib)
unset(_tbb_debug_lib)
unset(_tbb_root)
unset(_tbb_intel_arch)
unset(_tbb_arch_suffix)
+34
View File
@@ -0,0 +1,34 @@
# Copyright (c) 2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Prevent double invocation.
if (RISCV_TOOLCHAIN_INCLUDED)
return()
endif()
set(RISCV_TOOLCHAIN_INCLUDED TRUE)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_VERSION 1)
set(CMAKE_SYSTEM_PROCESSOR riscv)
# User can use -DCMAKE_FIND_ROOT_PATH to specific toolchain path
set(CMAKE_C_COMPILER ${CMAKE_FIND_ROOT_PATH}/bin/riscv64-unknown-linux-gnu-clang)
set(CMAKE_CXX_COMPILER ${CMAKE_FIND_ROOT_PATH}/bin/riscv64-unknown-linux-gnu-clang++)
set(CMAKE_LINKER ${CMAKE_FIND_ROOT_PATH}/bin/riscv64-unknown-linux-gnu-ld)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# Most linux on riscv64 support rv64imafd_zba_zbb extensions
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=rv64imafd_zba_zbb -mabi=lp64d " CACHE INTERNAL "")
+28 -17
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2022 Intel Corporation
# Copyright (c) 2020-2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -23,31 +23,42 @@ macro(tbb_remove_compile_flag flag)
endmacro()
macro(tbb_install_target target)
install(TARGETS ${target}
EXPORT TBBTargets
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
NAMELINK_SKIP
COMPONENT runtime
RUNTIME
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT runtime
ARCHIVE
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT devel)
if (BUILD_SHARED_LIBS)
if (TBB_INSTALL)
install(TARGETS ${target}
EXPORT TBBTargets
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
NAMELINK_ONLY
NAMELINK_SKIP
COMPONENT runtime
RUNTIME
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT runtime
ARCHIVE
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT devel)
if (BUILD_SHARED_LIBS)
install(TARGETS ${target}
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
NAMELINK_ONLY
COMPONENT devel)
endif()
if (MSVC AND BUILD_SHARED_LIBS)
install(FILES $<TARGET_PDB_FILE:${target}>
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT devel
OPTIONAL)
endif()
endif()
endmacro()
macro(tbb_handle_ipo target)
if (TBB_IPO_PROPERTY)
set_target_properties(${target} PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE)
set_target_properties(${target} PROPERTIES
INTERPROCEDURAL_OPTIMIZATION TRUE
INTERPROCEDURAL_OPTIMIZATION_DEBUG FALSE
)
elseif (TBB_IPO_FLAGS)
target_compile_options(${target} PRIVATE ${TBB_IPO_COMPILE_FLAGS})
if (COMMAND target_link_options)
+37
View File
@@ -0,0 +1,37 @@
window.MathJax = {
TeX: {
Macros: {
src: '\\operatorname{src}',
srclayer: '\\operatorname{src\\_layer}',
srciter: '\\operatorname{src\\_iter}',
srciterc: '\\operatorname{src\\_iter\\_c}',
weights: '\\operatorname{weights}',
weightslayer: '\\operatorname{weights\\_layer}',
weightsiter: '\\operatorname{weights\\_iter}',
weightspeephole: '\\operatorname{weights\\_peephole}',
weightsprojection: '\\operatorname{weights\\_projection}',
bias: '\\operatorname{bias}',
dst: '\\operatorname{dst}',
dstlayer: '\\operatorname{dst\\_layer}',
dstiter: '\\operatorname{dst\\_iter}',
dstiterc: '\\operatorname{dst\\_iter\\_c}',
diffsrc: '\\operatorname{diff\\_src}',
diffsrclayer: '\\operatorname{diff\\_src\\_layer}',
diffsrciter: '\\operatorname{diff\\_src\\_iter}',
diffsrciterc: '\\operatorname{diff\\_src\\_iter\\_c}',
diffweights: '\\operatorname{diff\\_weights}',
diffweightslayer: '\\operatorname{diff\\_weights\\_layer}',
diffweightsiter: '\\operatorname{diff\\_weights\\_iter}',
diffweightspeephole: '\\operatorname{diff\\_weights\\_peephole}',
diffweightsprojection: '\\operatorname{diff\\_weights\\_projection}',
diffbias: '\\operatorname{diff\\_bias}',
diffdst: '\\operatorname{diff\\_dst}',
diffdstlayer: '\\operatorname{diff\\_dst\\_layer}',
diffdstiter: '\\operatorname{diff\\_dst\\_iter}',
diffdstiterc: '\\operatorname{diff\\_dst\\_iter\\_c}',
diffgamma: '\\operatorname{diff\\_\\gamma}',
diffbeta: '\\operatorname{diff\\_\\beta}',
workspace: '\\operatorname{workspace}'
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

+13
View File
@@ -0,0 +1,13 @@
/* override table width restrictions */
@media screen and (min-width: 767px) {
.wy-table-responsive table td {
/* !important prevents the common CSS stylesheets from overriding
this as on RTD they are loaded after this stylesheet */
white-space: normal !important;
}
.wy-table-responsive {
overflow: visible !important;
}
}
+299
View File
@@ -0,0 +1,299 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
SOURCE_DIR = os.path.dirname(__file__)
LATEX_DIR = os.path.join(SOURCE_DIR, '_latex')
PREAMBLE_FILE = os.path.join(LATEX_DIR, 'preamble.tex')
TITLE_PAGE_FILE = os.path.join(LATEX_DIR, 'title_page.tex')
BUILD_TYPE = os.getenv("BUILD_TYPE")
# -- Project information -----------------------------------------------------
if BUILD_TYPE == 'oneapi' or BUILD_TYPE == 'dita':
project = u'Intel® oneAPI Threading Building Blocks (oneTBB)'
else:
project = u'oneAPI Threading Building Blocks (oneTBB)'
copyright = u'2021, Intel Corporation'
author = u'Intel'
# The short X.Y version
version = u''
# The full version, including alpha/beta/rc tags
release = u''
# -- General configuration ---------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.imgmath',
'sphinx.ext.ifconfig',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
# The master toctree document.
#master_doc = 'main/title_main'
master_doc = 'index'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = None
# Syntax highlighting for the :: directive
highlight_language = 'cpp'
if BUILD_TYPE == 'oneapi' or BUILD_TYPE == 'dita':
rst_prolog = """
.. |full_name| replace:: Intel\ |reg|\ oneAPI Threading Building Blocks (oneTBB)
.. |short_name| replace:: oneTBB
.. |product| replace:: oneTBB
.. |reg| unicode:: U+000AE
.. |copy| unicode:: U+000A9
.. |base_tk| replace:: Intel\ |reg|\ oneAPI Base Toolkit
.. |dpcpp| replace:: Intel\ |reg|\ oneAPI DPC++/C++ Compiler
"""
else:
rst_prolog = """
.. |full_name| replace:: oneAPI Threading Building Blocks (oneTBB)
.. |short_name| replace:: oneTBB
.. |product| replace:: oneTBB
.. |reg| unicode:: U+000AE
.. |copy| unicode:: U+000A9
.. |base_tk| replace:: Intel\ |reg|\ oneAPI Base Toolkit
.. |dpcpp| replace:: Intel\ |reg|\ oneAPI DPC++/C++ Compiler
"""
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
if BUILD_TYPE == 'oneapi' or BUILD_TYPE == 'dita':
html_theme = 'sphinx_rtd_theme'
else:
html_theme = 'sphinx_book_theme'
html_theme_options = {
'repository_url': 'https://github.com/oneapi-src/oneTBB',
'path_to_docs': 'doc/main',
'use_issues_button': True,
'use_edit_page_button': True,
'repository_branch': 'master',
'extra_footer': '<p align="right"><a href="https://www.intel.com/content/www/us/en/privacy/intel-cookie-notice.html">Cookies</a></p>'
}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
if BUILD_TYPE == 'oneapi' or BUILD_TYPE == 'dita':
html_context = {
'css_files': [
'_static/theme_overrides.css', # override wide tables in RTD theme
],
}
else:
html_js_files = ['custom.js']
html_logo = '_static/oneAPI-rgb-rev-100.png'
html_favicon = '_static/favicons.png'
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}
# -- Options for HTMLHelp output ---------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'sphinx-infodevdoc'
# -- Options for LaTeX output ------------------------------------------------
#latex_engine = 'xelatex'
#PDF_TITLE = 'Information Development Template'
#
#with open(PREAMBLE_FILE, 'r', encoding='utf-8') as f:
# PREAMBLE = f.read()
#
#with open(TITLE_PAGE_FILE, 'r', encoding='utf-8') as f:
# TITLE_PAGE = f.read().replace('<PDF_TITLE>', PDF_TITLE)
#
#
#latex_elements = {
# # The paper size ('letterpaper' or 'a4paper').
# #
# 'extraclassoptions': 'openany,oneside',
# 'babel' : '\\usepackage[english]{babel}',
# 'papersize': 'a4paper',
# 'releasename':" ",
# # Sonny, Lenny, Glenn, Conny, Rejne, Bjarne and Bjornstrup
# # 'fncychap': '\\usepackage[Lenny]{fncychap}',
# 'fncychap': '',
# #'fontpkg': '\\usepackage{amsmath,amsfonts,amssymb,amsthm}',
#
# 'figure_align':'htbp',
# # The font size ('10pt', '11pt' or '12pt').
# #
# 'pointsize': '12pt',
#
# # Additional stuff for the LaTeX preamble.
# #
# 'preamble': PREAMBLE,
#
# 'maketitle': TITLE_PAGE,
# # Latex figure (float) alignment
# #
# # 'figure_align': 'htbp',
# 'sphinxsetup': \
# 'hmargin={0.7in,0.7in}, vmargin={1in,1in}, \
# verbatimwithframe=true, \
# TitleColor={rgb}{0,0.686,0.941}, \
# HeaderFamily=\\rmfamily\\bfseries, \
# InnerLinkColor={rgb}{0,0.686,0.941}, \
# OuterLinkColor={rgb}{0,0.686,0.941}',
#
# 'tableofcontents':' '
#}
#
#latex_logo = '_latex/intel_logo.png'
## Grouping the document tree into LaTeX files. List of tuples
## (source start file, target name, title,
## author, documentclass [howto, manual, or own class]).
#latex_documents = [
# (master_doc, 'sphinx-infodev.tex', u'sphinx-infodev Documentation',
# u'Intel', 'manual'),
#]
#breathe_projects = { #todd-mod
# project: "../doxygen/xml"
#}
#breathe_default_project = project
# Setup the exhale extension
#exhale_args = { #todd-mod
# # These arguments are required
# "containmentFolder": "./api",
# "rootFileName": "library_root.rst",
# "rootFileTitle": "Library API",
# "doxygenStripFromPath": "..",
# "fullApiSubSectionTitle": 'Full API'
#}
# -- Options for manual page output ------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'sphinx-infodev', u'sphinx-infodev Documentation',
[author], 1)
]
# -- Options for Texinfo output ----------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'sphinx-infodev', u'sphinx-infodev Documentation',
author, 'sphinx-infodev', 'One line description of project.',
'Miscellaneous'),
]
# -- Options for Epub output -------------------------------------------------
# Bibliographic Dublin Core info.
epub_title = project
# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''
# A unique identification for the text.
#
# epub_uid = ''
# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
# -- Extension configuration -------------------------------------------------
# -- Options for intersphinx extension ---------------------------------------
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}
# -- Options for todo extension ----------------------------------------------
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
+17 -8
View File
@@ -1,15 +1,24 @@
.. _Get_Started_Guide:
Get Started with |short_name|
==============================
Get Started with |full_name|
=============================
.. include:: intro_gsg.rst
|short_name| Get Started Guide provides the information you need to begin working with oneTBB.
It is helpful for new users of parallel programming and experienced developers that want to improve code performance.
.. include:: system_requirements.rst
It is recommended for you to have a basic knowledge of C++ programming and some experience with parallel programming concepts.
.. include:: before_beginning_and_example.rst
Find more
*********
To start using oneTBB, follow the next steps:
*********************************************
#. Learn what :ref:`oneTBB is<intro>` and see the :ref:`System Requirements<system_requirements>`.
#. :ref:`Install oneTBB<installation>`.
#. Run your program using oneTBB following the :ref:`Next Steps <next_steps>`.
#. Learn how to :ref:`Integrate oneTBB into your project <integrate>` using CMake* and pkg-config tool.
#. See :ref:`oneTBB Samples <samples>`.
See our `documentation <https://oneapi-src.github.io/oneTBB/>`_ to learn more about |short_name|.
+40
View File
@@ -0,0 +1,40 @@
.. _hybrid_cpu_support:
Hybrid CPU and NUMA Support
***************************
If you need NUMA/Hybrid CPU support in oneTBB, you need to make sure that HWLOC* is installed on your system.
HWLOC* (Hardware Locality) is a library that provides a portable abstraction of the hierarchical topology of modern architectures (NUMA, hybrid CPU systems, etc).
oneTBB relies on HWLOC* to identify the underlying topology of the system to optimize thread scheduling and memory allocation.
Without HWLOC*, oneTBB may not take advantage of NUMA/Hybrid CPU support. Therefore, it's important to make sure that HWLOC* is installed before using oneTBB on such systems.
Check HWLOC* on the System
^^^^^^^^^^^^^^^^^^^^^^^^^^
To check if HWLOC* is already installed on your system, run `hwloc-ls`:
* For Linux* OS, in the command line.
* For Windows* OS, in the command prompt.
If HWLOC* is installed, the command displays information about the hardware topology of your system.
If it is not installed, you receive an error message saying that the command ``hwloc-ls`` could not be found.
.. note:: For Hybrid CPU support, make sure that HWLOC* is version 2.5 or higher.
For NUMA support, install HWLOC* version 1.11 or higher.
Install HWLOC*
^^^^^^^^^^^^^^
To install HWLOC*, visit the official Portable Hardware Locality website (https://www-lb.open-mpi.org/projects/hwloc/).
* For Windows* OS, binaries are available for download.
* For Linux* OS, only the source code is provided and binaries should be built.
On Linux* OS, HWLOC* can be also installed with package managers, such as APT*, YUM*, etc.
To do so, run: ``sudo apt install hwloc``.
.. note:: For Hybrid CPU support, make sure that HWLOC* is version 2.5 or higher.
For NUMA support, install HWLOC* version 1.11 or higher.
+121
View File
@@ -0,0 +1,121 @@
.. _Get_Started_Guide
Get Started with |full_name|
============================
|full_name| enables you to simplify parallel programming by breaking
computation into parallel running tasks. oneTBB is available as a stand-alone
product and as part of the |base_tk|.
|short_name| is a runtime-based parallel programming model for C++ code that uses threads.
It consists of a template-based runtime library to help you harness the latent performance
of multi-core processors. Use |short_name| to write scalable applications that:
- Specify logical parallel structure instead of threads
- Emphasize data parallel programming
- Take advantage of concurrent collections and parallel algorithms
System Requirements
*******************
Refer to the `oneTBB System Requirements <https://software.intel.com/content/www/us/en/develop/articles/intel-oneapi-threading-building-blocks-system-requirements.html>`_.
Before You Begin
****************
Download |short_name| as a `stand-alone product <https://software.intel.com/content/www/us/en/develop/articles/oneapi-standalone-components.html#onetbb>`_
or as a part of the `Intel(R) oneAPI Base Toolkit <https://software.intel.com/content/www/us/en/develop/tools/oneapi/base-toolkit/download.html>`_.
After installing |short_name|, you need to set the environment variables:
#. Go to the oneTBB installation directory (``<install_dir>``). By default, ``<install_dir>`` is the following:
* On Linux* OS:
* For superusers (root): ``/opt/intel/oneapi``
* For ordinary users (non-root): ``$HOME/intel/oneapi``
* On Windows* OS:
* ``<Program Files>\Intel\oneAPI``
#. Set the environment variables, using the script in <install_dir>, by running
* On Linux* OS:
``vars.{sh|csh} in <install_dir>/tbb/latest/env``
* On Windows* OS:
``vars.bat in <install_dir>/tbb/latest/env``
Example
*******
Below you can find a typical example for a |short_name| algorithm.
The sample calculates a sum of all integer numbers from 1 to 100.
.. code:: cpp
int sum = oneapi::tbb::parallel_reduce(oneapi::tbb::blocked_range<int>(1,101), 0,
[](oneapi::tbb::blocked_range<int> const& r, int init) -> int {
for (int v = r.begin(); v != r.end(); v++ ) {
init += v;
}
return init;
},
[](int lhs, int rhs) -> int {
return lhs + rhs;
}
);
Find more
*********
.. list-table::
:widths: 40 60
:header-rows: 0
* -
- `oneTBB Community Forum <https://community.intel.com/>`_
- `Product FAQs <https://software.intel.com/content/www/us/en/develop/support/faq-product.html>`_
- `Support requests <https://software.intel.com/content/www/us/en/develop/articles/how-to-create-a-support-request-at-online-service-center.html>`_
- Use these resources if you need support with oneTBB.
* - `Release Notes <https://software.intel.com/content/www/us/en/develop/articles/intel-oneapi-threading-building-blocks-release-notes.html>`_
- Find up-to-date information about the product, including detailed notes, known issues, and changes.
* - `Documentation <https://software.intel.com/content/www/us/en/develop/documentation/onetbb-documentation/top.html>`_: `Developer Guide <https://software.intel.com/content/www/us/en/develop/documentation/onetbb-documentation/top/onetbb-developer-guide.html>`_ and `API Reference <https://software.intel.com/content/www/us/en/develop/documentation/onetbb-documentation/top/onetbb-api-reference.html>`_
- Learn to use oneTBB.
* - `GitHub* <https://github.com/oneapi-src/oneTBB>`_
- Find oneTBB implementation in open source.
Notices and Disclaimers
***********************
Intel technologies may require enabled hardware, software or service activation.
No product or component can be absolutely secure.
Your costs and results may vary.
© Intel Corporation. Intel, the Intel logo, and other Intel marks are trademarks
of Intel Corporation or its subsidiaries. Other names and brands may be claimed
as the property of others.
No license (express or implied, by estoppel or otherwise) to any intellectual
property rights is granted by this document.
The products described may contain design defects or errors known as errata which
ay cause the product to deviate from published specifications. Current
characterized errata are available on request.
Intel disclaims all express and implied warranties, including without limitation,
the implied warranties of merchantability, fitness for a particular purpose,
and non-infringement, as well as any warranty arising from course of performance,
course of dealing, or usage in trade.
+68
View File
@@ -0,0 +1,68 @@
.. _integrate:
Integrate oneTBB
================
If you want to improve the performance and scalability of your application, you can integrate oneTBB into your project.
For example, you may want to integrate oneTBB if your application needs to process large amounts of data in parallel.
To integrate oneTBB, you need to:
* Link oneTBB with the project's source code.
* Provide the necessary compiler and linker flags.
However, you can use CMake* and the pkg-config tool to simplify the process of integrating oneTBB into your project and handling its dependencies.
See the instructions below to learn how to use the tools.
CMake*
*******
CMake* is a cross-platform build tool that helps you manage dependencies and build systems.
Integrating oneTBB into your project using CMake*:
* Simplifies the process of building and linking against the library.
* Ensures that your project can be built and run on multiple platforms.
* Lets you manage oneTBB dependencies.
To add oneTBB to another project using CMake*, add the following commands to your ``CMakeLists.txt`` file:
.. code-block::
`find_package(TBB REQUIRED)`
`target_link_libraries(my_executable TBB::tbb)`
After that, configure your project with CMake* as usual.
Compile a Program Using pkg-config
***********************************
The pkg-config tool is used to simplify the compilation line by retrieving information about packages
from special metadata files. It helps avoid large hard-coded paths and makes compilation more portable.
To compile a test program ``test.cpp`` with oneTBB on Linux* OS,
provide the full path to search for included files and libraries, or provide a line as the following:
.. code-block::
g++ -o test test.cpp $(pkg-config --libs --cflags tbb)
Where:
``--cflags`` provides oneTBB library include path:
.. code-block::
$ pkg-config --cflags tbb
-I<path-to>/tbb/latest/lib/pkgconfig/../..//include
``--libs`` provides the Intel(R) oneTBB library name and the search path to find it:
.. code-block::
$ pkg-config –libs tbb
-L<path to>tbb/latest/lib/pkgconfig/../..//lib/intel64/gcc4.8 -ltbb
.. note::
For Windows* OS, additionally, use the ``--msvc-syntax`` option flag that converts the compiling and linking flags in an appropriate mode.
+29
View File
@@ -0,0 +1,29 @@
.. _intro:
What oneTBB Is
==============
|full_name| is a runtime-based parallel programming model for C++ code that uses threads.
The template-based runtime library can help you harness the latent performance of multi-core processors.
oneTBB enables you to simplify parallel programming by breaking computation into parallel running tasks. Within a single process,
parallelism is carried out through threads, an operating system mechanism that allows the same or different sets of instructions
to be executed simultaneously. Using threads can make your program work faster and more efficiently.
Here you can see one of the possible executions of tasks by threads.
.. figure:: Images/how-oneTBB-works.png
:scale: 70%
:align: center
Use oneTBB to write scalable applications that:
* Specify logical parallel structure instead of threads.
* Emphasize data-parallel programming.
* Take advantage of concurrent collections and parallel algorithms.
oneTBB supports nested parallelism and load balancing. It means that you can use the library without worrying about oversubscribing a system, which happens when more tasks are assigned to a system than it can handle efficiently.
oneTBB is used in different areas, such as scientific simulations, gaming, data analysis, etc.
It is available as a stand-alone product and as part of the |base_tk|.
+157
View File
@@ -0,0 +1,157 @@
.. _next_steps:
Next Steps
===========
After installing oneTBB, complete the following steps to start working with the library.
Set the Environment Variables
*****************************
After installing |short_name|, set the environment variables:
#. Go to the oneTBB installation directory.
#. Set the environment variables using the script in ``<install_dir>`` by running:
* On Linux* OS: ``vars.{sh|csh} in <install_dir>/tbb/latest/env``
* On Windows* OS: ``vars.bat in <install_dir>/tbb/latest/env``
.. tip::
oneTBB can coordinate with Intel(R) OpenMP on CPU resources usage
to avoid excessive oversubscription when both runtimes are used within a process.
To enable this feature set up ``TCM_ENABLE`` environment variable to ``1``.
Build and Run a Sample
**********************
.. tabs::
.. group-tab:: Windows* OS
#. Create a new C++ project using your IDE. In this example, Microsoft* Visual Studio* Code is used.
#. Create an ``example.cpp`` file in the project.
#. Copy and paste the code below. It is a typical example of a |short_name| algorithm. The sample calculates a sum of all integer numbers from 1 to 100.
.. code::
#include <oneapi/tbb.h>
int main (){
int sum = oneapi::tbb::parallel_reduce(
oneapi::tbb::blocked_range<int>(1,101), 0,
[](oneapi::tbb::blocked_range<int> const& r, int init) -> int {
for (int v = r.begin(); v != r.end(); v++) {
init += v;
}
return init;
},
[](int lhs, int rhs) -> int {
return lhs + rhs;
}
);
printf("Sum: %d\n", sum);
return 0;
}
#. Open the ``tasks.json`` file in the ``.vscode`` directory and paste the following lines to the args array:
* ``-Ipath/to/oneTBB/include`` to add oneTBB include directory.
* ``path/to/oneTBB/`` to add oneTBB.
For example:
.. code-block::
{
"tasks": [
{
"label": "build & run",
"type": "cppbuild",
"group": {
"args": [
"/IC:\\Program Files (x86)\\Intel\\oneAPI\\tbb\\2021.9.0\\include",
"C:\\Program Files (x86)\\Intel\\oneAPI\\tbb\\2021.9.0\\lib\\ia32\\vc14\\tbb12.lib"
#. Build the project.
#. Run the example.
#. If oneTBB is configured correctly, the output displays ``Sum: 5050``.
.. group-tab:: Linux* OS
#. Create an ``example.cpp`` file in the project.
#. Copy and paste the code below. It is a typical example of a |short_name| algorithm. The sample calculates a sum of all integer numbers from 1 to 100.
.. code::
#include <oneapi/tbb.h>
int main(){
int sum = oneapi::tbb::parallel_reduce(
oneapi::tbb::blocked_range<int>(1,101), 0,
[](oneapi::tbb::blocked_range<int> const& r, int init) -> int {
for (int v = r.begin(); v != r.end(); v++) {
init += v;
}
return init;
},
[](int lhs, int rhs) -> int {
return lhs + rhs;
}
);
printf("Sum: %d\n", sum);
return 0;
}
#. Compile the code using oneTBB. For example,
.. code-block::
g++ -std=c++11 example.cpp -o example -ltbb
#. Run the executable:
.. code-block::
./example
#. If oneTBB is configured correctly, the output displays ``Sum: 5050``.
Hybrid CPU and NUMA Support
****************************
If you need NUMA/Hybrid CPU support in oneTBB, you need to make sure that HWLOC* is installed on your system.
HWLOC* (Hardware Locality) is a library that provides a portable abstraction of the hierarchical topology of modern architectures (NUMA, hybrid CPU systems, etc). oneTBB relies on HWLOC* to identify the underlying topology of the system to optimize thread scheduling and memory allocation.
Without HWLOC*, oneTBB may not take advantage of NUMA/Hybrid CPU support. Therefore, it's important to make sure that HWLOC* is installed before using oneTBB on such systems.
Check HWLOC* on the System
^^^^^^^^^^^^^^^^^^^^^^^^^^^
To check if HWLOC* is already installed on your system, run ``hwloc-ls``:
* For Linux* OS, in the command line.
* For Windows* OS, in the command prompt.
If HWLOC* is installed, the command displays information about the hardware topology of your system. If it is not installed, you receive an error message saying that the command ``hwloc-ls`` could not be found.
.. note:: For Hybrid CPU support, make sure that HWLOC* is version 2.5 or higher. For NUMA support, install HWLOC* version 1.11 or higher.
Install HWLOC*
^^^^^^^^^^^^^^
To install HWLOC*, visit the official Portable Hardware Locality website (https://www-lb.open-mpi.org/projects/hwloc/).
* For Windows* OS, binaries are available for download.
* For Linux* OS, only the source code is provided and binaries should be built.
On Linux* OS, HWLOC* can be also installed with package managers, such as APT*, YUM*, etc. To do so, run: sudo apt install hwloc.
.. note:: For Hybrid CPU support, make sure that HWLOC* is version 2.5 or higher. For NUMA support, install HWLOC* version 1.11 or higher.
+49
View File
@@ -0,0 +1,49 @@
.. _samples:
oneTBB Samples
==============
To become an expert in using oneTBB, explore its samples and examples to learn how
to properly utilize the features and functionality of oneTBB and avoid common mistakes that may impede your performance.
The following samples are available:
* **Containers**
* `concurrent_hash_map <https://github.com/oneapi-src/oneTBB/tree/master/examples/concurrent_hash_map>`_
* `concurrent_priority_queue <https://github.com/oneapi-src/oneTBB/tree/master/examples/concurrent_priority_queue>`_
* `Flow Graph <https://github.com/oneapi-src/oneTBB/tree/master/examples/graph>`_
* `A solution to the binpacking problem using a queue_node, a buffer_node, and function_node. <https://github.com/oneapi-src/oneTBB/tree/master/examples/graph/binpack>`_
* `Cholesky Factorization algorithm <https://github.com/oneapi-src/oneTBB/tree/master/examples/graph/cholesky>`_
* `An implementation of dining philosophers in graph using the reserving join_node <https://github.com/oneapi-src/oneTBB/tree/master/examples/graph/dining_philosophers>`_
* `A parallel implementation of bzip2 block-sorting file compressor <https://github.com/oneapi-src/oneTBB/tree/master/examples/graph/fgbzip2>`_
* `An example of a collection of digital logic gates that can be easily composed into larger circuits <https://github.com/oneapi-src/oneTBB/tree/master/examples/graph/logic_sim>`_
* `An example of a Kohonen Self-Organizing Map using cancellation <https://github.com/oneapi-src/oneTBB/tree/master/examples/graph/som>`_
* `Split computational kernel for execution between CPU and GPU <https://github.com/oneapi-src/oneAPI-samples/tree/master/Libraries/oneTBB/tbb-async-sycl>`_
* **Algorithms**
* `parallel_for <https://github.com/oneapi-src/oneTBB/tree/master/examples/parallel_for>`_
* `Game of life overlay <https://github.com/oneapi-src/oneTBB/tree/master/examples/parallel_for/game_of_life>`_
* `Polygon overlay <https://github.com/oneapi-src/oneTBB/tree/master/examples/parallel_for/polygon_overlay>`_
* `Parallel seismic wave simulation <https://github.com/oneapi-src/oneTBB/tree/master/examples/parallel_for/seismic>`_
* `Parallel 2-D raytracer/renderer <https://github.com/oneapi-src/oneTBB/tree/master/examples/parallel_for/tachyon>`_
* `Find largest matching substrings <https://github.com/oneapi-src/oneTBB/tree/master/examples/getting_started>`_
* `Resumable task: Split computational kernel for execution between CPU and GPU <https://github.com/oneapi-src/oneAPI-samples/tree/master/Libraries/oneTBB/tbb-resumable-tasks-sycl>`_
* `parallel_for_each <https://github.com/oneapi-src/oneTBB/tree/master/examples/parallel_for_each>`_
* `parallel_pipeline <https://github.com/oneapi-src/oneTBB/tree/master/examples/parallel_pipeline>`_
* `parallel_reduce <https://github.com/oneapi-src/oneTBB/tree/master/examples/parallel_reduce>`_
* **Task Scheduler**
* `task_arena <https://github.com/oneapi-src/oneTBB/tree/master/examples/task_arena>`_
* `task_group <https://github.com/oneapi-src/oneTBB/tree/master/examples/task_group>`_
* `Execute similar computational kernels, with one task executing the SYCL* code and the other task executing the oneTBB code <https://github.com/oneapi-src/oneAPI-samples/tree/master/Libraries/oneTBB/tbb-task-sycl>`_
* **Other**
* `Compute Fibonacci numbers in different ways <https://github.com/oneapi-src/oneTBB/tree/master/examples/test_all>`_
.. note:: You can also refer to the `oneAPI Samples <https://oneapi-src.github.io/oneAPI-samples/>`_ to learn more about the ecosystem.
+16 -5
View File
@@ -29,7 +29,7 @@ if BUILD_TYPE == 'oneapi' or BUILD_TYPE == 'dita':
project = u'Intel® oneAPI Threading Building Blocks (oneTBB)'
else:
project = u'oneTBB'
copyright = u'2022, Intel Corporation'
copyright = u'2023, Intel Corporation'
author = u'Intel'
# The short X.Y version
@@ -56,7 +56,8 @@ extensions = [
'sphinx.ext.imgmath',
'sphinx.ext.ifconfig',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages'
'sphinx.ext.githubpages',
'sphinx_tabs.tabs'
]
# Add any paths that contain templates here, relative to this directory.
@@ -77,7 +78,7 @@ master_doc = 'index'
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = 'en'
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
@@ -132,14 +133,18 @@ if BUILD_TYPE == 'dita':
else:
html_theme_options = {
'repository_url': 'https://github.com/oneapi-src/oneTBB',
'path_to_docs': 'doc/main',
'path_to_docs': 'doc',
'use_issues_button': True,
'use_edit_page_button': True,
'repository_branch': 'master',
'extra_footer': '<p align="right"><a href="https://www.intel.com/content/www/us/en/privacy/intel-cookie-notice.html">Cookies</a></p>'
}
if BUILD_TYPE != 'oneapi' and BUILD_TYPE != 'dita':
html_theme_options = {
"extra_footer": "<div><a href='https://www.intel.com/content/www/us/en/privacy/intel-cookie-notice.html' data-cookie-notice='true'>Cookies</a> <a href='https://www.intel.com/content/www/us/en/privacy/intel-privacy-notice.html'>| Privacy</a> <a data-wap_ref='dns' id='wap_dns' href='https://www.intel.com/content/www/us/en/privacy/intel-cookie- notice.html'>| Do Not Share My Personal Information</a> </div><div>&copy; Intel Corporation. Intel, the Intel logo, and other Intel marks are trademarks of Intel Corporation or its subsidiaries. Other names and brands may be claimed as the property of others. No license (express or implied, by estoppel or otherwise) to any intellectual property rights is granted by this document, with the sole exception that code included in this document is licensed subject to the Zero-Clause BSD open source license (OBSD), <a href='http://opensource.org/licenses/0BSD'>http://opensource.org/licenses/0BSD</a>. </div><br><div>oneTBB is licensed under Apache License Version 2.0. Refer to the <a href='https://github.com/oneapi-src/oneTBB/blob/master/LICENSE.txt'>LICENSE </a> file for the full license text and copyright notice.</div>"
}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
@@ -154,10 +159,16 @@ if BUILD_TYPE == 'oneapi' or BUILD_TYPE == 'dita':
else:
html_js_files = ['custom.js']
html_theme_options = {
"logo": {
"text": "oneTBB Documentation",
}
}
html_logo = '_static/oneAPI-rgb-rev-100.png'
html_favicon = '_static/favicons.png'
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
+7 -1
View File
@@ -8,6 +8,8 @@
/main/intro/notation
/main/intro/intro_os
/main/intro/Benefits
/main/intro/testing_approach
/main/intro/limitations.rst
.. toctree::
@@ -15,8 +17,12 @@
:maxdepth: 2
/GSG/get_started
/GSG/intro
/GSG/system_requirements
/GSG/installation
/GSG/examples
/GSG/next_steps
/GSG/integrate
/GSG/samples
.. toctree::
+37
View File
@@ -0,0 +1,37 @@
window.MathJax = {
TeX: {
Macros: {
src: '\\operatorname{src}',
srclayer: '\\operatorname{src\\_layer}',
srciter: '\\operatorname{src\\_iter}',
srciterc: '\\operatorname{src\\_iter\\_c}',
weights: '\\operatorname{weights}',
weightslayer: '\\operatorname{weights\\_layer}',
weightsiter: '\\operatorname{weights\\_iter}',
weightspeephole: '\\operatorname{weights\\_peephole}',
weightsprojection: '\\operatorname{weights\\_projection}',
bias: '\\operatorname{bias}',
dst: '\\operatorname{dst}',
dstlayer: '\\operatorname{dst\\_layer}',
dstiter: '\\operatorname{dst\\_iter}',
dstiterc: '\\operatorname{dst\\_iter\\_c}',
diffsrc: '\\operatorname{diff\\_src}',
diffsrclayer: '\\operatorname{diff\\_src\\_layer}',
diffsrciter: '\\operatorname{diff\\_src\\_iter}',
diffsrciterc: '\\operatorname{diff\\_src\\_iter\\_c}',
diffweights: '\\operatorname{diff\\_weights}',
diffweightslayer: '\\operatorname{diff\\_weights\\_layer}',
diffweightsiter: '\\operatorname{diff\\_weights\\_iter}',
diffweightspeephole: '\\operatorname{diff\\_weights\\_peephole}',
diffweightsprojection: '\\operatorname{diff\\_weights\\_projection}',
diffbias: '\\operatorname{diff\\_bias}',
diffdst: '\\operatorname{diff\\_dst}',
diffdstlayer: '\\operatorname{diff\\_dst\\_layer}',
diffdstiter: '\\operatorname{diff\\_dst\\_iter}',
diffdstiterc: '\\operatorname{diff\\_dst\\_iter\\_c}',
diffgamma: '\\operatorname{diff\\_\\gamma}',
diffbeta: '\\operatorname{diff\\_\\beta}',
workspace: '\\operatorname{workspace}'
}
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

+13
View File
@@ -0,0 +1,13 @@
/* override table width restrictions */
@media screen and (min-width: 767px) {
.wy-table-responsive table td {
/* !important prevents the common CSS stylesheets from overriding
this as on RTD they are loaded after this stylesheet */
white-space: normal !important;
}
.wy-table-responsive {
overflow: visible !important;
}
}
+4 -5
View File
@@ -6,11 +6,10 @@
var wapLocalCode = 'us-en'; // Dynamically set per localized site, see mapping table for values
var wapSection = "oneapi-tbb"; // WAP team will give you a unique section for your site
// Load TMS
(function () {
var url = 'https://www.intel.com/content/dam/www/global/wap/tms-loader.js'; // WAP file URL
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = url;
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
(function () {
var url = 'https://www.intel.com/content/dam/www/global/wap/tms-loader.js'; // WAP file URL
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true; po.src = url;
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script>
<link href="{{ pathto("_static/style.css", True) }}" rel="stylesheet" type="text/css">
{% endblock %}
+295
View File
@@ -0,0 +1,295 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config
# -- Path setup --------------------------------------------------------------
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))
SOURCE_DIR = os.path.dirname(__file__)
LATEX_DIR = os.path.join(SOURCE_DIR, '_latex')
PREAMBLE_FILE = os.path.join(LATEX_DIR, 'preamble.tex')
TITLE_PAGE_FILE = os.path.join(LATEX_DIR, 'title_page.tex')
BUILD_TYPE = os.getenv("BUILD_TYPE")
# -- Project information -----------------------------------------------------
if BUILD_TYPE == 'oneapi' or BUILD_TYPE == 'dita':
project = u'Intel® oneAPI Threading Building Blocks (oneTBB)'
else:
project = u'oneAPI Threading Building Blocks (oneTBB)'
copyright = u'2021, Intel Corporation'
author = u'Intel'
# The short X.Y version
version = u''
# The full version, including alpha/beta/rc tags
release = u''
# -- General configuration ---------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.doctest',
'sphinx.ext.intersphinx',
'sphinx.ext.todo',
'sphinx.ext.coverage',
'sphinx.ext.imgmath',
'sphinx.ext.ifconfig',
'sphinx.ext.viewcode',
'sphinx.ext.githubpages'
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
# The master toctree document.
#master_doc = 'main/title_main'
master_doc = 'index'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = []
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = None
# Syntax highlighting for the :: directive
highlight_language = 'cpp'
if BUILD_TYPE == 'oneapi' or BUILD_TYPE == 'dita':
rst_prolog = """
.. |full_name| replace:: Intel\ |reg|\ oneAPI Threading Building Blocks (oneTBB)
.. |short_name| replace:: oneTBB
.. |product| replace:: oneTBB
.. |reg| unicode:: U+000AE
.. |copy| unicode:: U+000A9
.. |base_tk| replace:: Intel\ |reg|\ oneAPI Base Toolkit
.. |dpcpp| replace:: Intel\ |reg|\ oneAPI DPC++/C++ Compiler
"""
else:
rst_prolog = """
.. |full_name| replace:: oneAPI Threading Building Blocks (oneTBB)
.. |short_name| replace:: oneTBB
.. |product| replace:: oneTBB
.. |reg| unicode:: U+000AE
.. |copy| unicode:: U+000A9
.. |base_tk| replace:: Intel\ |reg|\ oneAPI Base Toolkit
.. |dpcpp| replace:: Intel\ |reg|\ oneAPI DPC++/C++ Compiler
"""
# -- Options for HTML output -------------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
if BUILD_TYPE == 'oneapi' or BUILD_TYPE == 'dita':
html_theme = 'sphinx_rtd_theme'
else:
html_theme = 'sphinx_book_theme'
html_theme_options = {
'repository_url': 'https://github.com/oneapi-src/oneTBB',
'path_to_docs': 'doc/main',
'use_issues_button': True,
'use_edit_page_button': True,
'repository_branch': 'master',
'extra_footer': '<p align="right"><a href="https://www.intel.com/content/www/us/en/privacy/intel-cookie-notice.html">Cookies</a></p>'
}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
if BUILD_TYPE == 'oneapi' or BUILD_TYPE == 'dita':
html_context = {
'css_files': [
'_static/theme_overrides.css', # override wide tables in RTD theme
],
}
else:
html_js_files = ['custom.js']
html_logo = '_static/oneAPI-rgb-rev-100.png'
html_favicon = '_static/favicons.png'
# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}
# -- Options for HTMLHelp output ---------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'sphinx-infodevdoc'
# -- Options for LaTeX output ------------------------------------------------
#latex_engine = 'xelatex'
#PDF_TITLE = 'Information Development Template'
#
#with open(PREAMBLE_FILE, 'r', encoding='utf-8') as f:
# PREAMBLE = f.read()
#
#with open(TITLE_PAGE_FILE, 'r', encoding='utf-8') as f:
# TITLE_PAGE = f.read().replace('<PDF_TITLE>', PDF_TITLE)
#
#
#latex_elements = {
# # The paper size ('letterpaper' or 'a4paper').
# #
# 'extraclassoptions': 'openany,oneside',
# 'babel' : '\\usepackage[english]{babel}',
# 'papersize': 'a4paper',
# 'releasename':" ",
# # Sonny, Lenny, Glenn, Conny, Rejne, Bjarne and Bjornstrup
# # 'fncychap': '\\usepackage[Lenny]{fncychap}',
# 'fncychap': '',
# #'fontpkg': '\\usepackage{amsmath,amsfonts,amssymb,amsthm}',
#
# 'figure_align':'htbp',
# # The font size ('10pt', '11pt' or '12pt').
# #
# 'pointsize': '12pt',
#
# # Additional stuff for the LaTeX preamble.
# #
# 'preamble': PREAMBLE,
#
# 'maketitle': TITLE_PAGE,
# # Latex figure (float) alignment
# #
# # 'figure_align': 'htbp',
# 'sphinxsetup': \
# 'hmargin={0.7in,0.7in}, vmargin={1in,1in}, \
# verbatimwithframe=true, \
# TitleColor={rgb}{0,0.686,0.941}, \
# HeaderFamily=\\rmfamily\\bfseries, \
# InnerLinkColor={rgb}{0,0.686,0.941}, \
# OuterLinkColor={rgb}{0,0.686,0.941}',
#
# 'tableofcontents':' '
#}
#
#latex_logo = '_latex/intel_logo.png'
## Grouping the document tree into LaTeX files. List of tuples
## (source start file, target name, title,
## author, documentclass [howto, manual, or own class]).
#latex_documents = [
# (master_doc, 'sphinx-infodev.tex', u'sphinx-infodev Documentation',
# u'Intel', 'manual'),
#]
#breathe_projects = { #todd-mod
# project: "../doxygen/xml"
#}
#breathe_default_project = project
# Setup the exhale extension
#exhale_args = { #todd-mod
# # These arguments are required
# "containmentFolder": "./api",
# "rootFileName": "library_root.rst",
# "rootFileTitle": "Library API",
# "doxygenStripFromPath": "..",
# "fullApiSubSectionTitle": 'Full API'
#}
# -- Options for manual page output ------------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'sphinx-infodev', u'sphinx-infodev Documentation',
[author], 1)
]
# -- Options for Texinfo output ----------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'sphinx-infodev', u'sphinx-infodev Documentation',
author, 'sphinx-infodev', 'One line description of project.',
'Miscellaneous'),
]
# -- Options for Epub output -------------------------------------------------
# Bibliographic Dublin Core info.
epub_title = project
# The unique identifier of the text. This can be a ISBN number
# or the project homepage.
#
# epub_identifier = ''
# A unique identification for the text.
#
# epub_uid = ''
# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
# -- Extension configuration -------------------------------------------------
# -- Options for intersphinx extension ---------------------------------------
# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {'https://docs.python.org/': None}
# -- Options for todo extension ----------------------------------------------
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
+37
View File
@@ -0,0 +1,37 @@
|full_name|
===========
This document contains information about |full_name|.
|short_name| is a flexible performance library that can be found in the |base_tk|
or as a stand-alone product. More information and specifications can be found on the
|full_name| main page.
Documentation for older versions of |short_name| is available for download only.
For a list of available documentation downloads by product version, see these pages:
* `Download Documentation for Intel Parallel Studio XE <https://software.intel.com/content/www/us/en/develop/articles/download-documentation-intel-parallel-studio-xe-current-previous.html>`_
* `Download Documentation for Intel System Studio <https://software.intel.com/content/www/us/en/develop/articles/download-documentation-intel-system-studio-current-previous.html>`_
The following are some important topics for the ``novice user``:
* `Get Started with oneTBB <https://software.intel.com/content/www/us/en/develop/documentation/get-started-with-onetbb/top.html>`_ gives you a brief explanation of what oneTBB is.
* :ref:`Benefits` describes how |short_name| differs from typical threading packages.
* :ref:`Package_Contents` describes dynamic library files and header files for Windows*, Linux*, and macOS* operating systems used in |short_name|.
The following is an important topic for the ``experienced user``:
:ref:`Migration_Guide` describes how to migrate from TBB to oneTBB.
.. toctree::
:maxdepth: 2
intro/help_support
intro/notation
intro/intro
intro/Benefits
tbb_userguide/title
reference/reference
intro/notices_and_disclaimers
+1 -1
View File
@@ -20,7 +20,7 @@ it with any compiler supporting ISO C++. The library differs from
typical threading packages in the following ways:
- **oneTBB enables you to specify logical paralleism instead of
- **oneTBB enables you to specify logical parallelism 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
+39
View File
@@ -0,0 +1,39 @@
.. _intro:
Introduction
============
|full_name| is a library that supports scalable parallel programming using
standard ISO C++ code. It does not require special languages or
compilers. It is designed to promote scalable data parallel programming.
Additionally, it fully supports nested parallelism, so you can build
larger parallel components from smaller parallel components. To use the
library, you specify tasks, not threads, and let the library map tasks
onto threads in an efficient manner.
Many of the library interfaces employ generic programming, in which
interfaces are defined by requirements on types and not specific types.
The C++ Standard Template Library (STL) is an example of generic
programming. Generic programming enables oneTBB to be flexible yet
efficient. The generic interfaces enable you to customize components to
your specific needs.
.. note::
|full_name| requires C++11 standard compiler support.
The net result is that oneTBB enables you to specify parallelism far
more conveniently than using raw threads, and at the same time can
improve performance.
.. admonition:: Product and Performance Information
Performance varies by use, configuration and other factors. Learn more at `www.intel.com/PerformanceIndex <https://www.intel.com/PerformanceIndex>`_.
Notice revision #20201201
+39
View File
@@ -0,0 +1,39 @@
.. _introducing_main:
Introduction
============
|full_name| is a library that supports scalable parallel programming using
standard ISO C++ code. It does not require special languages or
compilers. It is designed to promote scalable data parallel programming.
Additionally, it fully supports nested parallelism, so you can build
larger parallel components from smaller parallel components. To use the
library, you specify tasks, not threads, and let the library map tasks
onto threads in an efficient manner.
Many of the library interfaces employ generic programming, in which
interfaces are defined by requirements on types and not specific types.
The C++ Standard Template Library (STL) is an example of generic
programming. Generic programming enables oneTBB to be flexible yet
efficient. The generic interfaces enable you to customize components to
your specific needs.
.. note::
|full_name| requires C++11 standard compiler support.
The net result is that oneTBB enables you to specify parallelism far
more conveniently than using raw threads, and at the same time can
improve performance.
.. admonition:: Product and Performance Information
Performance varies by use, configuration and other factors. Learn more at `www.intel.com/PerformanceIndex <https://www.intel.com/PerformanceIndex>`_.
Notice revision #20201201
+46
View File
@@ -0,0 +1,46 @@
.. _limitations:
Known Limitations
*****************
This page outlines the known limitations of oneTBB to help you better understand its capabilities.
Freestanding Compilation Mode
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**Limitation:** oneTBB does not support the freestanding compilation mode.
**Risk:** Compiling an application that utilizes oneTBB headers using the Intel(R) oneAPI DPC+/C+ Compiler may result in failure on Windows* OS if the ``/Qfreestanding`` compiler option is employed.
Static Assert
^^^^^^^^^^^^^
**Limitation:** A static assert causes the compilation failures in oneTBB headers if the following conditions are satisfied:
* Compilation is done with Clang 12.0.0 or a more recent version.
* The LLVM standard library is employed, coupled with the use of the ``-ffreestanding`` flag and C++11/14 compiler options.
**Risk:** The compilation failures.
Interface Incompatibilities: TBB vs oneTBB
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**Limitation:** An application using Parallel STL algorithms in the ``libstdc++`` versions 9 and 10 may fail to compile due to incompatible interface changes between earlier versions of Threading Building Blocks (TBB) and oneAPI Threading Building Blocks (oneTBB).
**Solution:** Disable support for Parallel STL algorithms by defining ``PSTL_USE_PARALLEL_POLICIES`` (in libstdc++ 9) or ``_GLIBCXX_USE_TBB_PAR_BACKEND`` (in libstdc++ 10) macro to zero before inclusion of the first standard header file in each translation unit.
Incorrect Installation Location
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
**Limitation:** On Linux* OS, if oneAPI Threading Building Blocks (oneTBB) or Threading Building Blocks (TBB) are installed in a system folder, such as ``/usr/lib64``, the application may fail to link due to the order in which the linker searches for libraries.
**Risk:** The issue does not affect the program execution.
**Solution:** Use the ``-L`` linker option to specify the correct location of oneTBB library.
``fork()`` Support
^^^^^^^^^^^^^^^^^^^
**Limitation:** oneTBB does not support ``fork()``.
**Solution:** To work-around the issue, consider using ``task_scheduler_handle`` to join oneTBB worker threads before using ``fork()``.
@@ -0,0 +1,49 @@
.. _notices_and_disclaimers:
Notices and Disclaimers
=======================
Intel technologies may require enabled hardware, software or service
activation.
No product or component can be absolutely secure.
Your costs and results may vary.
© Intel Corporation. Intel, the Intel logo, and other Intel marks are
trademarks of Intel Corporation or its subsidiaries. Other names and
brands may be claimed as the property of others.
Intel's compilers may or may not optimize to the same degree for
non-Intel microprocessors for optimizations that are not unique to Intel
microprocessors. These optimizations include SSE2, SSE3, and SSSE3
instruction sets and other optimizations. Intel does not guarantee the
availability, functionality, or effectiveness of any optimization on
microprocessors not manufactured by Intel. Microprocessor-dependent
optimizations in this product are intended for use with Intel
microprocessors. Certain optimizations not specific to Intel
microarchitecture are reserved for Intel microprocessors. Please refer
to the applicable product User and Reference Guides for more information
regarding the specific instruction sets covered by this notice.
No license (express or implied, by estoppel or otherwise) to any
intellectual property rights is granted by this document.
The products described may contain design defects or errors known as
errata which may cause the product to deviate from published
specifications. Current characterized errata are available on request.
Intel disclaims all express and implied warranties, including without
limitation, the implied warranties of merchantability, fitness for a
particular purpose, and non-infringement, as well as any warranty
arising from course of performance, course of dealing, or usage in
trade.
+31
View File
@@ -0,0 +1,31 @@
.. _testing_approach:
Testing Approach
================
There are four main types of errors/hazards you can encounter in the development of libraries for parallelism:
* Interface correspondence to specification
* Memory errors
* Data race
* Race conditions and deadlocks
|short_name| testing approach is designed to provide high coverage of these error types.
All types of errors are covered with unit testing and review.
Code coverage metrics are tracked to ensure high code coverage with tests. Uncovered branches are analyzed manually.
Memory errors and data races are additionally covered by special tools that include thread and memory sanitizers.
Race conditions and deadlocks are the most complicated errors.
They are covered by:
* **Unit tests** that, however, have limited capability to catch such errors
* **Integration tests**. Multiple different functionalities are heavily combined to emulate user use cases that may trigger such errors based on prior knowledge and expertise.
* **Stress testing with different possible combinations**. It ensures that even rarely triggered error conditions are caught by testing.
.. note:: Every fix is required to be covered by a test to guarantee the detection of such issues in the future.
Continuous Integration triggers all the tests on each commit. This ensures that:
* Issues are detected, starting from the early development phase and up to the moment of integration of changes into the library.
* The highest quality of the library is maintained even in such error-prone domains as parallelism.
+165
View File
@@ -0,0 +1,165 @@
.. _task_scheduler_handle_reference:
task_scheduler_handle Class
===========================
.. note::
To enable this feature, set the ``TBB_PREVIEW_WAITING_FOR_WORKERS`` macro to 1.
.. contents::
:local:
:depth: 1
Description
***********
The ``oneapi::tbb::task_scheduler_handle`` class and the ``oneapi::tbb::finalize`` function allow to wait for completion of worker threads.
When the ``oneapi::tbb::finalize`` function is called with an ``oneapi::tbb::task_scheduler_handle`` instance, it blocks the calling
thread until the completion of all worker threads that were implicitly created by the library.
API
***
Header
------
.. code:: cpp
#include <oneapi/tbb/global_control.h>
Synopsis
--------
.. code:: cpp
namespace oneapi {
namespace tbb {
class task_scheduler_handle {
public:
task_scheduler_handle() = default;
~task_scheduler_handle();
task_scheduler_handle(const task_scheduler_handle& other) = delete;
task_scheduler_handle(task_scheduler_handle&& other) noexcept;
task_scheduler_handle& operator=(const task_scheduler_handle& other) = delete;
task_scheduler_handle& operator=(task_scheduler_handle&& other) noexcept;
explicit operator bool() const noexcept;
static task_scheduler_handle get();
static void release(task_scheduler_handle& handle);
};
void finalize(task_scheduler_handle& handle);
bool finalize(task_scheduler_handle& handle, const std::nothrow_t&) noexcept;
} // namespace tbb
} // namespace oneapi
Member Functions
----------------
.. cpp:function:: task_scheduler_handle()
**Effects**: Creates an instance of the ``task_scheduler_handle`` class that does not contain any reference to the task scheduler.
-------------------------------------------------------
.. cpp:function:: ~task_scheduler_handle()
**Effects**: Destroys an instance of the ``task_scheduler_handle`` class.
Releases a reference to the task scheduler and deactivates an instance of the ``task_scheduler_handle`` class.
-------------------------------------------------------
.. cpp:function:: task_scheduler_handle(task_scheduler_handle&& other) noexcept
**Effects**: Creates an instance of the ``task_scheduler_handle`` class that references the task scheduler referenced by ``other``. In turn, ``other`` releases its reference to the task scheduler.
-------------------------------------------------------
.. cpp:function:: task_scheduler_handle& operator=(task_scheduler_handle&& other) noexcept
**Effects**: Releases a reference to the task scheduler referenced by ``this``. Adds a reference to the task scheduler referenced by ``other``.
In turn, ``other`` releases its reference to the task scheduler.
-------------------------------------------------------
.. cpp:function:: explicit operator bool() const noexcept
**Returns**: ``true`` if ``this`` references any task scheduler; ``false`` otherwise.
-------------------------------------------------------
.. cpp:function:: task_scheduler_handle get()
**Returns**: An instance of the ``task_scheduler_handle`` class that holds a reference to the task scheduler preventing
its premature destruction.
-------------------------------------------------------
.. cpp:function:: void release(task_scheduler_handle& handle)
**Effects**: Releases a reference to the task scheduler and deactivates an instance of the ``task_scheduler_handle``
class. Non-blocking method.
Non-member Functions
--------------------
.. cpp:function:: void finalize(task_scheduler_handle& handle)
**Effects**: Blocks the program execution until all worker threads have been completed. Throws the ``oneapi::tbb::unsafe_wait``
exception if it is not safe to wait for the completion of the worker threads.
The following conditions should be met for finalization to succeed:
- No active (not yet terminated) instances of class ``task_arena`` exist in the whole program;
- ``task_scheduler_handle::release`` is called for each other active instance of class ``task_scheduler_handle``, possibly by different application threads.
Under these conditions, it is guaranteed that at least one ``finalize`` call succeeds,
at which point all worker threads have been completed.
If calls are performed simultaneously, more than one call might succeed.
.. note::
If you know how many active ``task_scheduler_handle`` instances exist in the program,
it is necessary to ``release`` all but the last one, then call ``finalize`` for
the last instance.
.. caution::
The method always fails if called within a task, a parallel algorithm, or a flow graph node.
-------------------------------------------------------
.. cpp:function:: bool finalize(task_scheduler_handle& handle, const std::nothrow_t&) noexcept
**Effects**: Blocks the program execution until all worker threads have been completed. Same as above, but returns ``true`` if all worker
threads have been completed successfully, or ``false`` if it is not safe to wait for the completion of the worker threads.
Examples
********
.. code:: cpp
#define TBB_PREVIEW_WAITING_FOR_WORKERS 1
#include <oneapi/tbb/global_control.h>
#include <oneapi/tbb/parallel_for.h>
#include <iostream>
int main() {
oneapi::tbb::task_scheduler_handle handle = oneapi::tbb::task_scheduler_handle::get();
// Do some parallel work here, e.g.
oneapi::tbb::parallel_for(0, 10000, [](int){});
try {
oneapi::tbb::finalize(handle);
// oneTBB worker threads are terminated at this point.
} catch (const oneapi::tbb::unsafe_wait&) {
std::cerr << "Failed to terminate the worker threads." << std::endl;
}
return 0;
}
@@ -0,0 +1,241 @@
.. _heterogeneous_extensions_chmap:
Heterogeneous overloads for ``concurrent_hash_map`` member functions
====================================================================
.. note::
To enable this feature, define the ``TBB_PREVIEW_CONCURRENT_HASH_MAP_EXTENSIONS`` macro to 1.
A set of overloads for ``concurrent_hash_map`` member functions that allow to search, erase, and insert
elements into the container without creating a temporary ``key_type`` object.
.. contents::
:local:
:depth: 1
Description
***********
Heterogeneous overloads allow you to perform insert, lookup, and erasure operations on ``concurrent_hash_map`` object
using an object of the type that is different from ``key_type`` but comparable with it.
All member functions described below only participate in overload resolution if ``HashCompareType::is_transparent``
is valid and denotes a type.``HashCompareType`` is a type of the ``HashCompare`` passed as a template argument
for ``concurrent_hash_map``. It means that the ``HashCompare`` object calculates a hash and compares keys for
equality without creating a temporary ``key_type`` object.
API
***
Header
------
.. code:: cpp
#include "oneapi/tbb/concurrent_hash_map.h"
Synopsis
--------
.. code:: cpp
namespace oneapi {
namespace tbb {
template <typename Key, typename Mapped,
typename HashCompare = tbb_hash_compare<Key>,
typename Allocator = tbb_allocator<std::pair<const Key, Mapped>>>
class concurrent_hash_map {
public:
// Insertion
template <typename K>
bool insert( accessor& result, const K& k );
template <typename K>
bool insert( const_accessor& result, const K& k );
// Lookup
template <typename K>
bool find( accessor& result, const K& k );
template <typename K>
bool find( const_accessor& result, const K& k ) const;
template <typename K>
size_type count( const K& k ) const;
template <typename K>
std::pair<iterator, iterator> equal_range( const K& k );
template <typename K>
std::pair<const_iterator, const_iterator> equal_range( const K& k ) const;
// Erasure
template <typename K>
bool erase( const K& k );
};
} // namespace tbb
} // namespace oneapi
Member functions
----------------
Insertion
^^^^^^^^^
.. code:: cpp
template <typename K>
bool insert( accessor& result, const K& k );
template <typename K>
bool insert( const_accessor& result, const K& k );
If the accessor ``result`` is not empty, releases the ``result`` and tries to
insert the value constructed from ``{k, mapped_type()}`` into the container.
Sets the ``result`` to provide access to the inserted element or to the element with the key that
compares `equivalent` to the value ``k``.
This overload only participates in overload resolution if ``std::is_constructible<key_type, const K&>`` is ``true``.
**Returns**: ``true`` if the insertion was applied, ``false`` otherwise.
Lookup
^^^^^^
.. code:: cpp
template <typename K>
bool find( accessor& result, const K& k );
template <typename K>
bool find( const_accessor& result, const K& k ) const;
If the accessor ``result`` is not empty, releases the ``result``.
If an element with the key that compares `equivalent` to the value ``k`` exists,
sets the ``result`` to provide access to this element.
**Returns**: ``true`` if an element with the key that compares `equivalent` to the value ``k`` is found,
``false`` otherwise.
------------------------------------------------
.. code:: cpp
template <typename K>
size_type count( const K& k ) const;
**Returns**: ``1`` if an element with the key that compares `equivalent` to the value ``k`` exists, ``0`` otherwise.
------------------------------------------------
.. code:: cpp
template <typename K>
std::pair<iterator, iterator> equal_range( const K& k );
template <typename K>
std::pair<const_iterator, const_iterator> equal_range( const K& k ) const;
**Returns**:
- A pair of iterators ``{f, l}`` if an element with the key that compares `equivalent` to the value ``k`` exists in the container.
Here ``f`` is an iterator to this element, ``l`` is ``std::next(f)``.
- ``{end(), end()}`` otherwise.
.. rubric:: Example
The example below demonstrates how to use heterogeneous lookup feature to find an object with the key of type ``std::string``
using an object of type ``const char*`` without conversions.
.. code:: cpp
#define TBB_PREVIEW_CONCURRENT_HASH_MAP_EXTENSIONS 1
#include "oneapi/tbb/concurrent_hash_map.h"
#include <string>
#include <cstring>
// HashCompare an object that can calculate the hash code for
// std::string only and compare strings for equality
class RegularHashCompare {
private:
std::hash<std::string> my_hasher;
public:
std::size_t hash( const std::string& key ) const {
return my_hasher(key);
}
bool equal( const std::string& key1, const std::string& key2 ) const {
return key1 == key2;
}
};
// HashCompare an object that can calculate the hash code for
// std::string and const char*, and compare them for equality
class TransparentHashCompare {
private:
std::hash<char> my_hasher;
// Calculates a hash for the array of chars
std::size_t calculate_hash( const char* ptr ) const {
std::size_t h = 0;
for (auto c = ptr; *c; ++c) {
h = h ^ my_hasher(*c);
}
return h;
}
public:
using is_transparent = void;
std::size_t hash( const char* key ) const {
return calculate_hash(key);
}
std::size_t hash( const std::string& key ) const {
return calculate_hash(key.c_str());
}
bool equal( const char* key1, const char* key2 ) const {
return std::strcmp(key1, key2) == 0;
}
bool equal( const char* key1, const std::string& key2 ) const {
return std::strcmp(key1, key2.c_str()) == 0;
}
bool equal( const std::string& key1, const char* key2 ) const {
return std::strcmp(key1.c_str(), key2) == 0;
}
bool equal( const std::string& key1, const std::string& key2 ) const {
return std::strcmp(key1.c_str(), key2.c_str()) == 0;
}
};
int main() {
using regular_hash_map =
oneapi::tbb::concurrent_hash_map<std::string, int, RegularHashCompare>;
using transparent_hash_map =
oneapi::tbb::concurrent_hash_map<std::string, int, TransparentHashCompare>;
using regular_accessor = typename regular_hash_map::accessor;
using transparent_accessor = typename transparent_hash_map::accessor;
// Accessors
regular_accessor reg_accessor;
transparent_accessor tran_accessor;
// Maps
regular_hash_map regular_map;
transparent_hash_map tran_map;
// Heterogeneous overloads do not participate in overload resolution
// Such a call matches on the find overload, which accepts key_type (std::string)
// Creates a temporary key_type (std::string) object because of implicit conversion
bool result = regular_map.find(reg_accessor, "abc");
// Heterogeneous overloads participate in overload resolution
// No implicit conversion from const char* to std::string takes place
result = tran_map.find(tran_accessor, "abc");
}
+93
View File
@@ -0,0 +1,93 @@
.. _mutex:
mutex
==========
.. note::
To enable this feature, define the ``TBB_PREVIEW_MUTEXES`` macro to 1.
Description
***********
A ``mutex`` is a class that models the `Mutex requirement <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/named_requirements/mutexes/mutex.html>`_,
using adaptive approach: the combination of spinlock and waiting on system primitives.
The ``mutex`` class satisfies all of the mutex requirements described in the [thread.mutex.requirements] section of the ISO C++ standard.
The ``mutex`` class is not fair or recursive.
API
***
Header
------
.. code:: cpp
#include <oneapi/tbb/mutex.h>
Synopsis
--------
.. code:: cpp
namespace oneapi {
namespace tbb {
class mutex {
public:
mutex() noexcept;
~mutex();
mutex(const mutex&) = delete;
mutex& operator=(const mutex&) = delete;
class scoped_lock;
void lock();
bool try_lock();
void unlock();
static constexpr bool is_rw_mutex = false;
static constexpr bool is_recursive_mutex = false;
static constexpr bool is_fair_mutex = false;
};
}
}
Member classes
--------------
.. namespace:: tbb::mutex
.. cpp:class:: scoped_lock
The corresponding ``scoped_lock`` class. See the `Mutex requirement <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/named_requirements/mutexes/mutex.html>`_.
Member functions
----------------
.. cpp:function:: mutex()
Constructs ``mutex`` with unlocked state.
--------------------------------------------------
.. cpp:function:: ~mutex()
Destroys an unlocked ``mutex``.
--------------------------------------------------
.. cpp:function:: void lock()
Acquires a lock. It uses adaptive logic for waiting: it blocks after particular time period of busy wait.
--------------------------------------------------
.. cpp:function:: bool try_lock()
Tries to acquire a lock (non-blocking). Returns **true** if succeeded; **false** otherwise.
--------------------------------------------------
.. cpp:function:: void unlock()
Releases the lock held by a current thread.
+1 -3
View File
@@ -16,9 +16,9 @@ It also describes features that are not included in the oneTBB specification.
.. toctree::
:titlesonly:
info_namespace
parallel_for_each_semantics
parallel_sort_ranges_extension
scalable_memory_pools/malloc_replacement_log
Preview features
****************
@@ -47,7 +47,5 @@ The key properties of a preview feature are:
scalable_memory_pools
helpers_for_expressing_graphs
concurrent_lru_cache_cls
constraints_extensions
info_namespace_extensions
task_group_extensions
custom_mutex_chmap
+116
View File
@@ -0,0 +1,116 @@
.. _rw_mutex:
rw_mutex
=============
.. note::
To enable this feature, define the ``TBB_PREVIEW_MUTEXES`` macro to 1.
Description
***********
A ``rw_mutex`` is a class that models the `ReaderWriterMutex requirement <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/named_requirements/mutexes/rw_mutex.html>`_,
using adaptive approach: the combination of spinlock and waiting on system primitives.
The ``rw_mutex`` class satisfies all of the shared mutex requirements described in the [thread.sharedmutex.requirements] section of the ISO C++ standard.
The ``rw_mutex`` class is unfair reader-writer lock with writer-preference.
API
***
Header
------
.. code:: cpp
#include <oneapi/tbb/rw_mutex.h>
Synopsis
--------
.. code:: cpp
namespace oneapi {
namespace tbb {
class rw_mutex {
public:
rw_mutex() noexcept;
~rw_mutex();
rw_mutex(const rw_mutex&) = delete;
rw_mutex& operator=(const rw_mutex&) = delete;
class scoped_lock;
// exclusive ownership
void lock();
bool try_lock();
void unlock();
// shared ownership
void lock_shared();
bool try_lock_shared();
void unlock_shared();
static constexpr bool is_rw_mutex = true;
static constexpr bool is_recursive_mutex = false;
static constexpr bool is_fair_mutex = false;
};
}
}
Member classes
--------------
.. namespace:: tbb::rw_mutex
.. cpp:class:: scoped_lock
The corresponding scoped-lock class. See the `ReaderWriterMutex requirement <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/named_requirements/mutexes/rw_mutex.html>`_.
Member functions
----------------
.. cpp:function:: rw_mutex()
Constructs unlocked ``rw_mutex``.
--------------------------------------------------
.. cpp:function:: ~rw_mutex()
Destroys unlocked ``rw_mutex``.
--------------------------------------------------
.. cpp:function:: void lock()
Acquires a lock. It uses adaptive logic for waiting: it blocks after particular time period of busy wait.
--------------------------------------------------
.. cpp:function:: bool try_lock()
Tries to acquire a lock (non-blocking) on write. Returns **true** if succeeded; **false** otherwise.
--------------------------------------------------
.. cpp:function:: void unlock()
Releases the write lock held by the current thread.
--------------------------------------------------
.. cpp:function:: void lock_shared()
Acquires a lock on read. It uses adaptive logic for waiting: it blocks after particular time period of busy wait.
--------------------------------------------------
.. cpp:function:: bool try_lock_shared()
Tries to acquire the lock (non-blocking) on read. Returns **true** if succeeded; **false** otherwise.
--------------------------------------------------
.. cpp:function:: void unlock_shared()
Releases the read lock held by the current thread.
@@ -41,3 +41,4 @@ Here, ``P`` represents an instance of the memory pool class.
scalable_memory_pools/memory_pool_cls
scalable_memory_pools/fixed_pool_cls
scalable_memory_pools/memory_pool_allocator_cls
@@ -0,0 +1,84 @@
.. _malloc_replacement_log:
TBB_malloc_replacement_log Function
===================================
.. note:: This function is for Windows* OS only.
Summary
*******
Provides information about the status of dynamic memory allocation replacement.
Syntax
*******
::
extern "C" int TBB_malloc_replacement_log(char *** log_ptr);
Header
******
::
#include "oneapi/tbb/tbbmalloc_proxy.h"
Description
***********
Dynamic replacement of memory allocation functions on Windows* OS uses in-memory binary instrumentation techniques.
To make sure that such instrumentation is safe, oneTBB first searches for a subset of replaced functions in the Visual C++* runtime DLLs
and checks if each one has a known bytecode pattern. If any required function is not found or its bytecode pattern is unknown, the replacement is skipped,
and the program continues to use the standard memory allocation functions.
The ``TBB_malloc_replacement_log`` function allows the program to check if the dynamic memory replacement happens and to get a log of the performed checks.
**Returns:**
* 0, if all necessary functions are successfully found and the replacement takes place.
* 1, otherwise.
The ``log_ptr`` parameter must be an address of a char** variable or be ``NULL``. If it is not ``NULL``, the function writes there the address of an array of
NULL-terminated strings containing detailed information about the searched functions in the following format:
::
search_status: function_name (dll_name), byte pattern: <bytecodes>
For more information about the replacement of dynamic memory allocation functions, see :ref:`Windows_C_Dynamic_Memory_Interface_Replacement`.
Example
*******
::
#include "oneapi/tbb/tbbmalloc_proxy.h"
#include <stdio.h>
int main(){
char **func_replacement_log;
int func_replacement_status = TBB_malloc_replacement_log(&func_replacement_log);
if (func_replacement_status != 0) {
printf("tbbmalloc_proxy cannot replace memory allocation routines\n");
for (char** log_string = func_replacement_log; *log_string != 0; log_string++) {
printf("%s\n",*log_string);
}
}
return 0;
}
Example output:
::
tbbmalloc_proxy cannot replace memory allocation routines
Success: free (ucrtbase.dll), byte pattern: <C7442410000000008B4424>
Fail: _msize (ucrtbase.dll), byte pattern: <E90B000000CCCCCCCCCCCC>
+2 -4
View File
@@ -13,9 +13,7 @@ task_group extensions
Description
***********
|full_name| implementation extends the `tbb::task_group specification <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/task_scheduler/task_group/task_group_cls.html>`_ with the following members:
- requirements for a user-provided function object
|full_name| implementation extends the `tbb::task_group specification <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/task_scheduler/task_group/task_group_cls.html>`_ with the requirements for a user-provided function object.
API
@@ -88,4 +86,4 @@ As an optimization hint, ``F`` might return a ``task_handle``, which task object
* `oneapi::tbb::task_group specification <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/task_scheduler/task_group/task_group_cls.html>`_
* `oneapi::tbb::task_group_context specification <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/task_scheduler/scheduling_controls/task_group_context_cls.html>`_
* `oneapi::tbb::task_group_status specification <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/task_scheduler/task_group/task_group_status_enum.html>`_
* :doc:`oneapi::tbb::task_handle class <task_group_extensions/task_handle>`
* `oneapi::tbb::task_handle class <https://oneapi-src.github.io/oneAPI-spec/spec/elements/oneTBB/source/task_scheduler/task_group/task_handle.html>`_
@@ -0,0 +1,113 @@
.. _Bandwidth_and_Cache_Affinity:
Bandwidth and Cache Affinity
============================
For a sufficiently simple function ``Foo``, the examples might not show
good speedup when written as parallel loops. The cause could be
insufficient system bandwidth between the processors and memory. In that
case, you may have to rethink your algorithm to take better advantage of
cache. Restructuring to better utilize the cache usually benefits the
parallel program as well as the serial program.
An alternative to restructuring that works in some cases is
``affinity_partitioner.`` It not only automatically chooses the
grainsize, but also optimizes for cache affinity and tries to distribute
the data uniformly among threads. Using ``affinity_partitioner`` can
significantly improve performance when:
- The computation does a few operations per data access.
- The data acted upon by the loop fits in cache.
- The loop, or a similar loop, is re-executed over the same data.
- There are more than two hardware threads available (and especially if
the number of threads is not a power of two). If only two threads are
available, the default scheduling in |full_name|
usually provides sufficient cache affinity.
The following code shows how to use ``affinity_partitioner``.
::
#include "oneapi/tbb.h"
 
void ParallelApplyFoo( float a[], size_t n ) {
static affinity_partitioner ap;
parallel_for(blocked_range<size_t>(0,n), ApplyFoo(a), ap);
}
 
void TimeStepFoo( float a[], size_t n, int steps ) {
for( int t=0; t<steps; ++t )
ParallelApplyFoo( a, n );
}
In the example, the ``affinity_partitioner`` object ``ap`` lives between
loop iterations. It remembers where iterations of the loop ran, so that
each iteration can be handed to the same thread that executed it before.
The example code gets the lifetime of the partitioner right by declaring
the ``affinity_partitioner`` as a local static object. Another approach
would be to declare it at a scope outside the iterative loop in
``TimeStepFoo``, and hand it down the call chain to ``parallel_for``.
If the data does not fit across the system’s caches, there may be little
benefit. The following figure shows the situations.
.. container:: fignone
:name: fig3
Benefit of Affinity Determined by Relative Size of Data Set and Cache
|image0|
The next figure shows how parallel speedup might vary with the size of a
data set. The computation for the example is ``A[i]+=B[i]`` for ``i`` in
the range [0,N). It was chosen for dramatic effect. You are unlikely to
see quite this much variation in your code. The graph shows not much
improvement at the extremes. For small N, parallel scheduling overhead
dominates, resulting in little speedup. For large N, the data set is too
large to be carried in cache between loop invocations. The peak in the
middle is the sweet spot for affinity. Hence ``affinity_partitioner``
should be considered a tool, not a cure-all, when there is a low ratio
of computations to memory accesses.
.. container:: fignone
:name: fig4
Improvement from Affinity Dependent on Array Size
|image1|
.. admonition:: Product and Performance Information
Performance varies by use, configuration and other factors. Learn more at `www.Intel.com/PerformanceIndex <https://www.intel.com/PerformanceIndex>`_.
Notice revision #20201201
.. |image0| image:: Images/image007.jpg
:width: 453px
:height: 178px
.. |image1| image:: Images/image008.jpg
:width: 551px
:height: 192px
@@ -0,0 +1,175 @@
.. _Controlling_Chunking:
Controlling Chunking
====================
Chunking is controlled by a *partitioner* and a *grainsize.*\ To gain
the most control over chunking, you specify both.
- Specify ``simple_partitioner()`` as the third argument to
``parallel_for``. Doing so turns off automatic chunking.
- Specify the grainsize when constructing the range. The thread
argument form of the constructor is
``blocked_range<T>(begin,end,grainsize)``. The default value of
``grainsize`` is 1. It is in units of loop iterations per chunk.
If the chunks are too small, the overhead may exceed the performance
advantage.
The following code is the last example from parallel_for, modified to
use an explicit grainsize ``G``.
::
#include "oneapi/tbb.h"
 
void ParallelApplyFoo( float a[], size_t n ) {
parallel_for(blocked_range<size_t>(0,n,G), ApplyFoo(a),
simple_partitioner());
}
The grainsize sets a minimum threshold for parallelization. The
``parallel_for`` in the example invokes ``ApplyFoo::operator()`` on
chunks, possibly of different sizes. Let *chunksize* be the number of
iterations in a chunk. Using ``simple_partitioner`` guarantees that
[G/2] <= *chunksize* <= G.
There is also an intermediate level of control where you specify the
grainsize for the range, but use an ``auto_partitioner`` and
``affinity_partitioner``. An ``auto_partitioner`` is the default
partitioner. Both partitioners implement the automatic grainsize
heuristic described in :ref:`Automatic_Chunking`. An
``affinity_partitioner`` implies an additional hint, as explained later
in Section :ref:`Bandwidth_and_Cache_Affinity`. Though these partitioners
may cause chunks to have more than G iterations, they never generate
chunks with less than [G/2] iterations. Specifying a range with an
explicit grainsize may occasionally be useful to prevent these
partitioners from generating wastefully small chunks if their heuristics
fail.
Because of the impact of grainsize on parallel loops, it is worth
reading the following material even if you rely on ``auto_partitioner``
and ``affinity_partitioner`` to choose the grainsize automatically.
.. container:: tablenoborder
.. list-table::
:header-rows: 1
* - |image0|
- |image1|
* - Case A
- Case B
The above figure illustrates the impact of grainsize by showing the
useful work as the gray area inside a brown border that represents
overhead. Both Case A and Case B have the same total gray area. Case A
shows how too small a grainsize leads to a relatively high proportion of
overhead. Case B shows how a large grainsize reduces this proportion, at
the cost of reducing potential parallelism. The overhead as a fraction
of useful work depends upon the grainsize, not on the number of grains.
Consider this relationship and not the total number of iterations or
number of processors when setting a grainsize.
A rule of thumb is that ``grainsize`` iterations of ``operator()``
should take at least 100,000 clock cycles to execute. For example, if a
single iteration takes 100 clocks, then the ``grainsize`` needs to be at
least 1000 iterations. When in doubt, do the following experiment:
#. Set the ``grainsize`` parameter higher than necessary. The grainsize
is specified in units of loop iterations. If you have no idea of how
many clock cycles an iteration might take, start with
``grainsize``\ =100,000. The rationale is that each iteration
normally requires at least one clock per iteration. In most cases,
step 3 will guide you to a much smaller value.
#. Run your algorithm.
#. Iteratively halve the ``grainsize`` parameter and see how much the
algorithm slows down or speeds up as the value decreases.
A drawback of setting a grainsize too high is that it can reduce
parallelism. For example, if the grainsize is 1000 and the loop has 2000
iterations, the ``parallel_for`` distributes the loop across only two
processors, even if more are available. However, if you are unsure, err
on the side of being a little too high instead of a little too low,
because too low a value hurts serial performance, which in turns hurts
parallel performance if there is other parallelism available higher up
in the call tree.
.. tip::
You do not have to set the grainsize too precisely.
The next figure shows the typical "bathtub curve" for execution time
versus grainsize, based on the floating point ``a[i]=b[i]*c``
computation over a million indices. There is little work per iteration.
The times were collected on a four-socket machine with eight hardware
threads.
.. container:: fignone
:name: fig2
Wall Clock Time Versus Grainsize
|image2|
The scale is logarithmic. The downward slope on the left side indicates
that with a grainsize of one, most of the overhead is parallel
scheduling overhead, not useful work. An increase in grainsize brings a
proportional decrease in parallel overhead. Then the curve flattens out
because the parallel overhead becomes insignificant for a sufficiently
large grainsize. At the end on the right, the curve turns up because the
chunks are so large that there are fewer chunks than available hardware
threads. Notice that a grainsize over the wide range 100-100,000 works
quite well.
.. tip::
A general rule of thumb for parallelizing loop nests is to
parallelize the outermost one possible. The reason is that each
iteration of an outer loop is likely to provide a bigger grain of
work than an iteration of an inner loop.
.. admonition:: Product and Performance Information
Performance varies by use, configuration and other factors. Learn more at `www.intel.com/PerformanceIndex <https://www.intel.com/PerformanceIndex>`_.
Notice revision #20201201
.. |image0| image:: Images/image002.jpg
:width: 161px
:height: 163px
.. |image1| image:: Images/image004.jpg
:width: 157px
:height: 144px
.. |image2| image:: Images/image006.jpg
:width: 462px
:height: 193px
+2 -2
View File
@@ -37,8 +37,8 @@ it and then connect that to the first node with an edge.
g.wait_for_all();
Now there are two ``function_node``s, ``n`` and ``m``. The call to ``make_edge`` creates
an edge from ``n`` to ``m``. The node n is created with unlimited concurrency,
Now there are two ``function_node`` ``s``, ``n`` and ``m``. The call to ``make_edge`` creates
an edge from ``n`` to ``m``. The node ``n`` is created with unlimited concurrency,
while ``m`` has a concurrency limit of 1. The invocations of ``n`` can all
proceed in parallel, while the invocations of ``m`` will be serialized.
Because there is an edge from ``n`` to ``m``, each value ``v``, returned by ``n``, will
@@ -0,0 +1,60 @@
.. _Floating_Point_Settings:
Floating-point Settings
=======================
To propagate CPU-specific settings for floating-point computations to tasks executed by the task scheduler, you can use one of the following two methods:
* When a ``task_arena`` or a task scheduler for a given application thread is initialized, they capture the current floating-point settings of the thread.
* The ``task_group_context`` class has a method to capture the current floating-point settings.
By default, worker threads use floating-point settings obtained during the initialization of a ``task_arena`` or the implicit arena of the application thread. The settings are applied to all computations within that ``task_arena`` or started by that application thread.
For better control over floating point behavior, a thread may capture the current settings in a task group context. Do it at context creation with a special flag passed to the constructor:
::
task_group_context ctx( task_group_context::isolated,
task_group_context::default_traits | task_group_context::fp_settings );
Or call the ``capture_fp_settings`` method:
::
task_group_context ctx;
ctx.capture_fp_settings();
You can then pass the task group context to most parallel algorithms, including ``flow::graph``, to ensure that all tasks related to this algorithm use the specified floating-point settings.
It is possible to execute the parallel algorithms with different floating-point settings captured to separate contexts, even at the same time.
Floating-point settings captured to a task group context prevail over the settings captured during task scheduler initialization. It means, if a context is passed to a parallel algorithm, the floating-point settings captured to the context are used.
Otherwise, if floating-point settings are not captured to the context, or a context is not explicitly specified, the settings captured during the task arena initialization are used.
In a nested call to a parallel algorithm that does not use the context of a task group with explicitly captured floating-point settings, the outer-level settings are used.
If none of the outer-level contexts capture floating-point settings, the settings captured during task arena initialization are used.
It guarantees that:
* Floating-point settings are applied to all tasks executed within a task arena, if they are captured:
* To a task group context.
* During the arena initialization.
* A call to a oneTBB parallel algorithm does not change the floating-point settings of the calling thread, even if the algorithm uses different settings.
.. note::
The guarantees above apply only to the following conditions:
* A user code inside a task should:
* Not change the floating-point settings.
* Revert any modifications.
* Restore previous settings before the end of the task.
* oneTBB task scheduler observers are not used to set or modify floating point settings.
Otherwise, the stated guarantees are not valid and the behavior related to floating-point settings is undefined.
@@ -0,0 +1,17 @@
.. _Flow_Graph_exception_tips:
Flow Graph Tips for Exception Handling and Cancellation
=======================================================
The execution of a flow graph can be canceled directly or as a result of
an exception that propagates beyond a node's body. You can then
optionally reset the graph so that it can be re-executed.
.. toctree::
:maxdepth: 4
../tbb_userguide/catching_exceptions
../tbb_userguide/cancel_a_graph
../tbb_userguide/use_graph_reset
../tbb_userguide/cancelling_nested_parallelism
@@ -0,0 +1,11 @@
.. _Flow_Graph_waiting_tips:
Flow Graph Tips for Waiting for and Destroying a Flow Graph
===========================================================
.. toctree::
:maxdepth: 4
../tbb_userguide/always_use_wait_for_all
../tbb_userguide/avoid_dynamic_node_removal
../tbb_userguide/destroy_graphs_outside_main_thread
@@ -63,7 +63,7 @@ messages and do not support ``try_get()`` or ``try_reserve()``.
broadcast_node<int> bn(g);
buffer_node<int> buf1(g);
buffer_node<int> buf2(g);
typedef join_node<tuple<int,int> reserving> join_type;
typedef join_node<tuple<int,int>, reserving> join_type;
join_type jn(g);
buffer_node<join_type::output_type> buf_out(g);
join_type::output_type tuple_out;
@@ -71,9 +71,9 @@ messages and do not support ``try_get()`` or ``try_reserve()``.
// join_node predecessors are both reservable buffer_nodes
make_edge(buf1,input_port<0>jn));
make_edge(bn,input_port<0>jn)); // attach a broadcast_node
make_edge(buf2,input_port<1>jn));
make_edge(buf1,input_port<0>(jn));
make_edge(bn,input_port<0>(jn)); // attach a broadcast_node
make_edge(buf2,input_port<1>(jn));
make_edge(jn, buf_out);
bn.try_put(2);
buf1.try_put(3);
@@ -81,7 +81,7 @@ messages and do not support ``try_get()`` or ``try_reserve()``.
buf2.try_put(7);
g.wait_for_all();
while (buf_out.try_get(tuple_out)) {
printf("join_node output == (%d,%d)\n",get<0>tuple_out), get<1>tuple_out) );
printf("join_node output == (%d,%d)\n",get<0>(tuple_out), get<1>(tuple_out) );
}
if(buf1.try_get(icnt)) printf("buf1 had %d\n", icnt);
else printf("buf1 was empty\n");
+2 -2
View File
@@ -6,8 +6,8 @@ Flow Graph Tips and Tricks
.. toctree::
:maxdepth: 4
../tbb_userguide/Flow_Graph_waiting_tips
../tbb_userguide/Flow-Graph-waiting-tips
../tbb_userguide/Flow_Graph_making_edges_tips
../tbb_userguide/Flow_Graph_nested_parallelism_tips
../tbb_userguide/Flow_Graph_resource_tips
../tbb_userguide/Flow_Graph_exception_tips
../tbb_userguide/Flow-Graph-exception-tips
+7
View File
@@ -25,3 +25,10 @@ or edges, and therefore no tasks are spawned.
graph g;
g.wait_for_all();
The graph object does not own the nodes associated with it. You need to make sure that the graph object's lifetime is longer than the lifetimes of all nodes added to the graph and any activity associated with the graph.
.. tip:: Call ``wait_for_all`` on a graph object before destroying it to make sure all activities are complete.
Even when using smart pointers, be aware of the order of destruction for nodes and the graph to make sure that nodes are not deleted before the graph.
@@ -61,8 +61,9 @@ assign a NUMA node identifier to the ``task_arena::constraints::numa_id`` field.
The processors with `Intel® Hybrid Technology <https://www.intel.com/content/www/us/en/products/docs/processors/core/core-processors-with-hybrid-technology-brief.html>`_
contain several core types, each is suited for different purposes.
For example, some applications may improve their performance by preferring execution on the most performant cores.
To set execution preference, assign specific core type identifier to the ``task_arena::constraints::core_type`` field.
In most cases, systems with hybrid CPU architecture show reasonable performance without involving additional API calls.
However, in some exceptional scenarios, performance may be tuned by setting the preferred core type.
To set the preferred core type for the execution, assign a specific core type identifier to the ``task_arena::constraints::core_type`` field.
The example shows how to set the most performant core type as preferable for work execution:
+1 -1
View File
@@ -68,4 +68,4 @@ redirect the standard routines to these functions.
../tbb_userguide/Which_Dynamic_Libraries_to_Use
../tbb_userguide/Allocator_Configuration
../tbb_userguide/Automically_Replacing_malloc
../tbb_userguide/automatically-replacing-malloc
@@ -46,3 +46,4 @@ TBB possible output:
TBB: RML private
TBB: Tools support disabled
.. note:: The ``tbbmalloc`` library in oneTBB is fully binary compatible with TBB.
@@ -361,7 +361,7 @@ is not guaranteed to be executed next by the current thread.
tbb::task_spawn(child);
root.wait_for_all();;
root.wait_for_all();
}
In oneTBB, this can be done using ``oneapi::tbb::task_group``.
@@ -140,7 +140,8 @@ to set the stack size for oneTBB worker threads:
Terminating oneTBB scheduler
---------------------------------------
:ref:`task_scheduler_handle_reference`
`task_scheduler_handle <https://oneapi-src.github.io/oneAPI-spec/spec/elements/oneTBB/source/task_scheduler/scheduling_controls/task_scheduler_handle_cls.html>`_
allows waiting for oneTBB worker threads completion:
.. code:: cpp
@@ -14,4 +14,5 @@ and macOS\* operating systems as described in this section.
../tbb_userguide/Scalable_Memory_Allocator
../tbb_userguide/Windows_OS_ug
../tbb_userguide/Linux_OS
../tbb_userguide/Mac_OS
../tbb_userguide/Mac_OS
@@ -0,0 +1,48 @@
.. _Parallelizing_Simple_Loops:
Parallelizing Simple Loops
==========================
The simplest form of scalable parallelism is a loop of iterations that
can each run simultaneously without interfering with each other. The
following sections demonstrate how to parallelize simple loops.
.. note::
|full_name| components are
defined in namespace ``tbb``. For brevity’s sake, the namespace is
explicit in the first mention of a component, but implicit
afterwards.
When compiling oneTBB programs, be sure to link in the oneTBB shared
library, otherwise undefined references will occur. The following table
shows compilation commands that use the debug version of the library.
Remove the "``_debug``" portion to link against the production version
of the library.
.. container:: tablenoborder
.. list-table::
:header-rows: 1
* - Operating System
- Command line
* - Windows\* OS
- ``icl /MD example.cpp tbb_debug.lib``
* - Linux\* OS
- ``icc example.cpp -ltbb_debug``
.. toctree::
:maxdepth: 4
../tbb_userguide/Initializing_and_Terminating_the_Library
../tbb_userguide/parallel_for
../tbb_userguide/parallel_reduce
../tbb_userguide/Advanced_Example
../tbb_userguide/Advanced_Topic_Other_Kinds_of_Iteration_Spaces
@@ -25,7 +25,7 @@ pipeline.
.. CAUTION::
Since the body object provided to the filters of the
``parallel_pipline`` might be copied, its ``operator()`` should not
``parallel_pipeline`` might be copied, its ``operator()`` should not
modify the body. Otherwise the modification might or might not become
visible to the thread that invoked ``parallel_pipeline``, depending
upon whether ``operator()`` is acting on the original or a copy. As a
@@ -115,13 +115,13 @@ the overhead of copying a ``TextSlice``.
oneapi::tbb::parallel_pipeline(
ntoken,
oneapi::tbb::make_filter<void,TextSlice*>(
oneapi::tbb::filter::serial_in_order, MyInputFunc(input_file) )
oneapi::tbb::filter_mode::serial_in_order, MyInputFunc(input_file) )
&
oneapi::tbb::make_filter<TextSlice*,TextSlice*>(
oneapi::tbb::filter::parallel, MyTransformFunc() )
oneapi::tbb::filter_mode::parallel, MyTransformFunc() )
&
oneapi::tbb::make_filter<TextSlice*,void>(
oneapi::tbb::filter::serial_in_order, MyOutputFunc(output_file) ) );
oneapi::tbb::filter_mode::serial_in_order, MyOutputFunc(output_file) ) );
}
@@ -172,11 +172,11 @@ equivalent version of the previous example that does this follows:
void RunPipeline( int ntoken, FILE* input_file, FILE* output_file ) {
oneapi::tbb::filter<void,TextSlice*> f1( oneapi::tbb::filter::serial_in_order,
oneapi::tbb::filter<void,TextSlice*> f1( oneapi::tbb::filter_mode::serial_in_order,
MyInputFunc(input_file) );
oneapi::tbb::filter<TextSlice*,TextSlice*> f2(oneapi::tbb::filter::parallel,
oneapi::tbb::filter<TextSlice*,TextSlice*> f2(oneapi::tbb::filter_mode::parallel,
MyTransformFunc() );
oneapi::tbb::filter<TextSlice*,void> f3(oneapi::tbb::filter::serial_in_order,
oneapi::tbb::filter<TextSlice*,void> f3(oneapi::tbb::filter_mode::serial_in_order,
MyOutputFunc(output_file) );
oneapi::tbb::filter<void,void> f = f1 & f2 & f3;
oneapi::tbb::parallel_pipeline(ntoken,f);
@@ -1,7 +1,7 @@
.. _attach_flow_graph_to_arena:
Attach Flow Graph to an Arbitrary Task Arena
======================
=============================================
|short_name| ``task_arena`` interface provides mechanisms to guide tasks
@@ -0,0 +1,22 @@
.. _automatically-replacing-malloc:
Automatically Replacing ``malloc`` and Other C/C++ Functions for Dynamic Memory Allocation
==========================================================================================
On Windows*, Linux\* operating systems, it is possible to automatically
replace all calls to standard functions for dynamic memory allocation
(such as ``malloc``) with the |full_name| scalable equivalents.
Doing so can sometimes improve application performance.
Replacements are provided by the proxy library (the library names can be
found in platform-specific sections below). A proxy library and a
scalable memory allocator library should be taken from the same release
of oneTBB, otherwise the libraries may be mutually incompatible.
.. toctree::
:maxdepth: 4
../tbb_userguide/Windows_C_Dynamic_Memory_Interface_Replacement
../tbb_userguide/Linux_C_Dynamic_Memory_Interface_Replacement
@@ -1,7 +1,7 @@
.. _Lazy_Initialization:
Lazy Initialization
==================
====================
.. container:: section
+130
View File
@@ -0,0 +1,130 @@
.. _parallel_for:
parallel_for
============
Suppose you want to apply a function ``Foo`` to each element of an
array, and it is safe to process each element concurrently. Here is the
sequential code to do this:
::
void SerialApplyFoo( float a[], size_t n ) {
for( size_t i=0; i!=n; ++i )
Foo(a[i]);
}
The iteration space here is of type ``size_t``, and goes from ``0`` to
``n-1``. The template function ``oneapi::tbb::parallel_for`` breaks this iteration
space into chunks, and runs each chunk on a separate thread. The first
step in parallelizing this loop is to convert the loop body into a form
that operates on a chunk. The form is an STL-style function object,
called the *body* object, in which ``operator()`` processes a chunk. The
following code declares the body object.
::
#include "oneapi/tbb.h"
using namespace oneapi::tbb;
class ApplyFoo {
float *const my_a;
public:
void operator()( const blocked_range<size_t>& r ) const {
float *a = my_a;
for( size_t i=r.begin(); i!=r.end(); ++i )
Foo(a[i]);
}
ApplyFoo( float a[] ) :
my_a(a)
{}
};
The ``using`` directive in the example enables you to use the library
identifiers without having to write out the namespace prefix ``oneapi::tbb``
before each identifier. The rest of the examples assume that such a
``using`` directive is present.
Note the argument to ``operator()``. A ``blocked_range<T>`` is a
template class provided by the library. It describes a one-dimensional
iteration space over type ``T``. Class ``parallel_for`` works with other
kinds of iteration spaces too. The library provides ``blocked_range2d``
for two-dimensional spaces. You can define your own spaces as explained
in :ref:`Advanced_Topic_Other_Kinds_of_Iteration_Spaces`.
An instance of ``ApplyFoo`` needs member fields that remember all the
local variables that were defined outside the original loop but used
inside it. Usually, the constructor for the body object will initialize
these fields, though ``parallel_for`` does not care how the body object
is created. Template function ``parallel_for`` requires that the body
object have a copy constructor, which is invoked to create a separate
copy (or copies) for each worker thread. It also invokes the destructor
to destroy these copies. In most cases, the implicitly generated copy
constructor and destructor work correctly. If they do not, it is almost
always the case (as usual in C++) that you must define *both* to be
consistent.
Because the body object might be copied, its ``operator()`` should not
modify the body. Otherwise the modification might or might not become
visible to the thread that invoked ``parallel_for``, depending upon
whether ``operator()`` is acting on the original or a copy. As a
reminder of this nuance, ``parallel_for`` requires that the body
object's ``operator()`` be declared ``const``.
The example ``operator()`` loads ``my_a`` into a local variable ``a``.
Though not necessary, there are two reasons for doing this in the
example:
- **Style**. It makes the loop body look more like the original.
- **Performance**. Sometimes putting frequently accessed values into
local variables helps the compiler optimize the loop better, because
local variables are often easier for the compiler to track.
Once you have the loop body written as a body object, invoke the
template function ``parallel_for``, as follows:
::
#include "oneapi/tbb.h"
 
void ParallelApplyFoo( float a[], size_t n ) {
parallel_for(blocked_range<size_t>(0,n), ApplyFoo(a));
}
The ``blocked_range`` constructed here represents the entire iteration
space from 0 to n-1, which ``parallel_for`` divides into subspaces for
each processor. The general form of the constructor is
``blocked_range<T>(begin,end,grainsize)``. The ``T`` specifies the value
type. The arguments ``begin`` and ``end`` specify the iteration space
STL-style as a half-open interval [``begin``,\ ``end``). The argument
*grainsize* is explained in the :ref:`Controlling_Chunking` section. The
example uses the default grainsize of 1 because by default
``parallel_for`` applies a heuristic that works well with the default
grainsize.
.. toctree::
:maxdepth: 4
../tbb_userguide/Lambda_Expressions
../tbb_userguide/Automatic_Chunking
../tbb_userguide/Controlling_Chunking
../tbb_userguide/Bandwidth_and_Cache_Affinity
../tbb_userguide/Partitioner_Summary
@@ -17,10 +17,6 @@
/* Flow Graph Code Example for the Userguide.
*/
//! Enable extended task_arena constraints feature for supporting Intel Hybrid Technology
//! and Intel Hyper-Threading Technology.
#define TBB_PREVIEW_TASK_ARENA_CONSTRAINTS_EXTENSION 1
#include <oneapi/tbb/flow_graph.h>
#include <vector>
+217
View File
@@ -0,0 +1,217 @@
.. _std_invoke:
Invoke a Callable Object
==========================
Starting from C++17, the requirements for callable objects passed to algorithms or Flow Graph nodes are relaxed. It allows using additional types of bodies.
Previously, the body of the algorithm or Flow Graph node needed to be a Function Object (see `C++ Standard Function Object <https://en.cppreference.com/w/cpp/utility/functional>`_) and provide an
``operator()`` that accepts input parameters.
Now the body needs to meet the more relaxed requirements of being Callable (see `C++ Standard Callable <https://en.cppreference.com/w/cpp/named_req/Callable>`_) that covers three types of objects:
* **Function Objects that provide operator(arg1, arg2, ...)**, which accepts the input parameters
* **Pointers to member functions** that you can use as the body of the algorithm or the Flow Graph node
* **Pointers to member objects** work as the body of the algorithm or parallel construct
You can use it not only for a Flow Graph but also for algorithms. See the example below:
.. code::
// The class models oneTBB Range
class StrideRange {
public:
StrideRange(int* s, std::size_t sz, std::size_t str)
: start(s), size(sz), stride(str) {}
// A copy constructor
StrideRange(const StrideRange&) = default;
// A splitting constructor
StrideRange(StrideRange& other, oneapi::tbb::split)
: start(other.start), size(other.size / 2)
{
other.size -= size;
other.start += size;
}
~StrideRange() = default;
// Indicate if the range is empty
bool empty() const {
return size == 0;
}
// Indicate if the range can be divided
bool is_divisible() const {
return size >= stride;
}
void iterate() const {
for (std::size_t i = 0; i < size; i += stride) {
// Performed an action for each element of the range,
// implement the code based on your requirements
}
}
private:
int* start;
std::size_t size;
std::size_t stride;
};
Where:
* The ``StrideRange`` class models oneTBB range that should be iterated with a specified stride during its initial construction.
* The ``stride`` value is stored in a private field within the range. Therefore, the class provides the member function ``iterate() const`` that implements a loop with the specified stride.
``range.iterate()``
*******************
Before C++17, to utilize a range in a parallel algorithm, such as ``parallel_for``, it was required to provide a ``Function Object`` as the algorithm's body. This Function Object defined the operations to be executed on each iteration of the range:
.. code::
int main() {
std::size_t array_size = 1000;
int* array_to_iterate = new int[array_size];
StrideRange range(array_to_iterate, array_size, /* stride = */ 2);
// Define a lambda function as the body of the parallel_for loop
auto pfor_body = [] (const StrideRange& range) {
range.iterate();
};
// Perform parallel iteration
oneapi::tbb::parallel_for(range, pfor_body);
delete[] array_to_iterate;
}
An additional lambda function ``pfor_body`` was also required. This lambda function invoked the ``rage.iterate()`` function.
Now with C++17, you can directly utilize a pointer to ``range.iterate()`` as the body of the algorithm:
.. code::
int main() {
std::size_t array_size = 1000;
int* array_to_iterate = new int[array_size];
// Performs the iteration over the array elements with the specified stride
StrideRange range(array_to_iterate, array_size, /* stride = */ 2);
// Parallelize the iteration over the range object
oneapi::tbb::parallel_for(range, &StrideRange::iterate);
delete[] array_to_iterate;
}
``std::invoke``
****************
``std::invoke`` is a function template that provides a syntax for invoking different types of callable objects with a set of arguments.
oneTBB implementation uses the C++ standard function ``std::invoke(&StrideRange::iterate, range)`` to execute the body. It is the equivalent of ``range.iterate()``.
Therefore, it allows you to invoke a callable object, such as a function object, with the provided arguments.
.. tip:: Refer to `C++ Standard <https://en.cppreference.com/w/cpp/utility/functional/invoke>`_ to learn more about ``std::invoke``.
Example
^^^^^^^^
Consider a specific scenario with ``function_node`` within a Flow Graph.
In the example below, a ``function_node`` takes an object as an input to read a member object of that input and proceed it to the next node in the graph:
.. code::
struct Object {
int number;
};
int main() {
using namespace oneapi::tbb::flow;
// Lambda function to read the member object of the input Object
auto number_reader = [] (const Object& obj) {
return obj.number;
};
// Lambda function to process the received integer
auto number_processor = [] (int i) { /* processing integer */ };
graph g;
// Function node that takes an Object as input and produces an integer
function_node<Object, int> func1(g, unlimited, number_reader);
// Function node that takes an integer as input and processes it
function_node<int, int> func2(g, unlimited, number_processor);
// Connect the function nodes
make_edge(func1, func2);
// Provide produced input to the graph
func1.try_put(Object{1});
// Wait for the graph to complete
g.wait_for_all();
}
Before C++17, the ``function_node`` in the Flow Graph required the body to be a Function Object. A lambda function was required to extract the number from the Object.
With C++17, you can use ``std::invoke`` with a pointer to the member number directly as the body.
You can update the previous example as follows:
.. code::
struct Object {
int number;
};
int main() {
using namespace oneapi::tbb::flow;
// The processing logic for the received integer
auto number_processor = [] (int i) { /* processing integer */ };
// Create a graph object g to hold the flow graph
graph g;
// Use a member function pointer to the number member of the Object struct as the body
function_node<Object, int> func1(g, unlimited, &Object::number);
// Use the number_processor lambda function as the body
function_node<int, int> func2(g, unlimited, number_processor);
// Connect the function nodes
make_edge(func1, func2);
// Connect the function nodes
func1.try_put(Object{1});
// Wait for the graph to complete
g.wait_for_all();
}
Find More
*********
The following APIs supports Callable object as Bodies:
* `parallel_for <https://oneapi-src.github.io/oneAPI-spec/spec/elements/oneTBB/source/algorithms/functions/parallel_for_func.html>`_
* `parallel_reduce <https://oneapi-src.github.io/oneAPI-spec/spec/elements/oneTBB/source/algorithms/functions/parallel_reduce_func.html>`_
* `parallel_deterministic_reduce <https://oneapi-src.github.io/oneAPI-spec/spec/elements/oneTBB/source/algorithms/functions/parallel_deterministic_reduce_func.html>`_
* `parallel_for_each <https://oneapi-src.github.io/oneAPI-spec/spec/elements/oneTBB/source/algorithms/functions/parallel_for_each_func.html>`_
* `parallel_scan <https://oneapi-src.github.io/oneAPI-spec/spec/elements/oneTBB/source/algorithms/functions/parallel_scan_func.html>`_
* `parallel_pipeline <https://oneapi-src.github.io/oneAPI-spec/spec/elements/oneTBB/source/algorithms/functions/parallel_pipeline_func.html>`_
* `function_node <https://oneapi-src.github.io/oneAPI-spec/spec/elements/oneTBB/source/flow_graph/func_node_cls.html>`_
* `multifunction_node <https://oneapi-src.github.io/oneAPI-spec/spec/elements/oneTBB/source/flow_graph/multifunc_node_cls.html>`_
* `async_node <https://oneapi-src.github.io/oneAPI-spec/spec/elements/oneTBB/source/flow_graph/async_node_cls.html>`_
* `sequencer_node <https://oneapi-src.github.io/oneAPI-spec/spec/elements/oneTBB/source/flow_graph/sequencer_node_cls.html>`_
* `join_node with key_matching policy <https://oneapi-src.github.io/oneAPI-spec/spec/elements/oneTBB/source/flow_graph/join_node_cls.html>`_
+3 -1
View File
@@ -8,12 +8,13 @@
.. toctree::
:maxdepth: 4
../tbb_userguide/Package_Contents
../tbb_userguide/Package_Contents_os
../tbb_userguide/Parallelizing_Simple_Loops_os
../tbb_userguide/Parallelizing_Complex_Loops
../tbb_userguide/Flow_Graph
../tbb_userguide/work_isolation
../tbb_userguide/Exceptions_and_Cancellation
../tbb_userguide/Floating_Point_Settings
../tbb_userguide/Containers
../tbb_userguide/Mutual_Exclusion
../tbb_userguide/Timing
@@ -22,6 +23,7 @@
../tbb_userguide/design_patterns/Design_Patterns
../tbb_userguide/Migration_Guide
../tbb_userguide/Constraints
../tbb_userguide/std_invoke
../tbb_userguide/appendix_A
../tbb_userguide/appendix_B
../tbb_userguide/References
+5 -2
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021 Intel Corporation
# Copyright (c) 2020-2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.5)
project(tbb_examples CXX)
@@ -66,6 +66,7 @@ tbb_add_example(parallel_for_each parallel_preorder)
tbb_add_example(parallel_pipeline square)
tbb_add_example(parallel_reduce convex_hull)
tbb_add_example(parallel_reduce pi)
tbb_add_example(parallel_reduce primes)
tbb_add_example(task_arena fractal)
@@ -73,3 +74,5 @@ tbb_add_example(task_arena fractal)
tbb_add_example(task_group sudoku)
tbb_add_example(test_all fibonacci)
tbb_add_example(migration recursive_fibonacci)
+12 -10
View File
@@ -3,38 +3,40 @@ This directory contains example usages of oneAPI Threading Building Blocks.
| Code sample name | Description
|:--- |:---
| getting_started/sub_string_finder | Example referenced by the [oneAPI Threading Building Blocks Get Started Guide](https://software.intel.com/content/www/us/en/develop/documentation/get-started-with-onetbb/top.html). Finds largest matching substrings.
| getting_started/sub_string_finder | Example referenced by the [oneAPI Threading Building Blocks Get Started Guide](https://oneapi-src.github.io/oneTBB/GSG/get_started.html#get-started-guide). Finds the largest matching substrings.
| concurrent_hash_map/count_strings | Concurrently inserts strings into a `concurrent_hash_map` container.
| concurrent_priority_queue/shortpath | Solves the single source shortest path problem using a `concurrent_priority_queue` container.
| graph/binpack | A solution to the binpacking problem using a `queue_node`, a `buffer_node` and `function_node`s.
| graph/binpack | A solution to the binpacking problem using a `queue_node`, a `buffer_node`, and `function_node`s.
| graph/cholesky | Several versions of Cholesky Factorization algorithm implementation.
| graph/dining_philosophers | An implementation of dining philosophers in graph using the reserving `join_node`.
| graph/dining_philosophers | An implementation of dining philosophers in a graph using the reserving `join_node`.
| graph/fgbzip2 | A parallel implementation of bzip2 block-sorting file compressor.
| graph/logic_sim | An example of a collection of digital logic gates that can be easily composed into larger circuits.
| graph/som | An example of a Kohonen Self-Organizing Map using cancellation.
| parallel_for/game_of_life | Game of life overlay.
| parallel_for/polygon_overlay | polygon overlay.
| parallel_for/polygon_overlay | Polygon overlay.
| parallel_for/seismic | Parallel seismic wave simulation.
| parallel_for/tachyon | Parallel 2-D raytracer/renderer.
| parallel_for_each/parallel_preorder | Parallel preorder traversal of a graph.
| parallel_pipeline/square | Another string transformation example that squares numbers read from a file.
| parallel_reduce/convex_hull | Parallel version of convex hull algorithm (quick hull).
| parallel_reduce/pi | Parallel version of calculating &pi; by numerical integration.
| parallel_reduce/primes | Parallel version of the Sieve of Eratosthenes.
| task_arena/fractal |The example calculates two classical Mandelbrot fractals with different concurrency limits.
| task_group/sudoku | Compute all solutions for a Sudoku board.
| test_all/fibonacci | Compute Fibonacci numbers in different ways.
## System Requirements
"Refer to the [System Requirements](https://software.intel.com/content/www/us/en/develop/articles/intel-oneapi-threading-building-blocks-system-requirements.html) for the list of supported hardware and software".
Refer to the [System Requirements](https://github.com/oneapi-src/oneTBB/blob/master/SYSTEM_REQUIREMENTS.md) for the list of supported hardware and software.
### Graphical User Interface (GUI)
Some examples (fractal, seismic, tachyon, polygon_overlay) supports different GUI modes, which may be defined via the `EXAMPLES_UI_MODE` CMake variable. Supported values are:
Some examples (e.g., fractal, seismic, tachyon, polygon_overlay) support different GUI modes, which may be defined via the `EXAMPLES_UI_MODE` CMake variable.
Supported values are:
- Cross-platform:
- `con` - Console mode (Default).
- Windows:
- Windows* OS:
- `gdi` - `GDI+` based implementation.
- `d2d` - `Direct 2D` based implementation. May offer superior performance, but can only be used if the Microsoft* DirectX* SDK is installed on your system(`DXSDK_DIR` should be defined).
- Linux:
- `d2d` - `Direct 2D` based implementation. May offer superior performance but can only be used if the Microsoft* DirectX* SDK is installed on your system(`DXSDK_DIR` should be defined).
- Linux* OS:
- `x` - `X11` based implementation. Also `libXext` may be required to display the output correctly.
- MacOS:
- macOS*:
- `mac` - `OpenGL` based implementation. Also requires the `Foundation` and `Cocoa` libraries availability.
+2 -2
View File
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021 Intel Corporation
# Copyright (c) 2020-2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.5)
set(EXAMPLES_UI_MODE "con" CACHE STRING "EXAMPLES_UI_MODE")
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021 Intel Corporation
# Copyright (c) 2020-2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.5)
project(count_strings CXX)
@@ -1,4 +1,4 @@
# Copyright (c) 2020-2021 Intel Corporation
# Copyright (c) 2020-2023 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
cmake_minimum_required(VERSION 3.1)
cmake_minimum_required(VERSION 3.5)
project(shortpath CXX)

Some files were not shown because too many files have changed in this diff Show More