Skip to content

Commit 51c0b2f

Browse files
committed
Commit oneTBB source code 4ebd2d06
1 parent 7a257a3 commit 51c0b2f

File tree

409 files changed

+140948
-166
lines changed

Some content is hidden

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

409 files changed

+140948
-166
lines changed

.gitattributes

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Set the default behavior, in case people don't have core.autocrlf set.
2+
* text=auto
3+
4+
# Explicitly declare text files you want to always be normalized and converted
5+
# to native line endings on checkout.
6+
*.c text
7+
*.h text
8+
*.cpp text
9+
*.def text
10+
*.rc text
11+
*.i text
12+
*.sh text
13+
*.csh text
14+
*.mk text
15+
*.java text
16+
*.csv text
17+
*.lst text
18+
*.asm text
19+
*.cfg text
20+
*.css text
21+
*.inc text
22+
*.js text
23+
*.rb text
24+
*.strings text
25+
*.txt text
26+
*export.lst text
27+
*.xml text
28+
*.py text
29+
*.md text
30+
*.classpath text
31+
*.cproject text
32+
*.project text
33+
*.properties text
34+
*.java text
35+
*.gradle text
36+
37+
# Declare files that will always have CRLF line endings on checkout.
38+
*.sln text eol=crlf
39+
*.bat text eol=crlf
40+
41+
# Denote all files that are truly binary and should not be modified.
42+
*.png binary
43+
*.jpg binary
44+
*.ico binary
45+
*.spir binary

.gitignore

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# -------- C++ --------
2+
# Prerequisites
3+
*.d
4+
5+
# Compiled Object files
6+
*.slo
7+
*.lo
8+
*.o
9+
*.obj
10+
11+
# Precompiled Headers
12+
*.gch
13+
*.pch
14+
15+
# Compiled Dynamic libraries
16+
*.so
17+
*.so.*
18+
*.dylib
19+
*.dll
20+
21+
# Fortran module files
22+
*.mod
23+
*.smod
24+
25+
# Compiled Static libraries
26+
*.lai
27+
*.la
28+
*.a
29+
*.lib
30+
31+
# Executables
32+
*.exe
33+
*.out
34+
*.app
35+
36+
# -------- CMake --------
37+
CMakeCache.txt
38+
CMakeFiles
39+
CMakeScripts
40+
Testing
41+
Makefile
42+
cmake_install.cmake
43+
install_manifest.txt
44+
compile_commands.json
45+
CTestTestfile.cmake
46+
build/*
47+
48+
# -------- Python --------
49+
__pycache__/
50+
*.py[cod]
51+
*$py.class
52+
53+
# -------- IDE --------
54+
.vscode/*
55+
.vs/*
56+
out/*
57+
CMakeSettings.json
58+
59+
# -------- CTags --------
60+
.tags
61+
.ctags
62+

CMakeLists.txt

+258
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,258 @@
1+
# Copyright (c) 2020 Intel Corporation
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
cmake_minimum_required(VERSION 3.1)
16+
17+
include(CheckCXXCompilerFlag)
18+
19+
# Enable CMake policies
20+
21+
if (POLICY CMP0091)
22+
# The NEW behavior for this policy is to not place MSVC runtime library flags in the default
23+
# CMAKE_<LANG>_FLAGS_<CONFIG> cache entries and use CMAKE_MSVC_RUNTIME_LIBRARY abstraction instead.
24+
cmake_policy(SET CMP0091 NEW)
25+
elseif (DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
26+
message(FATAL_ERROR "CMAKE_MSVC_RUNTIME_LIBRARY was defined while policy CMP0091 is not available. Use CMake 3.15 or newer.")
27+
endif()
28+
29+
if (TBB_WINDOWS_DRIVER AND (NOT ("${CMAKE_MSVC_RUNTIME_LIBRARY}" STREQUAL MultiThreaded OR "${CMAKE_MSVC_RUNTIME_LIBRARY}" STREQUAL MultiThreadedDebug)))
30+
message(FATAL_ERROR "Enabled TBB_WINDOWS_DRIVER requires CMAKE_MSVC_RUNTIME_LIBRARY to be set to MultiThreaded or MultiThreadedDebug.")
31+
endif()
32+
33+
# Enable support of minimum supported macOS version flag
34+
if (APPLE)
35+
if (NOT CMAKE_CXX_OSX_DEPLOYMENT_TARGET_FLAG)
36+
set(CMAKE_CXX_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=" CACHE STRING "Minimum macOS version flag")
37+
endif()
38+
if (NOT CMAKE_C_OSX_DEPLOYMENT_TARGET_FLAG)
39+
set(CMAKE_C_OSX_DEPLOYMENT_TARGET_FLAG "-mmacosx-version-min=" CACHE STRING "Minimum macOS version flag")
40+
endif()
41+
endif()
42+
43+
# Until CMake 3.4.0 FindThreads.cmake requires C language enabled.
44+
# Enable C language before CXX to avoid possible override of CMAKE_SIZEOF_VOID_P.
45+
if (CMAKE_VERSION VERSION_LESS 3.4)
46+
enable_language(C)
47+
endif()
48+
49+
file(READ include/tbb/version.h _tbb_version_info)
50+
string(REGEX REPLACE ".*#define TBB_VERSION_MAJOR ([0-9]+).*" "\\1" _tbb_ver_major "${_tbb_version_info}")
51+
string(REGEX REPLACE ".*#define TBB_VERSION_MINOR ([0-9]+).*" "\\1" _tbb_ver_minor "${_tbb_version_info}")
52+
string(REGEX REPLACE ".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1" TBB_INTERFACE_VERSION "${_tbb_version_info}")
53+
string(REGEX REPLACE ".*#define __TBB_BINARY_VERSION ([0-9]+).*" "\\1" TBB_BINARY_VERSION "${_tbb_version_info}")
54+
set(TBB_BINARY_MINOR_VERSION 1)
55+
set(TBBMALLOC_BINARY_VERSION 2)
56+
set(TBBBIND_BINARY_VERSION 3)
57+
58+
project(TBB VERSION ${_tbb_ver_major}.${_tbb_ver_minor} LANGUAGES CXX)
59+
unset(_tbb_ver_major)
60+
unset(_tbb_ver_minor)
61+
62+
# ---------------------------------------------------------------------------------------------------------
63+
# Handle C++ standard version.
64+
if (NOT MSVC) # no need to cover MSVC as it uses C++14 by default.
65+
if (NOT CMAKE_CXX_STANDARD)
66+
set(CMAKE_CXX_STANDARD 11)
67+
endif()
68+
69+
if (CMAKE_CXX${CMAKE_CXX_STANDARD}_STANDARD_COMPILE_OPTION) # if standard option was detected by CMake
70+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
71+
else() # if standard option wasn't detected by CMake (e.g. for Intel Compiler with CMake 3.1)
72+
# TBB_CXX_STD_FLAG should be added to targets via target_compile_options
73+
set(TBB_CXX_STD_FLAG -std=c++${CMAKE_CXX_STANDARD})
74+
75+
check_cxx_compiler_flag(${TBB_CXX_STD_FLAG} c++${CMAKE_CXX_STANDARD})
76+
if (NOT c++${CMAKE_CXX_STANDARD})
77+
message(FATAL_ERROR "C++${CMAKE_CXX_STANDARD} (${TBB_CXX_STD_FLAG}) support is required")
78+
endif()
79+
unset(c++${CMAKE_CXX_STANDARD})
80+
endif()
81+
endif()
82+
83+
set(CMAKE_CXX_EXTENSIONS OFF) # use -std=c++... instead of -std=gnu++...
84+
# ---------------------------------------------------------------------------------------------------------
85+
86+
# Detect architecture (bitness).
87+
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
88+
set(TBB_ARCH 32)
89+
else()
90+
set(TBB_ARCH 64)
91+
endif()
92+
93+
option(TBB_TEST "Enable testing" ON)
94+
option(TBB_EXAMPLES "Enable examples" OFF)
95+
option(TBB_STRICT "Treat compiler warnings as errors" ON)
96+
option(TBB_NUMA_SUPPORT "Enable NUMA support that depends on Portable Hardware Locality (hwloc) library" OFF)
97+
option(TBB_WINDOWS_DRIVER "Build as Universal Windows Driver (UWD)" OFF)
98+
option(TBB_NO_APPCONTAINER "Apply /APPCONTAINER:NO (for testing binaries for Windows Store)" OFF)
99+
option(TBB4PY_BUILD "Enable tbb4py build" OFF)
100+
option(TBB_CPF "Enable preview features of the library" OFF)
101+
option(TBB_FIND_PACKAGE "Enable search for external oneTBB using find_package instead of build from sources" OFF)
102+
103+
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
104+
set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Build type" FORCE)
105+
message(STATUS "CMAKE_BUILD_TYPE is not specified. Using default: ${CMAKE_BUILD_TYPE}")
106+
# Possible values of build type for cmake-gui
107+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
108+
endif()
109+
110+
# -------------------------------------------------------------------
111+
# Files and folders naming
112+
set(CMAKE_DEBUG_POSTFIX _debug)
113+
114+
if (NOT DEFINED TBB_OUTPUT_DIR_BASE)
115+
if (MSVC)
116+
if (NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY OR CMAKE_MSVC_RUNTIME_LIBRARY MATCHES DLL)
117+
set(_tbb_msvc_runtime _md)
118+
else()
119+
set(_tbb_msvc_runtime _mt)
120+
endif()
121+
122+
if (WINDOWS_STORE)
123+
if (TBB_NO_APPCONTAINER)
124+
set(_tbb_win_store _wsnoappcont)
125+
else()
126+
set(_tbb_win_store _ws)
127+
endif()
128+
elseif(TBB_WINDOWS_DRIVER)
129+
set(_tbb_win_store _wd)
130+
endif()
131+
endif()
132+
133+
string(REGEX MATCH "^([0-9]+\.[0-9]+|[0-9]+)" _tbb_compiler_version_short ${CMAKE_CXX_COMPILER_VERSION})
134+
string(TOLOWER ${CMAKE_CXX_COMPILER_ID}_${_tbb_compiler_version_short}_cxx${CMAKE_CXX_STANDARD}_${TBB_ARCH}${_tbb_msvc_runtime}${_tbb_win_store} TBB_OUTPUT_DIR_BASE)
135+
unset(_tbb_msvc_runtime)
136+
unset(_tbb_win_store)
137+
unset(_tbb_compiler_version_short)
138+
endif()
139+
140+
foreach(output_type LIBRARY ARCHIVE PDB RUNTIME)
141+
if (CMAKE_BUILD_TYPE)
142+
string(TOLOWER ${CMAKE_BUILD_TYPE} _tbb_build_type_lower)
143+
set(CMAKE_${output_type}_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${TBB_OUTPUT_DIR_BASE}_${_tbb_build_type_lower})
144+
unset(_tbb_build_type_lower)
145+
endif()
146+
147+
if (CMAKE_CONFIGURATION_TYPES)
148+
foreach(suffix ${CMAKE_CONFIGURATION_TYPES})
149+
string(TOUPPER ${suffix} _tbb_suffix_upper)
150+
string(TOLOWER ${suffix} _tbb_suffix_lower)
151+
set(CMAKE_${output_type}_OUTPUT_DIRECTORY_${_tbb_suffix_upper} ${CMAKE_BINARY_DIR}/${TBB_OUTPUT_DIR_BASE}_${_tbb_suffix_lower})
152+
endforeach()
153+
unset(_tbb_suffix_lower)
154+
unset(_tbb_suffix_upper)
155+
endif()
156+
endforeach()
157+
158+
# -------------------------------------------------------------------
159+
160+
# -------------------------------------------------------------------
161+
# Common dependencies
162+
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
163+
find_package(Threads REQUIRED)
164+
# -------------------------------------------------------------------
165+
166+
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
167+
168+
file(GLOB FILES_WITH_EXTRA_TARGETS ${CMAKE_CURRENT_SOURCE_DIR}/cmake/*.cmake)
169+
foreach(FILE_WITH_EXTRA_TARGETS ${FILES_WITH_EXTRA_TARGETS})
170+
include(${FILE_WITH_EXTRA_TARGETS})
171+
endforeach()
172+
173+
set(TBB_COMPILER_SETTINGS_FILE ${CMAKE_CURRENT_SOURCE_DIR}/cmake/compilers/${CMAKE_CXX_COMPILER_ID}.cmake)
174+
if (EXISTS ${TBB_COMPILER_SETTINGS_FILE})
175+
include(${TBB_COMPILER_SETTINGS_FILE})
176+
else()
177+
message(WARNING "TBB compiler settings not found ${TBB_COMPILER_SETTINGS_FILE}")
178+
endif()
179+
180+
if (TBB_FIND_PACKAGE OR TBB_DIR)
181+
# Allow specifying external TBB to test with.
182+
# Do not add main targets and installation instructions in that case.
183+
message(STATUS "Using external TBB for testing")
184+
find_package(TBB REQUIRED)
185+
else()
186+
add_subdirectory(src/tbb)
187+
if (NOT "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "mips")
188+
add_subdirectory(src/tbbmalloc)
189+
add_subdirectory(src/tbbmalloc_proxy)
190+
if (TBB_NUMA_SUPPORT)
191+
if (APPLE)
192+
message(WARNING "TBBBind build target is disabled due to unsupported environment")
193+
else()
194+
add_subdirectory(src/tbbbind)
195+
endif()
196+
endif()
197+
endif()
198+
199+
# -------------------------------------------------------------------
200+
# Installation instructions
201+
include(CMakePackageConfigHelpers)
202+
203+
install(DIRECTORY include
204+
DESTINATION .)
205+
206+
install(EXPORT ${PROJECT_NAME}Targets
207+
NAMESPACE TBB::
208+
DESTINATION lib/cmake/${PROJECT_NAME})
209+
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
210+
"include(\${CMAKE_CURRENT_LIST_DIR}/${PROJECT_NAME}Targets.cmake)\n")
211+
212+
write_basic_package_version_file("${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
213+
COMPATIBILITY AnyNewerVersion)
214+
215+
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
216+
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
217+
DESTINATION lib/cmake/${PROJECT_NAME})
218+
# -------------------------------------------------------------------
219+
endif()
220+
221+
if (TBB_TEST)
222+
enable_testing()
223+
add_subdirectory(test)
224+
endif()
225+
226+
if (TBB_EXAMPLES)
227+
add_subdirectory(examples)
228+
endif()
229+
230+
if (TBB_BENCH)
231+
if (NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/benchmark)
232+
message(FATAL_ERROR "Benchmarks are not supported yet")
233+
endif()
234+
235+
enable_testing()
236+
add_subdirectory(benchmark)
237+
endif()
238+
239+
if (ANDROID_PLATFORM)
240+
if (${ANDROID_STL} STREQUAL "c++_shared")
241+
configure_file(
242+
"${ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libs/${ANDROID_ABI}/libc++_shared.so"
243+
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/libc++_shared.so"
244+
COPYONLY)
245+
endif()
246+
# This custom target may be implemented without separate CMake script, but it requires
247+
# ADB(Android Debug Bridge) executable file availability, so to incapsulate this requirement
248+
# only for corresponding custom target, it was implemented by this way.
249+
add_custom_target(device_environment_cleanup COMMAND ${CMAKE_COMMAND}
250+
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/android/device_environment_cleanup.cmake)
251+
endif()
252+
253+
if (TBB4PY_BUILD)
254+
add_subdirectory(python)
255+
endif()
256+
257+
# Keep it the last instruction.
258+
add_subdirectory(cmake/post_install)

0 commit comments

Comments
 (0)