Skip to content

Commit

Permalink
New Package: Intel oneTBB (#600)
Browse files Browse the repository at this point in the history
  • Loading branch information
craffael committed Aug 24, 2022
1 parent d4f3a43 commit e25a2f9
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmake/configs/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
32 changes: 32 additions & 0 deletions cmake/projects/oneTBB/hunter.cmake
Original file line number Diff line number Diff line change
@@ -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)
20 changes: 20 additions & 0 deletions docs/packages/pkg/oneTBB.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.. spelling::

oneTBB

.. index::
single: concurrency ; oneTBB

.. _pkg.oneTBB:

oneTBB
======

- `Official <https://github.com/oneapi-src/oneTBB>`__
- `Example <https://github.com/cpp-pm/hunter/blob/master/examples/oneTBB/CMakeLists.txt>`__
- Added by `craffael <https://github.com/craffael>`__ (`pr-600 <https://github.com/cpp-pm/hunter/pull/600>`__)

.. literalinclude:: /../examples/oneTBB/CMakeLists.txt
:language: cmake
:start-after: # DOCUMENTATION_START {
:end-before: # DOCUMENTATION_END }
19 changes: 19 additions & 0 deletions examples/oneTBB/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 }
16 changes: 16 additions & 0 deletions examples/oneTBB/boo.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#include <tbb/tbb.h>

int main() {
// Calculate sum of numbers 1 to 100
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 comments on commit e25a2f9

Please sign in to comment.