Skip to content

Commit 4533e4f

Browse files
committed
Commit oneTBB source code e0cc518
1 parent 3df08fe commit 4533e4f

File tree

178 files changed

+4272
-2108
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

178 files changed

+4272
-2108
lines changed

.bazelrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
# use Bazel internally. The Bazel build can have security risks or
1717
# optimization gaps.
1818

19-
build --symlink_prefix=/ # Out of source build
19+
build --symlink_prefix=/ # Out of source build

.bazelversion

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.1.0
1+
4.2.1

.github/pull_request_template.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ _Add comprehensive description of proposed changes_
44

55
Fixes # - _issue number(s) if exists_
66

7+
- [ ] - git commit message contains appropriate signed-off-by string _(see [CONTRIBUTING.md](https://github.com/oneapi-src/oneTBB/blob/master/CONTRIBUTING.md#pull-requests) for details)_
8+
79
### Type of change
810

911
_Choose one or multiple, leave empty if none of the other choices apply_

.github/workflows/ci.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ jobs:
4848
- uses: actions/checkout@v2
4949
- name: Run scan
5050
run: |
51+
command -v clang-format-10
5152
cp -r examples examples_formatted
52-
find examples_formatted -regex '.*\.\(cpp\|hpp\)' -exec clang-format-9 -style=file -i {} \;
53+
find examples_formatted -regex '.*\.\(cpp\|hpp\)' -exec clang-format-10 -style=file -i {} \;
5354
diff -r examples examples_formatted
5455
5556
documentation:
@@ -67,7 +68,7 @@ jobs:
6768
mkdir html
6869
- name: Build documentation
6970
run: |
70-
export BUILD_TYPE=${BUILD_TYPE} && sphinx-build doc/main html
71+
export BUILD_TYPE=${BUILD_TYPE} && sphinx-build doc html
7172
tar -czvf html.tar.gz html/
7273
- name: Save docs
7374
uses: actions/[email protected]

BUILD.bazel

+6-3
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@ cc_library(
3535
"include/oneapi/tbb/*.h",
3636
"include/oneapi/tbb/detail/*.h",
3737
]),
38-
copts = [
39-
"-w",
40-
],
38+
copts = ["-w"] + select({
39+
"@bazel_tools//platforms:windows": [
40+
"",
41+
],
42+
"//conditions:default": ["-mwaitpkg"],
43+
}),
4144
defines =
4245
select({
4346
"@platforms//cpu:x86_64": ["__TBB_NO_IMPLICIT_LINKAGE"],

Bazel.md

+55-19
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,38 @@
1-
# Bazel build support
1+
# Bazel* build support
22

3-
The main build system of oneTBB is CMake.
4-
Bazel support is community-based.
5-
The maintainers do not use Bazel internally.
6-
The Bazel configuration may not include recommended compiler and linker flags used in official CMake configuration.
3+
The main build system of oneTBB is CMake*.
4+
[Bazel*](https://bazel.build/) support is community-based.
5+
The Bazel configuration may not include recommended compiler and/or linker flags used in the official CMake configuration.
76

8-
The Bazel build of oneTBB currently only aims for a subset of oneTBB that suffices restricted use cases of the usage of oneTBB.
9-
Pull requests to improve the Bazel build experience are welcomed.
7+
---
8+
**NOTE**
109

11-
The standard approach of how Bazel handles third-party libraries is static linking.
12-
Even this is not recommended by the oneTBB maintainers this is chosen since this is considered as the best practice in the Bazel ecosystem.
10+
Bazel is not recommended for use by oneTBB maintainers. Thus, it is not used internally.
1311

14-
## Example usage
12+
---
1513

16-
1. [Install Bazel](https://docs.bazel.build/versions/main/install.html).
1714

18-
2. Create the following files in one folder (this folder will be considered as the workspace folder):
15+
The Bazel oneTBB build is currently only intended for a subset of oneTBB that suffices restricted use cases.
16+
Pull requests to improve the Bazel build experience are welcome.
1917

20-
_WORKSPACE.bazel_:
18+
The standard Bazel approach to handling third-party libraries is static linking. It is the best practice within the Bazel ecosystem.
19+
20+
## Using oneTBB as a dependency
21+
22+
This example demonstrates how to use oneTBB as a dependency within a Bazel project.
23+
24+
The following file structure is assumed:
25+
26+
```
27+
example
28+
├── .bazelrc
29+
├── BUILD.bazel
30+
├── main.cpp
31+
└── WORKSPACE.bazel
2132
```
33+
34+
_WORKSPACE.bazel_:
35+
```python
2236
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
2337

2438
git_repository(
@@ -28,17 +42,23 @@ git_repository(
2842
)
2943
```
3044

31-
_BUILD_:
32-
```
45+
In the *WORKSPACE* file, the oneTBB GitHub* repository is fetched.
46+
47+
_BUILD.bazel_:
48+
49+
```python
3350
cc_binary(
3451
name = "Demo",
3552
srcs = ["main.cpp"],
3653
deps = ["@oneTBB//:tbb"],
3754
)
3855
```
3956

57+
The *BUILD* file defines a binary named `Demo` that has a dependency to oneTBB.
58+
4059
_main.cpp_:
41-
```
60+
61+
```c++
4262
#include "oneapi/tbb/version.h"
4363

4464
#include <iostream>
@@ -54,7 +74,23 @@ int main() {
5474
}
5575
```
5676

57-
3. Switch to the folder where you create the files.
77+
The expected output of this program is the current version of oneTBB.
78+
79+
Switch to the folder with the files created earlier and run the binary with `bazel run //:Demo`.
80+
81+
## Build oneTBB using Bazel
82+
83+
Run ```bazel build //...``` in the oneTBB root directory.
84+
85+
## Compiler support
86+
87+
The Bazel build uses the compiler flag `-mwaitpkg` in non-Windows* builds.
88+
This flag is supported by the GNU* Compiler Collection (GCC) version 9.3, Clang* 12, and newer versions of those tools.
89+
90+
91+
---
92+
**NOTE**
93+
94+
To use the Bazel build with earlier versions of GCC, remove `-mwaitpkg` flag as it leads to errors during compilation.
5895

59-
4. Execute the command `bazel run //:Demo`.
60-
As an expected output, you should see the oneTBB version.
96+
---

CMakeLists.txt

+23-2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ unset(_tbb_ver_minor)
6060

6161
include(CheckCXXCompilerFlag)
6262
include(GNUInstallDirs)
63+
include(CMakeDependentOption)
6364

6465
# ---------------------------------------------------------------------------------------------------------
6566
# Handle C++ standard version.
@@ -100,9 +101,11 @@ option(TBB_NO_APPCONTAINER "Apply /APPCONTAINER:NO (for testing binaries for Win
100101
option(TBB4PY_BUILD "Enable tbb4py build" OFF)
101102
option(TBB_BUILD "Enable tbb build" ON)
102103
option(TBBMALLOC_BUILD "Enable tbbmalloc build" ON)
104+
cmake_dependent_option(TBBMALLOC_PROXY_BUILD "Enable tbbmalloc_proxy build" ON "TBBMALLOC_BUILD" OFF)
103105
option(TBB_CPF "Enable preview features of the library" OFF)
104106
option(TBB_FIND_PACKAGE "Enable search for external oneTBB using find_package instead of build from sources" OFF)
105107
option(TBB_DISABLE_HWLOC_AUTOMATIC_SEARCH "Disable HWLOC automatic search by pkg-config tool" OFF)
108+
option(TBB_ENABLE_IPO "Enable Interprocedural Optimization (IPO) during the compilation" ON)
106109

107110
if (NOT DEFINED BUILD_SHARED_LIBS)
108111
set(BUILD_SHARED_LIBS ON)
@@ -181,6 +184,22 @@ foreach(FILE_WITH_EXTRA_TARGETS ${FILES_WITH_EXTRA_TARGETS})
181184
include(${FILE_WITH_EXTRA_TARGETS})
182185
endforeach()
183186

187+
# - Enabling LTO on Android causes the NDK bug.
188+
# NDK throws the warning: "argument unused during compilation: '-Wa,--noexecstack'"
189+
# - For some reason GCC does not instrument code with Thread Sanitizer when lto is enabled and C linker is used.
190+
if (TBB_ENABLE_IPO AND BUILD_SHARED_LIBS AND NOT ANDROID_PLATFORM AND NOT TBB_SANITIZE MATCHES "thread")
191+
if (NOT CMAKE_VERSION VERSION_LESS 3.9)
192+
cmake_policy(SET CMP0069 NEW)
193+
include(CheckIPOSupported)
194+
check_ipo_supported(RESULT TBB_IPO_PROPERTY)
195+
else()
196+
set(TBB_IPO_FLAGS TRUE)
197+
endif()
198+
if (TBB_IPO_PROPERTY OR TBB_IPO_FLAGS)
199+
message(STATUS "IPO enabled")
200+
endif()
201+
endif()
202+
184203
set(TBB_COMPILER_SETTINGS_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/compilers/${CMAKE_CXX_COMPILER_ID}.cmake)
185204
if (EXISTS ${TBB_COMPILER_SETTINGS_FILE})
186205
include(${TBB_COMPILER_SETTINGS_FILE})
@@ -200,9 +219,11 @@ else()
200219
if (NOT "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "mips")
201220
if (TBBMALLOC_BUILD)
202221
add_subdirectory(src/tbbmalloc)
203-
add_subdirectory(src/tbbmalloc_proxy)
222+
if(TBBMALLOC_PROXY_BUILD AND NOT "${MSVC_CXX_ARCHITECTURE_ID}" MATCHES "ARM64")
223+
add_subdirectory(src/tbbmalloc_proxy)
224+
endif()
204225
endif()
205-
if (APPLE)
226+
if (APPLE OR NOT BUILD_SHARED_LIBS)
206227
message(STATUS "TBBBind build targets are disabled due to unsupported environment")
207228
else()
208229
add_subdirectory(src/tbbbind)

INSTALL.md

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Installation from Sources
2+
3+
4+
## Prerequisites
5+
6+
- Make sure you have installed CMake version 3.1 (or newer) on your system. oneTBB uses CMake build configuration.
7+
- Configure and build oneTBB. To work with build configurations, see [Build System Description](cmake/README.md).
8+
9+
10+
## Configure oneTB
11+
12+
At the command prompt, type:
13+
```
14+
cmake <options> <repo_root>
15+
```
16+
17+
You may want to use some additional options for configuration:
18+
19+
| Option | Purpose | Description |
20+
| ------ |------ | ------ |
21+
| `-G <generator>` | Specify project generator | For more information, run cmake `–help`. |
22+
|`-DCMAKE_BUILD_TYPE=Debug` | Specify for Debug build | Not applicable for multi-configuration generators such as Visual Studio generator. |
23+
24+
25+
## Build oneTBB
26+
27+
To build the system, run:
28+
```
29+
cmake --build . <options>
30+
```
31+
32+
Some useful build options:
33+
- `--target <target>` - specific target, "all" is default.
34+
- `--config <Release|Debug>` - build configuration, applicable only for multi-config generators such as Visual Studio generator.
35+
36+
37+
## Install and Pack oneTBB
38+
39+
---
40+
**NOTE**
41+
42+
Be careful about installing prefix. It defaults to `/usr/local` on UNIX* and `c:/Program Files/${PROJECT_NAME}` on Windows* OS.
43+
You can define custom `CMAKE_INSTALL_PREFIX` during configuration:
44+
45+
```
46+
cmake -DCMAKE_INSTALL_PREFIX=/my/install/prefix ..
47+
```
48+
49+
---
50+
51+
Installation can also be done using:
52+
53+
```
54+
cmake --install <project-binary-dir>
55+
```
56+
57+
Special ``--install`` target can alternatively be used for installation, e.g. ``make install``.
58+
59+
You can use the ``install`` components for partial installation.
60+
61+
The following install components are supported:
62+
- `runtime` - oneTBB runtime package (core shared libraries and `.dll` files on Windows* OS).
63+
- `devel` - oneTBB development package (header files, CMake integration files, library symbolic links, and `.lib` files on Windows* OS).
64+
- `tbb4py` - [oneTBB Module for Python](#onetbb-python-module-support).
65+
66+
If you want to install specific components after configuration and build, run:
67+
68+
```bash
69+
cmake -DCOMPONENT=<component> [-DBUILD_TYPE=<build-type>] -P cmake_install.cmake
70+
```
71+
72+
Simple packaging using CPack is supported.
73+
The following commands allow you to create a simple portable package that includes header files, libraries, and integration files for CMake:
74+
75+
```bash
76+
cmake <options> ..
77+
cpack
78+
```
79+
80+
## Example of Installation
81+
82+
### Single-configuration generators
83+
84+
The following example demonstrates how to install oneTBB for single-configuration generators (e.g. GNU Make, Ninja, etc.).
85+
```bash
86+
# Do our experiments in /tmp
87+
cd /tmp
88+
# Clone oneTBB repository
89+
git clone https://github.com/oneapi-src/oneTBB.git
90+
cd oneTBB
91+
# Create binary directory for out-of-source build
92+
mkdir build && cd build
93+
# Configure: customize CMAKE_INSTALL_PREFIX and disable TBB_TEST to avoid tests build
94+
cmake -DCMAKE_INSTALL_PREFIX=/tmp/my_installed_onetbb -DTBB_TEST=OFF ..
95+
# Build
96+
cmake --build .
97+
# Install
98+
cmake --install .
99+
# Well done! Your installed oneTBB is in /tmp/my_installed_onetbb
100+
```
101+
102+
### Multi-configuration generators
103+
104+
The following example demonstrates how to install oneTBB for multi-configuration generators such as Visual Studio*.
105+
106+
Choose the configuration during the build and install steps:
107+
```batch
108+
REM Do our experiments in %TMP%
109+
cd %TMP%
110+
REM Clone oneTBB repository
111+
git clone https://github.com/oneapi-src/oneTBB.git
112+
cd oneTBB
113+
REM Create binary directory for out-of-source build
114+
mkdir build && cd build
115+
REM Configure: customize CMAKE_INSTALL_PREFIX and disable TBB_TEST to avoid tests build
116+
cmake -DCMAKE_INSTALL_PREFIX=%TMP%\my_installed_onetbb -DTBB_TEST=OFF ..
117+
REM Build "release with debug information" configuration
118+
cmake --build . --config relwithdebinfo
119+
REM Install "release with debug information" configuration
120+
cmake --install . --config relwithdebinfo
121+
REM Well done! Your installed oneTBB is in %TMP%\my_installed_onetbb
122+
```

0 commit comments

Comments
 (0)