From 929758b3206343263b78300f6eafae91f084a5c6 Mon Sep 17 00:00:00 2001 From: Andrew <51118083+ArionThinker@users.noreply.github.com> Date: Fri, 6 Oct 2023 21:45:45 +0300 Subject: [PATCH] github.com/oneapi-src/oneTBB (#3278) * new file: projects/github.com/oneapi-src/oneTBB/cores-types.cpp new file: projects/github.com/oneapi-src/oneTBB/package.yml new file: projects/github.com/oneapi-src/oneTBB/sum1-100.cpp * display-name * well, this is complicated * hmmm * wip * wip * remove tea/gx * wip * let's try without Python first * --std=c++14 * wip * sure * add in gnu make on linux * wip * test * python tbb * PYTHONPATH & LDFLAGS * done * will the magic happen? * compiler to env? * it's redundant > install_log.txt 2>&1 * oh new python * problems with linux/aarch64 * i'll stop messing with this --------- Co-authored-by: Jacob Heider Co-authored-by: Jacob Heider --- .../oneapi-src/oneTBB/cores-types.cpp | 10 ++ .../github.com/oneapi-src/oneTBB/package.yml | 97 +++++++++++++++++++ .../github.com/oneapi-src/oneTBB/sum1-100.cpp | 22 +++++ 3 files changed, 129 insertions(+) create mode 100644 projects/github.com/oneapi-src/oneTBB/cores-types.cpp create mode 100644 projects/github.com/oneapi-src/oneTBB/package.yml create mode 100644 projects/github.com/oneapi-src/oneTBB/sum1-100.cpp diff --git a/projects/github.com/oneapi-src/oneTBB/cores-types.cpp b/projects/github.com/oneapi-src/oneTBB/cores-types.cpp new file mode 100644 index 00000000..f80ca835 --- /dev/null +++ b/projects/github.com/oneapi-src/oneTBB/cores-types.cpp @@ -0,0 +1,10 @@ +#include +#include + +int main() { + const auto numa_nodes = tbb::info::numa_nodes(); + const auto size = numa_nodes.size(); + const auto type = numa_nodes.front(); + + return size == 1 && type == tbb::task_arena::automatic ? EXIT_SUCCESS : EXIT_FAILURE; +} \ No newline at end of file diff --git a/projects/github.com/oneapi-src/oneTBB/package.yml b/projects/github.com/oneapi-src/oneTBB/package.yml new file mode 100644 index 00000000..73149d88 --- /dev/null +++ b/projects/github.com/oneapi-src/oneTBB/package.yml @@ -0,0 +1,97 @@ +distributable: + url: https://github.com/oneapi-src/oneTBB/archive/v{{version}}.tar.gz + strip-components: 1 + +display-name: tbb + +platforms: + - darwin + - linux/x86-64 + # FIXME: linux/aarch64 => undefined symbol: __aarch64_ldadd8_acq_rel + +versions: + github: oneapi-src/oneTBB + strip: /^v/ + ignore: # they moved _to_ calver + - /4\.4/ + +dependencies: + python.org: ~3.11 + +runtime: + env: + PYTHONPATH: '{{prefix}}/lib/python{{deps.python.org.version.major}}/site-packages:$PYTHONPATH' + +build: + dependencies: + cmake.org: '*' + swig.org: '*' + freedesktop.org/pkg-config: '*' + linux: + llvm.org: '*' + gnu.org/gcc: '>=4.8.5<11.2.1' + gnu.org/make: '*' + working-directory: build + script: + #build shared + - run: | + cmake -S ../.. $CMAKE_ARGS -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_RPATH="{{prefix}}" + cmake --build . + cmake --install . + working-directory: shared + + # build static + - run: | + cmake -S ../.. $CMAKE_ARGS -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_RPATH="{{prefix}}" + cmake --build . + install ./*/libtbb*.a {{prefix}}/lib/ + working-directory: static + + # build python + - run: | + cmake -S ../.. $CMAKE_ARGS -DTBB4PY_BUILD=ON + make irml + install gnu*/* {{prefix}}/lib + export LDFLAGS="-L{{prefix}}/lib/libirml.so -lirml $LDFLAGS" + export PYTHONPATH="$PWD/build/python{{deps.python.org.version.marketing}}/site-packages:$PYTHONPATH" + export CXX=clang++ + python ../../python/setup.py install --prefix=$PWD/build + working-directory: python + if: linux + + - run: | + python3 -m pip install --prefix={{prefix}} . + working-directory: ../python + + # python 3.xx => 3 symlink + - run: | + if [ ! -L "python{{deps.python.org.version.major}}" ]; then + ln -s python{{deps.python.org.version.marketing}} python{{deps.python.org.version.major}} + fi + working-directory: ${{prefix}}/lib + + env: + TBBROOT: '{{prefix}}' + CMAKE_ARGS: + - -DCMAKE_INSTALL_PREFIX="{{prefix}} + - -DCMAKE_BUILD_TYPE=Release + - -DCMAKE_FIND_FRAMEWORK=LAST + - -DCMAKE_VERBOSE_MAKEFILE=ON + - -Wno-dev + - -DTBB_TEST=OFF + PYTHONPATH: '{{prefix}}/lib/python{{deps.python.org.version.marketing}}/site-packages:$PYTHONPATH' + linux: + CC: gcc + CXX: g++ + +test: + dependencies: + freedesktop.org/pkg-config: '*' + script: + - pkg-config --modversion tbb | grep {{version}} + - c++ --std=c++14 cores-types.cpp $(pkg-config --libs tbb) -ltbb -o core-types + - ./core-types + - c++ --std=c++14 sum1-100.cpp $(pkg-config --libs tbb) -o sum1-100 + - ./sum1-100 | grep 5050 + - python -m TBB -h + - python -c "import TBB" diff --git a/projects/github.com/oneapi-src/oneTBB/sum1-100.cpp b/projects/github.com/oneapi-src/oneTBB/sum1-100.cpp new file mode 100644 index 00000000..2e290c2b --- /dev/null +++ b/projects/github.com/oneapi-src/oneTBB/sum1-100.cpp @@ -0,0 +1,22 @@ +#include +#include +#include + +int main() +{ +auto total = tbb::parallel_reduce( + tbb::blocked_range(0, 100), + 0.0, + [&](tbb::blocked_range r, int running_total) + { + for (int i=r.begin(); i < r.end(); ++i) { + running_total += i + 1; + } + + return running_total; + }, std::plus() +); + +std::cout << total << std::endl; +return 0; +} \ No newline at end of file