Skip to content

Commit

Permalink
Commit oneTBB 2021.3.0 source code
Browse files Browse the repository at this point in the history
  • Loading branch information
tbbdev committed Jun 30, 2021
1 parent 2dba207 commit 261fe22
Show file tree
Hide file tree
Showing 228 changed files with 9,022 additions and 2,375 deletions.
9 changes: 7 additions & 2 deletions cmake/compilers/AppleClang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@ set(TBB_WARNING_SUPPRESS -Wno-parentheses -Wno-non-virtual-dtor -Wno-dangling-el
# For correct ucontext.h structures layout
set(TBB_COMMON_COMPILE_FLAGS -D_XOPEN_SOURCE)

set(TBB_MMD_FLAG -MMD)
# 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()

if (NOT "${CMAKE_OSX_ARCHITECTURES}" MATCHES "^arm64$")
# Enable Intel(R) Transactional Synchronization Extensions (-mrtm) on relevant processors
if (NOT "${CMAKE_OSX_ARCHITECTURES}" MATCHES "^arm64$" AND CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64|AMD64)") # OSX systems are 64-bit only
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -mrtm)
endif()

Expand Down
27 changes: 21 additions & 6 deletions cmake/compilers/Clang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,23 @@
# 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 (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()

# 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)

Expand All @@ -23,14 +37,15 @@ if (NOT TBB_STRICT AND COMMAND tbb_remove_compile_flag)
tbb_remove_compile_flag(-Werror)
endif()

if (CMAKE_SYSTEM_PROCESSOR STREQUAL x86_64)
set(TBB_COMMON_COMPILE_FLAGS -mrtm)
# Enable Intel(R) Transactional Synchronization Extensions (-mrtm) and WAITPKG instructions support (-mwaitpkg) on relevant processors
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86|AMD64)")
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 dl)

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()

# TBB malloc settings
Expand Down
25 changes: 20 additions & 5 deletions cmake/compilers/GNU.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,29 @@
# 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 (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()

# Enable Intel(R) Transactional Synchronization Extensions (-mrtm) and WAITPKG instructions support (-mwaitpkg) on relevant processors
if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86|AMD64)")
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()

set(TBB_COMMON_LINK_LIBS dl)
Expand Down
23 changes: 23 additions & 0 deletions cmake/compilers/IntelLLVM.cmake
Original file line number Diff line number Diff line change
@@ -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)
else()
include(${CMAKE_CURRENT_LIST_DIR}/Clang.cmake)
endif()

if (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86|AMD64)")
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -mrtm -mwaitpkg)
endif()
23 changes: 22 additions & 1 deletion cmake/hwloc_detection.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ foreach(hwloc_version ${HWLOC_REQUIRED_VERSIONS})
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}")
Expand All @@ -37,6 +36,28 @@ foreach(hwloc_version ${HWLOC_REQUIRED_VERSIONS})
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)
find_package(PkgConfig QUIET)
if (PKG_CONFIG_FOUND)
pkg_search_module(HWLOC hwloc)
if (HWLOC_FOUND)
if (HWLOC_VERSION VERSION_LESS 2)
set(TBBBIND_LIBRARY_NAME tbbbind)
elseif(HWLOC_VERSION VERSION_LESS 2.4)
set(TBBBIND_LIBRARY_NAME tbbbind_2_0)
else()
set(TBBBIND_LIBRARY_NAME tbbbind_2_4)
endif()
endif()
endif()
endif()

65 changes: 65 additions & 0 deletions cmake/memcheck.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,68 @@ function(_tbb_run_memcheck test_target)
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
)
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ static void CountOccurrences(int nthreads) {
if (!silent && count_collisions) {
for (auto i = hashes.begin(); i != hashes.end(); ++i)
c += i->second - 1;
printf("hashes = %d collisions = %d ", hashes.size(), c);
printf("hashes = %d collisions = %d ", static_cast<int>(hashes.size()), c);
c = 0;
hashes.clear();
}
Expand Down
12 changes: 12 additions & 0 deletions examples/graph/fgbzip2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,18 @@ add_executable(fgbzip2
target_link_libraries(fgbzip2 TBB::tbb Threads::Threads)
target_compile_options(fgbzip2 PRIVATE ${TBB_CXX_STD_FLAG})

if (MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL IntelLLVM)
target_compile_options(fgbzip2 PRIVATE -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
endif()

if (MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL Intel)
if (COMMAND target_link_options)
target_link_options(fgbzip2 PRIVATE /FORCE:MULTIPLE /INCREMENTAL:NO)
else()
set_target_properties(fgbzip2 PROPERTIES LINK_FLAGS /FORCE:MULTIPLE /INCREMENTAL:NO)
endif()
endif()

set(EXECUTABLE "$<TARGET_FILE:fgbzip2>")
set(ARGS -b=9 -async "$<TARGET_FILE:fgbzip2>")

Expand Down
4 changes: 4 additions & 0 deletions examples/parallel_for/polygon_overlay/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ add_subdirectory(../../common/gui gui)

target_link_libraries(polygon_overlay TBB::tbb TBB::tbbmalloc Threads::Threads UI_LIB_polygon_overlay)
target_compile_options(polygon_overlay PRIVATE ${TBB_CXX_STD_FLAG})
if (MSVC)
target_compile_options(polygon_overlay PRIVATE -DNOMINMAX)
endif()

set(EXECUTABLE "$<TARGET_FILE:polygon_overlay>")
set(ARGS "")
set(LIGHT_ARGS --polys 10 --size 5x5)

add_execution_target(run_polygon_overlay polygon_overlay ${EXECUTABLE} "${ARGS}")
add_execution_target(light_test_polygon_overlay polygon_overlay ${EXECUTABLE} "${LIGHT_ARGS}")

4 changes: 0 additions & 4 deletions examples/parallel_for/polygon_overlay/polyover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
limitations under the License.
*/

#ifndef NOMINMAX
#define NOMINMAX
#endif // NOMINMAX

// Polygon overlay
//
#include <cstdlib>
Expand Down
4 changes: 0 additions & 4 deletions examples/parallel_for/polygon_overlay/pover_video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@

// Support for GUI display for Polygon overlay demo

#ifndef NOMINMAX
#define NOMINMAX
#endif // NOMINMAX

#define VIDEO_WINMAIN_ARGS
#include <iostream>

Expand Down
4 changes: 4 additions & 0 deletions examples/parallel_for/tachyon/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ add_subdirectory(../../common/gui gui)
target_link_libraries(tachyon TBB::tbb Threads::Threads UI_LIB_tachyon)
target_compile_options(tachyon PRIVATE ${TBB_CXX_STD_FLAG})

if (MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL IntelLLVM)
target_compile_options(tachyon PRIVATE -D_CRT_SECURE_NO_WARNINGS)
endif()

set(EXECUTABLE "$<TARGET_FILE:tachyon>")
set(ARGS ${CMAKE_CURRENT_SOURCE_DIR}/dat/balls.dat)
set(PERF_ARGS silent ${CMAKE_CURRENT_SOURCE_DIR}/dat/balls3.dat)
Expand Down
4 changes: 4 additions & 0 deletions examples/parallel_pipeline/square/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ add_executable(square gen_input.cpp square.cpp)
target_link_libraries(square TBB::tbb Threads::Threads)
target_compile_options(square PRIVATE ${TBB_CXX_STD_FLAG})

if (MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL IntelLLVM)
target_compile_options(square PRIVATE -D_CRT_SECURE_NO_WARNINGS)
endif()

set(EXECUTABLE "$<TARGET_FILE:square>")
set(ARGS 0 input.txt output.txt)
set(PERF_ARGS auto input.txt output.txt silent)
Expand Down
1 change: 1 addition & 0 deletions examples/parallel_pipeline/square/square.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// Example program that reads a file of decimal integers in text format
// and changes each to its square.
//

#include <cstring>
#include <cstdlib>
#include <cstdio>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

/*
This file contains the TBB-based implementation of convex hull algortihm.
This file contains the TBB-based implementation of convex hull algorithm.
It corresponds to the following settings in convex_hull_bench.cpp:
- USETBB defined to 1
- USECONCVEC defined to 1
Expand Down
4 changes: 4 additions & 0 deletions examples/task_group/sudoku/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ add_executable(sudoku sudoku.cpp)
target_link_libraries(sudoku TBB::tbb Threads::Threads)
target_compile_options(sudoku PRIVATE ${TBB_CXX_STD_FLAG})

if (MSVC AND CMAKE_CXX_COMPILER_ID STREQUAL IntelLLVM)
target_compile_options(sudoku PRIVATE -D_CRT_SECURE_NO_WARNINGS)
endif()

set(EXECUTABLE "$<TARGET_FILE:sudoku>")
set(ARGS 4 ${CMAKE_CURRENT_SOURCE_DIR}/input1 verbose)
set(PERF_ARGS auto ${CMAKE_CURRENT_SOURCE_DIR}/input1 silent)
Expand Down
2 changes: 2 additions & 0 deletions examples/test_all/fibonacci/fibonacci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,8 @@ int main(int argc, char *argv[]) {
}
if (!Verbose)
printf("TEST PASSED\n");
// flush to prevent bufferization on exit
fflush(stdout);
return 0;
}

Expand Down
7 changes: 7 additions & 0 deletions include/oneapi/tbb/blocked_range.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ namespace d1 {
//! A range over which to iterate.
/** @ingroup algorithms */
template<typename Value>
__TBB_requires(blocked_range_value<Value>)
class blocked_range {
public:
//! Type of a value
Expand Down Expand Up @@ -139,12 +140,18 @@ class blocked_range {
}

template<typename RowValue, typename ColValue>
__TBB_requires(blocked_range_value<RowValue> &&
blocked_range_value<ColValue>)
friend class blocked_range2d;

template<typename RowValue, typename ColValue, typename PageValue>
__TBB_requires(blocked_range_value<RowValue> &&
blocked_range_value<ColValue> &&
blocked_range_value<PageValue>)
friend class blocked_range3d;

template<typename DimValue, unsigned int N, typename>
__TBB_requires(blocked_range_value<DimValue>)
friend class blocked_rangeNd_impl;
};

Expand Down
Loading

0 comments on commit 261fe22

Please sign in to comment.