tbb 2021.2.0

master
Alexander Bayandin 2021-03-07 21:11:52 +00:00 committed by Carlo Cabrera
parent af940f86e4
commit 08fcb8e821
No known key found for this signature in database
GPG Key ID: C74D447FC549A1D0
1 changed files with 56 additions and 31 deletions

View File

@ -1,11 +1,9 @@
class Tbb < Formula
desc "Rich and complete approach to parallelism in C++"
homepage "https://github.com/oneapi-src/oneTBB"
url "https://github.com/intel/tbb/archive/v2020.3.tar.gz"
version "2020_U3"
sha256 "ebc4f6aa47972daed1f7bf71d100ae5bf6931c2e3144cf299c8cc7d041dca2f3"
url "https://github.com/oneapi-src/oneTBB/archive/refs/tags/v2021.2.0.tar.gz"
sha256 "cee20b0a71d977416f3e3b4ec643ee4f38cedeb2a9ff015303431dd9d8d79854"
license "Apache-2.0"
revision 1
bottle do
sha256 cellar: :any, arm64_big_sur: "33b261262efc28bb46c9aa4ff6ae74bc51033cc9f5877c3312a52af07130d534"
@ -19,50 +17,77 @@ class Tbb < Formula
depends_on "swig" => :build
depends_on "python@3.9"
# Remove when upstream fix is released
# https://github.com/oneapi-src/oneTBB/pull/258
patch do
url "https://github.com/oneapi-src/oneTBB/commit/86f6dcdc17a8f5ef2382faaef860cfa5243984fe.patch?full_index=1"
sha256 "d62cb666de4010998c339cde6f41c7623a07e9fc69e498f2e149821c0c2c6dd0"
end
# Fix installation of Python components
# See https://github.com/oneapi-src/oneTBB/issues/343
patch :DATA
def install
compiler = (ENV.compiler == :clang) ? "clang" : "gcc"
system "make", "tbb_build_prefix=BUILDPREFIX", "compiler=#{compiler}"
lib.install Dir["build/BUILDPREFIX_release/*.dylib"]
args = *std_cmake_args + %w[
-DTBB_TEST=OFF
-DTBB4PY_BUILD=ON
]
# Build and install static libraries
system "make", "tbb_build_prefix=BUILDPREFIX", "compiler=#{compiler}",
"extra_inc=big_iron.inc"
lib.install Dir["build/BUILDPREFIX_release/*.a"]
include.install "include/tbb"
mkdir "build" do
system "cmake", "..", *args
system "make"
system "make", "install"
end
cd "python" do
ENV.append_path "CMAKE_PREFIX_PATH", prefix.to_s
ENV["LDFLAGS"] = "-rpath #{opt_lib}"
ENV["TBBROOT"] = prefix
system Formula["python@3.9"].opt_bin/"python3", *Language::Python.setup_install_args(prefix)
end
system "cmake", *std_cmake_args,
"-DINSTALL_DIR=lib/cmake/TBB",
"-DSYSTEM_NAME=Darwin",
"-DTBB_VERSION_FILE=#{include}/tbb/tbb_stddef.h",
"-P", "cmake/tbb_config_installer.cmake"
(lib/"cmake"/"TBB").install Dir["lib/cmake/TBB/*.cmake"]
end
test do
(testpath/"test.cpp").write <<~EOS
#include <tbb/task_scheduler_init.h>
(testpath/"sum1-100.cpp").write <<~EOS
#include <iostream>
#include <tbb/blocked_range.h>
#include <tbb/parallel_reduce.h>
int main()
{
std::cout << tbb::task_scheduler_init::default_num_threads();
auto total = tbb::parallel_reduce(
tbb::blocked_range<int>(0, 100),
0.0,
[&](tbb::blocked_range<int> r, int running_total)
{
for (int i=r.begin(); i < r.end(); ++i) {
running_total += i + 1;
}
return running_total;
}, std::plus<int>()
);
std::cout << total << std::endl;
return 0;
}
EOS
system ENV.cxx, "test.cpp", "-L#{lib}", "-ltbb", "-o", "test"
system "./test"
system ENV.cxx, "sum1-100.cpp", "--std=c++14", "-L#{lib}", "-ltbb", "-o", "sum1-100"
assert_equal "5050", shell_output("./sum1-100").chomp
system Formula["python@3.9"].opt_bin/"python3", "-c", "import tbb"
end
end
__END__
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index da4f4f93..6c95bcde 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -49,8 +49,8 @@ add_test(NAME python_test
-DPYTHON_MODULE_BUILD_PATH=${PYTHON_BUILD_WORK_DIR}/build
-P ${PROJECT_SOURCE_DIR}/cmake/python/test_launcher.cmake)
-install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${PYTHON_BUILD_WORK_DIR}/build/lib/
- DESTINATION ${CMAKE_INSTALL_LIBDIR}
+install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${PYTHON_BUILD_WORK_DIR}/
+ DESTINATION .
COMPONENT tbb4py)
if (UNIX AND NOT APPLE)