diff --git a/cmake/configs/default.cmake b/cmake/configs/default.cmake index 9115e4def2..0d43fd72ae 100644 --- a/cmake/configs/default.cmake +++ b/cmake/configs/default.cmake @@ -417,6 +417,7 @@ hunter_default_version(odb-mysql VERSION 2.4.0) hunter_default_version(odb-pgsql VERSION 2.4.0) hunter_default_version(odb-sqlite VERSION 2.4.0) hunter_default_version(ogles_gpgpu VERSION 0.3.6) +hunter_default_version(oneTBB VERSION 2021.5.0) hunter_default_version(oniguruma VERSION 6.8.1-p0) hunter_default_version(onmt VERSION 0.4.1-p2) hunter_default_version(openddlparser VERSION 0.1.0-p2) diff --git a/cmake/projects/oneTBB/hunter.cmake b/cmake/projects/oneTBB/hunter.cmake new file mode 100644 index 0000000000..f8a4713406 --- /dev/null +++ b/cmake/projects/oneTBB/hunter.cmake @@ -0,0 +1,32 @@ +# Copyright (c) 2022, Raffael Casagrande +# All rights reserved. + +# !!! DO NOT PLACE HEADER GUARDS HERE !!! + +include(hunter_add_version) +include(hunter_cacheable) +include(hunter_download) +include(hunter_pick_scheme) +include(hunter_cmake_args) + +hunter_add_version( + PACKAGE_NAME + oneTBB + VERSION + 2021.5.0 + URL + "https://github.com/oneapi-src/oneTBB/archive/v2021.5.0.tar.gz" + SHA1 + 71750727bd1436f4047342d0adb827c25d7bc2b0 +) + +hunter_cmake_args( + oneTBB + CMAKE_ARGS + TBB_TEST=OFF + TBB_STRICT=OFF +) + +hunter_pick_scheme(DEFAULT url_sha1_cmake) +hunter_cacheable(oneTBB) +hunter_download(PACKAGE_NAME oneTBB) diff --git a/docs/packages/pkg/oneTBB.rst b/docs/packages/pkg/oneTBB.rst new file mode 100644 index 0000000000..ed9661a6ec --- /dev/null +++ b/docs/packages/pkg/oneTBB.rst @@ -0,0 +1,20 @@ +.. spelling:: + + oneTBB + +.. index:: + single: concurrency ; oneTBB + +.. _pkg.oneTBB: + +oneTBB +====== + +- `Official `__ +- `Example `__ +- Added by `craffael `__ (`pr-600 `__) + +.. literalinclude:: /../examples/oneTBB/CMakeLists.txt + :language: cmake + :start-after: # DOCUMENTATION_START { + :end-before: # DOCUMENTATION_END } diff --git a/examples/oneTBB/CMakeLists.txt b/examples/oneTBB/CMakeLists.txt new file mode 100644 index 0000000000..3ec7c74b96 --- /dev/null +++ b/examples/oneTBB/CMakeLists.txt @@ -0,0 +1,19 @@ +# Copyright (c) 2022, Raffael Casagrande +# All rights reserved. + +cmake_minimum_required(VERSION 3.2) + +# Emulate HunterGate: +# * https://github.com/hunter-packages/gate +include("../common.cmake") + +project(download-oneTBB) + +# DOCUMENTATION_START { +hunter_add_package(oneTBB) +find_package(TBB CONFIG REQUIRED) +find_package(Threads REQUIRED) + +add_executable(boo boo.cpp) +target_link_libraries(boo PUBLIC TBB::tbb) +# DOCUMENTATION_END } diff --git a/examples/oneTBB/boo.cpp b/examples/oneTBB/boo.cpp new file mode 100644 index 0000000000..876e52120a --- /dev/null +++ b/examples/oneTBB/boo.cpp @@ -0,0 +1,16 @@ +#include + +int main() { + // Calculate sum of numbers 1 to 100 + int sum = oneapi::tbb::parallel_reduce(oneapi::tbb::blocked_range(1,101), 0, + [](oneapi::tbb::blocked_range 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; + } + ); +}