Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04309a277e | ||
|
|
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 | ||
|
|
b53726aac7 | ||
|
|
fcb8377bee | ||
|
|
dbccbee9f5 | ||
|
|
edc30c82a1 | ||
|
|
7941f880cb | ||
|
|
8827ea7d1d | ||
|
|
a080baf996 | ||
|
|
9cef57778c | ||
|
|
e279ae19cb | ||
|
|
1098f48187 | ||
|
|
a85a8bd32f | ||
|
|
35147e0021 | ||
|
|
68e075cbb9 | ||
|
|
b3fb839485 | ||
|
|
6164044548 | ||
|
|
8e7f9e14ba | ||
|
|
a3151ce8ac | ||
|
|
43c1805ec6 | ||
|
|
c94904e909 | ||
|
|
c75ed5bf40 | ||
|
|
055cc6eaa0 | ||
|
|
07300f7eab | ||
|
|
a3a6cd638d | ||
|
|
59ac78fa87 | ||
|
|
734f0bc0be | ||
|
|
de8bf52c4a | ||
|
|
c646de018a | ||
|
|
e96dbf4b48 | ||
|
|
94b62cc1d8 | ||
|
|
112076d06c | ||
|
|
4a23d00235 | ||
|
|
a3635ce50b | ||
|
|
fa944e1960 | ||
|
|
3e4ab55091 | ||
|
|
67c1171696 | ||
|
|
c0b91bdba9 | ||
|
|
3a47fb3718 | ||
|
|
3a6580652d | ||
|
|
2ca2a5f206 | ||
|
|
0354fc109f | ||
|
|
4386b0f0cd | ||
|
|
16b6a651a9 | ||
|
|
ec505c7d5a | ||
|
|
e1b24895e6 | ||
|
|
ac3d43b691 | ||
|
|
fbc48b39c6 | ||
|
|
29009a8e51 | ||
|
|
4beec37a1d | ||
|
|
933a38a460 | ||
|
|
64715f43d8 | ||
|
|
2526dcf136 | ||
|
|
b36260b443 | ||
|
|
345a2204ca | ||
|
|
81dd27c4f6 | ||
|
|
55f9b17864 | ||
|
|
3119997522 | ||
|
|
fc9a3bbc78 | ||
|
|
25e2b1dd25 | ||
|
|
4b479c1e0b | ||
|
|
bf1f2ab6eb | ||
|
|
fde1856728 | ||
|
|
16350adcff | ||
|
|
012aea0351 | ||
|
|
c52c62ba78 | ||
|
|
3b04521726 | ||
|
|
fa3268c3df | ||
|
|
5d4a4acf95 | ||
|
|
0063fb3c76 | ||
|
|
d8251013ce | ||
|
|
444fd2bd0f | ||
|
|
3e9e8c9c4d | ||
|
|
c46e2aa03e | ||
|
|
a497817ca0 | ||
|
|
8b6f831c68 | ||
|
|
6aa706d879 | ||
|
|
6caecf9630 | ||
|
|
be66b3a1cf | ||
|
|
478de5b188 | ||
|
|
9e15720bc7 | ||
|
|
4523a7615e | ||
|
|
b15aabb39a | ||
|
|
d86ed7fbaa | ||
|
|
8dcbd5b11b | ||
|
|
49e08aac08 | ||
|
|
51c0b2f742 |
@@ -0,0 +1,19 @@
|
||||
# Copyright (c) 2021 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# DISCLAIMER: Bazel support is community-based. The maintainers do not
|
||||
# use Bazel internally. The Bazel build can have security risks or
|
||||
# optimization gaps.
|
||||
|
||||
build --symlink_prefix=/ # Out of source build
|
||||
@@ -0,0 +1 @@
|
||||
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
|
||||
@@ -0,0 +1,60 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# Copyright (c) 2021 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.
|
||||
|
||||
SCAN_TARGET=$1
|
||||
|
||||
SKIP_PATTERN='*/.github/*'
|
||||
|
||||
# Ignored cases
|
||||
IGNORE_COMMAND="sed -e /.*\\sOd\\s*=.*/d \
|
||||
-e /.*\\sOt\\s*=.*/d \
|
||||
-e /.*\\siff\\s*=.*/d \
|
||||
-e /.*\\sith\\s*=.*/d \
|
||||
-e /.*\\scas\\s*=.*/d \
|
||||
-e /.*\\sCAS\\s*=.*/d \
|
||||
-e /.*\\ssom\\s*=.*/d \
|
||||
-e /.*\\sSOM\\s*=.*/d \
|
||||
-e /.*\\suint\\s*=.*/d \
|
||||
-e /.*\\sUINT\\s*=.*/d \
|
||||
-e /.*\\scopyable\\s*=.*/d \
|
||||
-e /.*\\sCopyable\\s*=.*/d \
|
||||
-e /.*\\sFo\\s*=.*/d \
|
||||
-e /.*pipeline_filters.h.*nd\\s*=.*/d \
|
||||
-e /.*ittnotify.h.*unx\\s*=.*/d \
|
||||
-e /.*bzlib.cpp.*MSDOS\\s*=.*/d \
|
||||
-e /.*test_task.cpp.*tE\\s*=.*/d \
|
||||
-e /.*backend.cpp.*resSize\\s*=.*/d \
|
||||
-e /.*test_join_node.h.*Ned\\s*=.*/d \
|
||||
-e /.*test_indexer_node.cpp.*OT\\s*=.*/d \
|
||||
-e /.*allocator_stl_test_common.h.*Aci*\\s*=.*/d \
|
||||
-e /.*seismic_video.cpp.*DialogBox\\s*=.*/d \
|
||||
-e /.*test_composite_node.cpp.*que\\s*=.*/d \
|
||||
-e /.*blocksort.cpp.*hiSt\\s*=.*/d \
|
||||
-e /.*compress.cpp.*fave\\s*=.*/d \
|
||||
-e /.*count_strings.cpp.*ue\\s*=.*/d \
|
||||
-e /.*count_strings.cpp.*nd\\s*=.*/d \
|
||||
-e /.*count_strings.cpp.*ths\\s*=.*/d \
|
||||
-e /.*polygon_overlay\/README.md.*ist\\s*=.*/d \
|
||||
-e /.*_pipeline_filters.h.*nd\\s*=.*/d \
|
||||
-e /.*sub_string_finder\/README.md.*ba\\s*=.*/d"
|
||||
|
||||
SCAN_RESULT=`codespell --quiet-level=2 --skip "${SKIP_PATTERN}" ${SCAN_TARGET}`
|
||||
SCAN_RESULT=`echo -e "${SCAN_RESULT}" | ${IGNORE_COMMAND}`
|
||||
echo "${SCAN_RESULT}"
|
||||
|
||||
if [[ ! -z ${SCAN_RESULT} ]]; then
|
||||
exit 1
|
||||
fi
|
||||
@@ -0,0 +1,338 @@
|
||||
# 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.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
name: oneTBB CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
|
||||
pull_request:
|
||||
branches: [master]
|
||||
types:
|
||||
- opened
|
||||
- synchronize
|
||||
- reopened
|
||||
|
||||
env:
|
||||
BUILD_CONCURRENCY: 2
|
||||
MACOS_BUILD_CONCURRENCY: 3
|
||||
TEST_TIMEOUT: 180
|
||||
|
||||
jobs:
|
||||
codespell:
|
||||
runs-on: [ubuntu-20.04]
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run scan
|
||||
run: |
|
||||
sudo apt update && sudo apt install -y codespell
|
||||
${GITHUB_WORKSPACE}/.github/scripts/codespell.sh `pwd`
|
||||
|
||||
examples_clang-format:
|
||||
runs-on: [ubuntu-20.04]
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- 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-10 -style=file -i {} \;
|
||||
diff -r examples examples_formatted
|
||||
|
||||
documentation:
|
||||
needs: [codespell]
|
||||
env:
|
||||
BUILD_TYPE: oss
|
||||
runs-on: [ubuntu-20.04]
|
||||
timeout-minutes: 10
|
||||
steps:
|
||||
- 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 html
|
||||
tar -czvf html.tar.gz html/
|
||||
- name: Save docs
|
||||
uses: actions/upload-artifact@v2.2.1
|
||||
with:
|
||||
name: oneTBB-html-docs-${{ env.GITHUB_SHA_SHORT }}
|
||||
path: html.tar.gz
|
||||
|
||||
pages:
|
||||
if: ${{ github.ref == 'refs/heads/master' }}
|
||||
runs-on: ubuntu-latest
|
||||
needs: [documentation]
|
||||
steps:
|
||||
- name: Checkout gh-pages
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
ref: gh-pages
|
||||
path: gh-pages
|
||||
- name: Set env
|
||||
run: echo GITHUB_SHA_SHORT=${GITHUB_SHA::8} >> $GITHUB_ENV
|
||||
- name: Download documetation
|
||||
uses: actions/download-artifact@v2
|
||||
with:
|
||||
name: oneTBB-html-docs-${{ env.GITHUB_SHA_SHORT }}
|
||||
- name: Publish to github pages
|
||||
run: |
|
||||
tar -xvf html.tar.gz
|
||||
cd gh-pages
|
||||
rm -rf *
|
||||
touch .nojekyll # https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/
|
||||
cp -r ../html/* .
|
||||
git config user.name github-actions
|
||||
git config user.email github-actions@github.com
|
||||
git add .
|
||||
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
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run testing
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
cmake -DTBB4PY_BUILD=ON -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc ..
|
||||
make VERBOSE=1 -j${BUILD_CONCURRENCY} python_build
|
||||
ctest -R python_test --output-on-failure --timeout ${TEST_TIMEOUT}
|
||||
|
||||
linux-testing:
|
||||
name: ${{ matrix.os }}_${{ matrix.cxx_compiler }}_cxx${{ matrix.std }}_${{ matrix.build_type }}_preview=${{ matrix.preview }}
|
||||
runs-on: ['${{ matrix.os }}']
|
||||
timeout-minutes: 45
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-18.04
|
||||
c_compiler: gcc
|
||||
cxx_compiler: g++
|
||||
std: 14
|
||||
build_type: relwithdebinfo
|
||||
preview: 'OFF'
|
||||
- os: ubuntu-20.04
|
||||
c_compiler: gcc
|
||||
cxx_compiler: g++
|
||||
std: 17
|
||||
build_type: release
|
||||
preview: 'ON'
|
||||
- os: ubuntu-20.04
|
||||
c_compiler: gcc-10
|
||||
cxx_compiler: g++-10
|
||||
std: 20
|
||||
build_type: debug
|
||||
preview: 'ON'
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run testing
|
||||
shell: bash
|
||||
run: |
|
||||
set -x
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_CXX_STANDARD=${{ matrix.std }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
|
||||
-DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} -DTBB_CPF=${{ matrix.preview }} ..
|
||||
make VERBOSE=1 -j${BUILD_CONCURRENCY}
|
||||
ctest --timeout ${TEST_TIMEOUT} --output-on-failure
|
||||
|
||||
macos-testing:
|
||||
name: ${{ matrix.os }}_${{ matrix.cxx_compiler }}_cxx${{ matrix.std }}_${{ matrix.build_type }}_preview=${{ matrix.preview }}
|
||||
runs-on: ['${{ matrix.os }}']
|
||||
timeout-minutes: 45
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: macos-10.15
|
||||
c_compiler: clang
|
||||
cxx_compiler: clang++
|
||||
std: 14
|
||||
build_type: relwithdebinfo
|
||||
preview: 'ON'
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run testing
|
||||
shell: bash
|
||||
run: |
|
||||
set -x
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_CXX_STANDARD=${{ matrix.std }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
|
||||
-DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} -DTBB_CPF=${{ matrix.preview }} ..
|
||||
make VERBOSE=1 -j${MACOS_BUILD_CONCURRENCY}
|
||||
ctest --timeout ${TEST_TIMEOUT} --output-on-failure
|
||||
|
||||
windows-testing:
|
||||
name: ${{ matrix.job_name }}
|
||||
runs-on: ['${{ matrix.os }}']
|
||||
timeout-minutes: 45
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: windows-2019
|
||||
generator: Visual Studio 16 2019
|
||||
c_compiler: cl
|
||||
cxx_compiler: cl
|
||||
std: 14
|
||||
build_type: relwithdebinfo
|
||||
preview: 'ON'
|
||||
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_cl2022_cxx17_relwithdebinfo_preview=OFF
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run testing
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -G "${{ matrix.generator }}" -A x64 -DCMAKE_CXX_STANDARD=${{ matrix.std }} `
|
||||
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} `
|
||||
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} -DTBB_CPF=${{ matrix.preview }} ..
|
||||
cmake --build . --config ${{ matrix.build_type }} -j -v
|
||||
ctest -C ${{ matrix.build_type }} --timeout ${env:TEST_TIMEOUT} --output-on-failure
|
||||
|
||||
linux-examples-testing:
|
||||
name: examples_${{ matrix.os }}_${{ matrix.cxx_compiler }}_cxx${{ matrix.std }}_${{ matrix.build_type }}_preview=${{ matrix.preview }}
|
||||
runs-on: ['${{ matrix.os }}']
|
||||
timeout-minutes: 20
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: ubuntu-18.04
|
||||
c_compiler: gcc
|
||||
cxx_compiler: g++
|
||||
std: 14
|
||||
build_type: relwithdebinfo
|
||||
preview: 'OFF'
|
||||
- os: ubuntu-20.04
|
||||
c_compiler: gcc
|
||||
cxx_compiler: g++
|
||||
std: 17
|
||||
build_type: release
|
||||
preview: 'ON'
|
||||
- os: ubuntu-20.04
|
||||
c_compiler: gcc-10
|
||||
cxx_compiler: g++-10
|
||||
std: 20
|
||||
build_type: debug
|
||||
preview: 'ON'
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run testing
|
||||
shell: bash
|
||||
run: |
|
||||
set -x
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_CXX_STANDARD=${{ matrix.std }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
|
||||
-DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
|
||||
-DTBB_CPF=${{ matrix.preview }} -DTBB_TEST=OFF -DTBB_EXAMPLES=ON ..
|
||||
cmake --build . -v --target light_test_examples
|
||||
|
||||
macos-examples-testing:
|
||||
name: examples_${{ matrix.os }}_${{ matrix.cxx_compiler }}_cxx${{ matrix.std }}_${{ matrix.build_type }}_preview=${{ matrix.preview }}
|
||||
runs-on: ['${{ matrix.os }}']
|
||||
timeout-minutes: 20
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- os: macos-10.15
|
||||
c_compiler: clang
|
||||
cxx_compiler: clang++
|
||||
std: 14
|
||||
build_type: relwithdebinfo
|
||||
preview: 'ON'
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run testing
|
||||
shell: bash
|
||||
run: |
|
||||
set -x
|
||||
mkdir build && cd build
|
||||
cmake -DCMAKE_CXX_STANDARD=${{ matrix.std }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
|
||||
-DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} \
|
||||
-DTBB_CPF=${{ matrix.preview }} -DTBB_TEST=OFF -DTBB_EXAMPLES=ON ..
|
||||
cmake --build . -v --target light_test_examples
|
||||
|
||||
windows-examples-testing:
|
||||
name: ${{ matrix.job_name }}
|
||||
runs-on: ['${{ matrix.os }}']
|
||||
timeout-minutes: 20
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- 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_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_cl2022_cxx17_relwithdebinfo_preview=OFF
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Run testing
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -G "${{ matrix.generator }}" -A x64 -DCMAKE_CXX_STANDARD=${{ matrix.std }} `
|
||||
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_CXX_COMPILER=${{ matrix.cxx_compiler }} `
|
||||
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }} -DTBB_CPF=${{ matrix.preview }} -DTBB_TEST=OFF -DTBB_EXAMPLES=ON ..
|
||||
cmake --build . -v --target light_test_examples
|
||||
@@ -53,6 +53,8 @@ __pycache__/
|
||||
# -------- IDE --------
|
||||
.vscode/*
|
||||
.vs/*
|
||||
out/*
|
||||
CMakeSettings.json
|
||||
|
||||
# -------- CTags --------
|
||||
.tags
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
# 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.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# DISCLAIMER: Bazel support is community-based. The maintainers do not
|
||||
# use Bazel internally. The Bazel build can have security risks or
|
||||
# optimization gaps.
|
||||
|
||||
package(
|
||||
default_visibility = ["//visibility:public"],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "tbb",
|
||||
srcs = glob([
|
||||
"src/tbb/*.cpp",
|
||||
"src/tbb/*.h",
|
||||
]) + select({
|
||||
"@platforms//cpu:x86_64": glob(["src/tbb/tools_api/**/*.h"]),
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
hdrs = glob([
|
||||
"include/tbb/*.h",
|
||||
"include/oneapi/*.h",
|
||||
"include/oneapi/tbb/*.h",
|
||||
"include/oneapi/tbb/detail/*.h",
|
||||
]),
|
||||
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",
|
||||
],
|
||||
linkopts =
|
||||
select({
|
||||
"@bazel_tools//platforms:windows": [],
|
||||
"@bazel_tools//platforms:linux": [
|
||||
"-ldl",
|
||||
"-pthread",
|
||||
"-lrt",
|
||||
],
|
||||
"//conditions:default": ["-pthread"],
|
||||
}),
|
||||
local_defines = select({
|
||||
"@platforms//cpu:x86_64": [
|
||||
"__TBB_USE_ITT_NOTIFY",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}) + [
|
||||
"__TBB_BUILD",
|
||||
],
|
||||
textual_hdrs = select({
|
||||
"@platforms//cpu:x86_64": [
|
||||
"src/tbb/tools_api/ittnotify_static.c",
|
||||
],
|
||||
"//conditions:default": [],
|
||||
}),
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "tbbmalloc",
|
||||
srcs =
|
||||
glob([
|
||||
"src/tbbmalloc/*.h",
|
||||
"src/tbb/*.h",
|
||||
"src/tbbmalloc_proxy/*.h",
|
||||
]) + [
|
||||
"src/tbbmalloc/backend.cpp",
|
||||
"src/tbbmalloc/backref.cpp",
|
||||
"src/tbbmalloc/frontend.cpp",
|
||||
"src/tbbmalloc/large_objects.cpp",
|
||||
"src/tbbmalloc/tbbmalloc.cpp",
|
||||
],
|
||||
hdrs = glob([
|
||||
"include/tbb/*.h",
|
||||
"include/oneapi/tbb/detail/*.h",
|
||||
"include/oneapi/tbb/*.h",
|
||||
]),
|
||||
includes = [
|
||||
"include",
|
||||
],
|
||||
local_defines = [
|
||||
"__TBBMALLOC_BUILD",
|
||||
],
|
||||
)
|
||||
|
||||
cc_library(
|
||||
name = "tbbmalloc_proxy",
|
||||
srcs = [
|
||||
"src/tbbmalloc_proxy/function_replacement.cpp",
|
||||
"src/tbbmalloc_proxy/proxy.cpp",
|
||||
],
|
||||
deps = [
|
||||
":tbbmalloc",
|
||||
],
|
||||
)
|
||||
@@ -0,0 +1,96 @@
|
||||
# Bazel* build support
|
||||
|
||||
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.
|
||||
|
||||
---
|
||||
**NOTE**
|
||||
|
||||
Bazel is not recommended for use by oneTBB maintainers. Thus, it is not used internally.
|
||||
|
||||
---
|
||||
|
||||
|
||||
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(
|
||||
name = "oneTBB",
|
||||
branch = "master",
|
||||
remote = "https://github.com/oneapi-src/oneTBB/",
|
||||
)
|
||||
```
|
||||
|
||||
In the *WORKSPACE* file, the oneTBB GitHub* repository is fetched.
|
||||
|
||||
_BUILD.bazel_:
|
||||
|
||||
```python
|
||||
cc_binary(
|
||||
name = "Demo",
|
||||
srcs = ["main.cpp"],
|
||||
deps = ["@oneTBB//:tbb"],
|
||||
)
|
||||
```
|
||||
|
||||
The *BUILD* file defines a binary named `Demo` that has a dependency to oneTBB.
|
||||
|
||||
_main.cpp_:
|
||||
|
||||
```c++
|
||||
#include "oneapi/tbb/version.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
std::cout << "Hello from oneTBB "
|
||||
<< TBB_VERSION_MAJOR << "."
|
||||
<< TBB_VERSION_MINOR << "."
|
||||
<< TBB_VERSION_PATCH
|
||||
<< "!" << std::endl;
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
The expected output of this program is the current version of oneTBB.
|
||||
|
||||
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 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.
|
||||
@@ -14,8 +14,6 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.1)
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
# Enable CMake policies
|
||||
|
||||
if (POLICY CMP0091)
|
||||
@@ -30,23 +28,40 @@ if (TBB_WINDOWS_DRIVER AND (NOT ("${CMAKE_MSVC_RUNTIME_LIBRARY}" STREQUAL MultiT
|
||||
message(FATAL_ERROR "Enabled TBB_WINDOWS_DRIVER requires CMAKE_MSVC_RUNTIME_LIBRARY to be set to MultiThreaded or MultiThreadedDebug.")
|
||||
endif()
|
||||
|
||||
# Enable support of minimum supported macOS version flag
|
||||
if (APPLE)
|
||||
if (NOT CMAKE_CXX_OSX_DEPLOYMENT_TARGET_FLAG)
|
||||
set(CMAKE_CXX_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=" CACHE STRING "Minimum macOS version flag")
|
||||
endif()
|
||||
if (NOT CMAKE_C_OSX_DEPLOYMENT_TARGET_FLAG)
|
||||
set(CMAKE_C_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=" CACHE STRING "Minimum macOS version flag")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Until CMake 3.4.0 FindThreads.cmake requires C language enabled.
|
||||
# Enable C language before CXX to avoid possible override of CMAKE_SIZEOF_VOID_P.
|
||||
if (CMAKE_VERSION VERSION_LESS 3.4)
|
||||
enable_language(C)
|
||||
endif()
|
||||
|
||||
file(READ include/tbb/version.h _tbb_version_info)
|
||||
file(READ include/oneapi/tbb/version.h _tbb_version_info)
|
||||
string(REGEX REPLACE ".*#define TBB_VERSION_MAJOR ([0-9]+).*" "\\1" _tbb_ver_major "${_tbb_version_info}")
|
||||
string(REGEX REPLACE ".*#define TBB_VERSION_MINOR ([0-9]+).*" "\\1" _tbb_ver_minor "${_tbb_version_info}")
|
||||
string(REGEX REPLACE ".*#define TBB_VERSION_PATCH ([0-9]+).*" "\\1" _tbb_ver_patch "${_tbb_version_info}")
|
||||
string(REGEX REPLACE ".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1" TBB_INTERFACE_VERSION "${_tbb_version_info}")
|
||||
string(REGEX REPLACE ".*#define __TBB_BINARY_VERSION ([0-9]+).*" "\\1" TBB_BINARY_VERSION "${_tbb_version_info}")
|
||||
set(TBB_BINARY_MINOR_VERSION ${_tbb_ver_minor})
|
||||
set(TBBMALLOC_BINARY_VERSION 2)
|
||||
set(TBBBIND_BINARY_VERSION 3)
|
||||
|
||||
project(TBB VERSION ${_tbb_ver_major}.${_tbb_ver_minor} LANGUAGES CXX)
|
||||
project(TBB VERSION ${_tbb_ver_major}.${_tbb_ver_minor}.${_tbb_ver_patch} LANGUAGES CXX)
|
||||
unset(_tbb_ver_major)
|
||||
unset(_tbb_ver_minor)
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
include(GNUInstallDirs)
|
||||
include(CMakeDependentOption)
|
||||
|
||||
# ---------------------------------------------------------------------------------------------------------
|
||||
# Handle C++ standard version.
|
||||
if (NOT MSVC) # no need to cover MSVC as it uses C++14 by default.
|
||||
@@ -81,12 +96,25 @@ endif()
|
||||
option(TBB_TEST "Enable testing" ON)
|
||||
option(TBB_EXAMPLES "Enable examples" OFF)
|
||||
option(TBB_STRICT "Treat compiler warnings as errors" ON)
|
||||
option(TBB_NUMA_SUPPORT "Enable NUMA support that depends on Portable Hardware Locality (hwloc) library" OFF)
|
||||
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)
|
||||
endif()
|
||||
|
||||
if (NOT BUILD_SHARED_LIBS)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
message(WARNING "You are building oneTBB as a static library. This is highly discouraged and such configuration is not supported. Consider building a dynamic library to avoid unforeseen issues.")
|
||||
endif()
|
||||
|
||||
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
|
||||
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Build type" FORCE)
|
||||
@@ -151,13 +179,27 @@ set(THREADS_PREFER_PTHREAD_FLAG TRUE)
|
||||
find_package(Threads REQUIRED)
|
||||
# -------------------------------------------------------------------
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
|
||||
|
||||
file(GLOB FILES_WITH_EXTRA_TARGETS ${CMAKE_CURRENT_SOURCE_DIR}/cmake/*.cmake)
|
||||
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})
|
||||
@@ -171,11 +213,19 @@ 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 (TBB_NUMA_SUPPORT)
|
||||
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)
|
||||
endif()
|
||||
endif()
|
||||
@@ -184,21 +234,28 @@ else()
|
||||
# Installation instructions
|
||||
include(CMakePackageConfigHelpers)
|
||||
|
||||
install(DIRECTORY include
|
||||
DESTINATION .)
|
||||
install(DIRECTORY include/
|
||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||
COMPONENT devel)
|
||||
|
||||
install(EXPORT ${CMAKE_PROJECT_NAME}Targets
|
||||
install(EXPORT ${PROJECT_NAME}Targets
|
||||
NAMESPACE TBB::
|
||||
DESTINATION lib/cmake/${CMAKE_PROJECT_NAME})
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake
|
||||
"include(\${CMAKE_CURRENT_LIST_DIR}/${CMAKE_PROJECT_NAME}Targets.cmake)\n")
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
|
||||
COMPONENT devel)
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
|
||||
"include(\${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}Targets.cmake)\n")
|
||||
|
||||
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake"
|
||||
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
||||
COMPATIBILITY AnyNewerVersion)
|
||||
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}Config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_PROJECT_NAME}ConfigVersion.cmake"
|
||||
DESTINATION lib/cmake/${CMAKE_PROJECT_NAME})
|
||||
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
|
||||
COMPONENT devel)
|
||||
|
||||
install(FILES "README.md"
|
||||
DESTINATION ${CMAKE_INSTALL_DOCDIR}
|
||||
COMPONENT devel)
|
||||
# -------------------------------------------------------------------
|
||||
endif()
|
||||
|
||||
@@ -221,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,31 +1,53 @@
|
||||
# oneAPI Threading Building Blocks (Beta)
|
||||
[](LICENSE)
|
||||
# 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 documentation](https://software.intel.com/en-us/oneapi-tbb-documentation)
|
||||
* README for build system: [cmake/README.md](cmake/README.md)
|
||||
* [oneTBB Specification](https://spec.oneapi.com/versions/latest/elements/oneTBB/source/nested-index.html)
|
||||
* [oneTBB Developer Guide and Reference](https://oneapi-src.github.io/oneTBB)
|
||||
* [Migrating from TBB to oneTBB](https://oneapi-src.github.io/oneTBB/main/tbb_userguide/Migration_Guide.html)
|
||||
* [README for the CMake build system](cmake/README.md)
|
||||
* [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
|
||||
[TBB forum](http://software.intel.com/en-us/forums/intel-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.
|
||||
oneAPI Threading Building Blocks is licensed under [Apache License, Version 2.0](LICENSE).
|
||||
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.
|
||||
|
||||
|
||||
## 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, 22.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
|
||||
@@ -0,0 +1,19 @@
|
||||
# Copyright (c) 2021 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# DISCLAIMER: Bazel support is community-based. The maintainers do not
|
||||
# use Bazel internally. The Bazel build can have security risks or
|
||||
# optimization gaps.
|
||||
|
||||
workspace(name = "oneTBB")
|
||||
@@ -6,26 +6,25 @@ The following controls are available during the configure stage:
|
||||
```
|
||||
TBB_TEST:BOOL - Enable testing (ON by default)
|
||||
TBB_STRICT:BOOL - Treat compiler warnings as errors (ON by default)
|
||||
TBB_NUMA_SUPPORT:BOOL - Enable TBBBind build target and task_arena extensions for NUMA support (depends on Portable Hardware Locality (hwloc) library) (OFF 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)
|
||||
```
|
||||
|
||||
# Getting Started
|
||||
|
||||
## 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 somewhere and go there:
|
||||
To perform out-of-source build, create a build directory and go there:
|
||||
|
||||
```bash
|
||||
mkdir /tmp/my-build
|
||||
@@ -39,31 +38,75 @@ 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 doesn'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 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* OS or path to `.lib` file on Windows* OS
|
||||
- `CMAKE_HWLOC_<HWLOC_VER>_INCLUDE_PATH` - path to the corresponding HWLOC version including directory
|
||||
|
||||
|
||||
---
|
||||
**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 earlier can be replaced with one of the three values:
|
||||
- `1_11` for the `tbbbind` library configuration
|
||||
- `2` for the `tbbbind_2_0` library configuration
|
||||
- `2_5` for the `tbbbind_2_5` library configuration
|
||||
|
||||
If you specify variables for several TBBBind versions, the building process for all of these versions is performed during single build session.
|
||||
|
||||
---
|
||||
**TIP**
|
||||
|
||||
Specify the `TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH` to disable HWLOC libraries automatic search.
|
||||
|
||||
---
|
||||
|
||||
|
||||
### Build
|
||||
|
||||
```bash
|
||||
cmake --build <options> .
|
||||
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
|
||||
```
|
||||
@@ -73,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 ..
|
||||
@@ -95,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
|
||||
@@ -127,7 +180,21 @@ make -j
|
||||
ctest -V
|
||||
```
|
||||
|
||||
## Test specification (Doxygen)
|
||||
## Valgrind memcheck - configure, build, and run
|
||||
|
||||
### Prerequisites
|
||||
* Valgrind tool executable
|
||||
### Example
|
||||
```bash
|
||||
mkdir build
|
||||
cd build
|
||||
cmake -DTBB_VALGRIND_MEMCHECK=ON ..
|
||||
make -j memcheck-<test name> # or memcheck-all to scan all tests
|
||||
```
|
||||
|
||||
## Test specification
|
||||
|
||||
Use Doxygen to generate oneTBB test specification:
|
||||
|
||||
```bash
|
||||
mkdir build
|
||||
@@ -136,18 +203,50 @@ cmake -DTBB_TEST_SPEC=ON ..
|
||||
make test_spec
|
||||
```
|
||||
|
||||
## Intallation and packaging
|
||||
## TBBConfig - integration of binary packages
|
||||
|
||||
**NOTE: be careful about installation: avoid commands like `make install` unless you fully understand the consequences.**
|
||||
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.
|
||||
|
||||
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:
|
||||
How to use this module in your CMake project:
|
||||
1. Let CMake know where to search for TBBConfig, e.g. specify location of TBBConfig.cmake in `TBB_DIR` (for more details about search paths see [find_package](https://cmake.org/cmake/help/latest/command/find_package.html)).
|
||||
2. Use [find_package](https://cmake.org/cmake/help/latest/command/find_package.html) to find oneTBB.
|
||||
3. Use provided variables and/or imported targets (described below) to work with the found oneTBB.
|
||||
|
||||
```bash
|
||||
cmake <options> ..
|
||||
cpack
|
||||
Example:
|
||||
|
||||
```cmake
|
||||
add_executable(foo foo.cpp)
|
||||
find_package(TBB)
|
||||
target_link_libraries(foo TBB::tbb)
|
||||
```
|
||||
|
||||
oneTBB components can be passed to [find_package](https://cmake.org/cmake/help/latest/command/find_package.html) after keyword ``COMPONENTS`` or ``REQUIRED``.
|
||||
Use basic names of components (`tbb`, `tbbmalloc`, etc.).
|
||||
|
||||
If components are not specified then the default set is used: `tbb`, `tbbmalloc` and ``tbbmalloc_proxy``.
|
||||
|
||||
If `tbbmalloc_proxy` is requested, `tbbmalloc` component will also be added and set as dependency for `tbbmalloc_proxy`.
|
||||
|
||||
TBBConfig creates [imported targets](https://cmake.org/cmake/help/latest/manual/cmake-buildsystem.7.html#imported-targets>) as
|
||||
shared libraries using the following format: `TBB::<component>` (for example, `TBB::tbb`, `TBB::tbbmalloc`).
|
||||
|
||||
Set `TBB_FIND_RELEASE_ONLY` to `TRUE` before calling `find_package` in order to search only for release oneTBB version. This variable helps to avoid simultaneous linkage of release and debug oneTBB versions when CMake configuration is `Debug` but a third-party component depends on release oneTBB version.
|
||||
|
||||
Variables set during TBB configuration:
|
||||
|
||||
Variable | Description
|
||||
--- | ---
|
||||
`TBB_FOUND` | oneTBB is found
|
||||
`TBB_<component>_FOUND` | Specific oneTBB component is found
|
||||
`TBB_VERSION` | oneTBB version (format: `<major>.<minor>.<patch>.<tweak>`)
|
||||
`TBB_IMPORTED_TARGETS` | All created oneTBB imported targets (not supported for builds from source code)
|
||||
|
||||
Starting from [oneTBB 2021.1](https://github.com/oneapi-src/oneTBB/releases/tag/v2021.1) GitHub release TBBConfig files in the binary packages are located under `<tbb-root>/lib/cmake/TBB`.
|
||||
For example, `TBB_DIR` should be set to `<tbb-root>/lib/cmake/TBB`.
|
||||
|
||||
TBBConfig files are automatically created during the build from source code and can be installed together with the library.
|
||||
Also oneTBB provides a helper function that creates TBBConfig files from predefined templates: see `tbb_generate_config` in `cmake/config_generation.cmake`.
|
||||
|
||||
## oneTBB Python Module support
|
||||
`TBB4PY_BUILD` Cmake option provides ability to build Python module for oneTBB.
|
||||
|
||||
@@ -195,6 +294,7 @@ Variable | Description
|
||||
`TBB_LIB_LINK_LIBS ` | Applied to libraries as link libraries
|
||||
`TBB_TEST_COMPILE_FLAGS` | Applied to tests as compile options
|
||||
|
||||
Please specify the `LINK` options prefixed with dash(-) for MSVC(Visual Studio) compiler with CMake < 3.13 to avoid issues caused by `target_link_libraries` CMake command usage.
|
||||
|
||||
#### Specific options
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2020 Intel Corporation
|
||||
# Copyright (c) 2020-2021 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2020 Intel Corporation
|
||||
# Copyright (c) 2020-2021 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2020 Intel Corporation
|
||||
# Copyright (c) 2020-2021 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2020 Intel Corporation
|
||||
# Copyright (c) 2020-2021 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,11 +18,23 @@ set(TBB_WARNING_LEVEL -Wall -Wextra $<$<BOOL:${TBB_STRICT}>:-Werror>)
|
||||
set(TBB_TEST_WARNING_FLAGS -Wshadow -Wcast-qual -Woverloaded-virtual -Wnon-virtual-dtor)
|
||||
set(TBB_WARNING_SUPPRESS -Wno-parentheses -Wno-non-virtual-dtor -Wno-dangling-else)
|
||||
# For correct ucontext.h structures layout
|
||||
set(TBB_LIB_COMPILE_FLAGS -D_XOPEN_SOURCE)
|
||||
set(TBB_BENCH_COMPILE_FLAGS -D_XOPEN_SOURCE)
|
||||
set(TBB_COMMON_COMPILE_FLAGS -D_XOPEN_SOURCE)
|
||||
|
||||
set(TBB_MMD_FLAG -MMD)
|
||||
set(TBB_COMMON_COMPILE_FLAGS -mrtm)
|
||||
# Depfile options (e.g. -MD) are inserted automatically in some cases.
|
||||
# Don't add -MMD to avoid conflicts in such cases.
|
||||
if (NOT CMAKE_GENERATOR MATCHES "Ninja" AND NOT CMAKE_CXX_DEPENDS_USE_COMPILER)
|
||||
set(TBB_MMD_FLAG -MMD)
|
||||
endif()
|
||||
|
||||
# Ignore -Werror set through add_compile_options() or added to CMAKE_CXX_FLAGS if TBB_STRICT is disabled.
|
||||
if (NOT TBB_STRICT AND COMMAND tbb_remove_compile_flag)
|
||||
tbb_remove_compile_flag(-Werror)
|
||||
endif()
|
||||
|
||||
# Enable Intel(R) Transactional Synchronization Extensions (-mrtm) and WAITPKG instructions support (-mwaitpkg) on relevant processors
|
||||
if (NOT "${CMAKE_OSX_ARCHITECTURES}" MATCHES "^arm64$" AND CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64|amd64|AMD64)") # OSX systems are 64-bit only
|
||||
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -mrtm $<$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},12.0>>:-mwaitpkg>)
|
||||
endif()
|
||||
|
||||
# TBB malloc settings
|
||||
set(TBBMALLOC_LIB_COMPILE_FLAGS -fno-rtti -fno-exceptions)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2020 Intel Corporation
|
||||
# Copyright (c) 2020-2021 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -12,28 +12,54 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set(TBB_LINK_DEF_FILE_FLAG -Wl,--version-script=)
|
||||
set(TBB_DEF_FILE_PREFIX lin${TBB_ARCH})
|
||||
set(TBB_MMD_FLAG -MMD)
|
||||
if (MINGW)
|
||||
set(TBB_LINK_DEF_FILE_FLAG "")
|
||||
set(TBB_DEF_FILE_PREFIX "")
|
||||
elseif (APPLE)
|
||||
set(TBB_LINK_DEF_FILE_FLAG -Wl,-exported_symbols_list,)
|
||||
set(TBB_DEF_FILE_PREFIX mac${TBB_ARCH})
|
||||
|
||||
# For correct ucontext.h structures layout
|
||||
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -D_XOPEN_SOURCE)
|
||||
elseif (MSVC)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/MSVC.cmake)
|
||||
return()
|
||||
else()
|
||||
set(TBB_LINK_DEF_FILE_FLAG -Wl,--version-script=)
|
||||
set(TBB_DEF_FILE_PREFIX lin${TBB_ARCH})
|
||||
endif()
|
||||
|
||||
# Depfile options (e.g. -MD) are inserted automatically in some cases.
|
||||
# Don't add -MMD to avoid conflicts in such cases.
|
||||
if (NOT CMAKE_GENERATOR MATCHES "Ninja" AND NOT CMAKE_CXX_DEPENDS_USE_COMPILER)
|
||||
set(TBB_MMD_FLAG -MMD)
|
||||
endif()
|
||||
|
||||
set(TBB_WARNING_LEVEL -Wall -Wextra $<$<BOOL:${TBB_STRICT}>:-Werror>)
|
||||
set(TBB_TEST_WARNING_FLAGS -Wshadow -Wcast-qual -Woverloaded-virtual -Wnon-virtual-dtor)
|
||||
set(TBB_WARNING_SUPPRESS -Wno-parentheses -Wno-non-virtual-dtor -Wno-dangling-else)
|
||||
|
||||
if (CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
|
||||
set(TBB_COMMON_COMPILE_FLAGS -mrtm)
|
||||
# Ignore -Werror set through add_compile_options() or added to CMAKE_CXX_FLAGS if TBB_STRICT is disabled.
|
||||
if (NOT TBB_STRICT AND COMMAND tbb_remove_compile_flag)
|
||||
tbb_remove_compile_flag(-Werror)
|
||||
endif()
|
||||
|
||||
set(TBB_COMMON_LINK_LIBS dl)
|
||||
# Enable Intel(R) Transactional Synchronization Extensions (-mrtm) and WAITPKG instructions support (-mwaitpkg) on relevant processors
|
||||
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(AMD64|amd64|i.86|x86)")
|
||||
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -mrtm $<$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},12.0>>:-mwaitpkg>)
|
||||
endif()
|
||||
|
||||
set(TBB_COMMON_LINK_LIBS ${CMAKE_DL_LIBS})
|
||||
|
||||
set(TBB_WARNING_SUPPRESS -Wno-non-virtual-dtor -Wno-dangling-else)
|
||||
if (ANDROID_PLATFORM)
|
||||
set(TBB_COMMON_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:-D_FORTIFY_SOURCE=2>)
|
||||
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} $<$<NOT:$<CONFIG:Debug>>:-D_FORTIFY_SOURCE=2>)
|
||||
endif()
|
||||
|
||||
if (NOT APPLE)
|
||||
set(TBB_WARNING_SUPPRESS -Wno-parentheses)
|
||||
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>)
|
||||
|
||||
# TBB malloc settings
|
||||
set(TBBMALLOC_LIB_COMPILE_FLAGS -fno-rtti -fno-exceptions)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2020 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.
|
||||
@@ -12,37 +12,62 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
set(TBB_LINK_DEF_FILE_FLAG -Wl,--version-script=)
|
||||
set(TBB_DEF_FILE_PREFIX lin${TBB_ARCH})
|
||||
if (MINGW)
|
||||
set(TBB_LINK_DEF_FILE_FLAG "")
|
||||
set(TBB_DEF_FILE_PREFIX "")
|
||||
elseif (APPLE)
|
||||
set(TBB_LINK_DEF_FILE_FLAG -Wl,-exported_symbols_list,)
|
||||
set(TBB_DEF_FILE_PREFIX mac${TBB_ARCH})
|
||||
|
||||
# For correct ucontext.h structures layout
|
||||
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -D_XOPEN_SOURCE)
|
||||
else()
|
||||
set(TBB_LINK_DEF_FILE_FLAG -Wl,--version-script=)
|
||||
set(TBB_DEF_FILE_PREFIX lin${TBB_ARCH})
|
||||
endif()
|
||||
|
||||
set(TBB_WARNING_LEVEL -Wall -Wextra $<$<BOOL:${TBB_STRICT}>:-Werror> -Wfatal-errors)
|
||||
set(TBB_TEST_WARNING_FLAGS -Wshadow -Wcast-qual -Woverloaded-virtual -Wnon-virtual-dtor)
|
||||
|
||||
set(TBB_MMD_FLAG -MMD)
|
||||
if (CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
|
||||
set(TBB_COMMON_COMPILE_FLAGS -mrtm)
|
||||
# Depfile options (e.g. -MD) are inserted automatically in some cases.
|
||||
# Don't add -MMD to avoid conflicts in such cases.
|
||||
if (NOT CMAKE_GENERATOR MATCHES "Ninja" AND NOT CMAKE_CXX_DEPENDS_USE_COMPILER)
|
||||
set(TBB_MMD_FLAG -MMD)
|
||||
endif()
|
||||
|
||||
set(TBB_COMMON_LINK_LIBS dl)
|
||||
# Enable Intel(R) Transactional Synchronization Extensions (-mrtm) and WAITPKG instructions support (-mwaitpkg) on relevant processors
|
||||
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(AMD64|amd64|i.86|x86)")
|
||||
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -mrtm $<$<AND:$<NOT:$<CXX_COMPILER_ID:Intel>>,$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},11.0>>>:-mwaitpkg>)
|
||||
endif()
|
||||
|
||||
if (NOT MINGW)
|
||||
set(TBB_COMMON_LINK_LIBS dl)
|
||||
endif()
|
||||
|
||||
# Ignore -Werror set through add_compile_options() or added to CMAKE_CXX_FLAGS if TBB_STRICT is disabled.
|
||||
if (NOT TBB_STRICT AND COMMAND tbb_remove_compile_flag)
|
||||
tbb_remove_compile_flag(-Werror)
|
||||
endif()
|
||||
|
||||
if (NOT ${CMAKE_CXX_COMPILER_ID} STREQUAL Intel)
|
||||
# gcc 6.0 and later have -flifetime-dse option that controls elimination of stores done outside the object lifetime
|
||||
set(TBB_DSE_FLAG $<$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},6.0>>:-flifetime-dse=1>)
|
||||
endif()
|
||||
|
||||
if (NOT APPLE)
|
||||
set(TBB_WARNING_SUPPRESS -Wno-parentheses)
|
||||
# gcc 5.0 and later have -Wno-sized-deallocation options
|
||||
set(TBB_WARNING_SUPPRESS ${TBB_WARNING_SUPPRESS}
|
||||
$<$<NOT:$<VERSION_LESS:${CMAKE_CXX_COMPILER_VERSION},5.0>>:-Wno-sized-deallocation>)
|
||||
else()
|
||||
set(TBB_WARNING_SUPPRESS -Wno-non-virtual-dtor)
|
||||
# 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>:-fPIE -mxgot>)
|
||||
set(TBB_TEST_LINK_FLAGS ${TBB_TEST_LINK_FLAGS} $<$<CONFIG:DEBUG>:-pie>)
|
||||
endif()
|
||||
|
||||
# Workaround for heavy tests
|
||||
if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "mips")
|
||||
set(TBB_TEST_COMPILE_FLAGS ${TBB_TEST_COMPILE_FLAGS} -DTBB_TEST_LOW_WORKLOAD)
|
||||
endif()
|
||||
set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>)
|
||||
set(TBB_IPO_LINK_FLAGS $<$<NOT:$<CONFIG:Debug>>:-flto>)
|
||||
|
||||
|
||||
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)
|
||||
|
||||
set(TBB_OPENMP_FLAG -fopenmp)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2020 Intel Corporation
|
||||
# Copyright (c) 2020-2021 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -15,14 +15,22 @@
|
||||
if (MSVC)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/MSVC.cmake)
|
||||
set(TBB_WARNING_LEVEL ${TBB_WARNING_LEVEL} /W3)
|
||||
set(TBB_OPENMP_FLAG /Qopenmp)
|
||||
set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:/Qipo>)
|
||||
set(TBB_IPO_LINK_FLAGS $<$<NOT:$<CONFIG:Debug>>:/INCREMENTAL:NO>)
|
||||
elseif (APPLE)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/AppleClang.cmake)
|
||||
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -fstack-protector -Wformat -Wformat-security
|
||||
$<$<NOT:$<CONFIG:Debug>>:-fno-omit-frame-pointer -qno-opt-report-embed -D_FORTIFY_SOURCE=2>)
|
||||
set(TBB_OPENMP_FLAG -qopenmp)
|
||||
set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:-ipo>)
|
||||
else()
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/GNU.cmake)
|
||||
set(TBB_LIB_LINK_FLAGS ${TBB_LIB_LINK_FLAGS} -static-intel -Wl,-z,relro,-z,now,)
|
||||
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -fstack-protector -Wformat -Wformat-security
|
||||
$<$<NOT:$<CONFIG:Debug>>:-qno-opt-report-embed -D_FORTIFY_SOURCE=2>
|
||||
$<$<EQUAL:${TBB_ARCH},32>:-falign-stack=maintain-16-byte>)
|
||||
set(TBB_OPENMP_FLAG -qopenmp)
|
||||
set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:-ipo>)
|
||||
endif()
|
||||
set(TBB_IPO_LINK_FLAGS ${TBB_IPO_LINK_FLAGS} ${TBB_IPO_COMPILE_FLAGS})
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# Copyright (c) 2020-2021 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.
|
||||
|
||||
if (WIN32)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/MSVC.cmake)
|
||||
set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:/Qipo>)
|
||||
set(TBB_IPO_LINK_FLAGS $<$<NOT:$<CONFIG:Debug>>:/INCREMENTAL:NO>)
|
||||
else()
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/Clang.cmake)
|
||||
set(TBB_IPO_COMPILE_FLAGS $<$<NOT:$<CONFIG:Debug>>:-ipo>)
|
||||
endif()
|
||||
set(TBB_IPO_LINK_FLAGS ${TBB_IPO_LINK_FLAGS} ${TBB_IPO_COMPILE_FLAGS})
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2020 Intel Corporation
|
||||
# Copyright (c) 2020-2021 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,17 +19,30 @@ 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>)
|
||||
set(TBB_WARNING_SUPPRESS /wd4324 /wd4530 /wd4577)
|
||||
set(TBB_TEST_COMPILE_FLAGS /bigobj)
|
||||
set(TBB_LIB_COMPILE_FLAGS -D_CRT_SECURE_NO_WARNINGS /GS)
|
||||
|
||||
set(TBB_COMMON_COMPILE_FLAGS /volatile:iso /FS)
|
||||
# Warning suppression C4324: structure was padded due to alignment specifier
|
||||
set(TBB_WARNING_SUPPRESS /wd4324)
|
||||
|
||||
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.
|
||||
# More info can be found at
|
||||
# https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4503
|
||||
set(TBB_TEST_COMPILE_FLAGS ${TBB_TEST_COMPILE_FLAGS} /wd4503)
|
||||
endif()
|
||||
set(TBB_LIB_COMPILE_FLAGS -D_CRT_SECURE_NO_WARNINGS /GS)
|
||||
set(TBB_COMMON_COMPILE_FLAGS /volatile:iso /FS /EHsc)
|
||||
|
||||
# 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)
|
||||
tbb_remove_compile_flag(/WX)
|
||||
endif()
|
||||
|
||||
if (WINDOWS_STORE OR TBB_WINDOWS_DRIVER)
|
||||
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} /D_WIN32_WINNT=0x0A00)
|
||||
set(TBB_COMMON_LINK_FLAGS /NODEFAULTLIB:kernel32.lib /INCREMENTAL:NO)
|
||||
set(TBB_COMMON_LINK_FLAGS -NODEFAULTLIB:kernel32.lib -INCREMENTAL:NO)
|
||||
set(TBB_COMMON_LINK_LIBS OneCore.lib)
|
||||
endif()
|
||||
|
||||
@@ -44,7 +57,7 @@ if (WINDOWS_STORE)
|
||||
string(REGEX REPLACE "WindowsApp.lib" "" CMAKE_CXX_STANDARD_LIBRARIES "${CMAKE_CXX_STANDARD_LIBRARIES}")
|
||||
|
||||
if (TBB_NO_APPCONTAINER)
|
||||
set(TBB_LIB_LINK_FLAGS ${TBB_LIB_LINK_FLAGS} /APPCONTAINER:NO)
|
||||
set(TBB_LIB_LINK_FLAGS ${TBB_LIB_LINK_FLAGS} -APPCONTAINER:NO)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -57,3 +70,17 @@ 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()
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "(Clang|IntelLLVM)")
|
||||
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86|AMD64|i.86)")
|
||||
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -mrtm -mwaitpkg)
|
||||
endif()
|
||||
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
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2021 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/compilers/GNU.cmake)
|
||||
|
||||
# Remove dl library not present in QNX systems
|
||||
unset(TBB_COMMON_LINK_LIBS)
|
||||
@@ -0,0 +1,131 @@
|
||||
# Copyright (c) 2020-2021 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.
|
||||
|
||||
# Save current location,
|
||||
# see for details: https://cmake.org/cmake/help/latest/variable/CMAKE_CURRENT_LIST_DIR.html
|
||||
set(_tbb_gen_cfg_path ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
function(tbb_generate_config)
|
||||
set(options HANDLE_SUBDIRS)
|
||||
set(oneValueArgs INSTALL_DIR
|
||||
SYSTEM_NAME
|
||||
LIB_REL_PATH INC_REL_PATH DLL_REL_PATH
|
||||
VERSION
|
||||
TBB_BINARY_VERSION
|
||||
TBBMALLOC_BINARY_VERSION
|
||||
TBBMALLOC_PROXY_BINARY_VERSION
|
||||
TBBBIND_BINARY_VERSION)
|
||||
|
||||
cmake_parse_arguments(tbb_gen_cfg "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
get_filename_component(config_install_dir ${tbb_gen_cfg_INSTALL_DIR} ABSOLUTE)
|
||||
file(MAKE_DIRECTORY ${config_install_dir})
|
||||
|
||||
file(TO_CMAKE_PATH "${tbb_gen_cfg_LIB_REL_PATH}" TBB_LIB_REL_PATH)
|
||||
file(TO_CMAKE_PATH "${tbb_gen_cfg_DLL_REL_PATH}" TBB_DLL_REL_PATH)
|
||||
file(TO_CMAKE_PATH "${tbb_gen_cfg_INC_REL_PATH}" TBB_INC_REL_PATH)
|
||||
|
||||
set(TBB_VERSION ${tbb_gen_cfg_VERSION})
|
||||
|
||||
set(_tbb_pc_lib_name tbb)
|
||||
set(_prefix_for_pc_file "\${pcfiledir}/../../")
|
||||
set(_includedir_for_pc_file "\${prefix}/include")
|
||||
|
||||
set(TBB_COMPONENTS_BIN_VERSION "
|
||||
set(_tbb_bin_version ${tbb_gen_cfg_TBB_BINARY_VERSION})
|
||||
set(_tbbmalloc_bin_version ${tbb_gen_cfg_TBBMALLOC_BINARY_VERSION})
|
||||
set(_tbbmalloc_proxy_bin_version ${tbb_gen_cfg_TBBMALLOC_PROXY_BINARY_VERSION})
|
||||
set(_tbbbind_bin_version ${tbb_gen_cfg_TBBBIND_BINARY_VERSION})
|
||||
")
|
||||
|
||||
if (tbb_gen_cfg_SYSTEM_NAME STREQUAL "Linux")
|
||||
set(TBB_LIB_PREFIX "lib")
|
||||
set(TBB_LIB_EXT "so.\${_\${_tbb_component}_bin_version}")
|
||||
set(TBB_IMPLIB_RELEASE "")
|
||||
set(TBB_IMPLIB_DEBUG "")
|
||||
if (tbb_gen_cfg_HANDLE_SUBDIRS)
|
||||
set(TBB_HANDLE_SUBDIRS "
|
||||
if (CMAKE_SIZEOF_VOID_P STREQUAL \"8\")
|
||||
set(_tbb_subdir intel64/gcc4.8)
|
||||
else ()
|
||||
set(_tbb_subdir ia32/gcc4.8)
|
||||
endif()
|
||||
")
|
||||
|
||||
set(_libdir_for_pc_file "\${prefix}/lib/intel64/gcc4.8")
|
||||
configure_file(${_tbb_gen_cfg_path}/../integration/pkg-config/tbb.pc.in ${config_install_dir}/tbb.pc @ONLY)
|
||||
|
||||
set(_libdir_for_pc_file "\${prefix}/lib/ia32/gcc4.8")
|
||||
configure_file(${_tbb_gen_cfg_path}/../integration/pkg-config/tbb.pc.in ${config_install_dir}/tbb32.pc @ONLY)
|
||||
endif()
|
||||
elseif (tbb_gen_cfg_SYSTEM_NAME STREQUAL "Darwin")
|
||||
set(TBB_LIB_PREFIX "lib")
|
||||
set(TBB_LIB_EXT "\${_\${_tbb_component}_bin_version}.dylib")
|
||||
set(TBB_IMPLIB_RELEASE "")
|
||||
set(TBB_IMPLIB_DEBUG "")
|
||||
set(_libdir_for_pc_file "\${prefix}/lib")
|
||||
configure_file(${_tbb_gen_cfg_path}/../integration/pkg-config/tbb.pc.in ${config_install_dir}/tbb.pc @ONLY)
|
||||
elseif (tbb_gen_cfg_SYSTEM_NAME STREQUAL "Windows")
|
||||
set(TBB_LIB_PREFIX "")
|
||||
set(TBB_LIB_EXT "dll")
|
||||
set(TBB_COMPILE_DEFINITIONS "
|
||||
INTERFACE_COMPILE_DEFINITIONS \"__TBB_NO_IMPLICIT_LINKAGE=1\"")
|
||||
|
||||
# .lib files installed to TBB_LIB_REL_PATH (e.g. <prefix>/lib);
|
||||
# .dll files installed to TBB_DLL_REL_PATH (e.g. <prefix>/bin);
|
||||
# Expand TBB_LIB_REL_PATH here in IMPORTED_IMPLIB property and
|
||||
# redefine it with TBB_DLL_REL_PATH value to properly fill IMPORTED_LOCATION property in TBBConfig.cmake.in template.
|
||||
set(TBB_IMPLIB_RELEASE "
|
||||
IMPORTED_IMPLIB_RELEASE \"\${_tbb_root}/${TBB_LIB_REL_PATH}/\${_tbb_subdir}/\${_tbb_component}\${_bin_version}.lib\"")
|
||||
set(TBB_IMPLIB_DEBUG "
|
||||
IMPORTED_IMPLIB_DEBUG \"\${_tbb_root}/${TBB_LIB_REL_PATH}/\${_tbb_subdir}/\${_tbb_component}\${_bin_version}_debug.lib\"")
|
||||
set(TBB_LIB_REL_PATH ${TBB_DLL_REL_PATH})
|
||||
|
||||
if (tbb_gen_cfg_HANDLE_SUBDIRS)
|
||||
set(TBB_HANDLE_SUBDIRS "
|
||||
set(_tbb_subdir vc14)
|
||||
if (WINDOWS_STORE)
|
||||
set(_tbb_subdir \${_tbb_subdir}_uwp)
|
||||
endif()
|
||||
|
||||
if (CMAKE_SIZEOF_VOID_P STREQUAL \"8\")
|
||||
set(_tbb_subdir intel64/\${_tbb_subdir})
|
||||
else ()
|
||||
set(_tbb_subdir ia32/\${_tbb_subdir})
|
||||
endif()
|
||||
")
|
||||
set(_tbb_pc_lib_name ${_tbb_pc_lib_name}${TBB_BINARY_VERSION})
|
||||
|
||||
set(_libdir_for_pc_file "\${prefix}/lib/intel64/vc14")
|
||||
configure_file(${_tbb_gen_cfg_path}/../integration/pkg-config/tbb.pc.in ${config_install_dir}/tbb.pc @ONLY)
|
||||
|
||||
set(_libdir_for_pc_file "\${prefix}/lib/ia32/vc14")
|
||||
configure_file(${_tbb_gen_cfg_path}/../integration/pkg-config/tbb.pc.in ${config_install_dir}/tbb32.pc @ONLY)
|
||||
endif()
|
||||
|
||||
set(TBB_HANDLE_BIN_VERSION "
|
||||
unset(_bin_version)
|
||||
if (_tbb_component STREQUAL tbb)
|
||||
set(_bin_version \${_tbb_bin_version})
|
||||
endif()
|
||||
")
|
||||
else()
|
||||
message(FATAL_ERROR "Unsupported OS name: ${tbb_system_name}")
|
||||
endif()
|
||||
|
||||
configure_file(${_tbb_gen_cfg_path}/templates/TBBConfig.cmake.in ${config_install_dir}/TBBConfig.cmake @ONLY)
|
||||
configure_file(${_tbb_gen_cfg_path}/templates/TBBConfigVersion.cmake.in ${config_install_dir}/TBBConfigVersion.cmake @ONLY)
|
||||
endfunction()
|
||||
@@ -0,0 +1,66 @@
|
||||
# Copyright (c) 2020-2021 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.
|
||||
|
||||
list(APPEND HWLOC_REQUIRED_VERSIONS 1_11 2 2_5)
|
||||
|
||||
foreach(hwloc_version ${HWLOC_REQUIRED_VERSIONS})
|
||||
if (NOT WIN32)
|
||||
set(CMAKE_HWLOC_${hwloc_version}_DLL_PATH STUB)
|
||||
endif()
|
||||
set(HWLOC_TARGET_NAME HWLOC::hwloc_${hwloc_version})
|
||||
|
||||
if (NOT TARGET ${HWLOC_TARGET_NAME} AND
|
||||
CMAKE_HWLOC_${hwloc_version}_LIBRARY_PATH AND
|
||||
CMAKE_HWLOC_${hwloc_version}_DLL_PATH AND
|
||||
CMAKE_HWLOC_${hwloc_version}_INCLUDE_PATH
|
||||
)
|
||||
add_library(${HWLOC_TARGET_NAME} SHARED IMPORTED)
|
||||
set_target_properties(${HWLOC_TARGET_NAME} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${CMAKE_HWLOC_${hwloc_version}_INCLUDE_PATH}")
|
||||
if (WIN32)
|
||||
set_target_properties(${HWLOC_TARGET_NAME} PROPERTIES
|
||||
IMPORTED_LOCATION "${CMAKE_HWLOC_${hwloc_version}_DLL_PATH}"
|
||||
IMPORTED_IMPLIB "${CMAKE_HWLOC_${hwloc_version}_LIBRARY_PATH}")
|
||||
else()
|
||||
set_target_properties(${HWLOC_TARGET_NAME} PROPERTIES
|
||||
IMPORTED_LOCATION "${CMAKE_HWLOC_${hwloc_version}_LIBRARY_PATH}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (TARGET ${HWLOC_TARGET_NAME})
|
||||
set(HWLOC_TARGET_EXPLICITLY_DEFINED TRUE)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
unset(HWLOC_TARGET_NAME)
|
||||
|
||||
if (NOT HWLOC_TARGET_EXPLICITLY_DEFINED AND
|
||||
# No hwloc auto detection for cross compilation
|
||||
NOT CMAKE_CROSSCOMPILING AND
|
||||
NOT TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH
|
||||
)
|
||||
find_package(PkgConfig QUIET)
|
||||
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)
|
||||
set(TBBBIND_LIBRARY_NAME tbbbind_2_0)
|
||||
else()
|
||||
set(TBBBIND_LIBRARY_NAME tbbbind_2_5)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
@@ -0,0 +1,104 @@
|
||||
# Copyright (c) 2020-2021 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.
|
||||
|
||||
option(TBB_VALGRIND_MEMCHECK "Enable scan for memory leaks using Valgrind" OFF)
|
||||
|
||||
if (NOT TBB_VALGRIND_MEMCHECK)
|
||||
return()
|
||||
endif()
|
||||
|
||||
add_custom_target(memcheck-all
|
||||
COMMENT "Run memcheck on all tests")
|
||||
|
||||
find_program(VALGRIND_EXE valgrind)
|
||||
|
||||
if (NOT VALGRIND_EXE)
|
||||
message(FATAL_ERROR "Valgrind executable is not found, add tool to PATH or turn off TBB_VALGRIND_MEMCHECK")
|
||||
else()
|
||||
message(STATUS "Found Valgrind to run memory leak scan")
|
||||
endif()
|
||||
|
||||
file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/memcheck)
|
||||
|
||||
function(_tbb_run_memcheck test_target)
|
||||
set(target_name memcheck-${test_target})
|
||||
add_custom_target(${target_name}
|
||||
COMMAND ${VALGRIND_EXE} --leak-check=full --show-leak-kinds=all --log-file=${CMAKE_BINARY_DIR}/memcheck/${target_name}.log -v $<TARGET_FILE:${test_target}>)
|
||||
add_dependencies(memcheck-all ${target_name})
|
||||
endfunction()
|
||||
|
||||
add_custom_target(memcheck-short
|
||||
COMMENT "Run memcheck scan on specified list")
|
||||
|
||||
# List of reasonable and quick enough tests to use in automated memcheck
|
||||
add_dependencies(memcheck-short
|
||||
memcheck-test_allocators
|
||||
memcheck-test_arena_constraints
|
||||
memcheck-test_dynamic_link
|
||||
memcheck-test_concurrent_lru_cache
|
||||
memcheck-conformance_concurrent_unordered_map
|
||||
memcheck-conformance_concurrent_unordered_set
|
||||
memcheck-conformance_concurrent_map
|
||||
memcheck-conformance_concurrent_set
|
||||
memcheck-conformance_concurrent_priority_queue
|
||||
memcheck-conformance_concurrent_vector
|
||||
memcheck-conformance_concurrent_queue
|
||||
memcheck-conformance_concurrent_hash_map
|
||||
memcheck-test_parallel_for
|
||||
memcheck-test_parallel_for_each
|
||||
memcheck-test_parallel_reduce
|
||||
memcheck-test_parallel_sort
|
||||
memcheck-test_parallel_invoke
|
||||
memcheck-test_parallel_scan
|
||||
memcheck-test_parallel_pipeline
|
||||
memcheck-test_eh_algorithms
|
||||
memcheck-test_task_group
|
||||
memcheck-test_task_arena
|
||||
memcheck-test_enumerable_thread_specific
|
||||
memcheck-test_resumable_tasks
|
||||
memcheck-conformance_mutex
|
||||
memcheck-test_function_node
|
||||
memcheck-test_multifunction_node
|
||||
memcheck-test_broadcast_node
|
||||
memcheck-test_buffer_node
|
||||
memcheck-test_composite_node
|
||||
memcheck-test_continue_node
|
||||
memcheck-test_eh_flow_graph
|
||||
memcheck-test_flow_graph
|
||||
memcheck-test_flow_graph_priorities
|
||||
memcheck-test_flow_graph_whitebox
|
||||
memcheck-test_indexer_node
|
||||
memcheck-test_join_node
|
||||
memcheck-test_join_node_key_matching
|
||||
memcheck-test_join_node_msg_key_matching
|
||||
memcheck-test_priority_queue_node
|
||||
memcheck-test_sequencer_node
|
||||
memcheck-test_split_node
|
||||
memcheck-test_tagged_msg
|
||||
memcheck-test_overwrite_node
|
||||
memcheck-test_write_once_node
|
||||
memcheck-test_async_node
|
||||
memcheck-test_input_node
|
||||
memcheck-test_profiling
|
||||
memcheck-test_concurrent_queue_whitebox
|
||||
memcheck-test_intrusive_list
|
||||
memcheck-test_semaphore
|
||||
memcheck-test_environment_whitebox
|
||||
memcheck-test_handle_perror
|
||||
memcheck-test_hw_concurrency
|
||||
memcheck-test_eh_thread
|
||||
memcheck-test_global_control
|
||||
memcheck-test_task
|
||||
memcheck-test_concurrent_monitor
|
||||
)
|
||||
@@ -1,35 +0,0 @@
|
||||
# Copyright (c) 2020 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.
|
||||
|
||||
if (NOT HWLOC_FOUND)
|
||||
find_path(HWLOC_INCLUDE_DIRS
|
||||
NAMES hwloc.h
|
||||
HINTS $ENV{INCLUDE} $ENV{CPATH} $ENV{C_INCLUDE_PATH} $ENV{INCLUDE_PATH}
|
||||
PATH_SUFFIXES "hwloc")
|
||||
|
||||
if (UNIX)
|
||||
set(HWLOC_LIB_NAME hwloc)
|
||||
elseif(WIN32)
|
||||
set(HWLOC_LIB_NAME libhwloc)
|
||||
endif()
|
||||
|
||||
find_library(HWLOC_LIBRARIES
|
||||
NAMES ${HWLOC_LIB_NAME}
|
||||
HINTS $ENV{LIBRARY_PATH} $ENV{LD_LIBRARY_PATH} $ENV{DYLD_LIBRARY_PATH})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(HWLOC DEFAULT_MSG HWLOC_LIBRARIES HWLOC_INCLUDE_DIRS)
|
||||
|
||||
mark_as_advanced(HWLOC_LIB_NAME)
|
||||
endif()
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2020 Intel Corporation
|
||||
# Copyright (c) 2020-2021 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
# Note: current implementation uses CMAKE_BUILD_TYPE,
|
||||
# this parameter is not defined for multi-config generators.
|
||||
set(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
|
||||
set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
|
||||
set(CPACK_PACKAGE_VERSION "${TBB_VERSION}")
|
||||
string(TOLOWER ${CPACK_PACKAGE_NAME}-${PROJECT_VERSION}-${CMAKE_SYSTEM_NAME}_${TBB_OUTPUT_DIR_BASE}_${CMAKE_BUILD_TYPE} CPACK_PACKAGE_FILE_NAME)
|
||||
set(CPACK_GENERATOR ZIP)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2020 Intel Corporation
|
||||
# Copyright (c) 2020-2021 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -14,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})
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2020 Intel Corporation
|
||||
# Copyright (c) 2020-2021 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2020 Intel Corporation
|
||||
# Copyright (c) 2020-2021 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -34,5 +34,9 @@ if (NOT ${FLAG_DISPLAY_NAME})
|
||||
"please try another compiler or omit TBB_SANITIZE variable")
|
||||
endif()
|
||||
|
||||
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,50 @@
|
||||
# Copyright (c) 2020-2021 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/../config_generation.cmake)
|
||||
|
||||
# TBBConfig in TBB provided packages are expected to be placed into: <tbb-root>/lib/cmake/tbb*
|
||||
set(TBB_ROOT_REL_PATH "../../..")
|
||||
|
||||
# Paths relative to TBB root directory
|
||||
set(INC_REL_PATH "include")
|
||||
set(LIB_REL_PATH "lib")
|
||||
set(DLL_REL_PATH "redist")
|
||||
|
||||
# Parse version info
|
||||
file(READ ${CMAKE_CURRENT_LIST_DIR}/../../include/oneapi/tbb/version.h _tbb_version_info)
|
||||
string(REGEX REPLACE ".*#define TBB_VERSION_MAJOR ([0-9]+).*" "\\1" _tbb_ver_major "${_tbb_version_info}")
|
||||
string(REGEX REPLACE ".*#define TBB_VERSION_MINOR ([0-9]+).*" "\\1" _tbb_ver_minor "${_tbb_version_info}")
|
||||
string(REGEX REPLACE ".*#define TBB_VERSION_PATCH ([0-9]+).*" "\\1" _tbb_ver_patch "${_tbb_version_info}")
|
||||
string(REGEX REPLACE ".*#define __TBB_BINARY_VERSION ([0-9]+).*" "\\1" TBB_BINARY_VERSION "${_tbb_version_info}")
|
||||
file(READ ${CMAKE_CURRENT_LIST_DIR}/../../CMakeLists.txt _tbb_cmakelist)
|
||||
string(REGEX REPLACE ".*TBBMALLOC_BINARY_VERSION ([0-9]+).*" "\\1" TBBMALLOC_BINARY_VERSION "${_tbb_cmakelist}")
|
||||
set(TBBMALLOC_PROXY_BINARY_VERSION ${TBBMALLOC_BINARY_VERSION})
|
||||
string(REGEX REPLACE ".*TBBBIND_BINARY_VERSION ([0-9]+).*" "\\1" TBBBIND_BINARY_VERSION "${_tbb_cmakelist}")
|
||||
|
||||
set(COMMON_ARGS
|
||||
TBB_ROOT_REL_PATH ${TBB_ROOT_REL_PATH}
|
||||
INC_REL_PATH ${INC_REL_PATH}
|
||||
LIB_REL_PATH ${LIB_REL_PATH}
|
||||
VERSION ${_tbb_ver_major}.${_tbb_ver_minor}.${_tbb_ver_patch}
|
||||
TBB_BINARY_VERSION ${TBB_BINARY_VERSION}
|
||||
TBBMALLOC_BINARY_VERSION ${TBBMALLOC_BINARY_VERSION}
|
||||
TBBMALLOC_PROXY_BINARY_VERSION ${TBBMALLOC_PROXY_BINARY_VERSION}
|
||||
TBBBIND_BINARY_VERSION ${TBBBIND_BINARY_VERSION}
|
||||
)
|
||||
|
||||
tbb_generate_config(INSTALL_DIR ${INSTALL_DIR}/linux SYSTEM_NAME Linux HANDLE_SUBDIRS ${COMMON_ARGS})
|
||||
tbb_generate_config(INSTALL_DIR ${INSTALL_DIR}/windows SYSTEM_NAME Windows HANDLE_SUBDIRS DLL_REL_PATH ${DLL_REL_PATH} ${COMMON_ARGS})
|
||||
tbb_generate_config(INSTALL_DIR ${INSTALL_DIR}/darwin SYSTEM_NAME Darwin ${COMMON_ARGS})
|
||||
message(STATUS "TBBConfig files were created in ${INSTALL_DIR}")
|
||||
@@ -0,0 +1,2 @@
|
||||
# LSAN suppression for ltdl library known issue.
|
||||
leak:libltdl.so
|
||||
@@ -0,0 +1,3 @@
|
||||
# TSAN suppression for known issues.
|
||||
# Possible data race during ittnotify initialization. Low impact.
|
||||
race:__itt_nullify_all_pointers
|
||||
@@ -0,0 +1,98 @@
|
||||
# Copyright (c) 2017-2021 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.
|
||||
|
||||
# It defines the following variables:
|
||||
# TBB_<component>_FOUND
|
||||
# TBB_IMPORTED_TARGETS
|
||||
#
|
||||
# TBBConfigVersion.cmake defines TBB_VERSION
|
||||
#
|
||||
# Initialize to default values
|
||||
if (NOT TBB_IMPORTED_TARGETS)
|
||||
set(TBB_IMPORTED_TARGETS "")
|
||||
endif()
|
||||
|
||||
if (NOT TBB_FIND_COMPONENTS)
|
||||
set(TBB_FIND_COMPONENTS "tbb;tbbmalloc;tbbmalloc_proxy")
|
||||
foreach (_tbb_component ${TBB_FIND_COMPONENTS})
|
||||
set(TBB_FIND_REQUIRED_${_tbb_component} 1)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
get_filename_component(_tbb_root "${CMAKE_CURRENT_LIST_DIR}" REALPATH)
|
||||
get_filename_component(_tbb_root "${_tbb_root}/@TBB_ROOT_REL_PATH@" ABSOLUTE)
|
||||
|
||||
set(TBB_INTERFACE_VERSION @TBB_INTERFACE_VERSION@)
|
||||
@TBB_COMPONENTS_BIN_VERSION@
|
||||
# Add components with internal dependencies: tbbmalloc_proxy -> tbbmalloc
|
||||
list(FIND TBB_FIND_COMPONENTS tbbmalloc_proxy _tbbmalloc_proxy_ix)
|
||||
if (NOT _tbbmalloc_proxy_ix EQUAL -1)
|
||||
list(APPEND TBB_FIND_COMPONENTS tbbmalloc)
|
||||
list(REMOVE_DUPLICATES TBB_FIND_COMPONENTS)
|
||||
set(TBB_FIND_REQUIRED_tbbmalloc ${TBB_FIND_REQUIRED_tbbmalloc_proxy})
|
||||
endif()
|
||||
unset(_tbbmalloc_proxy_ix)
|
||||
@TBB_HANDLE_SUBDIRS@
|
||||
foreach (_tbb_component ${TBB_FIND_COMPONENTS})
|
||||
set(TBB_${_tbb_component}_FOUND 0)
|
||||
@TBB_HANDLE_BIN_VERSION@
|
||||
get_filename_component(_tbb_release_lib "${_tbb_root}/@TBB_LIB_REL_PATH@/${_tbb_subdir}/@TBB_LIB_PREFIX@${_tbb_component}${_bin_version}.@TBB_LIB_EXT@" ABSOLUTE)
|
||||
|
||||
if (NOT TBB_FIND_RELEASE_ONLY)
|
||||
get_filename_component(_tbb_debug_lib "${_tbb_root}/@TBB_LIB_REL_PATH@/${_tbb_subdir}/@TBB_LIB_PREFIX@${_tbb_component}${_bin_version}_debug.@TBB_LIB_EXT@" ABSOLUTE)
|
||||
endif()
|
||||
|
||||
if (EXISTS "${_tbb_release_lib}" OR EXISTS "${_tbb_debug_lib}")
|
||||
if (NOT TARGET TBB::${_tbb_component})
|
||||
add_library(TBB::${_tbb_component} SHARED IMPORTED)
|
||||
|
||||
get_filename_component(_tbb_include_dir "${_tbb_root}/@TBB_INC_REL_PATH@" ABSOLUTE)
|
||||
set_target_properties(TBB::${_tbb_component} PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${_tbb_include_dir}"@TBB_COMPILE_DEFINITIONS@)
|
||||
unset(_tbb_current_realpath)
|
||||
unset(_tbb_include_dir)
|
||||
|
||||
if (EXISTS "${_tbb_release_lib}")
|
||||
set_target_properties(TBB::${_tbb_component} PROPERTIES
|
||||
IMPORTED_LOCATION_RELEASE "${_tbb_release_lib}"@TBB_IMPLIB_RELEASE@)
|
||||
set_property(TARGET TBB::${_tbb_component} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE)
|
||||
endif()
|
||||
|
||||
if (EXISTS "${_tbb_debug_lib}")
|
||||
set_target_properties(TBB::${_tbb_component} PROPERTIES
|
||||
IMPORTED_LOCATION_DEBUG "${_tbb_debug_lib}"@TBB_IMPLIB_DEBUG@)
|
||||
set_property(TARGET TBB::${_tbb_component} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG)
|
||||
endif()
|
||||
|
||||
# Add internal dependencies for imported targets: TBB::tbbmalloc_proxy -> TBB::tbbmalloc
|
||||
if (_tbb_component STREQUAL tbbmalloc_proxy)
|
||||
set_target_properties(TBB::tbbmalloc_proxy PROPERTIES INTERFACE_LINK_LIBRARIES TBB::tbbmalloc)
|
||||
endif()
|
||||
endif()
|
||||
list(APPEND TBB_IMPORTED_TARGETS TBB::${_tbb_component})
|
||||
set(TBB_${_tbb_component}_FOUND 1)
|
||||
elseif (TBB_FIND_REQUIRED AND TBB_FIND_REQUIRED_${_tbb_component})
|
||||
message(STATUS "Missed required oneTBB component: ${_tbb_component}")
|
||||
if (TBB_FIND_RELEASE_ONLY)
|
||||
message(STATUS " ${_tbb_release_lib} must exist.")
|
||||
else()
|
||||
message(STATUS " one or both of:\n ${_tbb_release_lib}\n ${_tbb_debug_lib}\n files must exist.")
|
||||
endif()
|
||||
set(TBB_FOUND FALSE)
|
||||
endif()
|
||||
endforeach()
|
||||
list(REMOVE_DUPLICATES TBB_IMPORTED_TARGETS)
|
||||
unset(_tbb_release_lib)
|
||||
unset(_tbb_debug_lib)
|
||||
unset(_tbb_root)
|
||||
@@ -0,0 +1,24 @@
|
||||
# Copyright (c) 2017-2021 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.
|
||||
|
||||
set(PACKAGE_VERSION @TBB_VERSION@)
|
||||
|
||||
if ("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
|
||||
set(PACKAGE_VERSION_EXACT TRUE)
|
||||
endif()
|
||||
endif()
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2020 Intel Corporation
|
||||
# Copyright (c) 2020-2021 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2020 Intel Corporation
|
||||
# Copyright (c) 2020-2021 Intel Corporation
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
# 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.
|
||||
# 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.
|
||||
|
||||
macro(tbb_remove_compile_flag flag)
|
||||
get_property(_tbb_compile_options DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY COMPILE_OPTIONS)
|
||||
list(REMOVE_ITEM _tbb_compile_options ${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 "(^|[ \t\r\n]+)${flag}($|[ \t\r\n]+)" " " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(tbb_install_target target)
|
||||
install(TARGETS ${target}
|
||||
EXPORT TBBTargets
|
||||
LIBRARY
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
NAMELINK_SKIP
|
||||
COMPONENT runtime
|
||||
RUNTIME
|
||||
DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||
COMPONENT runtime
|
||||
ARCHIVE
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
COMPONENT devel)
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
install(TARGETS ${target}
|
||||
LIBRARY
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
NAMELINK_ONLY
|
||||
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()
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2020 Intel Corporation
|
||||
# Copyright (c) 2020-2021 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,20 +22,23 @@ else()
|
||||
set(TBB_VARS_TEMPLATE "linux/env/vars.sh.in")
|
||||
endif()
|
||||
|
||||
get_filename_component(TBB_VARS_TEMPLATE_NAME ${CMAKE_SOURCE_DIR}/integration/${TBB_VARS_TEMPLATE} NAME)
|
||||
get_filename_component(TBB_VARS_TEMPLATE_NAME ${PROJECT_SOURCE_DIR}/integration/${TBB_VARS_TEMPLATE} NAME)
|
||||
string(REPLACE ".in" "" TBB_VARS_NAME ${TBB_VARS_TEMPLATE_NAME})
|
||||
|
||||
macro(tbb_gen_vars target)
|
||||
add_custom_command(TARGET ${target} POST_BUILD COMMAND
|
||||
${CMAKE_COMMAND}
|
||||
-DBINARY_DIR=${CMAKE_BINARY_DIR}
|
||||
-DSOURCE_DIR=${CMAKE_SOURCE_DIR}
|
||||
-DBIN_PATH=$<TARGET_FILE_DIR:${target}>
|
||||
-DVARS_TEMPLATE=${TBB_VARS_TEMPLATE}
|
||||
-DVARS_NAME=${TBB_VARS_NAME}
|
||||
-DTBB_INSTALL_VARS=${TBB_INSTALL_VARS}
|
||||
-P ${CMAKE_SOURCE_DIR}/integration/cmake/generate_vars.cmake
|
||||
)
|
||||
if (${CMAKE_PROJECT_NAME} STREQUAL ${PROJECT_NAME})
|
||||
add_custom_command(TARGET ${target} POST_BUILD COMMAND
|
||||
${CMAKE_COMMAND}
|
||||
-DBINARY_DIR=${CMAKE_BINARY_DIR}
|
||||
-DSOURCE_DIR=${PROJECT_SOURCE_DIR}
|
||||
-DBIN_PATH=$<TARGET_FILE_DIR:${target}>
|
||||
-DVARS_TEMPLATE=${TBB_VARS_TEMPLATE}
|
||||
-DVARS_NAME=${TBB_VARS_NAME}
|
||||
-DTBB_INSTALL_VARS=${TBB_INSTALL_VARS}
|
||||
-DTBB_CMAKE_INSTALL_LIBDIR=${CMAKE_INSTALL_LIBDIR}
|
||||
-P ${PROJECT_SOURCE_DIR}/integration/cmake/generate_vars.cmake
|
||||
)
|
||||
endif()
|
||||
endmacro(tbb_gen_vars)
|
||||
|
||||
if (TBB_INSTALL_VARS)
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
<tab type="filelist" visible="no" title="" intro=""/>
|
||||
<tab type="globals" visible="no" title="" intro=""/>
|
||||
</tab>
|
||||
<tab type="user" url="@ref test_classification" visible="yes" title="Test Classification"/>
|
||||
<tab type="examples" visible="yes" title="" intro=""/>
|
||||
</navindex>
|
||||
|
||||
|
||||
|
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;
|
||||
}
|
||||
);
|
||||
@@ -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|.
|
||||
@@ -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.
|
||||
@@ -0,0 +1,37 @@
|
||||
window.MathJax = {
|
||||
TeX: {
|
||||
Macros: {
|
||||
src: '\\operatorname{src}',
|
||||
srclayer: '\\operatorname{src\\_layer}',
|
||||
srciter: '\\operatorname{src\\_iter}',
|
||||
srciterc: '\\operatorname{src\\_iter\\_c}',
|
||||
weights: '\\operatorname{weights}',
|
||||
weightslayer: '\\operatorname{weights\\_layer}',
|
||||
weightsiter: '\\operatorname{weights\\_iter}',
|
||||
weightspeephole: '\\operatorname{weights\\_peephole}',
|
||||
weightsprojection: '\\operatorname{weights\\_projection}',
|
||||
bias: '\\operatorname{bias}',
|
||||
dst: '\\operatorname{dst}',
|
||||
dstlayer: '\\operatorname{dst\\_layer}',
|
||||
dstiter: '\\operatorname{dst\\_iter}',
|
||||
dstiterc: '\\operatorname{dst\\_iter\\_c}',
|
||||
diffsrc: '\\operatorname{diff\\_src}',
|
||||
diffsrclayer: '\\operatorname{diff\\_src\\_layer}',
|
||||
diffsrciter: '\\operatorname{diff\\_src\\_iter}',
|
||||
diffsrciterc: '\\operatorname{diff\\_src\\_iter\\_c}',
|
||||
diffweights: '\\operatorname{diff\\_weights}',
|
||||
diffweightslayer: '\\operatorname{diff\\_weights\\_layer}',
|
||||
diffweightsiter: '\\operatorname{diff\\_weights\\_iter}',
|
||||
diffweightspeephole: '\\operatorname{diff\\_weights\\_peephole}',
|
||||
diffweightsprojection: '\\operatorname{diff\\_weights\\_projection}',
|
||||
diffbias: '\\operatorname{diff\\_bias}',
|
||||
diffdst: '\\operatorname{diff\\_dst}',
|
||||
diffdstlayer: '\\operatorname{diff\\_dst\\_layer}',
|
||||
diffdstiter: '\\operatorname{diff\\_dst\\_iter}',
|
||||
diffdstiterc: '\\operatorname{diff\\_dst\\_iter\\_c}',
|
||||
diffgamma: '\\operatorname{diff\\_\\gamma}',
|
||||
diffbeta: '\\operatorname{diff\\_\\beta}',
|
||||
workspace: '\\operatorname{workspace}'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
After Width: | Height: | Size: 467 B |
|
After Width: | Height: | Size: 7.2 KiB |
@@ -0,0 +1,13 @@
|
||||
/* override table width restrictions */
|
||||
@media screen and (min-width: 767px) {
|
||||
|
||||
.wy-table-responsive table td {
|
||||
/* !important prevents the common CSS stylesheets from overriding
|
||||
this as on RTD they are loaded after this stylesheet */
|
||||
white-space: normal !important;
|
||||
}
|
||||
|
||||
.wy-table-responsive {
|
||||
overflow: visible !important;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,301 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Configuration file for the Sphinx documentation builder.
|
||||
#
|
||||
# This file does only contain a selection of the most common options. For a
|
||||
# full list see the documentation:
|
||||
# http://www.sphinx-doc.org/en/master/config
|
||||
|
||||
# -- Path setup --------------------------------------------------------------
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#
|
||||
import os
|
||||
# import sys
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
SOURCE_DIR = os.path.dirname(__file__)
|
||||
LATEX_DIR = os.path.join(SOURCE_DIR, '_latex')
|
||||
PREAMBLE_FILE = os.path.join(LATEX_DIR, 'preamble.tex')
|
||||
TITLE_PAGE_FILE = os.path.join(LATEX_DIR, 'title_page.tex')
|
||||
|
||||
BUILD_TYPE = os.getenv("BUILD_TYPE")
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
if BUILD_TYPE == 'oneapi' or BUILD_TYPE == 'dita':
|
||||
project = u'Intel® oneAPI Threading Building Blocks (oneTBB)'
|
||||
else:
|
||||
project = u'oneTBB'
|
||||
copyright = u'2022, 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 = ['main/_templates']
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
#
|
||||
# source_suffix = ['.rst', '.md']
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The master toctree document.
|
||||
#master_doc = 'main/title_main'
|
||||
master_doc = 'index'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#
|
||||
# This is also used if you do content translation via gettext catalogs.
|
||||
# Usually you set "language" from the command line for these cases.
|
||||
language = None
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This pattern also affects html_static_path and html_extra_path.
|
||||
exclude_patterns = []
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = None
|
||||
|
||||
# Syntax highlighting for the :: directive
|
||||
highlight_language = 'cpp'
|
||||
|
||||
if BUILD_TYPE == 'oneapi' or BUILD_TYPE == 'dita':
|
||||
rst_prolog = """
|
||||
.. |full_name| replace:: Intel\ |reg|\ oneAPI Threading Building Blocks (oneTBB)
|
||||
.. |short_name| replace:: oneTBB
|
||||
.. |product| replace:: oneTBB
|
||||
.. |reg| unicode:: U+000AE
|
||||
.. |copy| unicode:: U+000A9
|
||||
.. |base_tk| replace:: Intel\ |reg|\ oneAPI Base Toolkit
|
||||
.. |dpcpp| replace:: Intel\ |reg|\ oneAPI DPC++/C++ Compiler
|
||||
"""
|
||||
else:
|
||||
rst_prolog = """
|
||||
.. |full_name| replace:: oneAPI Threading Building Blocks (oneTBB)
|
||||
.. |short_name| replace:: oneTBB
|
||||
.. |product| replace:: oneTBB
|
||||
.. |reg| unicode:: U+000AE
|
||||
.. |copy| unicode:: U+000A9
|
||||
.. |base_tk| replace:: Intel\ |reg|\ oneAPI Base Toolkit
|
||||
.. |dpcpp| replace:: Intel\ |reg|\ oneAPI DPC++/C++ Compiler
|
||||
"""
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#
|
||||
|
||||
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,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
if BUILD_TYPE == 'oneapi' or BUILD_TYPE == 'dita':
|
||||
html_context = {
|
||||
'css_files': [
|
||||
'_static/theme_overrides.css', # override wide tables in RTD theme
|
||||
],
|
||||
}
|
||||
else:
|
||||
html_js_files = ['custom.js']
|
||||
|
||||
|
||||
html_logo = '_static/oneAPI-rgb-rev-100.png'
|
||||
html_favicon = '_static/favicons.png'
|
||||
|
||||
# Custom sidebar templates, must be a dictionary that maps document names
|
||||
# to template names.
|
||||
#
|
||||
# The default sidebars (for documents that don't match any pattern) are
|
||||
# defined by theme itself. Builtin themes are using these templates by
|
||||
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
|
||||
# 'searchbox.html']``.
|
||||
#
|
||||
# html_sidebars = {}
|
||||
|
||||
|
||||
# -- Options for HTMLHelp output ---------------------------------------------
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'sphinx-infodevdoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output ------------------------------------------------
|
||||
|
||||
#latex_engine = 'xelatex'
|
||||
#PDF_TITLE = 'Information Development Template'
|
||||
#
|
||||
#with open(PREAMBLE_FILE, 'r', encoding='utf-8') as f:
|
||||
# PREAMBLE = f.read()
|
||||
#
|
||||
#with open(TITLE_PAGE_FILE, 'r', encoding='utf-8') as f:
|
||||
# TITLE_PAGE = f.read().replace('<PDF_TITLE>', PDF_TITLE)
|
||||
#
|
||||
#
|
||||
#latex_elements = {
|
||||
# # The paper size ('letterpaper' or 'a4paper').
|
||||
# #
|
||||
# 'extraclassoptions': 'openany,oneside',
|
||||
# 'babel' : '\\usepackage[english]{babel}',
|
||||
# 'papersize': 'a4paper',
|
||||
# 'releasename':" ",
|
||||
# # Sonny, Lenny, Glenn, Conny, Rejne, Bjarne and Bjornstrup
|
||||
# # 'fncychap': '\\usepackage[Lenny]{fncychap}',
|
||||
# 'fncychap': '',
|
||||
# #'fontpkg': '\\usepackage{amsmath,amsfonts,amssymb,amsthm}',
|
||||
#
|
||||
# 'figure_align':'htbp',
|
||||
# # The font size ('10pt', '11pt' or '12pt').
|
||||
# #
|
||||
# 'pointsize': '12pt',
|
||||
#
|
||||
# # Additional stuff for the LaTeX preamble.
|
||||
# #
|
||||
# 'preamble': PREAMBLE,
|
||||
#
|
||||
# 'maketitle': TITLE_PAGE,
|
||||
# # Latex figure (float) alignment
|
||||
# #
|
||||
# # 'figure_align': 'htbp',
|
||||
# 'sphinxsetup': \
|
||||
# 'hmargin={0.7in,0.7in}, vmargin={1in,1in}, \
|
||||
# verbatimwithframe=true, \
|
||||
# TitleColor={rgb}{0,0.686,0.941}, \
|
||||
# HeaderFamily=\\rmfamily\\bfseries, \
|
||||
# InnerLinkColor={rgb}{0,0.686,0.941}, \
|
||||
# OuterLinkColor={rgb}{0,0.686,0.941}',
|
||||
#
|
||||
# 'tableofcontents':' '
|
||||
#}
|
||||
#
|
||||
#latex_logo = '_latex/intel_logo.png'
|
||||
## Grouping the document tree into LaTeX files. List of tuples
|
||||
## (source start file, target name, title,
|
||||
## author, documentclass [howto, manual, or own class]).
|
||||
#latex_documents = [
|
||||
# (master_doc, 'sphinx-infodev.tex', u'sphinx-infodev Documentation',
|
||||
# u'Intel', 'manual'),
|
||||
#]
|
||||
|
||||
#breathe_projects = { #todd-mod
|
||||
# project: "../doxygen/xml"
|
||||
#}
|
||||
#breathe_default_project = project
|
||||
|
||||
# Setup the exhale extension
|
||||
#exhale_args = { #todd-mod
|
||||
# # These arguments are required
|
||||
# "containmentFolder": "./api",
|
||||
# "rootFileName": "library_root.rst",
|
||||
# "rootFileTitle": "Library API",
|
||||
# "doxygenStripFromPath": "..",
|
||||
# "fullApiSubSectionTitle": 'Full API'
|
||||
#}
|
||||
|
||||
|
||||
# -- Options for manual page output ------------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'sphinx-infodev', u'sphinx-infodev Documentation',
|
||||
[author], 1)
|
||||
]
|
||||
|
||||
|
||||
# -- Options for Texinfo output ----------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'sphinx-infodev', u'sphinx-infodev Documentation',
|
||||
author, 'sphinx-infodev', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
|
||||
# -- Options for Epub output -------------------------------------------------
|
||||
|
||||
# Bibliographic Dublin Core info.
|
||||
epub_title = project
|
||||
|
||||
# The unique identifier of the text. This can be a ISBN number
|
||||
# or the project homepage.
|
||||
#
|
||||
# epub_identifier = ''
|
||||
|
||||
# A unique identification for the text.
|
||||
#
|
||||
# epub_uid = ''
|
||||
|
||||
# A list of files that should not be packed into the epub file.
|
||||
epub_exclude_files = ['search.html']
|
||||
|
||||
|
||||
# -- Extension configuration -------------------------------------------------
|
||||
|
||||
# -- Options for intersphinx extension ---------------------------------------
|
||||
|
||||
# Example configuration for intersphinx: refer to the Python standard library.
|
||||
intersphinx_mapping = {'https://docs.python.org/': None}
|
||||
|
||||
# -- Options for todo extension ----------------------------------------------
|
||||
|
||||
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||
todo_include_todos = True
|
||||
@@ -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,33 @@
|
||||
.. _toctree:
|
||||
|
||||
.. toctree::
|
||||
:caption: About
|
||||
:maxdepth: 1
|
||||
|
||||
/main/intro/help_support
|
||||
/main/intro/notation
|
||||
/main/intro/intro_os
|
||||
/main/intro/Benefits
|
||||
|
||||
|
||||
.. 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 %}
|
||||
@@ -0,0 +1,88 @@
|
||||
.. _Benefits:
|
||||
|
||||
|short_name| Benefits
|
||||
=====================
|
||||
|
||||
|
||||
|full_name| is a library that helps you leverage multi-core performance
|
||||
without having to be a threading expert. Typically you can improve
|
||||
performance for multi-core processors by implementing the key points
|
||||
explained in the early sections of the Developer Guide. As your
|
||||
expertise grows, you may want to dive into more complex subjects that
|
||||
are covered in advanced sections.
|
||||
|
||||
|
||||
There are a variety of approaches to parallel programming, ranging from
|
||||
using platform-dependent threading primitives to exotic new languages.
|
||||
The advantage of oneTBB is that it works at a higher level than raw
|
||||
threads, yet does not require exotic languages or compilers. You can use
|
||||
it with any compiler supporting ISO C++. The library differs from
|
||||
typical threading packages in the following ways:
|
||||
|
||||
|
||||
- **oneTBB enables you to specify logical paralleism instead of
|
||||
threads**. Most threading packages require you to specify threads.
|
||||
Programming directly in terms of threads can be tedious and lead to
|
||||
inefficient programs, because threads are low-level, heavy constructs
|
||||
that are close to the hardware. Direct programming with threads
|
||||
forces you to efficiently map logical tasks onto threads. In
|
||||
contrast, the oneTBB run-time library automatically maps logical
|
||||
parallelism onto threads in a way that makes efficient use of
|
||||
processor resources.
|
||||
|
||||
|
||||
- **oneTBB targets threading for performance**. Most general-purpose
|
||||
threading packages support many different kinds of threading, such as
|
||||
threading for asynchronous events in graphical user interfaces. As a
|
||||
result, general-purpose packages tend to be low-level tools that
|
||||
provide a foundation, not a solution. Instead, oneTBB focuses on the
|
||||
particular goal of parallelizing computationally intensive work,
|
||||
delivering higher-level, simpler solutions.
|
||||
|
||||
|
||||
- **oneTBB is compatible with other threading packages.** Because the
|
||||
library is not designed to address all threading problems, it can
|
||||
coexist seamlessly with other threading packages.
|
||||
|
||||
|
||||
- **oneTBB emphasizes scalable, data parallel programming**. Breaking a
|
||||
program up into separate functional blocks, and assigning a separate
|
||||
thread to each block is a solution that typically does not scale well
|
||||
since typically the number of functional blocks is fixed. In
|
||||
contrast, oneTBB emphasizes *data-parallel* programming, enabling
|
||||
multiple threads to work on different parts of a collection.
|
||||
Data-parallel programming scales well to larger numbers of processors
|
||||
by dividing the collection into smaller pieces. With data-parallel
|
||||
programming, program performance increases as you add processors.
|
||||
|
||||
|
||||
- **oneTBB relies on generic programming**. Traditional libraries
|
||||
specify interfaces in terms of specific types or base classes.
|
||||
Instead, oneAPI Threading Building Blocks uses generic programming.
|
||||
The essence of generic programming is writing the best possible
|
||||
algorithms with the fewest constraints. The C++ Standard Template
|
||||
Library (STL) is a good example of generic programming in which the
|
||||
interfaces are specified by *requirements* on types. For example, C++
|
||||
STL has a template function ``sort`` that sorts a sequence abstractly
|
||||
defined in terms of iterators on the sequence. The requirements on
|
||||
the iterators are:
|
||||
|
||||
|
||||
- Provide random access
|
||||
|
||||
|
||||
- The expression ``*i<*j`` is true if the item pointed to by
|
||||
iterator ``i`` should precede the item pointed to by iterator
|
||||
``j``, and false otherwise.
|
||||
|
||||
|
||||
- The expression ``swap(*i,*j)`` swaps two elements.
|
||||
|
||||
|
||||
Specification in terms of requirements on types enables the template to
|
||||
sort many different representations of sequences, such as vectors and
|
||||
deques. Similarly, the oneTBB templates specify requirements on types,
|
||||
not particular types, and thus adapt to different data representations.
|
||||
Generic programming enables oneTBB to deliver high performance
|
||||
algorithms with broad applicability.
|
||||
|
||||
|
After Width: | Height: | Size: 8.1 KiB |
@@ -0,0 +1,15 @@
|
||||
.. _help_support:
|
||||
|
||||
Getting Help and Support
|
||||
========================
|
||||
|
||||
|
||||
.. container:: section
|
||||
|
||||
|
||||
.. rubric:: Getting Technical Support
|
||||
:class: sectiontitle
|
||||
|
||||
For general information about oneTBB technical support, product
|
||||
updates, user forums, FAQs, tips and tricks and other support
|
||||
questions, go to `GitHub issues <https://github.com/oneapi-src/oneTBB/issues>`_.
|
||||
@@ -0,0 +1,35 @@
|
||||
.. _intro:
|
||||
|
||||
Introduction
|
||||
============
|
||||
|
||||
|
||||
|full_name| is a library that supports scalable parallel programming using
|
||||
standard ISO C++ code. It does not require special languages or
|
||||
compilers. It is designed to promote scalable data parallel programming.
|
||||
Additionally, it fully supports nested parallelism, so you can build
|
||||
larger parallel components from smaller parallel components. To use the
|
||||
library, you specify tasks, not threads, and let the library map tasks
|
||||
onto threads in an efficient manner.
|
||||
|
||||
|
||||
Many of the library interfaces employ generic programming, in which
|
||||
interfaces are defined by requirements on types and not specific types.
|
||||
The C++ Standard Template Library (STL) is an example of generic
|
||||
programming. Generic programming enables oneTBB to be flexible yet
|
||||
efficient. The generic interfaces enable you to customize components to
|
||||
your specific needs.
|
||||
|
||||
|
||||
.. note::
|
||||
|full_name| requires C++11 standard compiler support.
|
||||
|
||||
|
||||
The net result is that oneTBB enables you to specify parallelism far
|
||||
more conveniently than using raw threads, and at the same time can
|
||||
improve performance.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
.. _notation:
|
||||
|
||||
Notational Conventions
|
||||
======================
|
||||
|
||||
|
||||
The following conventions may be used in this document.
|
||||
|
||||
|
||||
.. container:: tablenoborder
|
||||
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - Convention
|
||||
- Explanation
|
||||
- Example
|
||||
* - \ *Italic*
|
||||
- Used for introducing new terms, denotation of terms, placeholders, or titles of manuals.
|
||||
- The filename consists of the *basename* and the *extension*.
|
||||
* - \ ``Monospace``
|
||||
- Indicates directory paths and filenames, commands and command line options, function names, methods, classes, data structures in body text, source code.
|
||||
- \ ``ippsapi.h`` \ ``\alt\include`` Use the okCreateObjs() function to... \ ``printf("hello, world\n");``
|
||||
* - [ ]
|
||||
- Items enclosed in brackets are optional.
|
||||
- Fa[c] Indicates Fa or Fac.
|
||||
* - { \| }
|
||||
- Braces and vertical bars indicate the choice of one item from a selection of two or more items.
|
||||
- X{K \| W \| P} Indicates XK, XW, or XP.
|
||||
* - "[" "]" "{" | " }" "|"
|
||||
- Writing a metacharacter in quotation marks negates the syntactical meaning stated above; | the character is taken as a literal.
|
||||
- "[" X "]" [ Y ] Denotes the letter X enclosed in brackets, optionally followed by the letter Y.
|
||||
* - ...
|
||||
- The ellipsis indicates that the previous item can be repeated several times.
|
||||
- \ ``filename`` ... Indicates that one or more filenames can be specified.
|
||||
* - ,...
|
||||
- The ellipsis preceded by a comma indicates that the previous item can be repeated several times, | separated by commas.
|
||||
- \ ``word`` ,... Indicates that one or more words can be specified. If more than one word is specified, the words are comma-separated.
|
||||
|
||||
|
||||
|
||||
|
||||
.. container:: section
|
||||
|
||||
|
||||
Class members are summarized by informal class declarations that
|
||||
describe the class as it seems to clients, not how it is actually
|
||||
implemented. For example, here is an informal declaration of class
|
||||
``Foo``:
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
class Foo {
|
||||
public:
|
||||
int x();
|
||||
int y;
|
||||
~Foo();
|
||||
};
|
||||
|
||||
|
||||
The actual implementation might look like:
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
namespace internal {
|
||||
class FooBase {
|
||||
protected:
|
||||
int x();
|
||||
};
|
||||
|
||||
|
||||
class Foo_v3: protected FooBase {
|
||||
private:
|
||||
int internal_stuff;
|
||||
public:
|
||||
using FooBase::x;
|
||||
int y;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
typedef internal::Foo_v3 Foo;
|
||||
|
||||
|
||||
The example shows two cases where the actual implementation departs
|
||||
from the informal declaration:
|
||||
|
||||
|
||||
- ``Foo`` is actually a typedef to ``Foo_v3``.
|
||||
|
||||
|
||||
- Method ``x()`` is inherited from a protected base class.
|
||||
|
||||
|
||||
- The destructor is an implicit method generated by the compiler.
|
||||
|
||||
|
||||
The informal declarations are intended to show you what you need to
|
||||
know to use the class without the distraction of irrelevant clutter
|
||||
particular to the implementation.
|
||||
|
||||
|
After Width: | Height: | Size: 22 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 283 KiB |
@@ -0,0 +1,163 @@
|
||||
.. _concurrent_lru_cache:
|
||||
|
||||
concurrent_lru_cache
|
||||
====================
|
||||
|
||||
.. note::
|
||||
To enable this feature, define the ``TBB_PREVIEW_CONCURRENT_LRU_CACHE`` macro to 1.
|
||||
|
||||
A Class Template for Least Recently Used cache with concurrent operations.
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 1
|
||||
|
||||
Description
|
||||
***********
|
||||
|
||||
A ``concurrent_lru_cache`` container maps keys to values with the ability
|
||||
to limit the number of stored unused values. For each key, there is at most one item
|
||||
stored in the container.
|
||||
|
||||
The container permits multiple threads to concurrently retrieve items from it.
|
||||
|
||||
The container tracks which items are in use by returning a proxy
|
||||
``concurrent_lru_cache::handle`` object that refers to an item instead of its value.
|
||||
Once there are no ``handle`` objects holding reference to an item, it is considered unused.
|
||||
|
||||
The container stores all the items that are currently in use plus a limited
|
||||
number of unused items. Excessive unused items are erased according to
|
||||
least recently used policy.
|
||||
|
||||
When no item is found for a given key, the container calls the user-specified
|
||||
``value_function_type`` object to construct a value for the key, and stores that value.
|
||||
The ``value_function_type`` object must be thread-safe.
|
||||
|
||||
API
|
||||
***
|
||||
|
||||
Header
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include "oneapi/tbb/concurrent_lru_cache.h"
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
namespace oneapi {
|
||||
namespace tbb {
|
||||
template <typename Key, typename Value, typename ValueFunctionType = Value (*)(Key)>
|
||||
class concurrent_lru_cache {
|
||||
public:
|
||||
using key_type = Key;
|
||||
using value_type = Value;
|
||||
using pointer = value_type*;
|
||||
using const_pointer = const value_type*;
|
||||
using reference = value_type&;
|
||||
using const_reference = const value_type&;
|
||||
|
||||
using value_function_type = ValueFunctionType;
|
||||
|
||||
class handle {
|
||||
public:
|
||||
handle();
|
||||
handle( handle&& other );
|
||||
|
||||
~handle();
|
||||
|
||||
handle& operator=( handle&& other );
|
||||
|
||||
operator bool() const;
|
||||
value_type& value();
|
||||
}; // class handle
|
||||
|
||||
concurrent_lru_cache( value_function_type f, std::size_t number_of_lru_history_items );
|
||||
~concurrent_lru_cache();
|
||||
|
||||
handle operator[]( key_type key );
|
||||
}; // class concurrent_lru_cache
|
||||
} // namespace tbb
|
||||
} // namespace oneapi
|
||||
|
||||
Member Functions
|
||||
----------------
|
||||
|
||||
.. cpp:function:: concurrent_lru_cache( value_function_type f, std::size_t number_of_lru_history_items );
|
||||
|
||||
**Effects**: Constructs an empty cache that can keep up to ``number_of_lru_history_items``
|
||||
unused values, with a function object ``f`` for constructing new values.
|
||||
|
||||
-------------------------------------------------------
|
||||
|
||||
.. cpp:function:: ~concurrent_lru_cache();
|
||||
|
||||
**Effects**: Destroys the ``concurrent_lru_cache``. Calls the destructors of the stored elements and
|
||||
deallocates the used storage.
|
||||
|
||||
The behavior is undefined in case of concurrent operations with ``*this``.
|
||||
|
||||
-------------------------------------------------------
|
||||
|
||||
.. cpp:function:: handle operator[]( key_type k );
|
||||
|
||||
**Effects**: Searches the container for an item that corresponds to the given key.
|
||||
If such an item is not found, the user-specified function object is called to
|
||||
construct a value that is inserted into the container.
|
||||
|
||||
**Returns**: a ``handle`` object holding reference to the matching value.
|
||||
|
||||
Member Objects
|
||||
--------------
|
||||
|
||||
``handle`` class
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
**Member Functions**
|
||||
|
||||
.. cpp:function:: handle();
|
||||
|
||||
**Effects**: Constructs a ``handle`` object that does not refer to any value.
|
||||
|
||||
--------------------------------------------------
|
||||
|
||||
.. cpp:function:: handle( handle&& other );
|
||||
|
||||
**Effects**: Transfers the reference to the value stored in ``concurrent_lru_cache``
|
||||
from ``other`` to the newly constructed object. Upon completion,
|
||||
``other`` no longer refers to any value.
|
||||
|
||||
---------------------------------------------------
|
||||
|
||||
.. cpp:function:: ~handle();
|
||||
|
||||
**Effects**: Releases the reference (if it exists) to a value stored in ``concurrent_lru_cache``.
|
||||
|
||||
The behavior is undefined for concurrent operations with ``*this``.
|
||||
|
||||
---------------------------------------------------
|
||||
|
||||
.. cpp:function:: handle& operator=( handle&& other );
|
||||
|
||||
**Effects**: Transfers the reference to a value stored in ``concurrent_lru_cache`` from ``other``
|
||||
to ``*this``. If existed, the previous reference held by ``*this`` is released. Upon
|
||||
completion ``other`` no longer refers to any value.
|
||||
|
||||
**Returns**: a reference to ``*this``.
|
||||
|
||||
---------------------------------------------------
|
||||
|
||||
.. cpp:function:: operator bool() const;
|
||||
|
||||
**Returns**: ``true`` if ``*this`` holds reference to a value, ``false`` otherwise.
|
||||
|
||||
---------------------------------------------------
|
||||
|
||||
.. cpp:function:: value_type& value();
|
||||
|
||||
**Returns**: a reference to a ``value_type`` object stored in ``concurrent_lru_cache``.
|
||||
|
||||
The behavior is undefined if ``*this`` does not refer to any value.
|
||||
@@ -0,0 +1,118 @@
|
||||
.. _constraints_extensions:
|
||||
|
||||
task_arena::constraints extensions
|
||||
======================================
|
||||
|
||||
.. note::
|
||||
To enable this feature, set the ``TBB_PREVIEW_TASK_ARENA_CONSTRAINTS_EXTENSION`` macro to 1.
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 1
|
||||
|
||||
Description
|
||||
***********
|
||||
|
||||
These extensions allow to customize ``tbb::task_arena::constraints`` with the following properties:
|
||||
|
||||
* On machines with Intel® Hybrid Technology set the preferred core type for threads working within the task arena.
|
||||
* Limit the maximum number of threads that can be scheduled to one core simultaneously.
|
||||
|
||||
API
|
||||
***
|
||||
|
||||
Header
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include <oneapi/tbb/task_arena.h>
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
namespace oneapi {
|
||||
namespace tbb {
|
||||
|
||||
class task_arena {
|
||||
public:
|
||||
struct constraints {
|
||||
constraints& set_numa_id(numa_node_id id);
|
||||
constraints& set_max_concurrency(int maximal_concurrency);
|
||||
constraints& set_core_type(core_type_id id);
|
||||
constraints& set_max_threads_per_core(int threads_number);
|
||||
|
||||
numa_node_id numa_id = task_arena::automatic;
|
||||
int max_concurrency = task_arena::automatic;
|
||||
core_type_id core_type = task_arena::automatic;
|
||||
int max_threads_per_core = task_arena::automatic;
|
||||
}; // struct constraints
|
||||
}; // class task_arena
|
||||
|
||||
} // namespace tbb
|
||||
} // namespace oneapi
|
||||
|
||||
Member Functions
|
||||
----------------
|
||||
|
||||
.. cpp:function:: constraints& set_numa_id(numa_node_id id)
|
||||
|
||||
Sets the ``numa_id`` field to the ``id``.
|
||||
|
||||
**Returns:** Reference to ``*this``.
|
||||
|
||||
.. cpp:function:: constraints& set_max_concurrency(int maximal_concurrency)
|
||||
|
||||
Sets the ``max_concurrency`` field to the ``maximal_concurrency``.
|
||||
|
||||
**Returns:** Reference to ``*this``.
|
||||
|
||||
.. cpp:function:: constraints& set_core_type(core_type_id id)
|
||||
|
||||
Sets the ``core_type`` field to the ``id``.
|
||||
|
||||
**Returns:** Reference to ``*this``.
|
||||
|
||||
.. cpp:function:: constraints& set_max_threads_per_core(int threads_number)
|
||||
|
||||
Sets the ``max_threads_per_core`` field to the ``threads_number``.
|
||||
|
||||
**Returns:** Reference to ``*this``.
|
||||
|
||||
Member Objects
|
||||
--------------
|
||||
|
||||
.. cpp:member:: numa_node_id numa_id
|
||||
|
||||
An integral logical index uniquely identifying a NUMA node. All threads joining the
|
||||
``task_arena`` are bound to this NUMA node.
|
||||
|
||||
.. note::
|
||||
|
||||
To obtain a valid NUMA node ID, call ``oneapi::tbb::info::numa_nodes()``.
|
||||
|
||||
.. cpp:member:: int max_concurrency
|
||||
|
||||
The maximum number of threads that can participate in work processing within the
|
||||
``task_arena`` at the same time.
|
||||
|
||||
|
||||
.. cpp:member:: core_type_id core_type
|
||||
|
||||
An integral logical index uniquely identifying a core type. All threads joining the
|
||||
``task_arena`` are bound to this core type.
|
||||
|
||||
.. note::
|
||||
|
||||
To obtain a valid core type node ID, call ``oneapi::tbb::info::core_types()``.
|
||||
|
||||
.. cpp:member:: int max_threads_per_core
|
||||
|
||||
The maximum number of threads that can be scheduled to one core simultaneously.
|
||||
|
||||
See also:
|
||||
|
||||
* :doc:`oneapi::tbb::info namespace preview extensions <info_namespace_extensions>`
|
||||
* `oneapi::tbb::task_arena specification <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/task_scheduler/task_arena/task_arena_cls.html>`_
|
||||
@@ -0,0 +1,104 @@
|
||||
.. _constructors_for_fg_nodes:
|
||||
|
||||
Constructors for Flow Graph nodes
|
||||
=================================
|
||||
|
||||
.. note::
|
||||
To enable this feature, define the ``TBB_PREVIEW_FLOW_GRAPH_FEATURES`` macro to 1.
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 1
|
||||
|
||||
Description
|
||||
***********
|
||||
|
||||
The "Helper Functions for Expressing Graphs" feature adds a set of new constructors
|
||||
that can be used to construct a node that ``follows`` or ``precedes`` a set of nodes.
|
||||
|
||||
Where possible, the constructors support Class Template Argument Deduction (since C++17).
|
||||
|
||||
API
|
||||
***
|
||||
|
||||
Header
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include <oneapi/tbb/flow_graph.h>
|
||||
|
||||
Syntax
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
// continue_node
|
||||
continue_node(follows(...), Body body, Policy = Policy());
|
||||
continue_node(precedes(...), Body body, Policy = Policy());
|
||||
|
||||
continue_node(follows(...), int number_of_predecessors, Body body, Policy = Policy());
|
||||
continue_node(precedes(...), int number_of_predecessors, Body body, Policy = Policy());
|
||||
|
||||
// function_node
|
||||
function_node(follows(...), std::size_t concurrency, Policy = Policy());
|
||||
function_node(precedes(...), std::size_t concurrency, Policy = Policy());
|
||||
|
||||
// input_node
|
||||
input_node(precedes(...), body);
|
||||
|
||||
// multifunction_node
|
||||
multifunction_node(follows(...), std::size_t concurrency, Body body);
|
||||
multifunction_node(precedes(...), std::size_t concurrency, Body body);
|
||||
|
||||
// async_node
|
||||
async_node(follows(...), std::size_t concurrency, Body body);
|
||||
async_node(precedes(...), std::size_t concurrency, Body body);
|
||||
|
||||
// overwrite_node
|
||||
explicit overwrite_node(follows(...));
|
||||
explicit overwrite_node(precedes(...));
|
||||
|
||||
// write_once_node
|
||||
explicit write_once_node(follows(...));
|
||||
explicit write_once_node(precedes(...));
|
||||
|
||||
// buffer_node
|
||||
explicit buffer_node(follows(...));
|
||||
explicit buffer_node(precedes(...));
|
||||
|
||||
// queue_node
|
||||
explicit queue_node(follows(...));
|
||||
explicit queue_node(precedes(...));
|
||||
|
||||
// priority_queue_node
|
||||
explicit priority_queue_node(follows(...), const Compare& comp = Compare());
|
||||
explicit priority_queue_node(precedes(...), const Compare& compare = Compare());
|
||||
|
||||
// sequencer_node
|
||||
sequencer_node(follows(...), const Sequencer& s);
|
||||
sequencer_node(precedes(...), const Sequencer& s);
|
||||
|
||||
// limiter_node
|
||||
limiter_node(follows(...), std::size_t threshold);
|
||||
limiter_node(precedes(...), std::size_t threshold);
|
||||
|
||||
// broadcast_node
|
||||
explicit broadcast_node(follows(...));
|
||||
explicit broadcast_node(precedes(...));
|
||||
|
||||
// join_node
|
||||
explicit join_node(follows(...), Policy = Policy());
|
||||
explicit join_node(precedes(...), Policy = Policy());
|
||||
|
||||
// split_node
|
||||
explicit split_node(follows(...));
|
||||
explicit split_node(precedes(...));
|
||||
|
||||
// indexer_node
|
||||
indexer_node(follows(...));
|
||||
indexer_node(precedes(...));
|
||||
|
||||
See Also
|
||||
********
|
||||
:ref:`follows_precedes`
|
||||
@@ -0,0 +1,158 @@
|
||||
.. _custom_mutex_chmap:
|
||||
|
||||
The customizing mutex type for ``concurrent_hash_map``
|
||||
======================================================
|
||||
|
||||
.. note::
|
||||
To enable this feature, define the ``TBB_PREVIEW_CONCURRENT_HASH_MAP_EXTENSIONS`` macro to 1.
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 1
|
||||
|
||||
Description
|
||||
***********
|
||||
|
||||
oneTBB ``concurrnent_hash_map`` class uses reader-writer mutex
|
||||
to provide thread safety and avoid data races for insert, lookup, and erasure operations. This feature adds an extra template parameter
|
||||
for ``concurrent_hash_map`` that allows to customize the type of the reader-writer mutex.
|
||||
|
||||
API
|
||||
***
|
||||
|
||||
Header
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include <oneapi/tbb/concurrent_hash_map.h>
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
namespace oneapi {
|
||||
namespace tbb {
|
||||
|
||||
template <typename Key, typename T,
|
||||
typename HashCompare = tbb_hash_compare<Key>,
|
||||
typename Allocator = tbb_allocator<std::pair<const Key, T>>,
|
||||
typename Mutex = spin_rw_mutex>
|
||||
class concurrent_hash_map {
|
||||
using mutex_type = Mutex;
|
||||
};
|
||||
|
||||
} // namespace tbb
|
||||
} // namespace oneapi
|
||||
|
||||
Type requirements
|
||||
-----------------
|
||||
|
||||
The type of the mutex passed as a template argument for ``concurrent_hash_map`` should
|
||||
meet the requirements of `ReaderWriterMutex <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/named_requirements/mutexes/rw_mutex.html>`_.
|
||||
It should also provide the following API:
|
||||
|
||||
.. cpp:function:: bool ReaderWriterMutex::scoped_lock::is_writer() const;
|
||||
|
||||
**Returns**: ``true`` if the ``scoped_lock`` object acquires the mutex as a writer, ``false`` otherwise.
|
||||
|
||||
The behavior is undefined if the ``scoped_lock`` object does not acquire the mutex.
|
||||
|
||||
``oneapi::tbb::spin_rw_mutex``, ``oneapi::tbb::speculative_spin_rw_mutex``, ``oneapi::tbb::queuing_rw_mutex``, ``oneapi::tbb::null_rw_mutex``,
|
||||
and ``oneapi::tbb::rw_mutex`` meet the requirements above.
|
||||
|
||||
.. rubric:: Example
|
||||
|
||||
The example below demonstrates how to wrap ``std::shared_mutex`` (C++17) to meet the requirements
|
||||
of `ReaderWriterMutex` and how to customize ``concurrent_hash_map`` to use this mutex.
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#define TBB_PREVIEW_CONCURRENT_HASH_MAP_EXTENSIONS 1
|
||||
#include "oneapi/tbb/concurrent_hash_map.h"
|
||||
#include <shared_mutex>
|
||||
|
||||
class SharedMutexWrapper {
|
||||
public:
|
||||
// ReaderWriterMutex requirements
|
||||
|
||||
static constexpr bool is_rw_mutex = true;
|
||||
static constexpr bool is_recursive_mutex = false;
|
||||
static constexpr bool is_fair_mutex = false;
|
||||
|
||||
class scoped_lock {
|
||||
public:
|
||||
scoped_lock() : my_mutex_ptr(nullptr), my_writer_flag(false) {}
|
||||
scoped_lock(SharedMutexWrapper& mutex, bool write = true)
|
||||
: my_mutex_ptr(&mutex), my_writer_flag(write)
|
||||
{
|
||||
if (my_writer_flag) {
|
||||
my_mutex_ptr->my_mutex.lock();
|
||||
} else {
|
||||
my_mutex_ptr->my_mutex.lock_shared();
|
||||
}
|
||||
}
|
||||
|
||||
~scoped_lock() {
|
||||
if (my_mutex_ptr) release();
|
||||
}
|
||||
|
||||
void acquire(SharedMutexWrapper& mutex, bool write = true) {
|
||||
if (my_mutex_ptr) release();
|
||||
|
||||
my_mutex_ptr = &mutex;
|
||||
my_writer_flag = write;
|
||||
|
||||
if (my_writer_flag) {
|
||||
my_mutex_ptr->my_mutex.lock();
|
||||
} else {
|
||||
my_mutex_ptr->my_mutex.lock_shared();
|
||||
}
|
||||
}
|
||||
|
||||
void release() {
|
||||
if (my_writer_flag) {
|
||||
my_mutex_ptr->my_mutex.unlock();
|
||||
} else {
|
||||
my_mutex_ptr->my_mutex.unlock_shared();
|
||||
}
|
||||
}
|
||||
|
||||
bool upgrade_to_writer() {
|
||||
// std::shared_mutex does not have the upgrade/downgrade parallel_for_each_semantics
|
||||
if (my_writer_flag) return true; // Already a writer
|
||||
|
||||
my_mutex_ptr->my_mutex.unlock_shared();
|
||||
my_mutex_ptr->my_mutex.lock();
|
||||
return false; // The lock was reacquired
|
||||
}
|
||||
|
||||
bool downgrade_to_reader() {
|
||||
if (!my_writer_flag) return true; // Already a reader
|
||||
|
||||
my_mutex_ptr->my_mutex.unlock();
|
||||
my_mutex_ptr->my_mutex.lock_shared();
|
||||
return false;
|
||||
}
|
||||
|
||||
bool is_writer() const {
|
||||
return my_writer_flag;
|
||||
}
|
||||
|
||||
private:
|
||||
SharedMutexWrapper* my_mutex_ptr;
|
||||
bool my_writer_flag;
|
||||
};
|
||||
private:
|
||||
std::shared_mutex my_mutex;
|
||||
}; // struct SharedMutexWrapper
|
||||
|
||||
int main() {
|
||||
using map_type = oneapi::tbb::concurrent_hash_map<int, int,
|
||||
oneapi::tbb::tbb_hash_compare<int>,
|
||||
oneapi::tbb::tbb_allocator<std::pair<const int, int>>,
|
||||
SharedMutexWrapper>;
|
||||
|
||||
map_type map; // This object will use SharedMutexWrapper for thread safety of insert/find/erase operations
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
.. _follows_precedes:
|
||||
|
||||
``follows`` and ``precedes`` function templates
|
||||
===============================================
|
||||
|
||||
.. note::
|
||||
To enable this feature, define the ``TBB_PREVIEW_FLOW_GRAPH_FEATURES`` macro to 1.
|
||||
|
||||
The ``follows`` and ``precedes`` helper functions aid in expressing
|
||||
dependencies between nodes when building oneTBB flow graphs. These helper functions can
|
||||
only be used while constructing the node.
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 1
|
||||
|
||||
Description
|
||||
***********
|
||||
|
||||
The ``follows`` helper function specifies that the node being constructed is
|
||||
the successor of the set of nodes passed as an argument.
|
||||
|
||||
The ``precedes`` helper function specifies that the node being constructed is
|
||||
the predecessor of the set of nodes passed as an argument.
|
||||
|
||||
Functions ``follows`` and ``precedes`` are meant to replace the graph argument, which is
|
||||
passed as the first argument to the constructor of the node. The graph argument for the
|
||||
node being constructed is obtained either from the specified node set or the sequence of nodes passed
|
||||
to ``follows`` or ``precedes``.
|
||||
|
||||
If the nodes passed to ``follows`` or ``precedes`` belong to
|
||||
different graphs, the behavior is undefined.
|
||||
|
||||
API
|
||||
***
|
||||
|
||||
Header
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include <oneapi/tbb/flow_graph.h>
|
||||
|
||||
Syntax
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
// node_set is an exposition-only name for the type returned from make_node_set function
|
||||
|
||||
template <typename NodeType, typename... NodeTypes>
|
||||
/*unspecified*/ follows( node_set<NodeType, NodeTypes...>& set );
|
||||
|
||||
template <typename NodeType, typename... NodeTypes>
|
||||
/*unspecified*/ follows( NodeType& node, NodeTypes&... nodes );
|
||||
|
||||
template <typename NodeType, typename... NodeTypes>
|
||||
/*unspecified*/ precedes( node_set<NodeType, NodeTypes...>& set );
|
||||
|
||||
template <typename NodeType, typename... NodeTypes>
|
||||
/*unspecified*/ precedes( NodeType& node, NodeTypes&... nodes );
|
||||
|
||||
Input Parameters
|
||||
----------------
|
||||
|
||||
Either a set or a sequence of nodes can be used as arguments for ``follows`` and
|
||||
``precedes``. The following expressions are equivalent:
|
||||
|
||||
.. code-block:: cpp
|
||||
:caption: A set of nodes as an input
|
||||
|
||||
auto handlers = make_node_set(n1, n2, n3);
|
||||
broadcast_node<int> input(precedes(handlers));
|
||||
|
||||
.. code-block:: cpp
|
||||
:caption: A sequence of nodes as an input
|
||||
|
||||
broadcast_node<int> input(precedes(n1, n2, n3));
|
||||
@@ -0,0 +1,118 @@
|
||||
.. _helpers_for_expressing_graphs:
|
||||
|
||||
Helper Functions for Expressing Graphs
|
||||
======================================
|
||||
|
||||
.. note::
|
||||
To enable this feature, define the ``TBB_PREVIEW_FLOW_GRAPH_FEATURES`` macro to 1.
|
||||
|
||||
Helper functions are intended to make creation of the flow graphs less verbose.
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 1
|
||||
|
||||
Description
|
||||
***********
|
||||
|
||||
This feature adds ``make_edges``, ``make_node_set``,
|
||||
``follows`` and ``precedes`` functions to ``oneapi::tbb::flow`` namespace.
|
||||
These functions simplify the process of building flow graphs by allowing to gather nodes
|
||||
into sets and connect them to other nodes in the graph.
|
||||
|
||||
API
|
||||
***
|
||||
|
||||
.. toctree::
|
||||
:titlesonly:
|
||||
|
||||
constructors_for_nodes
|
||||
follows_and_precedes_functions
|
||||
make_node_set_function
|
||||
make_edges_function
|
||||
|
||||
Example
|
||||
*******
|
||||
|
||||
Consider the graph depicted below.
|
||||
|
||||
.. figure:: ./Resources/fg_api_graph_structure.png
|
||||
:align: center
|
||||
|
||||
In the examples below, C++17 Class Template Argument Deduction is used
|
||||
to avoid template parameter specification where possible.
|
||||
|
||||
**Regular API**
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include <oneapi/tbb/flow_graph.h>
|
||||
|
||||
int main() {
|
||||
using namespace oneapi::tbb::flow;
|
||||
|
||||
graph g;
|
||||
|
||||
broadcast_node<int> input(g);
|
||||
|
||||
function_node doubler(g, unlimited, [](const int& v) { return 2 * v; });
|
||||
function_node squarer(g, unlimited, [](const int&) { return v * v; });
|
||||
function_node cuber(g, unlimited, [](const int& v) { return v * v * v; });
|
||||
|
||||
join_node<std::tuple<int, int, int>> join(g);
|
||||
|
||||
int sum = 0;
|
||||
function_node summer(g, serial, [&](const std::tuple<int, int, int>& v) {
|
||||
int sub_sum = std::get<0>(v) + std::get<1>(v) + std::get<2>(v);
|
||||
sum += sub_sum;
|
||||
return sub_sum;
|
||||
});
|
||||
|
||||
make_edge(input, doubler);
|
||||
make_edge(input, squarer);
|
||||
make_edge(input, cuber);
|
||||
make_edge(doubler, std::get<0>(join.input_ports()));
|
||||
make_edge(squarer, std::get<1>(join.input_ports()));
|
||||
make_edge(cuber, std::get<2>(join.input_ports()));
|
||||
make_edge(join, summer);
|
||||
|
||||
for (int i = 1; i <= 10; ++i) {
|
||||
input.try_put(i);
|
||||
}
|
||||
g.wait_for_all();
|
||||
}
|
||||
|
||||
**Preview API**
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#define TBB_PREVIEW_FLOW_GRAPH_FEATURES 1
|
||||
#include <oneapi/tbb/flow_graph.h>
|
||||
|
||||
int main() {
|
||||
using namespace oneapi::tbb::flow;
|
||||
|
||||
graph g;
|
||||
|
||||
function_node doubler(g, unlimited, [](const int& v) { return 2 * v; });
|
||||
function_node squarer(g, unlimited, [](const int&) { return v * v; });
|
||||
function_node cuber(g, unlimited, [](const int& v) { return v * v * v; });
|
||||
|
||||
auto handlers = make_node_set(doubler, squarer, cuber);
|
||||
|
||||
broadcast_node input(precedes(handlers));
|
||||
join_node join(follows(handlers));
|
||||
|
||||
int sum = 0;
|
||||
function_node summer(follows(join), serial,
|
||||
[&](const std::tuple<int, int, int>& v) {
|
||||
int sub_sum = std::get<0>(v) + std::get<1>(v) + std::get<2>(v);
|
||||
sum += sub_sum;
|
||||
return sub_sum;
|
||||
});
|
||||
|
||||
for (int i = 1; i <= 10; ++i) {
|
||||
input.try_put(i);
|
||||
}
|
||||
g.wait_for_all();
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
.. _info_namespace:
|
||||
|
||||
oneapi::tbb::info namespace
|
||||
===========================
|
||||
|
||||
The ``oneapi::tbb::info`` namespace satisfies `the corresponding oneTBB specification section
|
||||
<https://spec.oneapi.com/versions/latest/elements/oneTBB/source/info_namespace.html>`_.
|
||||
|
||||
The |full_name| implementation requires `the hwloc library <https://www-lb.open-mpi.org/projects/hwloc>`_
|
||||
to query NUMA(version >= 1.11) and Hybrid CPUs(version >= 2.4) topology information.
|
||||
|
||||
See also:
|
||||
|
||||
* `info namespace specification <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/info_namespace.html>`_
|
||||
* `oneapi::tbb::task_arena specification <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/task_scheduler/task_arena/task_arena_cls.html>`_
|
||||
* :doc:`oneapi::tbb::info namespace preview extensions <info_namespace_extensions>`
|
||||
* :doc:`task_arena::constraints class preview extensions <constraints_extensions>`
|
||||
@@ -0,0 +1,71 @@
|
||||
.. _info_namespace_extensions:
|
||||
|
||||
oneapi::tbb::info namespace extensions
|
||||
======================================
|
||||
|
||||
.. note::
|
||||
To enable this feature, set the ``TBB_PREVIEW_TASK_ARENA_CONSTRAINTS_EXTENSION`` macro to 1.
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 1
|
||||
|
||||
Description
|
||||
***********
|
||||
|
||||
These extensions allow to query information about execution environment.
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 1
|
||||
|
||||
API
|
||||
***
|
||||
|
||||
Header
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include <oneapi/tbb/info.h>
|
||||
|
||||
Syntax
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
namespace oneapi {
|
||||
namespace tbb {
|
||||
using core_type_id = /*implementation-defined*/;
|
||||
namespace info {
|
||||
std::vector<core_type_id> core_types();
|
||||
int default_concurrency(task_arena::constraints c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Types
|
||||
-----
|
||||
|
||||
``core_type_id`` - Represents core type identifier.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
.. cpp:function:: std::vector<core_type_id> core_types()
|
||||
|
||||
Returns the vector of integral indexes that indicate available core types.
|
||||
The indexes are sorted from the least performant to the most performant core type.
|
||||
|
||||
.. note::
|
||||
If error occurs during system topology parsing, returns vector containing single element
|
||||
that equals to ``task_arena::automatic``.
|
||||
|
||||
.. cpp:function:: int default_concurrency(task_arena::constraints c)
|
||||
|
||||
Returns concurrency level for the given constraints.
|
||||
|
||||
See also:
|
||||
|
||||
* :doc:`task_arena::constraints class preview extensions <constraints_extensions>`
|
||||
* `info namespace specification <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/info_namespace.html>`_
|
||||
@@ -0,0 +1,81 @@
|
||||
.. _make_edges:
|
||||
|
||||
``make_edges`` function template
|
||||
================================
|
||||
|
||||
.. note::
|
||||
To enable this feature, define the ``TBB_PREVIEW_FLOW_GRAPH_FEATURES`` macro to 1.
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 1
|
||||
|
||||
Description
|
||||
***********
|
||||
|
||||
The ``make_edges`` function template creates edges between a single node
|
||||
and each node in a set of nodes.
|
||||
|
||||
There are two ways to connect nodes in a set and a single node using
|
||||
``make_edges``:
|
||||
|
||||
.. figure:: ./Resources/make_edges_usage.png
|
||||
:align: center
|
||||
|
||||
API
|
||||
***
|
||||
|
||||
Header
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include <oneapi/tbb/flow_graph.h>
|
||||
|
||||
Syntax
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
// node_set is an exposition-only name for the type returned from make_node_set function
|
||||
|
||||
template <typename NodeType, typename Node, typename... Nodes>
|
||||
void make_edges(node_set<Node, Nodes...>& set, NodeType& node);
|
||||
|
||||
template <typename NodeType, typename Node, typename... Nodes>
|
||||
void make_edges(NodeType& node, node_set<Node, Nodes...>& set);
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
The example implements the graph structure in the picture below.
|
||||
|
||||
.. figure:: ./Resources/make_edges_example.png
|
||||
:align: center
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#define TBB_PREVIEW_FLOW_GRAPH_FEATURES 1
|
||||
#include <oneapi/tbb/flow_graph.h>
|
||||
|
||||
int main() {
|
||||
using namespace oneapi::tbb::flow;
|
||||
|
||||
graph g;
|
||||
broadcast_node<int> input(g);
|
||||
|
||||
function_node doubler(g, unlimited, [](const int& i) { return 2 * i; });
|
||||
function_node squarer(g, unlimited, [](const int& i) { return i * i; });
|
||||
function_node cuber(g, unlimited, [](const int& i) { return i * i * i; });
|
||||
|
||||
buffer_node<int> buffer(g);
|
||||
|
||||
auto handlers = make_node_set(doubler, squarer, cuber);
|
||||
make_edges(input, handlers);
|
||||
make_edges(handlers, buffer);
|
||||
|
||||
for (int i = 1; i <= 10; ++i) {
|
||||
input.try_put(i);
|
||||
}
|
||||
g.wait_for_all();
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
.. _make_node_set:
|
||||
|
||||
``make_node_set`` function template
|
||||
===================================
|
||||
|
||||
.. note::
|
||||
To enable this feature, define the ``TBB_PREVIEW_FLOW_GRAPH_FEATURES`` macro to 1.
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 1
|
||||
|
||||
Description
|
||||
***********
|
||||
|
||||
The ``make_node_set`` function template creates a set of nodes that
|
||||
can be passed as arguments to ``make_edges``, ``follows`` and ``precedes`` functions.
|
||||
|
||||
API
|
||||
***
|
||||
|
||||
Header
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include <oneapi/tbb/flow_graph.h>
|
||||
|
||||
Syntax
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
template <typename Node, typename... Nodes>
|
||||
/*unspecified*/ make_node_set( Node& node, Nodes&... nodes );
|
||||
|
||||
See Also
|
||||
********
|
||||
|
||||
:ref:`make_edges`
|
||||
|
||||
:ref:`follows_precedes`
|
||||
@@ -0,0 +1,66 @@
|
||||
.. _parallel_for_each_semantics:
|
||||
|
||||
parallel_for_each Body semantics and requirements
|
||||
=================================================
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 1
|
||||
|
||||
Description
|
||||
***********
|
||||
|
||||
This page clarifies `ParallelForEachBody <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/named_requirements/algorithms/par_for_each_body.html>`_
|
||||
named requirements for ``tbb::parallel_for_each`` algorithm specification.
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
namespace oneapi {
|
||||
namespace tbb {
|
||||
|
||||
template <typaname InputIterator, typename Body>
|
||||
void parallel_for_each( InputIterator first, InputIterator last, Body body ); // overload (1)
|
||||
template <typename InputIterator, typename Body>
|
||||
void parallel_for_each( InputIterator first, InputIterator last, Body body, task_group_context& group ); // overload (2)
|
||||
|
||||
template <typename Container, typename Body>
|
||||
void parallel_for_each( Container& c, Body body ); // overload (3)
|
||||
template <typename Container, typename Body>
|
||||
void parallel_for_each( Container& c, Body body, task_group_context& group ); // overload (4)
|
||||
|
||||
template <typename Container, typename Body>
|
||||
void parallel_for_each( const Container& c, Body body ); // overload (5)
|
||||
template <typename Container, typename Body>
|
||||
void parallel_for_each( const Container& c, Body body, task_group_context& group ); // overload (6)
|
||||
|
||||
} // namespace tbb
|
||||
} // namespace oneapi
|
||||
|
||||
Terms
|
||||
-----
|
||||
|
||||
* ``iterator`` determines the type of the iterator passed into ``parallel_for_each`` algorithm (which is ``InputIterator`` for overloads `(1)` and `(2)`
|
||||
and ``decltype(std::begin(c))`` for overloads `(3) - (6)`)
|
||||
* ``value_type`` - the type ``typename std::iterator_traits<iterator>::value_type``
|
||||
* ``reference`` - the type ``typename std::iterator_traits<iterator>::reference``.
|
||||
|
||||
Requirements for different iterator types
|
||||
-----------------------------------------
|
||||
|
||||
If the ``iterator`` satisfies `Input iterator` named requirements from [input.iterators] ISO C++ Standard section and do not satisfies
|
||||
`Forward iterator` named requirements from [forward.iterators] ISO C++ Standard section, ``tbb::parallel_for_each`` requires the execution
|
||||
of the ``body`` with an object of type ``const value_type&`` or ``value_type&&`` to be well-formed. If both forms are well-formed, an overload with
|
||||
rvalue reference will be preferred.
|
||||
|
||||
.. caution::
|
||||
|
||||
If the ``Body`` only takes non-const lvalue reference to ``value_type``, named requirements above are violated and the program can be ill-formed.
|
||||
|
||||
If the ``iterator`` satisfies `Forward iterator` named requirements from [forward.iterators] ISO C++ Standard section, ``tbb::parallel_for_each`` requires the execution of the ``body``
|
||||
with an object of type ``reference`` to be well-formed.
|
||||
|
||||
Requirements for ``Body`` with ``feeder`` argument
|
||||
--------------------------------------------------
|
||||
|
||||
Additional elements submitted into ``tbb::parallel_for_each`` through the ``feeder::add`` passes to the ``Body`` as rvalues and therefore the corresponding
|
||||
execution of the ``Body`` is required to be well-formed.
|
||||
@@ -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());
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
.. _reference:
|
||||
|
||||
|short_name| API Reference
|
||||
==========================
|
||||
|
||||
For oneTBB API Reference, refer to `oneAPI Specification <https://spec.oneapi.com/>`_. The current supported
|
||||
version of oneAPI Specification is 1.0.
|
||||
|
||||
Specification extensions
|
||||
************************
|
||||
|
||||
|full_name| implements the `oneTBB specification <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/nested-index.html>`_.
|
||||
This document provides additional details or restrictions where necessary.
|
||||
It also describes features that are not included in the oneTBB specification.
|
||||
|
||||
.. toctree::
|
||||
:titlesonly:
|
||||
|
||||
info_namespace
|
||||
parallel_for_each_semantics
|
||||
parallel_sort_ranges_extension
|
||||
|
||||
Preview features
|
||||
****************
|
||||
|
||||
A preview feature is a component of oneTBB introduced to receive early feedback from
|
||||
users.
|
||||
|
||||
The key properties of a preview feature are:
|
||||
|
||||
- It is off by default and must be explicitly enabled.
|
||||
- It is intended to have a high quality implementation.
|
||||
- There is no guarantee of future existence or compatibility.
|
||||
- It may have limited or no support in tools such as correctness analyzers, profilers and debuggers.
|
||||
|
||||
|
||||
.. caution::
|
||||
A preview feature is subject to change in future. It might be removed or significantly
|
||||
altered in future releases. Changes to a preview feature do NOT require
|
||||
usual deprecation and removal process. Therefore, using preview features in production code
|
||||
is strongly discouraged.
|
||||
|
||||
.. toctree::
|
||||
:titlesonly:
|
||||
|
||||
type_specified_message_keys
|
||||
scalable_memory_pools
|
||||
helpers_for_expressing_graphs
|
||||
concurrent_lru_cache_cls
|
||||
constraints_extensions
|
||||
info_namespace_extensions
|
||||
task_group_extensions
|
||||
custom_mutex_chmap
|
||||
@@ -0,0 +1,43 @@
|
||||
.. _scalable_memory_pools_reference:
|
||||
|
||||
Scalable Memory Pools
|
||||
=====================
|
||||
|
||||
.. note::
|
||||
To enable this feature, set the ``TBB_PREVIEW_MEMORY_POOL`` macro to 1.
|
||||
|
||||
Memory pools allocate and free memory from a specified region or an underlying allocator using
|
||||
thread-safe, scalable operations. The following table summarizes the Memory Pool named requirement.
|
||||
Here, ``P`` represents an instance of the memory pool class.
|
||||
|
||||
.. container:: tablenoborder
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
|
||||
* - Pseudo-Signature
|
||||
- Semantics
|
||||
* - \ ``~P() throw();``
|
||||
- Destructor. Frees all the allocated memory.
|
||||
* - \ ``void P::recycle();``
|
||||
- Frees all the allocated memory.
|
||||
* - \ ``void* P::malloc(size_t n);``
|
||||
- Returns a pointer to ``n`` bytes allocated from the memory pool.
|
||||
* - \ ``void P::free(void* ptr);``
|
||||
- Frees the memory object specified via ``ptr`` pointer.
|
||||
* - \ ``void* P::realloc(void* ptr, size_t n);``
|
||||
- Reallocates the memory object pointed by ``ptr`` to ``n`` bytes.
|
||||
|
||||
.. container:: section
|
||||
|
||||
.. rubric:: Model Types
|
||||
:class: sectiontitle
|
||||
|
||||
The ``memory_pool`` template class and the ``fixed_pool`` class meet the Memory Pool named requirement.
|
||||
|
||||
.. toctree::
|
||||
:titlesonly:
|
||||
|
||||
scalable_memory_pools/memory_pool_cls
|
||||
scalable_memory_pools/fixed_pool_cls
|
||||
scalable_memory_pools/memory_pool_allocator_cls
|
||||
@@ -0,0 +1,76 @@
|
||||
.. _fixed_pool_cls:
|
||||
|
||||
fixed_pool
|
||||
==========
|
||||
|
||||
.. note::
|
||||
To enable this feature, set the ``TBB_PREVIEW_MEMORY_POOL`` macro to 1.
|
||||
|
||||
A class for scalable memory allocation from a buffer of fixed size.
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 1
|
||||
|
||||
Description
|
||||
***********
|
||||
|
||||
``fixed_pool`` allocates and frees memory in a way that scales with the number of processors.
|
||||
All the memory available for the allocation is initially passed through arguments of the constructor.
|
||||
``fixed_pool`` meet the :doc:`Memory Pool named requirement<../scalable_memory_pools>`.
|
||||
|
||||
API
|
||||
***
|
||||
|
||||
Header
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include "oneapi/tbb/memory_pool.h"
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
namespace oneapi {
|
||||
namespace tbb {
|
||||
class fixed_pool {
|
||||
public:
|
||||
fixed_pool(void *buffer, size_t size);
|
||||
fixed_pool(const fixed_pool& other) = delete;
|
||||
fixed_pool& operator=(const fixed_pool& other) = delete;
|
||||
~fixed_pool();
|
||||
|
||||
void recycle();
|
||||
void* malloc(size_t size);
|
||||
void free(void* ptr);
|
||||
void* realloc(void* ptr, size_t size);
|
||||
};
|
||||
} // namespace tbb
|
||||
} // namespace oneapi
|
||||
|
||||
Member Functions
|
||||
----------------
|
||||
|
||||
.. cpp:function:: fixed_pool(void *buffer, size_t size)
|
||||
|
||||
**Effects**: Constructs a memory pool to manage the memory of size ``size`` pointed to by ``buffer``.
|
||||
Throws the ``bad_alloc`` exception if the library fails to construct an instance of the class.
|
||||
|
||||
Examples
|
||||
********
|
||||
|
||||
The code below provides a simple example of allocation from a fixed pool.
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#define TBB_PREVIEW_MEMORY_POOL 1
|
||||
#include "oneapi/tbb/memory_pool.h"
|
||||
...
|
||||
char buf[1024*1024];
|
||||
oneapi::tbb::fixed_pool my_pool(buf, 1024*1024);
|
||||
void* my_ptr = my_pool.malloc(10);
|
||||
my_pool.free(my_ptr);}
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
.. _memory_pool_allocator_cls:
|
||||
|
||||
memory_pool_allocator
|
||||
=====================
|
||||
|
||||
.. note::
|
||||
To enable this feature, set the ``TBB_PREVIEW_MEMORY_POOL`` macro to 1.
|
||||
|
||||
A class template that provides a memory pool with a C++ allocator interface.
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 1
|
||||
|
||||
Description
|
||||
***********
|
||||
|
||||
``memory_pool_allocator`` meets the allocator requirements from the [allocator.requirements] ISO C++ Standard section
|
||||
It also provides a constructor to allocate and deallocate memory.
|
||||
This constructor is linked with an instance of either the ``memory_pool`` or the ``fixed_pool`` class.
|
||||
The class is mainly intended for enabling memory pools within STL containers.
|
||||
|
||||
API
|
||||
***
|
||||
|
||||
Header
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include "oneapi/tbb/memory_pool.h"
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
namespace oneapi {
|
||||
namespace tbb {
|
||||
template<typename T>
|
||||
class memory_pool_allocator {
|
||||
public:
|
||||
using value_type = T;
|
||||
using pointer = value_type*;
|
||||
using const_pointer = const value_type*;
|
||||
using reference = value_type&;
|
||||
using const_reference = const value_type&;
|
||||
using size_type = size_t;
|
||||
using difference_type = ptrdiff_t;
|
||||
template<typename U> struct rebind {
|
||||
using other = memory_pool_allocator<U>;
|
||||
};
|
||||
explicit memory_pool_allocator(memory_pool &pool) throw();
|
||||
explicit memory_pool_allocator(fixed_pool &pool) throw();
|
||||
memory_pool_allocator(const memory_pool_allocator& src) throw();
|
||||
template<typename U>
|
||||
memory_pool_allocator(const memory_pool_allocator<U,P>& src) throw();
|
||||
pointer address(reference x) const;
|
||||
const_pointer address(const_reference x) const;
|
||||
pointer allocate(size_type n, const void* hint=0);
|
||||
void deallocate(pointer p, size_type);
|
||||
size_type max_size() const throw();
|
||||
void construct(pointer p, const T& value);
|
||||
void destroy(pointer p);
|
||||
};
|
||||
|
||||
template<>
|
||||
class memory_pool_allocator<void> {
|
||||
public:
|
||||
using pointer = void*;
|
||||
using const_pointer = const void*;
|
||||
using value_type = void;
|
||||
template<typename U> struct rebind {
|
||||
using other = memory_pool_allocator<U>;
|
||||
};
|
||||
memory_pool_allocator(memory_pool &pool) throw();
|
||||
memory_pool_allocator(fixed_pool &pool) throw();
|
||||
memory_pool_allocator(const memory_pool_allocator& src) throw();
|
||||
template<typename U>
|
||||
memory_pool_allocator(const memory_pool_allocator<U>& src) throw();
|
||||
};
|
||||
} // namespace tbb
|
||||
} // namespace oneapi
|
||||
|
||||
template<typename T, typename U>
|
||||
inline bool operator==( const memory_pool_allocator<T>& a,
|
||||
const memory_pool_allocator<U>& b);
|
||||
template<typename T, typename U>
|
||||
inline bool operator!=( const memory_pool_allocator<T>& a,
|
||||
const memory_pool_allocator<U>& b);
|
||||
|
||||
Member Functions
|
||||
----------------
|
||||
|
||||
.. cpp:function:: explicit memory_pool_allocator(memory_pool &pool)
|
||||
|
||||
**Effects**: Constructs a memory pool allocator serviced by ``memory_pool`` instance pool.
|
||||
|
||||
-------------------------------------------------------
|
||||
|
||||
.. cpp:function:: explicit memory_pool_allocator(fixed_pool &pool)
|
||||
|
||||
**Effects**: Constructs a memory pool allocator serviced by ``fixed_pool`` instance pool.
|
||||
|
||||
Examples
|
||||
********
|
||||
|
||||
The code below provides a simple example of container construction with the use of a memory pool.
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#define TBB_PREVIEW_MEMORY_POOL 1
|
||||
#include "oneapi/tbb/memory_pool.h"
|
||||
...
|
||||
typedef oneapi::tbb::memory_pool_allocator<int>
|
||||
pool_allocator_t;
|
||||
std::list<int, pool_allocator_t> my_list(pool_allocator_t( my_pool ));
|
||||
@@ -0,0 +1,80 @@
|
||||
.. _memory_pool_cls:
|
||||
|
||||
memory_pool
|
||||
===========
|
||||
|
||||
.. note::
|
||||
To enable this feature, set the ``TBB_PREVIEW_MEMORY_POOL`` macro to 1.
|
||||
|
||||
A class template for scalable memory allocation from memory blocks provided by an underlying allocator.
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 1
|
||||
|
||||
Description
|
||||
***********
|
||||
|
||||
A ``memory_pool`` allocates and frees memory in a way that scales with the number of processors.
|
||||
The memory is obtained as big chunks from an underlying allocator specified by the template
|
||||
argument. The latter must satisfy the subset of the allocator requirements from the [allocator.requirements]
|
||||
ISO C++ Standard section. A ``memory_pool`` meet the :doc:`Memory Pool named requirement<../scalable_memory_pools>`.
|
||||
|
||||
.. caution::
|
||||
|
||||
If the underlying allocator refers to another scalable memory pool, the inner pool (or pools)
|
||||
must be destroyed before the outer pool is destroyed or recycled.
|
||||
|
||||
API
|
||||
***
|
||||
|
||||
Header
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include "oneapi/tbb/memory_pool.h"
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
namespace oneapi {
|
||||
namespace tbb {
|
||||
template <typename Alloc>
|
||||
class memory_pool {
|
||||
public:
|
||||
explicit memory_pool(const Alloc &src = Alloc());
|
||||
memory_pool(const memory_pool& other) = delete;
|
||||
memory_pool& operator=(const memory_pool& other) = delete;
|
||||
~memory_pool();
|
||||
void recycle();
|
||||
void *malloc(size_t size);
|
||||
void free(void* ptr);
|
||||
void *realloc(void* ptr, size_t size);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Member Functions
|
||||
----------------
|
||||
|
||||
.. cpp:function:: explicit memory_pool(const Alloc &src = Alloc())
|
||||
|
||||
**Effects**: Constructs a memory pool with an instance of underlying memory allocator of type ``Alloc`` copied from ``src``.
|
||||
Throws the ``bad_alloc`` exception if runtime fails to construct an instance of the class.
|
||||
|
||||
Examples
|
||||
********
|
||||
|
||||
The code below provides a simple example of allocation from an extensible memory pool.
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#define TBB_PREVIEW_MEMORY_POOL 1
|
||||
#include "oneapi/tbb/memory_pool.h"
|
||||
...
|
||||
oneapi::tbb::memory_pool<std::allocator<char> > my_pool;
|
||||
void* my_ptr = my_pool.malloc(10);
|
||||
my_pool.free(my_ptr);
|
||||
@@ -0,0 +1,91 @@
|
||||
.. _task_group_extensions:
|
||||
|
||||
task_group 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_group specification <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/task_scheduler/task_group/task_group_cls.html>`_ with the following members:
|
||||
|
||||
- requirements for a user-provided function object
|
||||
|
||||
|
||||
API
|
||||
***
|
||||
|
||||
Header
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include <oneapi/tbb/task_group.h>
|
||||
|
||||
Synopsis
|
||||
--------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
namespace oneapi {
|
||||
namespace tbb {
|
||||
|
||||
class task_group {
|
||||
public:
|
||||
|
||||
//only the requirements for the return type of function F are changed
|
||||
template<typename F>
|
||||
task_handle defer(F&& f);
|
||||
|
||||
//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);
|
||||
};
|
||||
|
||||
} // namespace tbb
|
||||
} // namespace oneapi
|
||||
|
||||
|
||||
|
||||
Member Functions
|
||||
----------------
|
||||
|
||||
.. cpp:function:: template<typename F> task_handle defer(F&& f)
|
||||
|
||||
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 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> task_group_status run_and_wait(const F& f)
|
||||
|
||||
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 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.
|
||||
|
||||
.. 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.
|
||||
|
||||
|
||||
.. rubric:: See also
|
||||
|
||||
* `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>`
|
||||
@@ -0,0 +1,69 @@
|
||||
.. _class_join_node_extension:
|
||||
|
||||
Type-specified message keys for join_node
|
||||
=========================================
|
||||
|
||||
.. note::
|
||||
To enable this feature, define the ``TBB_PREVIEW_FLOW_GRAPH_FEATURES`` macro to 1.
|
||||
|
||||
.. contents::
|
||||
:local:
|
||||
:depth: 1
|
||||
|
||||
Description
|
||||
***********
|
||||
|
||||
The extension allows a key matching ``join_node`` to obtain keys via functions associated with
|
||||
its input types. The extension simplifies the existing approach by removing the need to
|
||||
provide a function object for each input port of ``join_node``.
|
||||
|
||||
API
|
||||
***
|
||||
|
||||
Header
|
||||
------
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
#include "oneapi/tbb/flow_graph.h"
|
||||
|
||||
Syntax
|
||||
------
|
||||
|
||||
The extension adds a special constructor to the ``join_node`` interface when the
|
||||
``key_matching<typename K, class KHash=tbb_hash_compare>`` policy is
|
||||
used. The constructor has the following signature:
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
join_node( graph &g )
|
||||
|
||||
When constructed this way, a ``join_node`` calls the
|
||||
``key_from_message`` function for each incoming message to obtain the key associated
|
||||
with it. The default implementation of ``key_from_message`` is the following
|
||||
|
||||
.. code:: cpp
|
||||
|
||||
namespace oneapi {
|
||||
namespace tbb {
|
||||
namespace flow {
|
||||
template <typename K, typename T>
|
||||
K key_from_message( const T &t ) {
|
||||
return t.key();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
``T`` is one of the user-provided types in ``OutputTuple`` and is
|
||||
used to construct the ``join_node``, and ``K`` is the key type
|
||||
of the node.
|
||||
By default, the ``key()`` method defined in the message class will be called.
|
||||
Alternatively, the user can define its own ``key_from_message`` function in the
|
||||
same namespace with the message type. This function will be found via C++ argument-dependent
|
||||
lookup and used in place of the default implementation.
|
||||
|
||||
See Also
|
||||
********
|
||||
|
||||
`join_node Specification <https://spec.oneapi.com/versions/latest/elements/oneTBB/source/flow_graph/join_node_cls.html>`_
|
||||
@@ -0,0 +1,96 @@
|
||||
.. _Advanced_Example:
|
||||
|
||||
Advanced Example
|
||||
================
|
||||
|
||||
|
||||
An example of a more advanced associative operation is to find the index
|
||||
where ``Foo(i)`` is minimized. A serial version might look like this:
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
long SerialMinIndexFoo( const float a[], size_t n ) {
|
||||
float value_of_min = FLT_MAX; // FLT_MAX from <climits>
|
||||
long index_of_min = -1;
|
||||
for( size_t i=0; i<n; ++i ) {
|
||||
float value = Foo(a[i]);
|
||||
if( value<value_of_min ) {
|
||||
value_of_min = value;
|
||||
index_of_min = i;
|
||||
}
|
||||
}
|
||||
return index_of_min;
|
||||
}
|
||||
|
||||
|
||||
The loop works by keeping track of the minimum value found so far, and
|
||||
the index of this value. This is the only information carried between
|
||||
loop iterations. To convert the loop to use ``parallel_reduce``, the
|
||||
function object must keep track of the carried information, and how to
|
||||
merge this information when iterations are spread across multiple
|
||||
threads. Also, the function object must record a pointer to ``a`` to
|
||||
provide context.
|
||||
|
||||
|
||||
The following code shows the complete function object.
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
class MinIndexFoo {
|
||||
const float *const my_a;
|
||||
public:
|
||||
float value_of_min;
|
||||
long index_of_min;
|
||||
void operator()( const blocked_range<size_t>& r ) {
|
||||
const float *a = my_a;
|
||||
for( size_t i=r.begin(); i!=r.end(); ++i ) {
|
||||
float value = Foo(a[i]);
|
||||
if( value<value_of_min ) {
|
||||
value_of_min = value;
|
||||
index_of_min = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MinIndexFoo( MinIndexFoo& x, split ) :
|
||||
my_a(x.my_a),
|
||||
value_of_min(FLT_MAX), // FLT_MAX from <climits>
|
||||
index_of_min(-1)
|
||||
{}
|
||||
|
||||
|
||||
void join( const SumFoo& y ) {
|
||||
if( y.value_of_min<value_of_min ) {
|
||||
value_of_min = y.value_of_min;
|
||||
index_of_min = y.index_of_min;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MinIndexFoo( const float a[] ) :
|
||||
my_a(a),
|
||||
value_of_min(FLT_MAX), // FLT_MAX from <climits>
|
||||
index_of_min(-1),
|
||||
{}
|
||||
};
|
||||
|
||||
|
||||
Now ``SerialMinIndex`` can be rewritten using ``parallel_reduce`` as
|
||||
shown below:
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
long ParallelMinIndexFoo( float a[], size_t n ) {
|
||||
MinIndexFoo mif(a);
|
||||
parallel_reduce(blocked_range<size_t>(0,n), mif );
|
||||
|
||||
|
||||
return mif.index_of_min;
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
.. _Advanced_Topic_Other_Kinds_of_Iteration_Spaces:
|
||||
|
||||
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, and two predicate
|
||||
methods. If your class is called ``R``, the methods and constructors should be
|
||||
as follows:
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
class R {
|
||||
// True if range is empty
|
||||
bool empty() const;
|
||||
// True if range can be split into non-empty subranges
|
||||
bool is_divisible() const;
|
||||
// Splits r into subranges r and *this
|
||||
R( R& r, split );
|
||||
// (optional) Splits r into subranges r and *this in proportion p
|
||||
R( R& r, proportional_split p );
|
||||
...
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
The method ``empty`` should return true if the range is empty. The
|
||||
method ``is_divisible`` should return true if the range can be split
|
||||
into two non-empty subspaces, and such a split is worth the overhead.
|
||||
The basic splitting constructor should take two arguments:
|
||||
|
||||
|
||||
- The first of type ``R``
|
||||
|
||||
|
||||
- The second of type oneapi::tbb::split
|
||||
|
||||
|
||||
The second argument is not used; it serves only to distinguish the
|
||||
constructor from an ordinary copy constructor. The basic splitting
|
||||
constructor should attempt to split ``r`` roughly into two halves, and
|
||||
update ``r`` to be the first half, and set the constructed object as the
|
||||
second half.
|
||||
|
||||
|
||||
Unlike the basic splitting constructor, the proportional splitting
|
||||
constructor is optional and takes the second argument of type
|
||||
``oneapi::tbb::proportional_split``. The type has methods ``left`` and ``right``
|
||||
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.
|
||||
|
||||
|
||||
Both splitting constructors should guarantee that the updated ``r`` part
|
||||
and the constructed object are not empty. The parallel algorithm
|
||||
templates call the splitting constructors on ``r`` only if
|
||||
``r.is_divisible`` is true.
|
||||
|
||||
|
||||
The iteration space does not have to be linear. Look at
|
||||
``oneapi/tbb/blocked_range2d.h`` for an example of a range that is
|
||||
two-dimensional. Its splitting constructor attempts to split the range
|
||||
along its longest axis. When used with ``parallel_for``, it causes the
|
||||
loop to be "recursively blocked" in a way that improves cache usage.
|
||||
This nice cache behavior means that using ``parallel_for`` over a
|
||||
``blocked_range2d<T>`` can make a loop run faster than the sequential
|
||||
equivalent, even on a single processor.
|
||||
@@ -0,0 +1,42 @@
|
||||
.. _Allocator_Configuration:
|
||||
|
||||
Configuring the Memory Allocator
|
||||
================================
|
||||
|
||||
|
||||
The oneTBB memory allocator provides the following API functions and
|
||||
environment variables to configure its behavior:
|
||||
|
||||
|
||||
- the ``scalable_allocation_command`` function instructs the allocator
|
||||
to perform a certain action, such as cleaning up its internal memory
|
||||
buffers.
|
||||
|
||||
|
||||
- the ``scalable_allocation_mode`` function allows an application to
|
||||
set certain parameters for the memory allocator, such as an option to
|
||||
map memory in huge pages or define a recommended heap size. These
|
||||
settings take effect until modified by another call to
|
||||
``scalable_allocation_mode``.
|
||||
|
||||
|
||||
Some of the memory allocator parameters can also be set via system
|
||||
environment variables. It can be useful to adjust the behavior without
|
||||
modifying application source code, to ensure that a setting takes effect
|
||||
as early as possible, or to avoid explicit dependency on the oneTBB
|
||||
allocator binaries. The following environment variables are recognized:
|
||||
|
||||
|
||||
- ``TBB_MALLOC_USE_HUGE_PAGES`` controls usage of huge pages for memory
|
||||
mapping.
|
||||
|
||||
|
||||
- ``TBB_MALLOC_SET_HUGE_OBJECT_THRESHOLD`` defines the lower bound for
|
||||
the size (bytes), that is interpreted as huge and not released during
|
||||
regular cleanup operations.
|
||||
|
||||
|
||||
These variables only take effect at the time the memory manager is
|
||||
initialized; later environment changes are ignored. A call to
|
||||
``scalable_allocation_mode`` overrides the effect of the corresponding
|
||||
environment variable.
|
||||
@@ -0,0 +1,23 @@
|
||||
.. _Automatic_Chunking:
|
||||
|
||||
Automatic Chunking
|
||||
==================
|
||||
|
||||
|
||||
A parallel loop construct incurs overhead cost for every chunk of work
|
||||
that it schedules. |full_name|
|
||||
chooses chunk sizes automatically, depending upon load balancing
|
||||
needs. The heuristic attempts to limit overheads while
|
||||
still providing ample opportunities for load balancing.
|
||||
|
||||
|
||||
.. CAUTION::
|
||||
Typically a loop needs to take at least a million clock cycles to
|
||||
make it worth using ``parallel_for``. For example, a loop that takes
|
||||
at least 500 microseconds on a 2 GHz processor might benefit from
|
||||
``parallel_for``.
|
||||
|
||||
|
||||
The default automatic chunking is recommended for most uses. As with
|
||||
most heuristics, however, there are situations where controlling the
|
||||
chunk size more precisely might yield better performance.
|
||||
@@ -0,0 +1,22 @@
|
||||
.. _Automically_Replacing_malloc:
|
||||
|
||||
Automatically Replacing ``malloc`` and Other C/C++ Functions for Dynamic Memory Allocation
|
||||
==========================================================================================
|
||||
|
||||
|
||||
On Windows*, Linux\* operating systems, it is possible to automatically
|
||||
replace all calls to standard functions for dynamic memory allocation
|
||||
(such as ``malloc``) with the |full_name| scalable equivalents.
|
||||
Doing so can sometimes improve application performance.
|
||||
|
||||
|
||||
Replacements are provided by the proxy library (the library names can be
|
||||
found in platform-specific sections below). A proxy library and a
|
||||
scalable memory allocator library should be taken from the same release
|
||||
of oneTBB, otherwise the libraries may be mutually incompatible.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
|
||||
../tbb_userguide/Windows_C_Dynamic_Memory_Interface_Replacement
|
||||
../tbb_userguide/Linux_C_Dynamic_Memory_Interface_Replacement
|
||||
@@ -0,0 +1,107 @@
|
||||
.. _Bandwidth_and_Cache_Affinity:
|
||||
|
||||
Bandwidth and Cache Affinity
|
||||
============================
|
||||
|
||||
|
||||
For a sufficiently simple function ``Foo``, the examples might not show
|
||||
good speedup when written as parallel loops. The cause could be
|
||||
insufficient system bandwidth between the processors and memory. In that
|
||||
case, you may have to rethink your algorithm to take better advantage of
|
||||
cache. Restructuring to better utilize the cache usually benefits the
|
||||
parallel program as well as the serial program.
|
||||
|
||||
|
||||
An alternative to restructuring that works in some cases is
|
||||
``affinity_partitioner.`` It not only automatically chooses the
|
||||
grainsize, but also optimizes for cache affinity and tries to distribute
|
||||
the data uniformly among threads. Using ``affinity_partitioner`` can
|
||||
significantly improve performance when:
|
||||
|
||||
|
||||
- The computation does a few operations per data access.
|
||||
|
||||
|
||||
- The data acted upon by the loop fits in cache.
|
||||
|
||||
|
||||
- The loop, or a similar loop, is re-executed over the same data.
|
||||
|
||||
|
||||
- There are more than two hardware threads available (and especially if
|
||||
the number of threads is not a power of two). If only two threads are
|
||||
available, the default scheduling in |full_name|
|
||||
usually provides sufficient cache affinity.
|
||||
|
||||
|
||||
The following code shows how to use ``affinity_partitioner``.
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
#include "oneapi/tbb.h"
|
||||
|
||||
|
||||
void ParallelApplyFoo( float a[], size_t n ) {
|
||||
static affinity_partitioner ap;
|
||||
parallel_for(blocked_range<size_t>(0,n), ApplyFoo(a), ap);
|
||||
}
|
||||
|
||||
|
||||
void TimeStepFoo( float a[], size_t n, int steps ) {
|
||||
for( int t=0; t<steps; ++t )
|
||||
ParallelApplyFoo( a, n );
|
||||
}
|
||||
|
||||
|
||||
In the example, the ``affinity_partitioner`` object ``ap`` lives between
|
||||
loop iterations. It remembers where iterations of the loop ran, so that
|
||||
each iteration can be handed to the same thread that executed it before.
|
||||
The example code gets the lifetime of the partitioner right by declaring
|
||||
the ``affinity_partitioner`` as a local static object. Another approach
|
||||
would be to declare it at a scope outside the iterative loop in
|
||||
``TimeStepFoo``, and hand it down the call chain to ``parallel_for``.
|
||||
|
||||
|
||||
If the data does not fit across the system’s caches, there may be little
|
||||
benefit. The following figure shows the situations.
|
||||
|
||||
|
||||
.. container:: fignone
|
||||
:name: fig3
|
||||
|
||||
|
||||
Benefit of Affinity Determined by Relative Size of Data Set and Cache
|
||||
|image0|
|
||||
|
||||
|
||||
The next figure shows how parallel speedup might vary with the size of a
|
||||
data set. The computation for the example is ``A[i]+=B[i]`` for ``i`` in
|
||||
the range [0,N). It was chosen for dramatic effect. You are unlikely to
|
||||
see quite this much variation in your code. The graph shows not much
|
||||
improvement at the extremes. For small N, parallel scheduling overhead
|
||||
dominates, resulting in little speedup. For large N, the data set is too
|
||||
large to be carried in cache between loop invocations. The peak in the
|
||||
middle is the sweet spot for affinity. Hence ``affinity_partitioner``
|
||||
should be considered a tool, not a cure-all, when there is a low ratio
|
||||
of computations to memory accesses.
|
||||
|
||||
|
||||
.. container:: fignone
|
||||
:name: fig4
|
||||
|
||||
|
||||
Improvement from Affinity Dependent on Array Size
|
||||
|image1|
|
||||
|
||||
|
||||
|
||||
|
||||
.. |image0| image:: Images/image007.jpg
|
||||
:width: 453px
|
||||
:height: 178px
|
||||
.. |image1| image:: Images/image008.jpg
|
||||
:width: 551px
|
||||
:height: 192px
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
.. _Basic_Flow_Graph_concepts:
|
||||
|
||||
Basic Flow Graph Concepts
|
||||
=========================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
|
||||
../tbb_userguide/Graph_Object
|
||||
../tbb_userguide/Nodes
|
||||
../tbb_userguide/Edges
|
||||
../tbb_userguide/Mapping_Nodes2Tasks
|
||||
../tbb_userguide/Flow_Graph_Message_Passing_Protocol
|
||||
../tbb_userguide/Flow_Graph_Single_Vs_Broadcast
|
||||
../tbb_userguide/Flow_Graph_Buffering_in_Nodes
|
||||
../tbb_userguide/Flow_Graph_Reservation
|
||||
@@ -0,0 +1,46 @@
|
||||
.. _Cancellation_Without_An_Exception:
|
||||
|
||||
Cancellation Without An Exception
|
||||
=================================
|
||||
|
||||
|
||||
To cancel an algorithm but not throw an exception, use the expression ``current_context()->cancel_group_execution()``.
|
||||
The part ``current_context()`` references the ``task_group_context*`` of the currently executing task if any on the current thread.
|
||||
Calling ``cancel_group_execution()`` cancels all tasks in its ``task_group_context``, which is explained in more detail in :ref:`Cancellation_and_Nested_Parallelism`.
|
||||
The method returns ``true`` if it actually causes cancellation, ``false`` if the ``task_group_context`` was already cancelled.
|
||||
|
||||
The example below shows how to use ``current_context()->cancel_group_execution()``.
|
||||
|
||||
::
|
||||
|
||||
#include "oneapi/tbb.h"
|
||||
|
||||
#include <vector>
|
||||
#include <iostream>
|
||||
|
||||
using namespace oneapi::tbb;
|
||||
using namespace std;
|
||||
|
||||
vector<int> Data;
|
||||
|
||||
struct Update {
|
||||
void operator()( const blocked_range<int>& r ) const {
|
||||
for( int i=r.begin(); i!=r.end(); ++i )
|
||||
if( i<Data.size() ) {
|
||||
++Data[i];
|
||||
} else {
|
||||
// Cancel related tasks.
|
||||
if( current_context()->cancel_group_execution() )
|
||||
cout << "Index " << i << " caused cancellation\n";
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
int main() {
|
||||
Data.resize(1000);
|
||||
parallel_for( blocked_range<int>(0, 2000), Update());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,136 @@
|
||||
.. _Cancellation_and_Nested_Parallelism:
|
||||
|
||||
Cancellation and Nested Parallelism
|
||||
===================================
|
||||
|
||||
|
||||
The discussion so far was simplified by assuming non-nested parallelism
|
||||
and skipping details of ``task_group_context``. This topic explains
|
||||
both.
|
||||
|
||||
|
||||
An |full_name| algorithm executes
|
||||
by creating ``task`` objects that execute the snippets of code that you
|
||||
supply to the algorithm template. By default, these ``task`` objects are
|
||||
associated with a ``task_group_context`` created by the algorithm.
|
||||
Nested oneTBB algorithms create a tree of these ``task_group_context``
|
||||
objects. Cancelling a ``task_group_context`` cancels all of its child
|
||||
``task_group_context`` objects, and transitively all its descendants.
|
||||
Hence an algorithm and all algorithms it called can be cancelled with a
|
||||
single request.
|
||||
|
||||
|
||||
Exceptions propagate upwards. Cancellation propagates downwards. The
|
||||
opposition interplays to cleanly stop a nested computation when an
|
||||
exception occurs. For example, consider the tree in the following
|
||||
figure. Imagine that each node represents an algorithm and its
|
||||
``task_group_context``.
|
||||
|
||||
|
||||
.. container:: fignone
|
||||
:name: fig6
|
||||
|
||||
|
||||
Tree of task_group_context
|
||||
|image0|
|
||||
|
||||
|
||||
Suppose that the algorithm in C throws an exception and no node catches
|
||||
the exception. oneTBB propagates the exception upwards, cancelling
|
||||
related subtrees downwards, as follows:
|
||||
|
||||
|
||||
#. Handle exception in C:
|
||||
|
||||
|
||||
a. Capture exception in C.
|
||||
|
||||
|
||||
b. Cancel tasks in C.
|
||||
|
||||
|
||||
c. Throw exception from C to B.
|
||||
|
||||
|
||||
#. Handle exception in B:
|
||||
|
||||
|
||||
a. Capture exception in B.
|
||||
|
||||
|
||||
b. Cancel tasks in B and, by downwards propagation, in D.
|
||||
|
||||
|
||||
c. Throw an exception out of B to A.
|
||||
|
||||
|
||||
#. Handle exception in A:
|
||||
|
||||
|
||||
a. Capture exception in A.
|
||||
|
||||
|
||||
b. Cancel tasks in A and, by downwards propagation, in E, F, and G.
|
||||
|
||||
|
||||
c. Throw an exception upwards out of A.
|
||||
|
||||
|
||||
If your code catches the exception at any level, then oneTBB does not
|
||||
propagate it any further. For example, an exception that does not escape
|
||||
outside the body of a ``parallel_for`` does not cause cancellation of
|
||||
other iterations.
|
||||
|
||||
|
||||
To prevent downwards propagation of cancellation into an algorithm,
|
||||
construct an 'isolated' ``task_group_context`` on the stack and pass it
|
||||
to the algorithm explicitly. The example uses C++11 lambda expressions for brevity.
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
#include "oneapi/tbb.h"
|
||||
|
||||
|
||||
bool Data[1000][1000];
|
||||
|
||||
|
||||
int main() {
|
||||
try {
|
||||
parallel_for( 0, 1000, 1,
|
||||
[]( int i ) {
|
||||
task_group_context root(task_group_context::isolated);
|
||||
parallel_for( 0, 1000, 1,
|
||||
[]( int ) {
|
||||
Data[i][j] = true;
|
||||
},
|
||||
root);
|
||||
throw "oops";
|
||||
});
|
||||
} catch(...) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
The example performs two parallel loops: an outer loop over ``i`` and
|
||||
inner loop over ``j``. The creation of the isolated
|
||||
``task_group_context`` ``root`` protects the inner loop from downwards
|
||||
propagation of cancellation from the ``i`` loop. When the exception
|
||||
propagates to the outer loop, any pending ``outer`` iterations are
|
||||
cancelled, but not inner iterations for an outer iteration that started.
|
||||
Hence when the program completes, each row of ``Data`` may be different,
|
||||
depending upon whether its iteration ``i`` ran at all, but within a row,
|
||||
the elements will be homogeneously ``false`` or ``true``, not a mixture.
|
||||
|
||||
|
||||
Removing the blue text would permit cancellation to propagate down into
|
||||
the inner loop. In that case, a row of ``Data`` might end up with both
|
||||
``true`` and ``false`` values.
|
||||
|
||||
|
||||
.. |image0| image:: Images/image013.jpg
|
||||
:width: 261px
|
||||
:height: 131px
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
.. _Concurrent_Queue_Classes:
|
||||
|
||||
Concurrent Queue Classes
|
||||
========================
|
||||
|
||||
|
||||
Template class ``concurrent_queue<T,Alloc>`` implements a concurrent
|
||||
queue with values of type ``T``. Multiple threads may simultaneously
|
||||
push and pop elements from the queue. The queue is unbounded and has no
|
||||
blocking operations. The fundamental operations on it are ``push`` and
|
||||
``try_pop``. The ``push`` operation works just like ``push`` for a
|
||||
std::queue. The operation ``try_pop`` pops an item if it is available.
|
||||
The check and popping have to be done in a single operation for sake of
|
||||
thread safety.
|
||||
|
||||
|
||||
For example, consider the following serial code:
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
extern std::queue<T> MySerialQueue;
|
||||
T item;
|
||||
if( !MySerialQueue.empty() ) {
|
||||
item = MySerialQueue.front();
|
||||
MySerialQueue.pop_front();
|
||||
... process item...
|
||||
}
|
||||
|
||||
|
||||
Even if each std::queue method were implemented in a thread-safe manner,
|
||||
the composition of those methods as shown in the example would not be
|
||||
thread safe if there were other threads also popping from the same
|
||||
queue. For example, ``MySerialQueue.empty()`` might return true just
|
||||
before another thread snatches the last item from ``MySerialQueue``.
|
||||
|
||||
|
||||
The equivalent thread-safe |full_name| code is:
|
||||
|
||||
|
||||
::
|
||||
|
||||
|
||||
extern concurrent_queue<T> MyQueue;
|
||||
T item;
|
||||
if( MyQueue.try_pop(item) ) {
|
||||
...process item...
|
||||
}
|
||||
|
||||
|
||||
In a single-threaded program, a queue is a first-in first-out structure.
|
||||
But if multiple threads are pushing and popping concurrently, the
|
||||
definition of "first" is uncertain. Use of ``concurrent_queue``
|
||||
guarantees that if a thread pushes two values, and another thread pops
|
||||
those two values, they will be popped in the same order that they were
|
||||
pushed.
|
||||
|
||||
|
||||
Template class ``concurrent_queue`` is unbounded and has no methods that
|
||||
wait. It is up to the user to provide synchronization to avoid overflow,
|
||||
or to wait for the queue to become non-empty. Typically this is
|
||||
appropriate when the synchronization has to be done at a higher level.
|
||||
|
||||
|
||||
Template class ``concurrent_bounded_queue<T,Alloc>`` is a variant that
|
||||
adds blocking operations and the ability to specify a capacity. The
|
||||
methods of particular interest on it are:
|
||||
|
||||
|
||||
- ``pop(item)`` waits until it can succeed.
|
||||
|
||||
|
||||
- ``push(item)`` waits until it can succeed without exceeding the
|
||||
queue's capacity.
|
||||
|
||||
|
||||
- ``try_push(item)`` pushes ``item`` only if it would not exceed the
|
||||
queue's capacity.
|
||||
|
||||
|
||||
- size() returns a *signed* integer.
|
||||
|
||||
|
||||
The value of concurrent_queue::size() is defined as the number of push
|
||||
operations started minus the number of pop operations started. If pops
|
||||
outnumber pushes, ``size()`` becomes negative. For example, if a
|
||||
``concurrent_queue`` is empty, and there are ``n`` pending pop
|
||||
operations, ``size()`` returns -\ ``n``. This provides an easy way for
|
||||
producers to know how many consumers are waiting on the queue. Method
|
||||
``empty()`` is defined to be true if and only if ``size()`` is not
|
||||
positive.
|
||||
|
||||
|
||||
By default, a ``concurrent_bounded_queue`` is unbounded. It may hold any
|
||||
number of values, until memory runs out. It can be bounded by setting
|
||||
the queue capacity with method ``set_capacity``.Setting the capacity
|
||||
causes ``push`` to block until there is room in the queue. Bounded
|
||||
queues are slower than unbounded queues, so if there is a constraint
|
||||
elsewhere in your program that prevents the queue from becoming too
|
||||
large, it is better not to set the capacity. If you do not need the
|
||||
bounds or the blocking pop, consider using ``concurrent_queue`` instead.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
|
||||
../tbb_userguide/Iterating_Over_a_Concurrent_Queue_for_Debugging
|
||||
../tbb_userguide/When_Not_to_Use_Queues
|
||||