CbmRoot
Loading...
Searching...
No Matches
Algorithm.h
Go to the documentation of this file.
1/* Copyright (C) 2023 FIAS Frankfurt Institute for Advanced Studies, Frankfurt / Main
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Felix Weiglhofer [committer] */
4#ifndef CBM_ALGO_BASE_COMPAT_ALGORITHMS_H
5#define CBM_ALGO_BASE_COMPAT_ALGORITHMS_H
6
18#include "BuildInfo.h"
19
20#include <algorithm>
21#include <poolstl/algorithm>
22#include <poolstl/execution>
23
24#ifdef HAVE_PARALLEL_ALGORITHM
25#include <execution>
26#endif
27
28namespace cbm::algo
29{
30
37 task_thread_pool::task_thread_pool& GetGlobalSTLThreadPool();
38
45 template<typename It, typename Compare>
46 void Sort(It first, It last, Compare comp)
47 {
48// Disable parallel sorting for the moment
49// The underlying implementation in libTBB has a massive memory leak:
50// https://community.intel.com/t5/Intel-oneAPI-Threading-Building/std-sort-std-execution-par-unseq-has-a-memory-leak-on-Linux/m-p/1580910
51//
52// Update 2024-05-02: Add poolstl as a replacement for libTBB
53#if 0
54// #ifdef HAVE_PARALLEL_STL_LIBTBB
55 std::sort(std::execution::par_unseq, first, last, comp);
56#elif defined(HAVE_PARALLEL_STL_POOLSTL)
57 std::sort(poolstl::par.on(GetGlobalSTLThreadPool()), first, last, comp);
58#else
59 std::sort(first, last, comp);
60#endif
61 }
62} // namespace cbm::algo
63
64
65#endif
bool first
task_thread_pool::task_thread_pool & GetGlobalSTLThreadPool()
Get the global thread pool for parallel stl algorithms.
Definition Algorithm.cxx:8
void Sort(It first, It last, Compare comp)
Wrapper for std::sort.
Definition Algorithm.h:46