Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0baaad609a | ||
|
|
cb8fa21a84 | ||
|
|
912cd2b0b3 | ||
|
|
e8666c0b9c | ||
|
|
71b04524d0 | ||
|
|
aa247fa816 | ||
|
|
13544f9432 | ||
|
|
635761449f | ||
|
|
6bfd29bde7 | ||
|
|
e6459e22ae | ||
|
|
85792ca411 | ||
|
|
3fbdbb8b2e | ||
|
|
3c91aea522 | ||
|
|
2eccd5f998 | ||
|
|
cc3a9aa992 | ||
|
|
104fb5c9de | ||
|
|
f10350212b | ||
|
|
8155aaeb6b | ||
|
|
f3747fed09 | ||
|
|
a748475d7a | ||
|
|
57f8bb1d99 | ||
|
|
01fa1414a2 | ||
|
|
dce182a7b5 | ||
|
|
5cb212d447 | ||
|
|
323260671b | ||
|
|
4b895704d8 | ||
|
|
fc824596aa | ||
|
|
bc7e83a2f0 | ||
|
|
0a521127a8 | ||
|
|
5deb46f4c2 | ||
|
|
801df0edeb | ||
|
|
451e76ef68 | ||
|
|
faaf43c4ab | ||
|
|
9d2a3477ce | ||
|
|
3e352b4812 | ||
|
|
4aa0b0b2db | ||
|
|
3859d1111f | ||
|
|
efea9935d1 | ||
|
|
ed9d4b5e9a | ||
|
|
0a0a5926ee | ||
|
|
2c4f282e86 | ||
|
|
05023723ff | ||
|
|
500abe33f8 | ||
|
|
1da8f0d33b | ||
|
|
a938322524 | ||
|
|
af90f6cffc | ||
|
|
e386960a77 | ||
|
|
ce0d258e72 | ||
|
|
09346731f1 | ||
|
|
e5cbe500d2 | ||
|
|
a392038c6d | ||
|
|
f8102d5ba7 | ||
|
|
31cba51f69 | ||
|
|
ab1409e16b | ||
|
|
a8681a54c2 | ||
|
|
e77098d67f | ||
|
|
6666292fbf | ||
|
|
c9e43df346 | ||
|
|
39c6fa3010 | ||
|
|
690aaf497a | ||
|
|
56cb263e40 | ||
|
|
18e06f7f6b | ||
|
|
fd76f45215 | ||
|
|
3a7f96db56 | ||
|
|
e274a9e4b3 | ||
|
|
f5ed9a6b6a | ||
|
|
6a15b64093 | ||
|
|
c17f1ec1cb | ||
|
|
219c42520c | ||
|
|
5d21288abc | ||
|
|
2a9ed7045e | ||
|
|
c21e688ad0 | ||
|
|
cd6a5f9f4a | ||
|
|
3c76824ade | ||
|
|
525a38895c | ||
|
|
57f524ca71 | ||
|
|
4d2254b08f | ||
|
|
4eda0f93a7 | ||
|
|
e0cc518745 | ||
|
|
35e0f552bd | ||
|
|
74207e5d2d | ||
|
|
13f9f32b3a | ||
|
|
555bc873f8 | ||
|
|
1bfd90d19a | ||
|
|
a36bf9cb86 | ||
|
|
70ac2444f5 | ||
|
|
1318c0582e | ||
|
|
6b0507b72d | ||
|
|
84efdd2a87 | ||
|
|
f1ba69bde9 | ||
|
|
14d3d41f81 | ||
|
|
ec39c5463d | ||
|
|
1eaccf7a8c | ||
|
|
3db67b5ba2 | ||
|
|
4ba6676737 | ||
|
|
603d9f7e17 | ||
|
|
e386c96deb | ||
|
|
d1667d514d | ||
|
|
5fc0a5f6b3 | ||
|
|
90b0671b31 | ||
|
|
0860b7f562 | ||
|
|
013035b4e9 | ||
|
|
534428d0f8 | ||
|
|
8a87469451 | ||
|
|
74b7fc748b | ||
|
|
6563a2225b | ||
|
|
883c2e5245 | ||
|
|
0815661e4c | ||
|
|
6edb5c3ae9 | ||
|
|
56d44d28bb | ||
|
|
952845afef | ||
|
|
324afd9e4d | ||
|
|
4eec89fe7a | ||
|
|
f5de7b039e | ||
|
|
b7a062e2d9 | ||
|
|
fc8717e18c | ||
|
|
2713d41e4c | ||
|
|
cf0a673956 | ||
|
|
fb8ae3b97d | ||
|
|
3ab999a0a7 | ||
|
|
46d3acde26 | ||
|
|
7631793a32 | ||
|
|
3692900c51 | ||
|
|
25f8494f45 | ||
|
|
252ee0d301 | ||
|
|
7b3cb6747d | ||
|
|
bd4fb54e72 | ||
|
|
588c6a9f8b | ||
|
|
b2cbc926ec | ||
|
|
7dee0fbd15 | ||
|
|
9052aaabd9 | ||
|
|
2915b9b93f | ||
|
|
51277f0e58 | ||
|
|
ce47617377 | ||
|
|
c8211a2168 | ||
|
|
e82d250338 | ||
|
|
cb885710ab | ||
|
|
cf29ce8177 | ||
|
|
8c9445dee5 | ||
|
|
b95bbc9c9f | ||
|
|
7c7be274a1 | ||
|
|
6feeba8035 | ||
|
|
01a68ed7b3 | ||
|
|
ba947f1806 | ||
|
|
adf44fbf25 | ||
|
|
d439ddfb80 | ||
|
|
963dfbf770 | ||
|
|
15c838cea3 | ||
|
|
1b41b7e6cc | ||
|
|
a1f53c8fa2 | ||
|
|
c4a42feb53 | ||
|
|
106e08a45a | ||
|
|
1168c5cb83 | ||
|
|
155a9af909 | ||
|
|
ef970eb0d9 | ||
|
|
b61fd08145 | ||
|
|
6fad69889d | ||
|
|
3c20b8f0b2 | ||
|
|
70bf10c0a9 | ||
|
|
144f75fd65 | ||
|
|
b3d63b7a7f | ||
|
|
a8206f8540 | ||
|
|
4ca7d964db | ||
|
|
c09c4163ca | ||
|
|
5ab8e5f6ea | ||
|
|
f13f3ef35a | ||
|
|
d65c9b3a5f | ||
|
|
e6162e8838 | ||
|
|
43169c243f | ||
|
|
5d7abed881 | ||
|
|
f580ec8edb | ||
|
|
c4a120705f | ||
|
|
3b1bc31f45 | ||
|
|
e8037363ac | ||
|
|
0a57bda871 | ||
|
|
4624e4ff59 | ||
|
|
7567de93ae | ||
|
|
97ac8f4324 | ||
|
|
40a9a10600 | ||
|
|
5d8ddb3fb6 | ||
|
|
4d3f9752d0 | ||
|
|
0a2b398702 | ||
|
|
497a2b1695 | ||
|
|
86fe3f04c1 | ||
|
|
dd8f8a7826 | ||
|
|
f81abcb640 | ||
|
|
6aab19f72a | ||
|
|
a6b90fc9f5 | ||
|
|
1ea36d9e9d | ||
|
|
9924f9e808 | ||
|
|
b60c4d3631 | ||
|
|
0695d176ff | ||
|
|
c6045a4f6f | ||
|
|
d2405e35d1 | ||
|
|
de0109bed0 | ||
|
|
b44f164b5c | ||
|
|
1167f54bdf | ||
|
|
8584c45634 | ||
|
|
1ecde27f49 | ||
|
|
5a643c2360 | ||
|
|
357c9b27fa | ||
|
|
4df48f9850 | ||
|
|
552f342b26 | ||
|
|
34c7d170ca | ||
|
|
7ec3cf8408 | ||
|
|
a070e5f208 | ||
|
|
7d70bb51c3 |
@@ -16,4 +16,4 @@
|
||||
# use Bazel internally. The Bazel build can have security risks or
|
||||
# optimization gaps.
|
||||
|
||||
build --symlink_prefix=/ # Out of source build
|
||||
build --symlink_prefix=/ # Out of source build
|
||||
|
||||
@@ -1 +1 @@
|
||||
4.1.0
|
||||
5.0.0
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
### Description
|
||||
_Add a comprehensive description of proposed changes_
|
||||
|
||||
|
||||
Fixes # - _issue number(s) if exists_
|
||||
|
||||
- [ ] - git commit message contains an appropriate signed-off-by string _(see [CONTRIBUTING.md](https://github.com/oneapi-src/oneTBB/blob/master/CONTRIBUTING.md#pull-requests) for details)_
|
||||
|
||||
### Type of change
|
||||
|
||||
_Choose one or multiple, leave empty if none of the other choices apply_
|
||||
|
||||
_Add a respective label(s) to PR if you have permissions_
|
||||
|
||||
- [ ] bug fix - _change that fixes an issue_
|
||||
- [ ] new feature - _change that adds functionality_
|
||||
- [ ] tests - _change in tests_
|
||||
- [ ] infrastructure - _change in infrastructure and CI_
|
||||
- [ ] documentation - _documentation update_
|
||||
|
||||
### Tests
|
||||
|
||||
- [ ] added - _required for new features and some bug fixes_
|
||||
- [ ] not needed
|
||||
|
||||
### Documentation
|
||||
|
||||
- [ ] updated in # - _add PR number_
|
||||
- [ ] needs to be updated
|
||||
- [ ] not needed
|
||||
|
||||
### Breaks backward compatibility
|
||||
- [ ] Yes
|
||||
- [ ] No
|
||||
- [ ] Unknown
|
||||
|
||||
### Notify the following users
|
||||
_List users with `@` to send notifications_
|
||||
|
||||
### Other information
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Intel Corporation
|
||||
# Copyright (c) 2021-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.
|
||||
@@ -48,8 +48,9 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run scan
|
||||
run: |
|
||||
command -v clang-format-10
|
||||
cp -r examples examples_formatted
|
||||
find examples_formatted -regex '.*\.\(cpp\|hpp\)' -exec clang-format-9 -style=file -i {} \;
|
||||
find examples_formatted -regex '.*\.\(cpp\|hpp\)' -exec clang-format-10 -style=file -i {} \;
|
||||
diff -r examples examples_formatted
|
||||
|
||||
documentation:
|
||||
@@ -62,12 +63,13 @@ jobs:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install prerequisites
|
||||
run: |
|
||||
pip3 install -U Jinja2
|
||||
pip3 install git+https://github.com/executablebooks/sphinx-book-theme.git
|
||||
echo GITHUB_SHA_SHORT=${GITHUB_SHA::8} >> $GITHUB_ENV
|
||||
mkdir html
|
||||
- name: Build documentation
|
||||
run: |
|
||||
export BUILD_TYPE=${BUILD_TYPE} && sphinx-build doc/main html
|
||||
export BUILD_TYPE=${BUILD_TYPE} && sphinx-build doc html
|
||||
tar -czvf html.tar.gz html/
|
||||
- name: Save docs
|
||||
uses: actions/upload-artifact@v2.2.1
|
||||
@@ -104,6 +106,26 @@ jobs:
|
||||
git commit --reset-author --amend -m "Update from GitHub Actions"
|
||||
git push --force origin gh-pages
|
||||
|
||||
copyright_check:
|
||||
if: ${{ github.ref != 'refs/heads/master' }}
|
||||
runs-on: [ubuntu-20.04]
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Run check
|
||||
run: |
|
||||
sed -i \
|
||||
-e "/Copyright (c) .* Intel Corporation/s/ \([0-9]\+\)[-0-9]*/ \\1-$(date +%Y)/" \
|
||||
-e "/Copyright (c) .* Intel Corporation/s/$(date +%Y)-$(date +%Y)/$(date +%Y)/" \
|
||||
$(git diff --diff-filter=d --name-only ${{ github.event.pull_request.base.sha }})
|
||||
git checkout -- third-party-programs.txt
|
||||
git diff > years.diff
|
||||
if [[ -s years.diff ]]; then
|
||||
echo "Wrong copyright years"
|
||||
cat years.diff
|
||||
exit 1
|
||||
fi
|
||||
python_module_test_ubuntu18-04:
|
||||
runs-on: [ubuntu-18.04]
|
||||
timeout-minutes: 15
|
||||
@@ -188,22 +210,22 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2016
|
||||
generator: Visual Studio 15 2017
|
||||
- os: windows-2019
|
||||
generator: Visual Studio 16 2019
|
||||
c_compiler: cl
|
||||
cxx_compiler: cl
|
||||
std: 14
|
||||
build_type: relwithdebinfo
|
||||
preview: 'ON'
|
||||
job_name: windows_cl2017_cxx14_relwithdebinfo_preview=ON
|
||||
- os: windows-2019
|
||||
generator: Visual Studio 16 2019
|
||||
job_name: windows_cl2019_cxx14_relwithdebinfo_preview=ON
|
||||
- os: windows-2022
|
||||
generator: Visual Studio 17 2022
|
||||
c_compiler: cl
|
||||
cxx_compiler: cl
|
||||
std: 17
|
||||
build_type: relwithdebinfo
|
||||
preview: 'OFF'
|
||||
job_name: windows_cl2019_cxx17_relwithdebinfo_preview=OFF
|
||||
job_name: windows_cl2022_cxx17_relwithdebinfo_preview=OFF
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run testing
|
||||
@@ -288,22 +310,22 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2016
|
||||
generator: Visual Studio 15 2017
|
||||
- os: windows-2019
|
||||
generator: Visual Studio 16 2019
|
||||
c_compiler: cl
|
||||
cxx_compiler: cl
|
||||
std: 14
|
||||
build_type: relwithdebinfo
|
||||
preview: 'ON'
|
||||
job_name: examples_windows_cl2017_cxx14_relwithdebinfo_preview=ON
|
||||
- os: windows-2019
|
||||
generator: Visual Studio 16 2019
|
||||
job_name: examples_windows_cl2019_cxx14_relwithdebinfo_preview=ON
|
||||
- os: windows-2022
|
||||
generator: Visual Studio 17 2022
|
||||
c_compiler: cl
|
||||
cxx_compiler: cl
|
||||
std: 17
|
||||
build_type: relwithdebinfo
|
||||
preview: 'OFF'
|
||||
job_name: examples_windows_cl2019_cxx17_relwithdebinfo_preview=OFF
|
||||
job_name: examples_windows_cl2022_cxx17_relwithdebinfo_preview=OFF
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run testing
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2021 Intel Corporation
|
||||
# Copyright (c) 2021-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.
|
||||
@@ -35,15 +35,20 @@ cc_library(
|
||||
"include/oneapi/tbb/*.h",
|
||||
"include/oneapi/tbb/detail/*.h",
|
||||
]),
|
||||
copts = [
|
||||
"-w",
|
||||
],
|
||||
copts = ["-w"] + select({
|
||||
"@bazel_tools//platforms:windows": [""],
|
||||
"//conditions:default": ["-mwaitpkg"],
|
||||
}),
|
||||
defines =
|
||||
select({
|
||||
"@platforms//cpu:x86_64": ["__TBB_NO_IMPLICIT_LINKAGE"],
|
||||
"//conditions:default": [
|
||||
"USE_PTHREAD",
|
||||
],
|
||||
}) +
|
||||
select({
|
||||
"@bazel_tools//platforms:osx": ["_XOPEN_SOURCE"],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
includes = [
|
||||
"include",
|
||||
@@ -51,11 +56,12 @@ cc_library(
|
||||
linkopts =
|
||||
select({
|
||||
"@bazel_tools//platforms:windows": [],
|
||||
"//conditions:default": [
|
||||
"@bazel_tools//platforms:linux": [
|
||||
"-ldl",
|
||||
"-pthread",
|
||||
"-lrt",
|
||||
],
|
||||
"//conditions:default": ["-pthread"],
|
||||
}),
|
||||
local_defines = select({
|
||||
"@platforms//cpu:x86_64": [
|
||||
|
||||
@@ -1,24 +1,38 @@
|
||||
# Bazel build support
|
||||
# Bazel* build support
|
||||
|
||||
The main build system of oneTBB is CMake.
|
||||
Bazel support is community-based.
|
||||
The maintainers do not use Bazel internally.
|
||||
The Bazel configuration may not include recommended compiler and linker flags used in official CMake configuration.
|
||||
The main build system of oneTBB is CMake*.
|
||||
[Bazel*](https://bazel.build/) support is community-based.
|
||||
The Bazel configuration may not include recommended compiler and/or linker flags used in the official CMake configuration.
|
||||
|
||||
The Bazel build of oneTBB currently only aims for a subset of oneTBB that suffices restricted use cases of the usage of oneTBB.
|
||||
Pull requests to improve the Bazel build experience are welcomed.
|
||||
---
|
||||
**NOTE**
|
||||
|
||||
The standard approach of how Bazel handles third-party libraries is static linking.
|
||||
Even this is not recommended by the oneTBB maintainers this is chosen since this is considered as the best practice in the Bazel ecosystem.
|
||||
Bazel is not recommended for use by oneTBB maintainers. Thus, it is not used internally.
|
||||
|
||||
## Example usage
|
||||
---
|
||||
|
||||
1. [Install Bazel](https://docs.bazel.build/versions/main/install.html).
|
||||
|
||||
2. Create the following files in one folder (this folder will be considered as the workspace folder):
|
||||
The Bazel oneTBB build is currently only intended for a subset of oneTBB that suffices restricted use cases.
|
||||
Pull requests to improve the Bazel build experience are welcome.
|
||||
|
||||
The standard Bazel approach to handling third-party libraries is static linking. It is the best practice within the Bazel ecosystem.
|
||||
|
||||
## Using oneTBB as a dependency
|
||||
|
||||
This example demonstrates how to use oneTBB as a dependency within a Bazel project.
|
||||
|
||||
The following file structure is assumed:
|
||||
|
||||
```
|
||||
example
|
||||
├── .bazelrc
|
||||
├── BUILD.bazel
|
||||
├── main.cpp
|
||||
└── WORKSPACE.bazel
|
||||
```
|
||||
|
||||
_WORKSPACE.bazel_:
|
||||
```
|
||||
```python
|
||||
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
|
||||
|
||||
git_repository(
|
||||
@@ -28,8 +42,11 @@ git_repository(
|
||||
)
|
||||
```
|
||||
|
||||
_BUILD_:
|
||||
```
|
||||
In the *WORKSPACE* file, the oneTBB GitHub* repository is fetched.
|
||||
|
||||
_BUILD.bazel_:
|
||||
|
||||
```python
|
||||
cc_binary(
|
||||
name = "Demo",
|
||||
srcs = ["main.cpp"],
|
||||
@@ -37,8 +54,11 @@ cc_binary(
|
||||
)
|
||||
```
|
||||
|
||||
The *BUILD* file defines a binary named `Demo` that has a dependency to oneTBB.
|
||||
|
||||
_main.cpp_:
|
||||
```
|
||||
|
||||
```c++
|
||||
#include "oneapi/tbb/version.h"
|
||||
|
||||
#include <iostream>
|
||||
@@ -54,7 +74,23 @@ int main() {
|
||||
}
|
||||
```
|
||||
|
||||
3. Switch to the folder where you create the files.
|
||||
The expected output of this program is the current version of oneTBB.
|
||||
|
||||
4. Execute the command `bazel run //:Demo`.
|
||||
As an expected output, you should see the oneTBB version.
|
||||
Switch to the folder with the files created earlier and run the binary with `bazel run //:Demo`.
|
||||
|
||||
## Build oneTBB using Bazel
|
||||
|
||||
Run ```bazel build //...``` in the oneTBB root directory.
|
||||
|
||||
## Compiler support
|
||||
|
||||
The Bazel build uses the compiler flag `-mwaitpkg` in non-Windows* builds.
|
||||
This flag is supported by the GNU* Compiler Collection (GCC) version 9.3, Clang* 12, and newer versions of those tools.
|
||||
|
||||
|
||||
---
|
||||
**NOTE**
|
||||
|
||||
To use the Bazel build with earlier versions of GCC, remove `-mwaitpkg` flag as it leads to errors during compilation.
|
||||
|
||||
---
|
||||
|
||||
@@ -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.
|
||||
@@ -60,6 +60,7 @@ unset(_tbb_ver_minor)
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
include(GNUInstallDirs)
|
||||
include(CMakeDependentOption)
|
||||
|
||||
# ---------------------------------------------------------------------------------------------------------
|
||||
# Handle C++ standard version.
|
||||
@@ -98,9 +99,13 @@ option(TBB_STRICT "Treat compiler warnings as errors" ON)
|
||||
option(TBB_WINDOWS_DRIVER "Build as Universal Windows Driver (UWD)" OFF)
|
||||
option(TBB_NO_APPCONTAINER "Apply /APPCONTAINER:NO (for testing binaries for Windows Store)" OFF)
|
||||
option(TBB4PY_BUILD "Enable tbb4py build" OFF)
|
||||
option(TBB_BUILD "Enable tbb build" ON)
|
||||
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_ENABLE_IPO "Enable Interprocedural Optimization (IPO) during the compilation" ON)
|
||||
|
||||
if (NOT DEFINED BUILD_SHARED_LIBS)
|
||||
set(BUILD_SHARED_LIBS ON)
|
||||
@@ -179,6 +184,22 @@ foreach(FILE_WITH_EXTRA_TARGETS ${FILES_WITH_EXTRA_TARGETS})
|
||||
include(${FILE_WITH_EXTRA_TARGETS})
|
||||
endforeach()
|
||||
|
||||
# - Enabling LTO on Android causes the NDK bug.
|
||||
# NDK throws the warning: "argument unused during compilation: '-Wa,--noexecstack'"
|
||||
# - For some reason GCC does not instrument code with Thread Sanitizer when lto is enabled and C linker is used.
|
||||
if (TBB_ENABLE_IPO AND BUILD_SHARED_LIBS AND NOT ANDROID_PLATFORM AND NOT TBB_SANITIZE MATCHES "thread")
|
||||
if (NOT CMAKE_VERSION VERSION_LESS 3.9)
|
||||
cmake_policy(SET CMP0069 NEW)
|
||||
include(CheckIPOSupported)
|
||||
check_ipo_supported(RESULT TBB_IPO_PROPERTY)
|
||||
else()
|
||||
set(TBB_IPO_FLAGS TRUE)
|
||||
endif()
|
||||
if (TBB_IPO_PROPERTY OR TBB_IPO_FLAGS)
|
||||
message(STATUS "IPO enabled")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(TBB_COMPILER_SETTINGS_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/compilers/${CMAKE_CXX_COMPILER_ID}.cmake)
|
||||
if (EXISTS ${TBB_COMPILER_SETTINGS_FILE})
|
||||
include(${TBB_COMPILER_SETTINGS_FILE})
|
||||
@@ -192,11 +213,17 @@ if (TBB_FIND_PACKAGE OR TBB_DIR)
|
||||
message(STATUS "Using external TBB for testing")
|
||||
find_package(TBB REQUIRED)
|
||||
else()
|
||||
add_subdirectory(src/tbb)
|
||||
if (TBB_BUILD)
|
||||
add_subdirectory(src/tbb)
|
||||
endif()
|
||||
if (NOT "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "mips")
|
||||
add_subdirectory(src/tbbmalloc)
|
||||
add_subdirectory(src/tbbmalloc_proxy)
|
||||
if (APPLE)
|
||||
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)
|
||||
@@ -251,7 +278,7 @@ if (TBB_BENCH)
|
||||
endif()
|
||||
|
||||
if (ANDROID_PLATFORM)
|
||||
if (${ANDROID_STL} STREQUAL "c++_shared")
|
||||
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"
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
<!--
|
||||
******************************************************************************
|
||||
*
|
||||
* 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.
|
||||
*******************************************************************************/-->
|
||||
|
||||
# How to Contribute
|
||||
As an open source project, we welcome community contributions to oneAPI Threading Building Blocks (oneTBB). This document explains how to participate in project conversations, log bugs and enhancement requests, and submit code patches to the project.
|
||||
|
||||
## Licensing
|
||||
|
||||
Licensing is very important to open source projects. It helps ensure the software continues to be available under the terms that the author desired. The oneTBB project uses the [Apache 2.0 License](https://github.com/oneapi-src/oneTBB/blob/master/LICENSE.txt), a permissive open source license that allows you to freely use, modify, and distribute your own products that include Apache 2.0 licensed software. By contributing to the oneTBB project, you agree to the license and copyright terms therein and release your own contributions under these terms.
|
||||
|
||||
Some imported or reused components within oneTBB use other licenses, as described in [third-party-programs.txt](https://github.com/oneapi-src/oneTBB/blob/master/third-party-programs.txt). By carefully reviewing potential contributions and enforcing a [Developer Certification of Origin (DCO)](https://developercertificate.org/) for contributed code, we can ensure that the community can develop products with oneTBB without concerns over patent or copyright issues.
|
||||
|
||||
The DCO is an attestation attached to every contribution made by every developer. In the commit message of the contribution, (described later), the developer simply adds a Signed-off-by statement and thereby agrees to the DCO.
|
||||
|
||||
## Prerequisites
|
||||
|
||||
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.
|
||||
|
||||
No anonymous contributions are accepted. The name in the commit message Signed-off-by line and your email must match the change authorship information. Make sure your .gitconfig is set up correctly so you can use `git commit -s` for signing your patches:
|
||||
|
||||
`git config --global user.name "Taylor Developer"`
|
||||
|
||||
`git config --global user.email taylor.developer@company.com`
|
||||
|
||||
### Before contributing changes directly to the oneTBB repository
|
||||
|
||||
* Make sure you can build the product and run all the tests with your patch.
|
||||
* For a larger feature, provide a relevant test.
|
||||
* Document your code. The oneTBB project uses reStructuredText for documentation.
|
||||
* Update the copyright year in the first line of the changing file(s).
|
||||
For example, if you commit your changes in 2022:
|
||||
* the copyright year should be `2005-2022` for existing files
|
||||
* the copyright year should be `2022` for new files
|
||||
* Submit a pull request into the master branch. You can submit changes with a pull request (preferred) or by sending an email patch.
|
||||
|
||||
Continuous Integration (CI) testing is enabled for the repository. Your pull request must pass all checks before it can be merged. We will review your contribution and may provide feedback to guide you if any additional fixes or modifications are necessary. When reviewed and accepted, your pull request will be merged into our GitHub repository.
|
||||
@@ -0,0 +1,122 @@
|
||||
# Installation from Sources
|
||||
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Make sure you have installed CMake version 3.1 (or newer) on your system. oneTBB uses CMake build configuration.
|
||||
- Configure and build oneTBB. To work with build configurations, see [Build System Description](cmake/README.md).
|
||||
|
||||
|
||||
## Configure oneTBB
|
||||
|
||||
At the command prompt, type:
|
||||
```
|
||||
cmake <options> <repo_root>
|
||||
```
|
||||
|
||||
You may want to use some additional options for configuration:
|
||||
|
||||
| Option | Purpose | Description |
|
||||
| ------ |------ | ------ |
|
||||
| `-G <generator>` | Specify project generator | For more information, run cmake `–help`. |
|
||||
|`-DCMAKE_BUILD_TYPE=Debug` | Specify for Debug build | Not applicable for multi-configuration generators such as Visual Studio generator. |
|
||||
|
||||
|
||||
## Build oneTBB
|
||||
|
||||
To build the system, run:
|
||||
```
|
||||
cmake --build . <options>
|
||||
```
|
||||
|
||||
Some useful build options:
|
||||
- `--target <target>` - specific target, "all" is default.
|
||||
- `--config <Release|Debug>` - build configuration, applicable only for multi-config generators such as Visual Studio generator.
|
||||
|
||||
|
||||
## Install and Pack oneTBB
|
||||
|
||||
---
|
||||
**NOTE**
|
||||
|
||||
Be careful about installing prefix. It defaults to `/usr/local` on UNIX* and `c:/Program Files/${PROJECT_NAME}` on Windows* OS.
|
||||
You can define custom `CMAKE_INSTALL_PREFIX` during configuration:
|
||||
|
||||
```
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/my/install/prefix ..
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
Installation can also be done using:
|
||||
|
||||
```
|
||||
cmake --install <project-binary-dir>
|
||||
```
|
||||
|
||||
Special ``--install`` target can alternatively be used for installation, e.g. ``make install``.
|
||||
|
||||
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).
|
||||
|
||||
If you want to install specific components after configuration and build, run:
|
||||
|
||||
```bash
|
||||
cmake -DCOMPONENT=<component> [-DBUILD_TYPE=<build-type>] -P cmake_install.cmake
|
||||
```
|
||||
|
||||
Simple packaging using CPack is supported.
|
||||
The following commands allow you to create a simple portable package that includes header files, libraries, and integration files for CMake:
|
||||
|
||||
```bash
|
||||
cmake <options> ..
|
||||
cpack
|
||||
```
|
||||
|
||||
## Example of Installation
|
||||
|
||||
### Single-configuration generators
|
||||
|
||||
The following example demonstrates how to install oneTBB for single-configuration generators (e.g. GNU Make, Ninja, etc.).
|
||||
```bash
|
||||
# Do our experiments in /tmp
|
||||
cd /tmp
|
||||
# Clone oneTBB repository
|
||||
git clone https://github.com/oneapi-src/oneTBB.git
|
||||
cd oneTBB
|
||||
# Create binary directory for out-of-source build
|
||||
mkdir build && cd build
|
||||
# Configure: customize CMAKE_INSTALL_PREFIX and disable TBB_TEST to avoid tests build
|
||||
cmake -DCMAKE_INSTALL_PREFIX=/tmp/my_installed_onetbb -DTBB_TEST=OFF ..
|
||||
# Build
|
||||
cmake --build .
|
||||
# Install
|
||||
cmake --install .
|
||||
# Well done! Your installed oneTBB is in /tmp/my_installed_onetbb
|
||||
```
|
||||
|
||||
### Multi-configuration generators
|
||||
|
||||
The following example demonstrates how to install oneTBB for multi-configuration generators such as Visual Studio*.
|
||||
|
||||
Choose the configuration during the build and install steps:
|
||||
```batch
|
||||
REM Do our experiments in %TMP%
|
||||
cd %TMP%
|
||||
REM Clone oneTBB repository
|
||||
git clone https://github.com/oneapi-src/oneTBB.git
|
||||
cd oneTBB
|
||||
REM Create binary directory for out-of-source build
|
||||
mkdir build && cd build
|
||||
REM Configure: customize CMAKE_INSTALL_PREFIX and disable TBB_TEST to avoid tests build
|
||||
cmake -DCMAKE_INSTALL_PREFIX=%TMP%\my_installed_onetbb -DTBB_TEST=OFF ..
|
||||
REM Build "release with debug information" configuration
|
||||
cmake --build . --config relwithdebinfo
|
||||
REM Install "release with debug information" configuration
|
||||
cmake --install . --config relwithdebinfo
|
||||
REM Well done! Your installed oneTBB is in %TMP%\my_installed_onetbb
|
||||
```
|
||||
@@ -1,52 +1,54 @@
|
||||
# oneAPI Threading Building Blocks
|
||||
[](LICENSE.txt) [](https://github.com/oneapi-src/oneTBB/actions/workflows/ci.yml?query=branch%3Amaster)
|
||||
|
||||
oneAPI Threading Building Blocks (oneTBB) lets you easily write parallel C++ programs that take
|
||||
full advantage of multicore performance, that are portable, composable and have future-proof scalability.
|
||||
oneTBB is a flexible C++ library that simplifies the work of adding parallelism
|
||||
to complex applications, even if you are not a threading expert.
|
||||
|
||||
The library lets you easily write parallel programs that take full advantage of the multi-core performance. Such programs are portable,
|
||||
composable and have a future-proof scalability. oneTBB provides you with functions, interfaces, and classes to parallelize and scale the code.
|
||||
All you have to do is to use the templates.
|
||||
|
||||
The library differs from typical threading packages in the following ways:
|
||||
* oneTBB enables you to specify logical parallelism instead of threads.
|
||||
* oneTBB targets threading for performance.
|
||||
* oneTBB is compatible with other threading packages.
|
||||
* oneTBB emphasizes scalable, data parallel programming.
|
||||
* oneTBB relies on generic programming.
|
||||
|
||||
|
||||
Refer to oneTBB [examples](examples) and [samples](https://github.com/oneapi-src/oneAPI-samples/tree/master/Libraries/oneTBB) to see how you can use the library.
|
||||
|
||||
oneTBB is a part of [oneAPI](https://oneapi.io). The current branch implements version 1.1 of oneAPI Specification.
|
||||
|
||||
## Release Information
|
||||
Here are [Release Notes]( https://software.intel.com/en-us/articles/intel-oneapi-threading-building-blocks-release-notes) and
|
||||
[System Requirements](https://software.intel.com/en-us/articles/intel-oneapi-threading-building-blocks-system-requirements).
|
||||
Here are [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://software.intel.com/en-us/oneapi-tbb-documentation)
|
||||
* [Migrating from TBB to oneTBB](https://software.intel.com/content/www/us/en/develop/documentation/onetbb-documentation/top/onetbb-developer-guide/migrating-from-threading-building-blocks-tbb.html)
|
||||
* README for build system: [cmake/README.md](cmake/README.md)
|
||||
* [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)
|
||||
|
||||
## 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) or start a topic on the
|
||||
[oneTBB forum](https://community.intel.com/t5/Intel-oneAPI-Threading-Building/bd-p/oneapi-threading-building-blocks).
|
||||
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.
|
||||
|
||||
## How to Contribute
|
||||
To contribute to oneTBB, please open a GitHub pull request (preferred) or send us a patch by e-mail.
|
||||
|
||||
Please use the sign-off line at the end of the patch.
|
||||
Your signature certifies that you wrote the patch or
|
||||
otherwise have the right to pass it on as an open-source patch.
|
||||
The rules are pretty simple:
|
||||
if you can certify the https://developercertificate.org then you just add a line to every git commit message:
|
||||
```
|
||||
Signed-off-by: Name Surname <user@email.com>
|
||||
```
|
||||
Use your real name (sorry, no pseudonyms or anonymous contributions).
|
||||
|
||||
If you set your `user.name` and `user.email` git configs, you can sign your
|
||||
commit automatically with `git commit -s`.
|
||||
We welcome community contributions, so check our [Contributing Guidelines](CONTRIBUTING.md)
|
||||
to learn more.
|
||||
|
||||
## License
|
||||
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.
|
||||
|
||||
## Security
|
||||
To report security issues please go to https://intel.com/security.
|
||||
|
||||
## Engineering team contacts
|
||||
* [E-mail us.](mailto:inteltbbdevelopers@intel.com)
|
||||
* [Email us.](mailto:inteltbbdevelopers@intel.com)
|
||||
|
||||
------------------------------------------------------------------------
|
||||
Intel and the Intel logo are trademarks of Intel Corporation or its subsidiaries in the U.S. and/or other countries.
|
||||
|
||||
\* Other names and brands may be claimed as the property of others.
|
||||
\* All names and brands may be claimed as the property of others.
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<!--
|
||||
******************************************************************************
|
||||
*
|
||||
* 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.
|
||||
*******************************************************************************/-->
|
||||
|
||||
# Release Notes <!-- omit in toc -->
|
||||
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.
|
||||
- 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.
|
||||
- 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).
|
||||
|
||||
## :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).
|
||||
@@ -0,0 +1,65 @@
|
||||
<!--
|
||||
******************************************************************************
|
||||
*
|
||||
* 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.
|
||||
*******************************************************************************/-->
|
||||
|
||||
# System Requirements <!-- omit in toc -->
|
||||
This document provides details about hardware, operating system, and software prerequisites for the oneAPI Threading Building Blocks (oneTBB).
|
||||
|
||||
## Table of Contents <!-- omit in toc -->
|
||||
- [Supported Hardware](#supported-hardware)
|
||||
- [Software](#software)
|
||||
- [Supported Operating Systems](#supported-operating-systems)
|
||||
- [Supported Compilers](#supported-compilers)
|
||||
|
||||
|
||||
## 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
|
||||
|
||||
|
||||
## Software
|
||||
|
||||
### Supported Operating Systems
|
||||
- Systems with Microsoft* Windows* operating systems
|
||||
- Microsoft* Windows* 10
|
||||
- Microsoft* Windows* Server 2016
|
||||
- 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
|
||||
- SuSE* Linux* Enterprise Server 15
|
||||
- Ubuntu* 18.04 LTS, 20.04, 21.04
|
||||
- Systems with macOS* operating systems
|
||||
- macOS* 10.15, 11.x
|
||||
- Systems with Android* operating systems
|
||||
- Android* 9
|
||||
|
||||
### 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)
|
||||
- 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
|
||||
@@ -16,4 +16,4 @@
|
||||
# use Bazel internally. The Bazel build can have security risks or
|
||||
# optimization gaps.
|
||||
|
||||
workspace(name = "oneTBB")
|
||||
workspace(name = "oneTBB")
|
||||
|
||||
@@ -9,22 +9,22 @@ 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_ARGS:STRING - Additional arguments for TBB_SIGNTOOL, used if TBB_SIGNTOOL is set.
|
||||
TBB4PY_BUILD:BOOL - Enable Intel(R) oneAPI Threading Building Blocks (oneTBB) Python module build (OFF by default)
|
||||
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_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
|
||||
|
||||
### Prerequisites
|
||||
|
||||
* CMake >= 3.1
|
||||
## Configure, build, and test
|
||||
|
||||
### Preparation
|
||||
|
||||
In order to perform out-of-source build you have to create a build directory and go there:
|
||||
To perform out-of-source build, create a build directory and go there:
|
||||
|
||||
```bash
|
||||
mkdir /tmp/my-build
|
||||
@@ -38,27 +38,46 @@ 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 isn't applicable for multi-config generators, e.g. for Visual Studio generator).
|
||||
- `-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.
|
||||
|
||||
#### 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.
|
||||
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
|
||||
|
||||
The search for a suitable version of the HWLOC library is enabled by default, but if you want to use a specific version of the library, you can specify the path to it manually using the following CMake variables:
|
||||
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:
|
||||
|
||||
- `CMAKE_HWLOC_<HWLOC_VER>_LIBRARY_PATH` - path to the corresponding HWLOC version shared library on Linux or path to `.lib` file on Windows.
|
||||
- `CMAKE_HWLOC_<HWLOC_VER>_INCLUDE_PATH` - path to the corresponding HWLOC version includes directory.
|
||||
- `CMAKE_HWLOC_<HWLOC_VER>_LIBRARY_PATH` - path to the corresponding HWLOC version shared library on Linux* OS or path to `.lib` file on Windows* OS
|
||||
- `CMAKE_HWLOC_<HWLOC_VER>_INCLUDE_PATH` - path to the corresponding HWLOC version including directory
|
||||
|
||||
Windows requires one additional variable for correct TBBBind library building:
|
||||
|
||||
---
|
||||
**NOTE:** Automatic HWLOC searching requires CMake version 3.6 or higher.
|
||||
|
||||
---
|
||||
|
||||
|
||||
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 above can be replaced with one of the three values: `1_11` for the `tbbbind` library configuration, `2` for the `tbbbind_2_0`, and `2_5` for the `tbbbind_2_5` library configuration.
|
||||
`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, then building process for all of these versions will be performed during single build session.
|
||||
If you specify variables for several TBBBind versions, the building process for all of these versions is performed during single build session.
|
||||
|
||||
---
|
||||
**TIP**
|
||||
|
||||
Specify the `TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH` to disable HWLOC libraries automatic search.
|
||||
|
||||
---
|
||||
|
||||
|
||||
### Build
|
||||
|
||||
```bash
|
||||
@@ -67,20 +86,27 @@ cmake --build . <options>
|
||||
|
||||
Some useful options:
|
||||
- `--target <target>` - specific target, "all" is default.
|
||||
- `--config <Release|Debug>` - build configuration, applicable only for multi-config generators, e.g. Visual Studio generator.
|
||||
- `--config <Release|Debug>` - build configuration, applicable only for multiconfig generators, e.g. Visual Studio* generator.
|
||||
|
||||
Binaries are placed to `./<compiler-id>_<compiler-ver>_cxx<stdver>_<build-type>` (for example, `./gnu_4.8_cxx11_release`)
|
||||
The binaries are placed to `./<compiler-id>_<compiler-ver>_cxx<stdver>_<build-type>`. For example, `./gnu_4.8_cxx11_release`.
|
||||
|
||||
#### Build for 32-bit
|
||||
|
||||
* Intel Compiler: just 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.
|
||||
* GCC/Clang: specify `-m32` during the configuration: `CXXFLAGS=-m32 cmake ..` or `cmake -DCMAKE_CXX_FLAGS=-m32 ..`
|
||||
* Any other compiler which builds for 64-bit by default: specify 32-bit compiler key during the configuration as above.
|
||||
* **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.
|
||||
* **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.
|
||||
|
||||
#### Windows specific builds (CMake 3.15 or newer is required)
|
||||
#### Windows* OS specific builds
|
||||
|
||||
* Dynamic linkage with CRT: default behavior, can be explicitly specified by setting `CMAKE_MSVC_RUNTIME_LIBRARY` to `MultiThreadedDLL` or `MultiThreadedDebugDLL`.
|
||||
---
|
||||
**NOTE**
|
||||
|
||||
Following builds require CMake version 3.15 or higher.
|
||||
|
||||
---
|
||||
|
||||
* **Dynamic linkage with C Runtime Library (CRT)**. The default behavior can be explicitly specified by setting `CMAKE_MSVC_RUNTIME_LIBRARY` to `MultiThreadedDLL` or `MultiThreadedDebugDLL`.
|
||||
```bash
|
||||
cmake .. # dynamic linkage is used by default
|
||||
```
|
||||
@@ -90,20 +116,27 @@ cmake -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDLL ..
|
||||
```bash
|
||||
cmake -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebugDLL -DCMAKE_BUILD_TYPE=Debug ..
|
||||
```
|
||||
* Static linkage with CRT: set `CMAKE_MSVC_RUNTIME_LIBRARY` to `MultiThreaded` or `MultiThreadedDebug`.
|
||||
* **Static linkage with CRT**. Set `CMAKE_MSVC_RUNTIME_LIBRARY` to `MultiThreaded` or `MultiThreadedDebug`.
|
||||
```bash
|
||||
cmake -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ..
|
||||
```
|
||||
```bash
|
||||
cmake -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreadedDebug -DCMAKE_BUILD_TYPE=Debug ..
|
||||
```
|
||||
* Windows 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).
|
||||
|
||||
---
|
||||
|
||||
_Note: set `TBB_NO_APPCONTAINER` to `ON` in order to apply `/APPCONTAINER:NO` option during the compilation (used for testing)._
|
||||
```bash
|
||||
cmake -DCMAKE_SYSTEM_NAME:STRING=WindowsStore -DCMAKE_SYSTEM_VERSION:STRING=10.0 ..
|
||||
```
|
||||
* Universal Windows Driver build: set `TBB_WINDOWS_DRIVER` to `ON` and use static linkage with CRT (see above).
|
||||
|
||||
* **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 ..
|
||||
@@ -112,29 +145,32 @@ cmake -DTBB_WINDOWS_DRIVER=ON -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded ..
|
||||
### Test
|
||||
|
||||
#### Build test
|
||||
Using default ('all') target:
|
||||
To build a test, use the default target 'all':
|
||||
```
|
||||
cmake --build .
|
||||
```
|
||||
|
||||
or using specific test target:
|
||||
Or use a specific test target:
|
||||
```
|
||||
cmake --build . --target <test> # e.g. test_version
|
||||
```
|
||||
|
||||
#### Run test
|
||||
|
||||
Using CTest:
|
||||
You can run a test by using CTest:
|
||||
```bash
|
||||
ctest
|
||||
```
|
||||
|
||||
or using 'test' target:
|
||||
Or by using 'test' target:
|
||||
```bash
|
||||
cmake --build . --target test # currently doesn't work on Windows
|
||||
cmake --build . --target test # currently does not work on Windows* OS
|
||||
```
|
||||
|
||||
## Sanitizers - сonfigure, build and run
|
||||
## Installation
|
||||
See [Installation from Sources](../INSTALL.md) to learn how to install oneTBB.
|
||||
|
||||
## Sanitizers - сonfigure, build, and run
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
@@ -144,7 +180,7 @@ make -j
|
||||
ctest -V
|
||||
```
|
||||
|
||||
## Valgrind memcheck - configure, build and run
|
||||
## Valgrind memcheck - configure, build, and run
|
||||
|
||||
### Prerequisites
|
||||
* Valgrind tool executable
|
||||
@@ -156,7 +192,9 @@ cmake -DTBB_VALGRIND_MEMCHECK=ON ..
|
||||
make -j memcheck-<test name> # or memcheck-all to scan all tests
|
||||
```
|
||||
|
||||
## Test specification (Doxygen)
|
||||
## Test specification
|
||||
|
||||
Use Doxygen to generate oneTBB test specification:
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
@@ -165,29 +203,6 @@ cmake -DTBB_TEST_SPEC=ON ..
|
||||
make test_spec
|
||||
```
|
||||
|
||||
## Intallation and packaging
|
||||
|
||||
**NOTE: be careful about installation: avoid commands like `make install` unless you fully understand the consequences.**
|
||||
|
||||
The following install components are supported:
|
||||
- `runtime` - oneTBB runtime package (core shared libraries and `.dll` files on Windows).
|
||||
- `devel` - oneTBB development package (header files, CMake integration files, library symbolic links and `.lib` files on Windows).
|
||||
- `tbb4py` - [oneTBB Module for Python](#onetbb-python-module-support).
|
||||
|
||||
How to install specific components after configuration and build:
|
||||
|
||||
```bash
|
||||
cmake -DCOMPONENT=<component> [-DBUILD_TYPE=<build-type>] -P cmake_install.cmake
|
||||
```
|
||||
|
||||
Simple packaging using CPack is supported.
|
||||
The following commands allow to create a simple portable package which includes header files, libraries and integration files for CMake:
|
||||
|
||||
```bash
|
||||
cmake <options> ..
|
||||
cpack
|
||||
```
|
||||
|
||||
## 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.
|
||||
|
||||
@@ -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.
|
||||
@@ -31,10 +31,16 @@ if (NOT TBB_STRICT AND COMMAND tbb_remove_compile_flag)
|
||||
tbb_remove_compile_flag(-Werror)
|
||||
endif()
|
||||
|
||||
# Enable Intel(R) Transactional Synchronization Extensions (-mrtm) on relevant processors
|
||||
if (NOT "${CMAKE_OSX_ARCHITECTURES}" MATCHES "^arm64$" AND CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64|AMD64)") # OSX systems are 64-bit only
|
||||
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -mrtm)
|
||||
# Enable Intel(R) Transactional Synchronization Extensions (-mrtm) and WAITPKG instructions support (-mwaitpkg) on relevant processors
|
||||
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)
|
||||
|
||||
@@ -44,7 +44,7 @@ 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 "(x86|AMD64)")
|
||||
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(AMD64|amd64|i.86|x86)")
|
||||
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -mrtm $<$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},12.0>>:-mwaitpkg>)
|
||||
endif()
|
||||
|
||||
@@ -58,12 +58,8 @@ if (MINGW)
|
||||
list(APPEND TBB_COMMON_COMPILE_FLAGS -U__STRICT_ANSI__)
|
||||
endif()
|
||||
|
||||
# Enabling LTO on Android causes the NDK bug.
|
||||
# NDK throws the warning: "argument unused during compilation: '-Wa,--noexecstack'"
|
||||
if (NOT ANDROID_PLATFORM AND BUILD_SHARED_LIBS)
|
||||
set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>)
|
||||
set(TBB_IPO_LINK_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>)
|
||||
endif()
|
||||
set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>)
|
||||
set(TBB_IPO_LINK_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>)
|
||||
|
||||
# TBB malloc settings
|
||||
set(TBBMALLOC_LIB_COMPILE_FLAGS -fno-rtti -fno-exceptions)
|
||||
|
||||
@@ -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.
|
||||
@@ -36,7 +36,7 @@ if (NOT CMAKE_GENERATOR MATCHES "Ninja" AND NOT CMAKE_CXX_DEPENDS_USE_COMPILER)
|
||||
endif()
|
||||
|
||||
# Enable Intel(R) Transactional Synchronization Extensions (-mrtm) and WAITPKG instructions support (-mwaitpkg) on relevant processors
|
||||
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86|AMD64)")
|
||||
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()
|
||||
|
||||
@@ -56,18 +56,17 @@ endif()
|
||||
|
||||
# Workaround for heavy tests and too many symbols in debug (rellocation truncated to fit: R_MIPS_CALL16)
|
||||
if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "mips")
|
||||
set(TBB_TEST_COMPILE_FLAGS ${TBB_TEST_COMPILE_FLAGS} -DTBB_TEST_LOW_WORKLOAD $<$<CONFIG:DEBUG>:-mxgot>)
|
||||
set(TBB_TEST_COMPILE_FLAGS ${TBB_TEST_COMPILE_FLAGS} -DTBB_TEST_LOW_WORKLOAD $<$<CONFIG:DEBUG>:-fPIE -mxgot>)
|
||||
set(TBB_TEST_LINK_FLAGS ${TBB_TEST_LINK_FLAGS} $<$<CONFIG:DEBUG>:-pie>)
|
||||
endif()
|
||||
|
||||
if (MINGW)
|
||||
list(APPEND TBB_COMMON_COMPILE_FLAGS -U__STRICT_ANSI__)
|
||||
endif()
|
||||
set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>)
|
||||
set(TBB_IPO_LINK_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>)
|
||||
|
||||
# For some reason GCC does not instrument code with Thread Sanitizer when lto is enabled and C linker is used.
|
||||
if (NOT TBB_SANITIZE MATCHES "thread")
|
||||
set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>)
|
||||
set(TBB_IPO_LINK_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>)
|
||||
endif()
|
||||
|
||||
if (MINGW AND CMAKE_SYSTEM_PROCESSOR MATCHES "i.86")
|
||||
list (APPEND TBB_COMMON_COMPILE_FLAGS -msse2)
|
||||
endif ()
|
||||
|
||||
# TBB malloc settings
|
||||
set(TBBMALLOC_LIB_COMPILE_FLAGS -fno-rtti -fno-exceptions)
|
||||
|
||||
@@ -19,10 +19,12 @@ set(TBB_DEF_FILE_PREFIX win${TBB_ARCH})
|
||||
# TODO: consider use of CMP0092 CMake policy.
|
||||
string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
# Warning suppression C4324: structure was padded due to alignment specifier
|
||||
set(TBB_WARNING_LEVEL $<$<NOT:$<CXX_COMPILER_ID:Intel>>:/W4> $<$<BOOL:${TBB_STRICT}>:/WX>)
|
||||
|
||||
# Warning suppression C4324: structure was padded due to alignment specifier
|
||||
set(TBB_WARNING_SUPPRESS /wd4324)
|
||||
set(TBB_TEST_COMPILE_FLAGS /bigobj)
|
||||
|
||||
set(TBB_TEST_COMPILE_FLAGS ${TBB_TEST_COMPILE_FLAGS} /bigobj)
|
||||
if (MSVC_VERSION LESS_EQUAL 1900)
|
||||
# Warning suppression C4503 for VS2015 and earlier:
|
||||
# decorated name length exceeded, name was truncated.
|
||||
@@ -31,7 +33,7 @@ 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)
|
||||
set(TBB_COMMON_COMPILE_FLAGS /volatile:iso /FS /EHsc)
|
||||
|
||||
# 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)
|
||||
@@ -69,14 +71,16 @@ if (TBB_WINDOWS_DRIVER)
|
||||
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} /D _UNICODE /DUNICODE /DWINAPI_FAMILY=WINAPI_FAMILY_APP /D__WRL_NO_DEFAULT_LIB__)
|
||||
endif()
|
||||
|
||||
set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:/GL>)
|
||||
set(TBB_IPO_LINK_FLAGS $<$<NOT:$<CONFIG:Debug>>:-LTCG> $<$<NOT:$<CONFIG:Debug>>:-INCREMENTAL:NO>)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "(Clang|IntelLLVM)")
|
||||
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86|AMD64)")
|
||||
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86|AMD64|i.86)")
|
||||
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -mrtm -mwaitpkg)
|
||||
endif()
|
||||
set(TBB_OPENMP_NO_LINK_FLAG TRUE)
|
||||
set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>)
|
||||
set(TBB_IPO_LINK_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>)
|
||||
else()
|
||||
set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:/GL>)
|
||||
set(TBB_IPO_LINK_FLAGS $<$<NOT:$<CONFIG:Debug>>:-LTCG> $<$<NOT:$<CONFIG:Debug>>:-INCREMENTAL:NO>)
|
||||
endif()
|
||||
|
||||
set(TBB_OPENMP_FLAG /openmp)
|
||||
set(TBB_OPENMP_NO_LINK_FLAG TRUE) # TBB_OPENMP_FLAG will be used only on compilation but not on linkage
|
||||
|
||||
@@ -51,9 +51,9 @@ if (NOT HWLOC_TARGET_EXPLICITLY_DEFINED AND
|
||||
NOT TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH
|
||||
)
|
||||
find_package(PkgConfig QUIET)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_search_module(HWLOC hwloc)
|
||||
if (HWLOC_FOUND)
|
||||
if (PKG_CONFIG_FOUND AND NOT CMAKE_VERSION VERSION_LESS 3.6)
|
||||
pkg_search_module(HWLOC hwloc IMPORTED_TARGET)
|
||||
if (TARGET PkgConfig::HWLOC)
|
||||
if (HWLOC_VERSION VERSION_LESS 2)
|
||||
set(TBBBIND_LIBRARY_NAME tbbbind)
|
||||
elseif(HWLOC_VERSION VERSION_LESS 2.5)
|
||||
@@ -64,4 +64,3 @@ if (NOT HWLOC_TARGET_EXPLICITLY_DEFINED AND
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
|
||||
# Add code signing as post-install step.
|
||||
if (DEFINED TBB_SIGNTOOL)
|
||||
file(TO_CMAKE_PATH "${TBB_SIGNTOOL}" TBB_SIGNTOOL)
|
||||
install(CODE "
|
||||
file(GLOB_RECURSE FILES_TO_SIGN \${CMAKE_INSTALL_PREFIX}/*${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
execute_process(COMMAND ${TBB_SIGNTOOL} \${FILES_TO_SIGN} ${TBB_SIGNTOOL_ARGS})
|
||||
|
||||
@@ -34,7 +34,9 @@ if (NOT ${FLAG_DISPLAY_NAME})
|
||||
"please try another compiler or omit TBB_SANITIZE variable")
|
||||
endif()
|
||||
|
||||
set(TBB_TESTS_ENVIRONMENT ${TBB_TESTS_ENVIRONMENT} "LSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/cmake/suppressions/lsan.suppressions")
|
||||
set(TBB_TESTS_ENVIRONMENT ${TBB_TESTS_ENVIRONMENT}
|
||||
"TSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/cmake/suppressions/tsan.suppressions"
|
||||
"LSAN_OPTIONS=suppressions=${CMAKE_CURRENT_SOURCE_DIR}/cmake/suppressions/lsan.suppressions")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TBB_SANITIZE_OPTION}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${TBB_SANITIZE_OPTION}")
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
# TSAN suppression for known issues.
|
||||
# Possible data race during ittnotify initialization. Low impact.
|
||||
race:__itt_nullify_all_pointers
|
||||
@@ -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.
|
||||
@@ -18,7 +18,7 @@ macro(tbb_remove_compile_flag flag)
|
||||
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_OPTIONS ${_tbb_compile_options})
|
||||
unset(_tbb_compile_options)
|
||||
if (CMAKE_CXX_FLAGS)
|
||||
string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
string(REGEX REPLACE "(^|[ \t\r\n]+)${flag}($|[ \t\r\n]+)" " " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
@@ -44,3 +44,16 @@ macro(tbb_install_target target)
|
||||
COMPONENT devel)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(tbb_handle_ipo target)
|
||||
if (TBB_IPO_PROPERTY)
|
||||
set_target_properties(${target} PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||
elseif (TBB_IPO_FLAGS)
|
||||
target_compile_options(${target} PRIVATE ${TBB_IPO_COMPILE_FLAGS})
|
||||
if (COMMAND target_link_options)
|
||||
target_link_options(${target} PRIVATE ${TBB_IPO_LINK_FLAGS})
|
||||
else()
|
||||
target_link_libraries(${target} PRIVATE ${TBB_IPO_LINK_FLAGS})
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
|
After Width: | Height: | Size: 52 KiB |
@@ -0,0 +1,48 @@
|
||||
.. _Before_You_Begin:
|
||||
|
||||
Before You Begin
|
||||
****************
|
||||
|
||||
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;
|
||||
}
|
||||
);
|
||||
@@ -1,262 +0,0 @@
|
||||
# -*- 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 -----------------------------------------------------
|
||||
|
||||
|
||||
project = u'Intel® 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'
|
||||
|
||||
|
||||
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
|
||||
"""
|
||||
|
||||
|
||||
# -- 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.
|
||||
#
|
||||
html_theme = 'sphinx_book_theme'
|
||||
|
||||
# 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']
|
||||
|
||||
|
||||
|
||||
# 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
|
||||
@@ -0,0 +1,45 @@
|
||||
.. _examples:
|
||||
|
||||
oneTBB Samples
|
||||
==============
|
||||
|
||||
Refer to the following examples to see how |short_name| works.
|
||||
|
||||
* **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>`_
|
||||
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
.. _Get_Started_Guide:
|
||||
|
||||
Get Started with |short_name|
|
||||
==============================
|
||||
|
||||
.. include:: intro_gsg.rst
|
||||
|
||||
.. include:: system_requirements.rst
|
||||
|
||||
.. include:: before_beginning_and_example.rst
|
||||
|
||||
Find more
|
||||
*********
|
||||
|
||||
See our `documentation <https://oneapi-src.github.io/oneTBB/>`_ to learn more about |short_name|.
|
||||
@@ -1,97 +0,0 @@
|
||||
.. _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
|
||||
|
||||
Before You Begin
|
||||
****************
|
||||
|
||||
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``
|
||||
|
||||
|
||||
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>`_.
|
||||
|
||||
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.
|
||||
@@ -0,0 +1,7 @@
|
||||
.. _installation:
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
See the `installation instructions <https://github.com/oneapi-src/oneTBB/blob/master/INSTALL.md>`_
|
||||
that will help you to install |short_name| successfully.
|
||||
@@ -0,0 +1,23 @@
|
||||
.. _Intro_gsg:
|
||||
|
||||
|
||||
|full_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.
|
||||
|
||||
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.
|
||||
|
||||
Here you can see one of the possible executions of tasks by threads.
|
||||
|
||||
.. figure:: /GSG/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 being worried about oversubscribing a system.
|
||||
@@ -0,0 +1,6 @@
|
||||
.. _System_Requirements:
|
||||
|
||||
System Requirements
|
||||
*******************
|
||||
|
||||
Refer to the `oneTBB System Requirements <https://github.com/oneapi-src/oneTBB/blob/master/SYSTEM_REQUIREMENTS.md>`_.
|
||||
@@ -0,0 +1,36 @@
|
||||
#===============================================================================
|
||||
# Copyright (C) 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.
|
||||
# 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.
|
||||
#===============================================================================
|
||||
|
||||
# Minimal makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line, and also
|
||||
# from the environment for the first two.
|
||||
SPHINXOPTS ?=
|
||||
SPHINXBUILD ?= sphinx-build
|
||||
SOURCEDIR = doc
|
||||
BUILDDIR = build
|
||||
|
||||
# Put it first so that "make" without argument is like "make help".
|
||||
help:
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
.PHONY: help Makefile
|
||||
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
@@ -0,0 +1,34 @@
|
||||
# How to build oneTBB documentation
|
||||
|
||||
Our documentation is written in restructured text markup (.rst) and built using [Sphinx](http://www.sphinx-doc.org/en/master/).
|
||||
|
||||
This document explains how to build oneTBB documentation locally.
|
||||
|
||||
## Prerequisites
|
||||
- Python 3.7.0 or higher
|
||||
- Sphinx
|
||||
|
||||
## Build documentation
|
||||
|
||||
Do the following to generate HTML output of the documentation:
|
||||
|
||||
1. Clone oneTBB repository:
|
||||
|
||||
```
|
||||
git clone https://github.com/oneapi-src/oneTBB.git
|
||||
```
|
||||
|
||||
2. Go to the `doc` folder:
|
||||
|
||||
```
|
||||
cd oneTBB/doc
|
||||
```
|
||||
|
||||
3. Run in the command line:
|
||||
|
||||
```
|
||||
make html
|
||||
```
|
||||
|
||||
|
||||
That's it! Your built documentation is located in the ``build/html`` folder.
|
||||
@@ -1,19 +1,3 @@
|
||||
//configure tms
|
||||
var wapLocalCode = 'us-en';
|
||||
//dynamically set per localized site, see mapping table for values
|
||||
var wapSection = "oneapi-docs";
|
||||
//load tms
|
||||
(function() {
|
||||
var host = (window.document.location.protocol == 'http:') ? "http://www.intel.com" : "https://www.intel.com";
|
||||
var url = host+"/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);
|
||||
})();
|
||||
|
||||
window.MathJax = {
|
||||
TeX: {
|
||||
Macros: {
|
||||
|
Before Width: | Height: | Size: 467 B After Width: | Height: | Size: 467 B |
|
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
@@ -25,11 +25,11 @@ BUILD_TYPE = os.getenv("BUILD_TYPE")
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
if BUILD_TYPE == 'oneapi':
|
||||
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'
|
||||
project = u'oneTBB'
|
||||
copyright = u'2022, Intel Corporation'
|
||||
author = u'Intel'
|
||||
|
||||
# The short X.Y version
|
||||
@@ -60,7 +60,7 @@ extensions = [
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
templates_path = ['main/_templates']
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
@@ -90,7 +90,7 @@ pygments_style = None
|
||||
# Syntax highlighting for the :: directive
|
||||
highlight_language = 'cpp'
|
||||
|
||||
if BUILD_TYPE == 'oneapi':
|
||||
if BUILD_TYPE == 'oneapi' or BUILD_TYPE == 'dita':
|
||||
rst_prolog = """
|
||||
.. |full_name| replace:: Intel\ |reg|\ oneAPI Threading Building Blocks (oneTBB)
|
||||
.. |short_name| replace:: oneTBB
|
||||
@@ -120,18 +120,24 @@ else:
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#
|
||||
if BUILD_TYPE == 'oneapi':
|
||||
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'
|
||||
}
|
||||
|
||||
html_theme = 'sphinx_book_theme'
|
||||
|
||||
if BUILD_TYPE == 'dita':
|
||||
html_theme_options = {
|
||||
'repository_url': 'https://github.com/oneapi-src/oneTBB',
|
||||
'path_to_docs': 'doc',
|
||||
'repository_branch': 'master'
|
||||
}
|
||||
else:
|
||||
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,
|
||||
@@ -139,7 +145,7 @@ else:
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
if BUILD_TYPE == 'oneapi':
|
||||
if BUILD_TYPE == 'oneapi' or BUILD_TYPE == 'dita':
|
||||
html_context = {
|
||||
'css_files': [
|
||||
'_static/theme_overrides.css', # override wide tables in RTD theme
|
||||
@@ -147,8 +153,10 @@ if BUILD_TYPE == 'oneapi':
|
||||
}
|
||||
else:
|
||||
html_js_files = ['custom.js']
|
||||
html_logo = '_static/oneAPI-rgb-rev-100.png'
|
||||
html_favicon = '_static/favicons.png'
|
||||
|
||||
|
||||
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.
|
||||
@@ -0,0 +1,15 @@
|
||||
|full_name|
|
||||
===========
|
||||
|
||||
.. include:: index/index_intro.rst
|
||||
|
||||
|
||||
The following are some important topics for the ``novice user``:
|
||||
|
||||
* :ref:`Get_Started_Guide` 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|.
|
||||
|
||||
.. include:: index/useful_topics.rst
|
||||
|
||||
.. include:: index/toctree.rst
|
||||
@@ -0,0 +1,5 @@
|
||||
.. _index_intro:
|
||||
|
||||
This document contains information about |short_name|.
|
||||
It is a flexible performance library that let you break computation into parallel running tasks.
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
.. _toctree:
|
||||
|
||||
.. toctree::
|
||||
:caption: About
|
||||
:maxdepth: 1
|
||||
|
||||
/main/intro/help_support
|
||||
/main/intro/notation
|
||||
/main/intro/intro_os
|
||||
/main/intro/Benefits
|
||||
/main/intro/testing_approach
|
||||
|
||||
|
||||
.. toctree::
|
||||
:caption: Get Started
|
||||
:maxdepth: 2
|
||||
|
||||
/GSG/get_started
|
||||
/GSG/installation
|
||||
/GSG/examples
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 3
|
||||
:caption: Developer Guide
|
||||
|
||||
/main/tbb_userguide/title
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 3
|
||||
:caption: Developer Reference
|
||||
|
||||
/main/reference/reference
|
||||
@@ -0,0 +1,5 @@
|
||||
.. _Usefull_Topics:
|
||||
|
||||
The following is an important topic for the ``experienced user``:
|
||||
|
||||
:ref:`Migration_Guide` describes how to migrate from TBB to oneTBB.
|
||||
@@ -0,0 +1,16 @@
|
||||
{% extends "!layout.html" %}
|
||||
{% block extrahead %}
|
||||
<script defer type="text/javascript" src="https://www.intel.com/content/dam/www/global/wap/performance-config.js" ></script>
|
||||
<script type="text/javascript">
|
||||
// Configure TMS settings
|
||||
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);
|
||||
})();
|
||||
</script>
|
||||
<link href="{{ pathto("_static/style.css", True) }}" rel="stylesheet" type="text/css">
|
||||
{% endblock %}
|
||||
@@ -1,13 +0,0 @@
|
||||
|full_name|
|
||||
===========
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
intro/help_support
|
||||
intro/notation
|
||||
intro/intro
|
||||
intro/Benefits
|
||||
tbb_userguide/title
|
||||
reference/reference
|
||||
intro/notices_and_disclaimers
|
||||
@@ -4,23 +4,12 @@ Getting Help and Support
|
||||
========================
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.. container:: section
|
||||
|
||||
|
||||
.. rubric:: Getting Technical Support
|
||||
:class: sectiontitle
|
||||
|
||||
If you did not register your Intel® software product during
|
||||
installation, please do so now at the Intel® Software Development
|
||||
Products Registration Center. Registration entitles you to free
|
||||
technical support, product updates and upgrades for the duration of
|
||||
the support term.
|
||||
|
||||
|
||||
For general information about Intel technical support, product
|
||||
For general information about oneTBB technical support, product
|
||||
updates, user forums, FAQs, tips and tricks and other support
|
||||
questions, go to: http://www.intel.com/software/products/support/.
|
||||
|
||||
questions, go to `GitHub issues <https://github.com/oneapi-src/oneTBB/issues>`_.
|
||||
|
||||
@@ -30,10 +30,6 @@ 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
|
||||
|
||||
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
.. _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
|
||||
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
.. _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.
|
||||
|
||||
@@ -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.
|
||||
@@ -1,137 +0,0 @@
|
||||
.. _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;
|
||||
|
||||
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**: 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 get()
|
||||
|
||||
**Returns**: An instance of the ``task_scheduler_handle`` class.
|
||||
|
||||
-------------------------------------------------------
|
||||
|
||||
.. 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;
|
||||
}
|
||||
@@ -1,241 +0,0 @@
|
||||
.. _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");
|
||||
}
|
||||
@@ -1,93 +0,0 @@
|
||||
.. _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.
|
||||
@@ -0,0 +1,72 @@
|
||||
.. _parallel_sort_ranges_extension:
|
||||
|
||||
parallel_sort ranges interface extension
|
||||
========================================
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 1
|
||||
|
||||
Description
|
||||
***********
|
||||
|
||||
|full_name| implementation extends the `oneapi::tbb::parallel_sort specification <https://spec.oneapi.io/versions/latest/elements/oneTBB/source/algorithms/functions/parallel_sort_func.html>`_
|
||||
with overloads that takes the container by forwarding reference.
|
||||
|
||||
|
||||
API
|
||||
***
|
||||
|
||||
Header
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include <oneapi/tbb/parallel_sort.h>
|
||||
|
||||
Syntax
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
namespace oneapi {
|
||||
namespace tbb {
|
||||
|
||||
template <typename Container>
|
||||
void parallel_sort( Container&& c );
|
||||
template <typename Container, typename Compare>
|
||||
void parallel_sort( Container&& c, const Compare& comp );
|
||||
|
||||
} // namespace tbb
|
||||
} // namespace oneapi
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
.. cpp:function:: template <typename Container> void parallel_sort( Container&& c );
|
||||
|
||||
Equivalent to ``parallel_sort( std::begin(c), std::end(c), comp )``, where `comp` uses `operator<` to determine relative orderings.
|
||||
|
||||
.. cpp:function:: template <typename Container, typename Compare> void parallel_sort( Container&& c, const Compare& comp );
|
||||
|
||||
Equivalent to ``parallel_sort( std::begin(c), std::end(c), comp )``.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
This interface may be used for sorting rvalue or constant views:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include <array>
|
||||
#include <span> // requires C++20
|
||||
#include <oneapi/tbb/parallel_sort.h>
|
||||
|
||||
std::span<int> get_span() {
|
||||
static std::array<int, 3> arr = {3, 2, 1};
|
||||
return std::span<int>(arr);
|
||||
}
|
||||
|
||||
int main() {
|
||||
tbb::parallel_sort(get_span());
|
||||
}
|
||||
@@ -18,6 +18,7 @@ It also describes features that are not included in the oneTBB specification.
|
||||
|
||||
info_namespace
|
||||
parallel_for_each_semantics
|
||||
parallel_sort_ranges_extension
|
||||
|
||||
Preview features
|
||||
****************
|
||||
@@ -43,16 +44,10 @@ The key properties of a preview feature are:
|
||||
:titlesonly:
|
||||
|
||||
type_specified_message_keys
|
||||
blocking_terminate
|
||||
scalable_memory_pools
|
||||
helpers_for_expressing_graphs
|
||||
concurrent_lru_cache_cls
|
||||
constraints_extensions
|
||||
info_namespace_extensions
|
||||
task_group_extensions
|
||||
task_arena_extensions
|
||||
this_task_arena_extensions
|
||||
mutex_cls
|
||||
rw_mutex_cls
|
||||
heterogeneous_extensions_chmap
|
||||
custom_mutex_chmap
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
.. _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.
|
||||
@@ -1,61 +0,0 @@
|
||||
.. _task_arena_extensions:
|
||||
|
||||
task_arena extensions
|
||||
=====================
|
||||
|
||||
.. note::
|
||||
To enable these extensions, set the ``TBB_PREVIEW_TASK_GROUP_EXTENSIONS`` macro to 1.
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 1
|
||||
|
||||
Description
|
||||
***********
|
||||
|
||||
|full_name| implementation extends the `tbb::task_arena specification <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/task_scheduler/task_arena/task_arena_cls.html>`_
|
||||
with an overload of ``enqueue`` method accepting ``task_handle``.
|
||||
|
||||
|
||||
API
|
||||
***
|
||||
|
||||
Header
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include <oneapi/tbb/task_arena.h>
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
namespace oneapi {
|
||||
namespace tbb {
|
||||
|
||||
class task_arena {
|
||||
public:
|
||||
void enqueue(task_handle&& h);
|
||||
};
|
||||
|
||||
} // namespace tbb
|
||||
} // namespace oneapi
|
||||
|
||||
Member Functions
|
||||
----------------
|
||||
|
||||
.. cpp:function:: void enqueue(task_handle&& h)
|
||||
|
||||
Enqueues a task owned by ``h`` into the ``task_arena`` for procession.
|
||||
|
||||
Behavior of this function is identical to generic version (``template<typename F> void task_arena::enqueue(F&& f)``) except parameter type.
|
||||
|
||||
.. note::
|
||||
``h`` should not be empty to avoid undefined behavior.
|
||||
|
||||
.. rubric:: See also
|
||||
|
||||
* `oneapi::tbb::task_arena specification <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/task_scheduler/task_arena/task_arena_cls.html>`_
|
||||
* :ref:`task_handle`
|
||||
@@ -15,9 +15,7 @@ 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:
|
||||
|
||||
- Constructor that takes a custom ``tbb::task_group_context`` object as an argument.
|
||||
- Methods to create and run deferred tasks with ``task_handle``.
|
||||
- Requirements for a user-provided function object.
|
||||
- requirements for a user-provided function object
|
||||
|
||||
|
||||
API
|
||||
@@ -40,14 +38,16 @@ Synopsis
|
||||
|
||||
class task_group {
|
||||
public:
|
||||
task_group(task_group_context& context);
|
||||
|
||||
|
||||
//only the requirements for the return type of function F are changed
|
||||
template<typename F>
|
||||
task_handle defer(F&& f);
|
||||
|
||||
void run(task_handle&& h);
|
||||
|
||||
//only F return type requirements have changed
|
||||
//only the requirements for the return type of function F are changed
|
||||
template<typename F>
|
||||
task_group_status run_and_wait(const F& f);
|
||||
|
||||
//only the requirements for the return type of function F are changed
|
||||
template<typename F>
|
||||
void run(F&& f);
|
||||
};
|
||||
@@ -55,38 +55,26 @@ Synopsis
|
||||
} // namespace tbb
|
||||
} // namespace oneapi
|
||||
|
||||
|
||||
|
||||
Member Functions
|
||||
----------------
|
||||
|
||||
.. cpp:function:: task_group(task_group_context& context)
|
||||
|
||||
Constructs an empty ``task_group``, which tasks are associated with the ``context``.
|
||||
|
||||
.. cpp:function:: template<typename F> task_handle defer(F&& f)
|
||||
|
||||
Creates a deferred task to compute ``f()`` and returns ``task_handle`` pointing to it.
|
||||
|
||||
The task is not scheduled for execution until explicitly requested. For example, with the ``task_group::run`` method.
|
||||
However, the task is still added into the ``task_group``, thus the ``task_group::wait`` method waits until the ``task_handle`` is either scheduled or destroyed.
|
||||
|
||||
The ``F`` type must meet the `Function Objects` requirements described in the [function.objects] section of the ISO C++ Standard.
|
||||
|
||||
As an optimization hint, ``F`` might return a ``task_handle``, which task object can be executed next.
|
||||
|
||||
.. note::
|
||||
The ``task_handle`` returned by the function must be created with ``*this`` ``task_group``. It means, with the one for which run method is called, otherwise it is an undefined behavior.
|
||||
The ``task_handle`` returned by the function must be created using ``*this`` ``task_group``. That is, the one for which the run method is called, otherwise it is undefined behavior.
|
||||
|
||||
**Returns:** ``task_handle`` object pointing to task to compute ``f()``.
|
||||
.. cpp:function:: template<typename F> task_group_status run_and_wait(const F& f)
|
||||
|
||||
.. cpp:function:: void run(task_handle&& h)
|
||||
|
||||
Schedules the task object pointed by the ``h`` for execution.
|
||||
As an optimization hint, ``F`` might return a ``task_handle``, which task object can be executed next.
|
||||
|
||||
.. note::
|
||||
The failure to satisfy the following conditions leads to undefined behavior:
|
||||
* ``h`` is not empty.
|
||||
* ``*this`` is the same ``task_group`` that ``h`` is created with.
|
||||
The ``task_handle`` returned by the function must be created using ``*this`` ``task_group``. That is, the one for which the run method is called, otherwise it is undefined behavior.
|
||||
|
||||
|
||||
.. cpp:function:: template<typename F> void run(F&& f)
|
||||
|
||||
As an optimization hint, ``F`` might return a ``task_handle``, which task object can be executed next.
|
||||
@@ -99,4 +87,5 @@ 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>`
|
||||
|
||||
@@ -1,101 +0,0 @@
|
||||
.. _task_handle:
|
||||
|
||||
task_handle
|
||||
===========
|
||||
|
||||
.. note:: To enable these extensions, set the ``TBB_PREVIEW_TASK_GROUP_EXTENSIONS`` macro to 1.
|
||||
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 1
|
||||
|
||||
Description
|
||||
***********
|
||||
|
||||
This class owns a deferred task object.
|
||||
|
||||
API
|
||||
***
|
||||
|
||||
Header
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include <oneapi/tbb/task_group.h>
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
namespace oneapi {
|
||||
namespace tbb {
|
||||
|
||||
class task_handle {
|
||||
public:
|
||||
task_handle();
|
||||
task_handle(task_handle&& src);
|
||||
|
||||
~task_handle();
|
||||
|
||||
task_handle& operator=(task_handle&& src);
|
||||
|
||||
explicit operator bool() const noexcept;
|
||||
};
|
||||
|
||||
bool operator==(task_handle const& h, std::nullptr_t) noexcept;
|
||||
bool operator==(std::nullptr_t, task_handle const& h) noexcept;
|
||||
|
||||
bool operator!=(task_handle const& h, std::nullptr_t) noexcept;
|
||||
bool operator!=(std::nullptr_t, task_handle const& h) noexcept;
|
||||
|
||||
} // namespace tbb
|
||||
} // namespace oneapi
|
||||
|
||||
Member Functions
|
||||
----------------
|
||||
|
||||
.. cpp:function:: task_handle()
|
||||
|
||||
Creates an empty ``task_handle`` object.
|
||||
|
||||
.. cpp:function:: task_handle(task_handle&& src)
|
||||
|
||||
Constructs ``task_handle`` object with the content of ``src`` using move semantics. ``src`` is left in an empty state.
|
||||
|
||||
.. cpp:function:: ~task_handle()
|
||||
|
||||
Destroys the ``task_handle`` object and associated task if it exists.
|
||||
|
||||
.. cpp:function:: task_handle& operator=(task_handle&& src)
|
||||
|
||||
Replaces the content of ``task_handle`` object with the content of ``src`` using move semantics. ``src`` is left in an empty state.
|
||||
The previously associated task object, if any, is destroyed before the assignment.
|
||||
|
||||
**Returns:** Reference to ``*this``.
|
||||
|
||||
.. cpp:function:: explicit operator bool() const noexcept
|
||||
|
||||
Checks if ``*this`` has an associated task object.
|
||||
|
||||
**Returns:** ``true`` if ``*this`` is not empty, ``false`` otherwise.
|
||||
|
||||
Non-Member Functions
|
||||
--------------------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
bool operator==(task_handle const& h, std::nullptr_t) noexcept
|
||||
bool operator==(std::nullptr_t, task_handle const& h) noexcept
|
||||
|
||||
**Returns**: ``true`` if ``h`` is empty, ``false`` otherwise.
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
bool operator!=(task_handle const& h, std::nullptr_t) noexcept
|
||||
bool operator!=(std::nullptr_t, task_handle const& h) noexcept
|
||||
|
||||
**Returns**: ``true`` if ``h`` is not empty, ``false`` otherwise.
|
||||
|
||||
@@ -1,71 +0,0 @@
|
||||
.. _this_task_arena_extensions:
|
||||
|
||||
this_task_arena extensions
|
||||
==========================
|
||||
|
||||
.. note::
|
||||
To enable these extensions, set the ``TBB_PREVIEW_TASK_GROUP_EXTENSIONS`` macro to 1.
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 1
|
||||
|
||||
Description
|
||||
***********
|
||||
|
||||
|full_name| implementation extends the `tbb::this_task_arena specification <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/task_scheduler/task_arena/this_task_arena_ns.html>`_
|
||||
with an overloaded ``enqueue`` function.
|
||||
|
||||
|
||||
API
|
||||
***
|
||||
|
||||
Header
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include <oneapi/tbb/task_arena.h>
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
namespace oneapi {
|
||||
namespace tbb {
|
||||
namespace this_task_arena {
|
||||
void enqueue(task_handle&& h);
|
||||
|
||||
template<typename F>
|
||||
void enqueue(F&& f) ;
|
||||
} // namespace this_task_arena
|
||||
} // namespace tbb
|
||||
} // namespace oneapi
|
||||
|
||||
Member Functions
|
||||
----------------
|
||||
|
||||
|
||||
.. cpp:function:: template<typename F> void enqueue(F&& f)
|
||||
|
||||
Enqueues a task into the ``task_arena`` currently used by the calling thread to process the specified functor, then immediately returns.
|
||||
The ``F`` type must meet the `Function Objects` requirements described in the [function.objects] section of the ISO C++ Standard.
|
||||
|
||||
Behavior of this function is identical to ``template<typename F> void task_arena::enqueue(F&& f)`` applied to ``task_arena`` object constructed with ``attach`` parameter.
|
||||
|
||||
.. cpp:function:: void enqueue(task_handle&& h)
|
||||
|
||||
Enqueues a task owned by ``h`` into the ``task_arena`` that is currently used by the calling thread.
|
||||
|
||||
Behavior of this function is identical to generic version (``template<typename F> void enqueue(F&& f)``) except the parameter type.
|
||||
|
||||
.. note::
|
||||
``h`` should not be empty to avoid undefined behavior.
|
||||
|
||||
|
||||
.. rubric:: See also:
|
||||
|
||||
* `oneapi::tbb::this_task_arena specification <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/task_scheduler/task_arena/this_task_arena_ns.html>`_
|
||||
* `oneapi::tbb::task_arena specification <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/task_scheduler/task_arena/task_arena_cls.html>`_
|
||||
* :ref:`task_handle`
|
||||
@@ -4,15 +4,13 @@ Advanced Topic: Other Kinds of Iteration Spaces
|
||||
===============================================
|
||||
|
||||
|
||||
The examples so far have used the class ``blocked_range<T>`` to specify
|
||||
ranges. This class is useful in many situations, but it does not fit
|
||||
every situation. You can use |full_name|
|
||||
to define your own iteration space objects. The object must specify how
|
||||
it can be split into subspaces by providing a basic splitting
|
||||
constructor, an optional proportional splitting constructor (accompanied
|
||||
with a trait value that enables its usage), and two predicate methods.
|
||||
If your class is called ``R``, the methods and constructors should be as
|
||||
follows:
|
||||
The examples so far have used the class ``blocked_range<T>`` to specify ranges.
|
||||
This class is useful in many situations, but it does not fit every situation.
|
||||
You can use |full_name| to define your own iteration space objects. The object
|
||||
must specify how it can be split into subspaces by providing a basic splitting
|
||||
constructor, an optional proportional splitting constructor, and two predicate
|
||||
methods. If your class is called ``R``, the methods and constructors should be
|
||||
as follows:
|
||||
|
||||
|
||||
::
|
||||
@@ -25,10 +23,8 @@ follows:
|
||||
bool is_divisible() const;
|
||||
// Splits r into subranges r and *this
|
||||
R( R& r, split );
|
||||
// Splits r into subranges r and *this in proportion p
|
||||
// (optional) Splits r into subranges r and *this in proportion p
|
||||
R( R& r, proportional_split p );
|
||||
// Allows usage of proportional splitting constructor
|
||||
static const bool is_splittable_in_proportion = true;
|
||||
...
|
||||
};
|
||||
|
||||
@@ -60,9 +56,7 @@ constructor is optional and takes the second argument of type
|
||||
that return the values of the proportion. These values should be used to
|
||||
split ``r`` accordingly, so that the updated ``r`` corresponds to the
|
||||
left part of the proportion, and the constructed object corresponds to
|
||||
the right part. The proportional splitting constructor will be used only
|
||||
if the static constant ``is_splittable_in_proportion`` is defined in the
|
||||
class and assigned the value of ``true``.
|
||||
the right part.
|
||||
|
||||
|
||||
Both splitting constructors should guarantee that the updated ``r`` part
|
||||
|
||||
@@ -96,12 +96,6 @@ of computations to memory accesses.
|
||||
|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
|
||||
@@ -157,11 +157,6 @@ quite well.
|
||||
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
|
||||
@@ -191,8 +191,7 @@ This final implementation has all of the nodes and edges from the
|
||||
much advantage in using an ``input_node`` over an explicit loop. But,
|
||||
because an ``input_node`` is able to react to the behavior of downstream
|
||||
nodes, it can limit memory use in more complex graphs. For more
|
||||
information, see `Creating a Token-Based
|
||||
System <create_token_based_system.html#create_token_based_system>`__
|
||||
information, see:ref:`create_token_based_system` .
|
||||
|
||||
|
||||
.. |image0| image:: Images/flow_graph.jpg
|
||||
|
||||
@@ -14,4 +14,5 @@ in a flow graph.
|
||||
|
||||
../tbb_userguide/use_limiter_node
|
||||
../tbb_userguide/use_concurrency_limits
|
||||
../tbb_userguide/create_token_based_system
|
||||
../tbb_userguide/create_token_based_system
|
||||
../tbb_userguide/attach_flow_graph_to_arena
|
||||
@@ -0,0 +1,50 @@
|
||||
.. _How_Task_Scheduler_Works.rst:
|
||||
|
||||
How Task Scheduler Works
|
||||
========================
|
||||
|
||||
|
||||
While the task scheduler is not bound to any particular type of parallelism,
|
||||
it was designed to work efficiently for fork-join parallelism with lots of forks.
|
||||
This type of parallelism is typical for parallel algorithms such as `oneapi::tbb::parallel_for
|
||||
<https://spec.oneapi.io/versions/latest/elements/oneTBB/source/algorithms/functions/parallel_for_func.html>`_.
|
||||
|
||||
Let's consider the mapping of fork-join parallelism on the task scheduler in more detail.
|
||||
|
||||
The scheduler runs tasks in a way that tries to achieve several targets simultaneously:
|
||||
- Enable as many threads as possible, by creating enough job, to achieve actual parallelism
|
||||
- Preserve data locality to make a single thread execution more efficient
|
||||
- Minimize both memory demands and cross-thread communication to reduce an overhead
|
||||
|
||||
To achieve this, a balance between depth-first and breadth-first execution strategies
|
||||
must be reached. Assuming that the task graph is finite, depth-first is better for
|
||||
a sequential execution because:
|
||||
|
||||
- **Strike when the cache is hot**. The deepest tasks are the most recently created tasks and therefore are the hottest in the cache.
|
||||
Also, if they can be completed, tasks that depend on it can continue executing, and though not the hottest in a cache,
|
||||
they are still warmer than the older tasks deeper in the dequeue.
|
||||
|
||||
- **Minimize space**. Execution of the shallowest task leads to the breadth-first unfolding of a graph. It creates an exponential
|
||||
number of nodes that co-exist simultaneously. In contrast, depth-first execution creates the same number
|
||||
of nodes, but only a linear number can exists at the same time, since it creates a stack of other ready
|
||||
tasks.
|
||||
|
||||
Each thread has its deque of tasks that are ready to run. When a
|
||||
thread spawns a task, it pushes it onto the bottom of its deque.
|
||||
|
||||
When a thread participates in the evaluation of tasks, it constantly executes
|
||||
a task obtained by the first rule that applies from the roughly equivalent ruleset:
|
||||
|
||||
- Get the task returned by the previous one, if any.
|
||||
|
||||
- Take a task from the bottom of its deque, if any.
|
||||
|
||||
- Steal a task from the top of another randomly chosen deque. If the
|
||||
selected deque is empty, the thread tries again to execute this rule until it succeeds.
|
||||
|
||||
Rule 1 is described in :doc:`Task Scheduler Bypass <Task_Scheduler_Bypass>`.
|
||||
The overall effect of rule 2 is to execute the *youngest* task spawned by the thread,
|
||||
which causes the depth-first execution until the thread runs out of work.
|
||||
Then rule 3 applies. It steals the *oldest* task spawned by another thread,
|
||||
which causes temporary breadth-first execution that converts potential parallelism
|
||||
into actual parallelism.
|
||||
@@ -325,3 +325,129 @@ task:
|
||||
}
|
||||
tg.wait();
|
||||
}
|
||||
|
||||
|
||||
Scheduler Bypass
|
||||
----------------
|
||||
|
||||
TBB ``task::execute()`` method can return a pointer to a task that can be executed next by the current thread.
|
||||
This might reduce scheduling overheads compared to direct ``spawn``. Similar to ``spawn``, the returned task
|
||||
is not guaranteed to be executed next by the current thread.
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include <tbb/task.h>
|
||||
|
||||
// Assuming OtherTask is defined.
|
||||
|
||||
struct Task : tbb::task {
|
||||
task* execute(){
|
||||
// some work to do ...
|
||||
|
||||
auto* other_p = new(this->parent().allocate_child()) OtherTask{};
|
||||
this->parent().add_ref_count();
|
||||
|
||||
return other_p;
|
||||
}
|
||||
};
|
||||
|
||||
int main(){
|
||||
// Assuming RootTask is defined.
|
||||
RootTask& root = *new(tbb::task::allocate_root()) RootTask{};
|
||||
|
||||
Task& child = *new(root.allocate_child()) Task{/*params*/};
|
||||
|
||||
root.add_ref_count();
|
||||
|
||||
tbb::task_spawn(child);
|
||||
|
||||
root.wait_for_all();;
|
||||
}
|
||||
|
||||
In oneTBB, this can be done using ``oneapi::tbb::task_group``.
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include <oneapi/tbb/task_group.h>
|
||||
|
||||
// Assuming OtherTask is defined.
|
||||
|
||||
int main(){
|
||||
oneapi::tbb::task_group tg;
|
||||
|
||||
tg.run([&tg](){
|
||||
//some work to do ...
|
||||
|
||||
return tg.defer(OtherTask{});
|
||||
});
|
||||
|
||||
tg.wait();
|
||||
}
|
||||
|
||||
Here ``oneapi::tbb::task_group::defer`` adds a new task into the ``tg``. However, the task is not put into a
|
||||
queue of tasks ready for execution via ``oneapi::tbb::task_group::run``, but bypassed to the executing thread directly
|
||||
via function return value.
|
||||
|
||||
Deferred task creation
|
||||
----------------------
|
||||
The TBB low-level task API separates the task creation from the actual spawning. This separation allows to
|
||||
postpone the task spawning, while the parent task and final result production are blocked from premature leave.
|
||||
For example, ``RootTask``, ``ChildTask``, and ``CallBackTask`` are the user-side functors that
|
||||
inherit ``tbb::task`` and implement its interface. Then, blocking the ``RootTask`` from leaving prematurely
|
||||
and waiting on it is implemented as follows:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include <tbb/task.h>
|
||||
|
||||
int main() {
|
||||
// Assuming RootTask, ChildTask, and CallBackTask are defined.
|
||||
RootTask& root = *new(tbb::task::allocate_root()) RootTask{};
|
||||
|
||||
ChildTask& child = *new(root.allocate_child()) ChildTask{/*params*/};
|
||||
CallBackTask& cb_task = *new(root.allocate_child()) CallBackTask{/*params*/};
|
||||
|
||||
root.set_ref_count(3);
|
||||
|
||||
tbb::task::spawn(child);
|
||||
|
||||
register_callback([cb_task&](){
|
||||
tbb::task::enqueue(cb_task);
|
||||
});
|
||||
|
||||
root.wait_for_all();
|
||||
// Control flow will reach here only after both ChildTask and CallBackTask are executed,
|
||||
// i.e. after the callback is called
|
||||
}
|
||||
|
||||
In oneTBB, this can be done using ``oneapi::tbb::task_group``.
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include <oneapi/tbb/task_group.h>
|
||||
|
||||
int main(){
|
||||
oneapi::tbb::task_group tg;
|
||||
oneapi::tbb::task_arena arena;
|
||||
// Assuming ChildTask and CallBackTask are defined.
|
||||
|
||||
auto cb = tg.defer(CallBackTask{/*params*/});
|
||||
|
||||
register_callback([&tg, c = std::move(cb), &arena]{
|
||||
arena.enqueue(c);
|
||||
});
|
||||
|
||||
tg.run(ChildTask{/*params*/});
|
||||
|
||||
|
||||
tg.wait();
|
||||
// Control flow gets here once both ChildTask and CallBackTask are executed
|
||||
// i.e. after the callback is called
|
||||
}
|
||||
|
||||
Here ``oneapi::tbb::task_group::defer`` adds a new task into the ``tg``. However, the task is not spawned until
|
||||
``oneapi::tbb::task_arena::enqueue`` is called.
|
||||
|
||||
.. note::
|
||||
The call to ``oneapi::tbb::task_group::wait`` will not return control until both ``ChildTask`` and
|
||||
``CallBackTask`` are executed.
|
||||
|
||||
@@ -145,12 +145,11 @@ allows waiting for oneTBB worker threads completion:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#define TBB_PREVIEW_WAITING_FOR_WORKERS 1
|
||||
#include <oneapi/tbb/global_control.h>
|
||||
#include <oneapi/tbb/parallel_for.h>
|
||||
|
||||
int main() {
|
||||
oneapi::tbb::task_scheduler_handle handle = oneapi::tbb::task_scheduler_handle::get();
|
||||
oneapi::tbb::task_scheduler_handle handle{tbb::attach{}};
|
||||
// Do some parallel work here
|
||||
oneapi::tbb::parallel_for(/* ... */);
|
||||
oneapi::tbb::finalize(handle);
|
||||
|
||||
@@ -37,12 +37,4 @@ of the library.
|
||||
- ``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
|
||||
.. include:: Parallelizing_Simple_Loops_toctree.rst
|
||||
@@ -0,0 +1,11 @@
|
||||
.. _Parallelizing_Simple_Loops_toctree:
|
||||
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
|
||||
../tbb_userguide/Initializing_and_Terminating_the_Library
|
||||
../tbb_userguide/parallel_for_os
|
||||
../tbb_userguide/parallel_reduce
|
||||
../tbb_userguide/Advanced_Example
|
||||
../tbb_userguide/Advanced_Topic_Other_Kinds_of_Iteration_Spaces
|
||||
@@ -0,0 +1,20 @@
|
||||
.. _Task_Scheduler_Bypass:
|
||||
|
||||
Task Scheduler Bypass
|
||||
=====================
|
||||
|
||||
Scheduler bypass is an optimization where you directly specify the next task to run.
|
||||
According to the rules of execution described in :doc:`How Task Scheduler Works <How_Task_Scheduler_Works>`,
|
||||
the spawning of the new task to be executed by the current thread involves the next steps:
|
||||
|
||||
- Push a new task onto the thread's deque.
|
||||
- Continue to execute the current task until it is completed.
|
||||
- Take a task from the thread's deque, unless it is stolen by another thread.
|
||||
|
||||
Steps 1 and 3 introduce unnecessary deque operations or, even worse, allow stealing that can hurt
|
||||
locality without adding significant parallelism. These problems can be avoided by using "Task Scheduler Bypass" technique to directly point the preferable task to be executed next
|
||||
instead of spawning it. When, as described in :doc:`How Task Scheduler Works <How_Task_Scheduler_Works>`,
|
||||
the returned task becomes the first candidate for the next task to be executed by the thread. Furthermore, this approach almost guarantees that
|
||||
the task is executed by the current thread and not by any other thread.
|
||||
|
||||
Please note that at the moment the only way to use this optimization is to use `preview feature of ``onepai::tbb::task_group``
|
||||
@@ -1,11 +0,0 @@
|
||||
.. _Task_Scheduler_Summary:
|
||||
|
||||
Task Scheduler Summary
|
||||
======================
|
||||
|
||||
|
||||
The task scheduler works most efficiently for fork-join parallelism with
|
||||
lots of forks, so that the task-stealing can cause sufficient
|
||||
breadth-first behavior to occupy threads, which then conduct themselves
|
||||
in a depth-first manner until they need to steal more work.
|
||||
|
||||
@@ -16,5 +16,6 @@ onto one of the high-level templates, use the task scheduler.
|
||||
|
||||
../tbb_userguide/Task-Based_Programming
|
||||
../tbb_userguide/When_Task-Based_Programming_Is_Inappropriate
|
||||
../tbb_userguide/Task_Scheduler_Summary
|
||||
../tbb_userguide/How_Task_Scheduler_Works
|
||||
../tbb_userguide/Task_Scheduler_Bypass
|
||||
../tbb_userguide/Guiding_Task_Scheduler_Execution
|
||||
@@ -0,0 +1,47 @@
|
||||
.. _attach_flow_graph_to_arena:
|
||||
|
||||
Attach Flow Graph to an Arbitrary Task Arena
|
||||
======================
|
||||
|
||||
|
||||
|short_name| ``task_arena`` interface provides mechanisms to guide tasks
|
||||
execution within the arena by setting the preferred computation units,
|
||||
restricting part of computation units, or limiting arena concurrency. In some
|
||||
cases, you may want to apply such mechanisms when a flow graph executes.
|
||||
|
||||
During its construction, a ``graph`` object attaches to the arena, in which the constructing
|
||||
thread occupies a slot.
|
||||
|
||||
This example shows how to set the most performant core type as the preferred one
|
||||
for a graph execution:
|
||||
|
||||
|
||||
.. literalinclude:: ./snippets/flow_graph_examples.cpp
|
||||
:language: c++
|
||||
:start-after: /*begin_attach_to_arena_1*/
|
||||
:end-before: /*end_attach_to_arena_1*/
|
||||
|
||||
|
||||
A ``graph`` object can be reattached to a different ``task_arena`` by calling
|
||||
the ``graph::reset()`` function. It reinitializes and reattaches the ``graph`` to
|
||||
the task arena instance, inside which the ``graph::reset()`` method is executed.
|
||||
|
||||
This example shows how to reattach existing graph to an arena with the most performant
|
||||
core type as the preferred one for a work execution. Whenever a task is spawned on behalf
|
||||
of the graph, it is spawned in the arena of a graph it is attached to, disregarding
|
||||
the arena of the thread that the task is spawned from:
|
||||
|
||||
|
||||
.. literalinclude:: ./snippets/flow_graph_examples.cpp
|
||||
:language: c++
|
||||
:start-after: /*begin_attach_to_arena_2*/
|
||||
:end-before: /*end_attach_to_arena_2*/
|
||||
|
||||
See the following topics to learn more:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
|
||||
../tbb_userguide/Guiding_Task_Scheduler_Execution
|
||||
../tbb_userguide/work_isolation
|
||||
|
||||
@@ -51,6 +51,7 @@ expressions into equivalent C++03 code.
|
||||
../../tbb_userguide/design_patterns/Divide_and_Conquer
|
||||
../../tbb_userguide/design_patterns/GUI_Thread
|
||||
../../tbb_userguide/design_patterns/Non-Preemptive_Priorities
|
||||
../../tbb_userguide/design_patterns/Lazy_Initialization
|
||||
../../tbb_userguide/design_patterns/Local_Serializer
|
||||
../../tbb_userguide/design_patterns/Fenced_Data_Transfer
|
||||
../../tbb_userguide/design_patterns/Reference_Counting
|
||||
|
||||
|
After Width: | Height: | Size: 30 KiB |
|
After Width: | Height: | Size: 21 KiB |
@@ -0,0 +1,109 @@
|
||||
.. _Lazy_Initialization:
|
||||
|
||||
Lazy Initialization
|
||||
==================
|
||||
|
||||
|
||||
.. container:: section
|
||||
|
||||
|
||||
.. rubric:: Problem
|
||||
:class: sectiontitle
|
||||
|
||||
Delay the creation of an object, potentially expensive, until it is accessed.
|
||||
In parallel programming, initialization must also be guarded against race conditions.
|
||||
|
||||
|
||||
.. container:: section
|
||||
|
||||
|
||||
.. rubric:: Context
|
||||
:class: sectiontitle
|
||||
|
||||
The cost of operations that take place during the initialization
|
||||
of the object may be considerably high. In that case, the object
|
||||
should be initialized only when needed. Lazy initialization is
|
||||
the common tactic that allows implementing such an approach.
|
||||
|
||||
|
||||
.. container:: section
|
||||
|
||||
|
||||
.. rubric:: Solution
|
||||
:class: sectiontitle
|
||||
|
||||
Using ``oneapi::tbb::collaborative_call_once`` with ``oneapi::tbb::collaborative_once_flag``
|
||||
helps to implement thread-safe lazy initialization for a user object.
|
||||
|
||||
|
||||
In addition, ``collaborative_call_once`` allows other thread blocked on
|
||||
the same ``collaborative_once_flag`` to join other |short_name|
|
||||
parallel constructions called within the initializing function.
|
||||
|
||||
|
||||
.. container:: section
|
||||
|
||||
|
||||
.. rubric:: Example
|
||||
:class: sectiontitle
|
||||
|
||||
This example illustrates the implementation of lazy initialization
|
||||
for the calculation of the Fibonacci numbers. Here is a graphical
|
||||
representation of the Fibonacci recursion tree for N=4.
|
||||
|
||||
|
||||
|image0|
|
||||
|
||||
|
||||
As seen in the diagram, some elements are recalculated more than once. These operations are redundant,
|
||||
so the "lazy initialized" Fibonacci numbers are relevant here.
|
||||
|
||||
|
||||
An implementation without the use of lazy initialization would have *O(2^N)* time complexity due to
|
||||
the full recursion tree traversal and recalculation of values. Since all the nodes are traversed once,
|
||||
the tree becomes a list, making the time complexity *O(N)*.
|
||||
|
||||
|
||||
|image1|
|
||||
|
||||
|
||||
Here you can see the code for the implementation. Already calculated values are stored in a buffer
|
||||
paired with ``collaborative_once_flag`` and will not be recalculated when ``collaborative_call_once``
|
||||
is invoked when initialization has already been done.
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
using FibBuffer = std::vector<std::pair<oneapi::tbb::collaborative_once_flag, std::uint64_t>>;
|
||||
|
||||
std::uint64_t LazyFibHelper(int n, FibBuffer& buffer) {
|
||||
// Base case
|
||||
if (n <= 1) {
|
||||
return n;
|
||||
}
|
||||
// Calculate nth value only once and store it in the buffer.
|
||||
// Other threads won't be blocked on already taken collaborative_once_flag
|
||||
// but join parallelism inside functor
|
||||
oneapi::tbb::collaborative_call_once(buffer[n].first, [&]() {
|
||||
std::uint64_t a, b;
|
||||
oneapi::tbb::parallel_invoke([&] { a = LazyFibHelper(n - 2, buffer); },
|
||||
[&] { b = LazyFibHelper(n - 1, buffer); });
|
||||
buffer[n].second = a + b;
|
||||
});
|
||||
|
||||
return buffer[n].second;
|
||||
}
|
||||
|
||||
std::uint64_t Fib(int n) {
|
||||
FibBuffer buffer(n+1);
|
||||
return LazyFibHelper(n, buffer);
|
||||
}
|
||||
|
||||
|
||||
.. |image0| image:: Images/image008a.jpg
|
||||
:width: 744px
|
||||
:height: 367px
|
||||
.. |image1| image:: Images/image009a.jpg
|
||||
:width: 744px
|
||||
:height: 367px
|
||||
@@ -9,8 +9,7 @@ You may not always want to block the main application thread by calling
|
||||
wait_for_all(). However, it is safest to call wait_for_all on a graph
|
||||
before destroying it. A common solution is to enqueue a task to build
|
||||
and wait for the graph to complete. For example, assume you really do
|
||||
not want to call a wait_for_all in the example from `Always Use
|
||||
wait_for_all() <always_use_wait_for_all.html#always_use_wait4all>`__,
|
||||
not want to call a wait_for_all in the example from :ref:`always_use_wait_for_all`,
|
||||
Instead you can enqueue a task that creates the graph and waits for it:
|
||||
|
||||
|
||||
|
||||
@@ -120,11 +120,5 @@ 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
|
||||
.. include:: parallel_for_toctree.rst
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
.. _parallel_for_toctree:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
|
||||
../tbb_userguide/Lambda_Expressions
|
||||
../tbb_userguide/Automatic_Chunking
|
||||
../tbb_userguide/Controlling_Chunking_os
|
||||
../tbb_userguide/Bandwidth_and_Cache_Affinity_os
|
||||
../tbb_userguide/Partitioner_Summary
|
||||
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
Copyright (c) 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.
|
||||
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.
|
||||
*/
|
||||
|
||||
/* 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>
|
||||
|
||||
using namespace tbb::flow;
|
||||
|
||||
//! Example shows how to set the most performant core type as the preferred one
|
||||
//! for a graph execution.
|
||||
static void flow_graph_attach_to_arena_1() {
|
||||
/*begin_attach_to_arena_1*/
|
||||
std::vector<tbb::core_type_id> core_types = tbb::info::core_types();
|
||||
tbb::task_arena arena(
|
||||
tbb::task_arena::constraints{}.set_core_type(core_types.back())
|
||||
);
|
||||
|
||||
arena.execute( [&]() {
|
||||
graph g;
|
||||
function_node< int > f( g, unlimited, []( int ) {
|
||||
/*the most performant core type is defined as preferred.*/
|
||||
} );
|
||||
f.try_put(1);
|
||||
g.wait_for_all();
|
||||
} );
|
||||
/*end_attach_to_arena_1*/
|
||||
}
|
||||
|
||||
//! Reattach existing graph to an arena with the most performant core type as
|
||||
//! the preferred one for a work execution.
|
||||
static void flow_graph_attach_to_arena_2() {
|
||||
/*begin_attach_to_arena_2*/
|
||||
graph g;
|
||||
function_node< int > f( g, unlimited, []( int ) {
|
||||
/*the most performant core type is defined as preferred.*/
|
||||
} );
|
||||
|
||||
std::vector<tbb::core_type_id> core_types = tbb::info::core_types();
|
||||
tbb::task_arena arena(
|
||||
tbb::task_arena::constraints{}.set_core_type(core_types.back())
|
||||
);
|
||||
|
||||
arena.execute( [&]() {
|
||||
g.reset();
|
||||
} );
|
||||
f.try_put(1);
|
||||
g.wait_for_all();
|
||||
/*end_attach_to_arena_2*/
|
||||
}
|
||||
|
||||
int main() {
|
||||
flow_graph_attach_to_arena_1();
|
||||
flow_graph_attach_to_arena_2();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
:maxdepth: 4
|
||||
|
||||
../tbb_userguide/Package_Contents
|
||||
../tbb_userguide/Parallelizing_Simple_Loops
|
||||
../tbb_userguide/Parallelizing_Simple_Loops_os
|
||||
../tbb_userguide/Parallelizing_Complex_Loops
|
||||
../tbb_userguide/Flow_Graph
|
||||
../tbb_userguide/work_isolation
|
||||
|
||||
@@ -7,8 +7,7 @@ Use graph::reset() to Reset a Canceled Graph
|
||||
When a graph execution is canceled either because of an unhandled
|
||||
exception or because its task_group_context is canceled explicitly, the
|
||||
graph and its nodes may be left in an indeterminate state. For example,
|
||||
in the code samples shown in `Cancel a Graph
|
||||
Explicitly <cancel_a_graph.html#cancel_a_graph>`__ the input 2 may be
|
||||
in the code samples shown in :ref:`cancel_a_graph` the input 2 may be
|
||||
left in a buffer. But even beyond remnants in the buffers, there are
|
||||
other optimizations performed during the execution of a flow graph that
|
||||
can leave its nodes and edges in an indeterminate state. If you want to
|
||||
|
||||
@@ -29,8 +29,7 @@ All ``input_node`` objects are constructed in the inactive state and usually
|
||||
activated after the entire flow graph is constructed.
|
||||
|
||||
|
||||
For example, you can use the code in `Data Flow
|
||||
Graph <Data_Flow_Graph.html#Data_Flow_Graph>`__. In that implementation,
|
||||
For example, you can use the code in :ref:`Data_Flow_Graph`. In that implementation,
|
||||
the ``input_node`` is constructed in the inactive state and activated after
|
||||
all other edges are made:
|
||||
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
@ECHO OFF
|
||||
|
||||
rem ============================================================================
|
||||
rem Copyright (C) 2022 Intel Corporation
|
||||
rem
|
||||
rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
rem you may not use this file except in compliance with the License.
|
||||
rem You may obtain a copy of the License at
|
||||
rem
|
||||
rem http://www.apache.org/licenses/LICENSE-2.0
|
||||
rem
|
||||
rem Unless required by applicable law or agreed to in writing, software
|
||||
rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
rem See the License for the specific language governing permissions and
|
||||
rem limitations under the License.
|
||||
rem ============================================================================
|
||||
|
||||
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set SOURCEDIR=doc
|
||||
set BUILDDIR=build
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
%SPHINXBUILD% >NUL 2>NUL
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.http://sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
goto end
|
||||
|
||||
:help
|
||||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
|
||||
:end
|
||||
popd
|
||||
@@ -121,6 +121,7 @@ if (NOT _find_index EQUAL -1)
|
||||
elseif ("${EXAMPLES_UI_MODE}" STREQUAL "x")
|
||||
set_x_ui_project_settings()
|
||||
endif()
|
||||
target_compile_options(UI_LIB_${PROJECT_NAME} PRIVATE ${TBB_CXX_STD_FLAG})
|
||||
endif()
|
||||
|
||||
unset(_available_ui_modes)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2005-2021 Intel Corporation
|
||||
Copyright (c) 2005-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.
|
||||
@@ -19,9 +19,9 @@
|
||||
|
||||
#include "video.hpp"
|
||||
|
||||
unsigned int *g_pImg = 0;
|
||||
unsigned int *g_pImg = nullptr;
|
||||
int g_sizex, g_sizey;
|
||||
static video *g_video = 0;
|
||||
static video *g_video = nullptr;
|
||||
static int g_fps = 0;
|
||||
|
||||
#if _WIN32 || _WIN64
|
||||
@@ -52,7 +52,7 @@ video::video()
|
||||
red_mask(0xff),
|
||||
green_mask(0xff00),
|
||||
blue_mask(0xff0000) {
|
||||
assert(g_video == 0);
|
||||
assert(g_video == nullptr);
|
||||
g_video = this;
|
||||
title = "Video";
|
||||
updating = calc_fps = false;
|
||||
@@ -87,12 +87,11 @@ void video::terminate() {
|
||||
printf("%s: %.1f fps\n", title, fps);
|
||||
}
|
||||
#endif
|
||||
g_video = 0;
|
||||
g_video = nullptr;
|
||||
running = false;
|
||||
if (g_pImg) {
|
||||
delete[] g_pImg;
|
||||
g_pImg = 0;
|
||||
}
|
||||
|
||||
delete[] g_pImg;
|
||||
g_pImg = nullptr;
|
||||
}
|
||||
|
||||
video::~video() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2005-2021 Intel Corporation
|
||||
Copyright (c) 2005-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.
|
||||
@@ -59,7 +59,7 @@ void DrawBitmap() {
|
||||
if (m_pRenderTarget) {
|
||||
m_pRenderTarget->BeginDraw();
|
||||
if (m_pBitmap)
|
||||
hr = m_pBitmap->CopyFromMemory(NULL, (BYTE *)g_pImg, 4 * g_sizex);
|
||||
hr = m_pBitmap->CopyFromMemory(nullptr, (BYTE *)g_pImg, 4 * g_sizex);
|
||||
DisplayError("DrawBitmap error", hr);
|
||||
m_pRenderTarget->DrawBitmap(m_pBitmap);
|
||||
m_pRenderTarget->EndDraw();
|
||||
@@ -82,7 +82,7 @@ LRESULT CALLBACK InternalWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lPa
|
||||
// Check to make sure our window exists before we tell it to repaint.
|
||||
// This will fail the first time (while the window is being created).
|
||||
if (hwnd) {
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
InvalidateRect(hwnd, nullptr, FALSE);
|
||||
UpdateWindow(hwnd);
|
||||
}
|
||||
return 0L;
|
||||
@@ -162,12 +162,11 @@ void video::terminate() {
|
||||
m_pRenderTarget->Release();
|
||||
if (m_pD2DFactory)
|
||||
m_pD2DFactory->Release();
|
||||
g_video = 0;
|
||||
g_video = nullptr;
|
||||
running = false;
|
||||
if (g_pImg) {
|
||||
delete[] g_pImg;
|
||||
g_pImg = 0;
|
||||
}
|
||||
|
||||
delete[] g_pImg;
|
||||
g_pImg = nullptr;
|
||||
}
|
||||
|
||||
//////////// drawing area constructor & destructor /////////////
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2005-2021 Intel Corporation
|
||||
Copyright (c) 2005-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.
|
||||
@@ -40,12 +40,12 @@ bool DisplayError(LPSTR lpstrErr, HRESULT hres) {
|
||||
hres = GetLastError();
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
nullptr,
|
||||
hres,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR)&lpMsgBuf,
|
||||
0,
|
||||
NULL);
|
||||
nullptr);
|
||||
retval = MessageBox(g_hAppWnd, lpstrErr, lpMsgBuf, MB_OK | MB_ICONERROR);
|
||||
LocalFree((HLOCAL)lpMsgBuf);
|
||||
InError = false;
|
||||
@@ -60,7 +60,7 @@ LRESULT CALLBACK InternalWndProc(HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lPa
|
||||
// Check to make sure our window exists before we tell it to repaint.
|
||||
// This will fail the first time (while the window is being created).
|
||||
if (hwnd) {
|
||||
InvalidateRect(hwnd, NULL, FALSE);
|
||||
InvalidateRect(hwnd, nullptr, FALSE);
|
||||
UpdateWindow(hwnd);
|
||||
}
|
||||
return 0L;
|
||||
@@ -114,7 +114,7 @@ bool video::init_window(int sizex, int sizey) {
|
||||
return false;
|
||||
}
|
||||
ShowWindow(g_hAppWnd, SW_SHOW);
|
||||
Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
|
||||
Gdiplus::GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, nullptr);
|
||||
g_pImg = new unsigned int[sizex * sizey];
|
||||
g_pBitmap =
|
||||
new Gdiplus::Bitmap(g_sizex, g_sizey, 4 * g_sizex, PixelFormat32bppRGB, (BYTE*)g_pImg);
|
||||
@@ -123,17 +123,15 @@ bool video::init_window(int sizex, int sizey) {
|
||||
}
|
||||
|
||||
void video::terminate() {
|
||||
if (g_pBitmap) {
|
||||
delete g_pBitmap;
|
||||
g_pBitmap = 0;
|
||||
}
|
||||
delete g_pBitmap;
|
||||
g_pBitmap = nullptr;
|
||||
|
||||
Gdiplus::GdiplusShutdown(gdiplusToken);
|
||||
g_video = 0;
|
||||
g_video = nullptr;
|
||||
running = false;
|
||||
if (g_pImg) {
|
||||
delete[] g_pImg;
|
||||
g_pImg = 0;
|
||||
}
|
||||
|
||||
delete[] g_pImg;
|
||||
g_pImg = nullptr;
|
||||
}
|
||||
|
||||
//////////// drawing area constructor & destructor /////////////
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2005-2021 Intel Corporation
|
||||
Copyright (c) 2005-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.
|
||||
@@ -20,11 +20,11 @@
|
||||
#include <iostream>
|
||||
#include <pthread.h>
|
||||
|
||||
unsigned int *g_pImg = 0;
|
||||
unsigned int *g_pImg = nullptr;
|
||||
int g_sizex = 0, g_sizey = 0;
|
||||
static video *g_video = 0;
|
||||
static video *g_video = nullptr;
|
||||
static int g_fps = 0;
|
||||
char *window_title = NULL;
|
||||
char *window_title = nullptr;
|
||||
#define WINDOW_TITLE_SIZE 256
|
||||
int cocoa_update = 0;
|
||||
|
||||
@@ -51,7 +51,7 @@ video::video()
|
||||
blue_mask(0xff)
|
||||
#endif
|
||||
{
|
||||
assert(g_video == 0);
|
||||
assert(g_video == nullptr);
|
||||
g_video = this;
|
||||
title = "Video";
|
||||
cocoa_update = 1;
|
||||
@@ -63,7 +63,7 @@ bool video::init_window(int x, int y) {
|
||||
g_sizex = x;
|
||||
g_sizey = y;
|
||||
g_pImg = new unsigned int[x * y];
|
||||
if (window_title == NULL)
|
||||
if (window_title == nullptr)
|
||||
window_title = (char *)malloc(WINDOW_TITLE_SIZE);
|
||||
strncpy(window_title, title, WINDOW_TITLE_SIZE - 1);
|
||||
running = true;
|
||||
@@ -85,12 +85,11 @@ void video::terminate() {
|
||||
(g_time.tv_sec + 1.0 * g_time.tv_usec / 1000000.0);
|
||||
printf("%s: %.1f fps\n", title, fps);
|
||||
}
|
||||
g_video = 0;
|
||||
g_video = nullptr;
|
||||
running = false;
|
||||
if (g_pImg) {
|
||||
delete[] g_pImg;
|
||||
g_pImg = 0;
|
||||
}
|
||||
|
||||
delete[] g_pImg;
|
||||
g_pImg = nullptr;
|
||||
}
|
||||
|
||||
video::~video() {
|
||||
@@ -151,9 +150,9 @@ void video::main_loop() {
|
||||
pthread_t handle;
|
||||
pthread_attr_t attr;
|
||||
pthread_attr_init(&attr);
|
||||
pthread_create(&handle, &attr, &thread_func, (void *)NULL);
|
||||
pthread_create(&handle, &attr, &thread_func, (void *)nullptr);
|
||||
pthread_detach(handle);
|
||||
cocoa_main(0, NULL);
|
||||
cocoa_main(0, nullptr);
|
||||
}
|
||||
|
||||
//! Change window title
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2005-2021 Intel Corporation
|
||||
Copyright (c) 2005-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.
|
||||
@@ -73,7 +73,7 @@ bool WinInit(HINSTANCE hInstance,
|
||||
}
|
||||
else {
|
||||
memset(&wndclass, 0, sizeof(wndclass));
|
||||
wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
|
||||
wndclass.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
||||
wndclass.lpszClassName = title;
|
||||
}
|
||||
wndclass.cbSize = sizeof(wndclass);
|
||||
@@ -99,11 +99,11 @@ bool WinInit(HINSTANCE hInstance,
|
||||
0, // Initial y pos: not used here
|
||||
g_sizex + xaddend, // Initial x size
|
||||
g_sizey + yaddend, // Initial y size
|
||||
NULL, // parent window handle
|
||||
NULL, // window menu handle
|
||||
nullptr, // parent window handle
|
||||
nullptr, // window menu handle
|
||||
hInstance, // program instance handle
|
||||
NULL); // Creation parameters
|
||||
return g_hAppWnd != NULL;
|
||||
nullptr); // Creation parameters
|
||||
return g_hAppWnd != nullptr;
|
||||
}
|
||||
|
||||
//! create console window with redirection
|
||||
@@ -127,7 +127,7 @@ static bool RedirectIOToConsole(void) {
|
||||
return false;
|
||||
fp = _fdopen(hConHandle, "w");
|
||||
*stdout = *fp;
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
setvbuf(stdout, nullptr, _IONBF, 0);
|
||||
|
||||
// redirect unbuffered STDERR to the console
|
||||
lStdHandle = (size_t)GetStdHandle(STD_ERROR_HANDLE);
|
||||
@@ -135,7 +135,7 @@ static bool RedirectIOToConsole(void) {
|
||||
if (hConHandle > 0) {
|
||||
fp = _fdopen(hConHandle, "w");
|
||||
*stderr = *fp;
|
||||
setvbuf(stderr, NULL, _IONBF, 0);
|
||||
setvbuf(stderr, nullptr, _IONBF, 0);
|
||||
}
|
||||
|
||||
// redirect unbuffered STDIN to the console
|
||||
@@ -144,7 +144,7 @@ static bool RedirectIOToConsole(void) {
|
||||
if (hConHandle > 0) {
|
||||
fp = _fdopen(hConHandle, "r");
|
||||
*stdin = *fp;
|
||||
setvbuf(stdin, NULL, _IONBF, 0);
|
||||
setvbuf(stdin, nullptr, _IONBF, 0);
|
||||
}
|
||||
|
||||
// make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog
|
||||
@@ -229,7 +229,7 @@ static bool loop_once(video *v) {
|
||||
}
|
||||
// event processing, including painting
|
||||
MSG msg;
|
||||
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
|
||||
if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) {
|
||||
if (msg.message == WM_QUIT) {
|
||||
v->running = false;
|
||||
return false;
|
||||
@@ -255,7 +255,7 @@ void video::main_loop() {
|
||||
g_msec = GetTickCount();
|
||||
// now, start main process
|
||||
if (threaded) {
|
||||
g_handles[0] = CreateThread(NULL, // LPSECURITY_ATTRIBUTES security_attrs
|
||||
g_handles[0] = CreateThread(nullptr, // LPSECURITY_ATTRIBUTES security_attrs
|
||||
0, // SIZE_T stacksize
|
||||
(LPTHREAD_START_ROUTINE)thread_video,
|
||||
this, // argument
|
||||
@@ -266,7 +266,7 @@ void video::main_loop() {
|
||||
return;
|
||||
}
|
||||
else // harmless race is possible here
|
||||
g_handles[1] = CreateEvent(NULL, false, false, NULL);
|
||||
g_handles[1] = CreateEvent(nullptr, false, false, nullptr);
|
||||
while (running) {
|
||||
while (loop_once(this))
|
||||
;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2005-2021 Intel Corporation
|
||||
Copyright (c) 2005-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.
|
||||
@@ -56,8 +56,8 @@ static Pixmap pixmap = 0;
|
||||
static bool already_called_X_ShmAttach = false;
|
||||
static bool already_advised_about_NOSHMEM_workarounds = false;
|
||||
#endif
|
||||
static char *display_name = NULL;
|
||||
static Display *dpy = NULL;
|
||||
static char *display_name = nullptr;
|
||||
static Display *dpy = nullptr;
|
||||
static Screen *scrn;
|
||||
static Visual *vis;
|
||||
static Colormap cmap;
|
||||
@@ -181,7 +181,7 @@ bool video::init_window(int xsize, int ysize) {
|
||||
sh.flags = PSize | PMinSize | PMaxSize;
|
||||
sh.width = sh.min_width = sh.max_width = xsize;
|
||||
sh.height = sh.min_height = sh.max_height = ysize;
|
||||
XSetStandardProperties(dpy, win, g_video->title, g_video->title, None, NULL, 0, &sh);
|
||||
XSetStandardProperties(dpy, win, g_video->title, g_video->title, None, nullptr, 0, &sh);
|
||||
_XA_WM_DELETE_WINDOW = XInternAtom(dpy, "WM_DELETE_WINDOW", false);
|
||||
XSetWMProtocols(dpy, win, &_XA_WM_DELETE_WINDOW, 1);
|
||||
gc = XCreateGC(dpy, win, 0L, &xgcv);
|
||||
@@ -206,7 +206,7 @@ bool video::init_window(int xsize, int ysize) {
|
||||
g_pImg = (unsigned int *)(shmseginfo.shmaddr = (char *)shmat(shmseginfo.shmid, 0, 0));
|
||||
if (g_pImg == (unsigned int *)-1) {
|
||||
fprintf(stderr, "Warning: Can't attach to shared memory: %s\n", strerror(errno));
|
||||
shmctl(shmseginfo.shmid, IPC_RMID, NULL);
|
||||
shmctl(shmseginfo.shmid, IPC_RMID, nullptr);
|
||||
goto generic;
|
||||
}
|
||||
shmseginfo.readOnly = false;
|
||||
@@ -218,7 +218,7 @@ bool video::init_window(int xsize, int ysize) {
|
||||
err,
|
||||
x_error);
|
||||
shmdt(shmseginfo.shmaddr);
|
||||
shmctl(shmseginfo.shmid, IPC_RMID, NULL);
|
||||
shmctl(shmseginfo.shmid, IPC_RMID, nullptr);
|
||||
goto generic;
|
||||
}
|
||||
already_called_X_ShmAttach = true;
|
||||
@@ -323,7 +323,7 @@ void video::terminate() {
|
||||
g_pImg = 0;
|
||||
}
|
||||
if (shmseginfo.shmid >= 0)
|
||||
shmctl(shmseginfo.shmid, IPC_RMID, NULL);
|
||||
shmctl(shmseginfo.shmid, IPC_RMID, nullptr);
|
||||
#endif
|
||||
if (gc)
|
||||
XFreeGC(dpy, gc);
|
||||
|
||||
@@ -125,8 +125,8 @@ void ParallelEvolution::Run(double execution_time, int nthread) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (pGlobControl)
|
||||
delete pGlobControl;
|
||||
delete pGlobControl;
|
||||
pGlobControl = nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -124,8 +124,8 @@ public:
|
||||
|
||||
~ParallelEvolution() {
|
||||
//! delete global_control object
|
||||
if (m_pGlobControl != nullptr)
|
||||
delete m_pGlobControl;
|
||||
delete m_pGlobControl;
|
||||
m_pGlobControl = nullptr;
|
||||
}
|
||||
virtual void Run(double execution_time, int nthread);
|
||||
virtual void Step();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2005-2021 Intel Corporation
|
||||
Copyright (c) 2005-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.
|
||||
@@ -98,7 +98,7 @@ bool ParseCommandLine(int argc, char* argv[]) {
|
||||
high = strtol(s, &end, 0);
|
||||
low = strtol(s, &end, 0);
|
||||
switch (*end) {
|
||||
case ':': high = strtol(end + 1, 0, 0); break;
|
||||
case ':': high = strtol(end + 1, nullptr, 0); break;
|
||||
case '\0': break;
|
||||
default: PrintUsage(); return false;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2005-2021 Intel Corporation
|
||||
Copyright (c) 2005-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.
|
||||
@@ -167,7 +167,7 @@ bool ParseCmdLine(int argc, char *argv[]) {
|
||||
char *end;
|
||||
gThreadsHigh = gThreadsLow = (int)strtol(argv[0], &end, 0);
|
||||
switch (*end) {
|
||||
case ':': gThreadsHigh = (int)strtol(end + 1, 0, 0); break;
|
||||
case ':': gThreadsHigh = (int)strtol(end + 1, nullptr, 0); break;
|
||||
case '\0': break;
|
||||
default:
|
||||
std::cout << "Unexpected character in thread specifier: " << *end << "\n";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2005-2021 Intel Corporation
|
||||
Copyright (c) 2005-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.
|
||||
@@ -19,9 +19,9 @@
|
||||
|
||||
#include "pover_global.hpp" // for declaration of DEFINE and INIT
|
||||
|
||||
DEFINE Polygon_map_t *gPolymap1 INIT(0);
|
||||
DEFINE Polygon_map_t *gPolymap2 INIT(0);
|
||||
DEFINE Polygon_map_t *gResultMap INIT(0);
|
||||
DEFINE Polygon_map_t *gPolymap1 INIT(nullptr);
|
||||
DEFINE Polygon_map_t *gPolymap2 INIT(nullptr);
|
||||
DEFINE Polygon_map_t *gResultMap INIT(nullptr);
|
||||
|
||||
extern void Usage(int argc, char *argv[]);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2005-2021 Intel Corporation
|
||||
Copyright (c) 2005-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.
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include "pover_global.hpp" // for declaration of DEFINE and INIT
|
||||
|
||||
DEFINE class video *gVideo INIT(0);
|
||||
DEFINE class video *gVideo INIT(nullptr);
|
||||
|
||||
DEFINE int n_next_frame_calls INIT(0);
|
||||
DEFINE int frame_skips INIT(10);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
Copyright (c) 2005-2021 Intel Corporation
|
||||
Copyright (c) 2005-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.
|
||||
@@ -74,7 +74,7 @@ bool global_usegraphics;
|
||||
|
||||
bool silent_mode = false; /* silent mode */
|
||||
|
||||
class tachyon_video *video = 0;
|
||||
class tachyon_video *video = nullptr;
|
||||
|
||||
typedef struct {
|
||||
int foundfilename; /* was a model file name found in the args? */
|
||||
|
||||