From 7a67c0b13c80d3cb5522e61ca738b4e1524b2bad Mon Sep 17 00:00:00 2001 From: Dan Hoeflinger Date: Wed, 18 Dec 2024 17:03:15 -0500 Subject: [PATCH] cleanup unnecessary code Signed-off-by: Dan Hoeflinger --- include/oneapi/dpl/internal/version_impl.h | 1 - include/oneapi/dpl/pstl/algorithm_impl.h | 1 - .../oneapi/dpl/pstl/omp/parallel_histogram.h | 109 ------------------ .../oneapi/dpl/pstl/parallel_backend_omp.h | 5 - .../oneapi/dpl/pstl/parallel_backend_serial.h | 12 -- .../oneapi/dpl/pstl/parallel_backend_tbb.h | 33 ------ 6 files changed, 161 deletions(-) delete mode 100644 include/oneapi/dpl/pstl/omp/parallel_histogram.h diff --git a/include/oneapi/dpl/internal/version_impl.h b/include/oneapi/dpl/internal/version_impl.h index 6b2d64598ec..46bd36a7427 100644 --- a/include/oneapi/dpl/internal/version_impl.h +++ b/include/oneapi/dpl/internal/version_impl.h @@ -20,7 +20,6 @@ # define _ONEDPL_STD_FEATURE_MACROS_PRESENT 1 // Clang 15 and older do not support range adaptors, see https://bugs.llvm.org/show_bug.cgi?id=44833 # define _ONEDPL_CPP20_RANGES_PRESENT ((__cpp_lib_ranges >= 201911L) && !(__clang__ && __clang_major__ < 16)) -# define _ONEDPL_CPP20_ATOMIC_REF_PRESENT (__cpp_lib_atomic_ref >= 201806L) #else # define _ONEDPL_STD_FEATURE_MACROS_PRESENT 0 # define _ONEDPL_CPP20_RANGES_PRESENT 0 diff --git a/include/oneapi/dpl/pstl/algorithm_impl.h b/include/oneapi/dpl/pstl/algorithm_impl.h index 1fcc5d7f9f1..0e6a9a09390 100644 --- a/include/oneapi/dpl/pstl/algorithm_impl.h +++ b/include/oneapi/dpl/pstl/algorithm_impl.h @@ -20,7 +20,6 @@ #include #include #include -#include #include "algorithm_fwd.h" diff --git a/include/oneapi/dpl/pstl/omp/parallel_histogram.h b/include/oneapi/dpl/pstl/omp/parallel_histogram.h deleted file mode 100644 index de1dc8187c8..00000000000 --- a/include/oneapi/dpl/pstl/omp/parallel_histogram.h +++ /dev/null @@ -1,109 +0,0 @@ -// -*- C++ -*- -//===----------------------------------------------------------------------===// -// -// Copyright (C) Intel Corporation -// -// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -// -// This file incorporates work covered by the following copyright and permission -// notice: -// -// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -// See https://llvm.org/LICENSE.txt for license information. -// -//===----------------------------------------------------------------------===// - -#ifndef _ONEDPL_INTERNAL_OMP_PARALLEL_HISTOGRAM_H -#define _ONEDPL_INTERNAL_OMP_PARALLEL_HISTOGRAM_H - -#include "util.h" - -namespace oneapi -{ -namespace dpl -{ -namespace __omp_backend -{ - -template -void -__histogram_body(_RandomAccessIterator1 __first, _RandomAccessIterator1 __last, _Size __num_bins, - _RandomAccessIterator2 __histogram_first, _FpHist __f, _FpInitialize __init, _FpAccum __accum) -{ - using _HistogramValueT = typename ::std::iterator_traits<_RandomAccessIterator2>::value_type; - - const std::size_t __num_threads = omp_get_num_threads(); - const std::size_t __size = __last - __first; - - // Initial partition of the iteration space into chunks. If the range is too small, - // this will result in a nonsense policy, so we check on the size as well below. - auto __policy1 = oneapi::dpl::__omp_backend::__chunk_partitioner(__first, __last); - auto __policy2 = oneapi::dpl::__omp_backend::__chunk_partitioner(__histogram_first, __histogram_first + __num_bins); - - std::vector> __local_histograms(__num_threads); - _PSTL_PRAGMA(omp taskloop shared(__local_histograms)) - for (std::size_t __tid = 0; __tid < __num_threads; ++__tid) - { - __local_histograms[__tid].resize(__num_bins, _HistogramValueT{0}); - } - - // main loop - _PSTL_PRAGMA(omp taskloop shared(__local_histograms)) - for (std::size_t __chunk = 0; __chunk < __policy1.__n_chunks; ++__chunk) - { - oneapi::dpl::__omp_backend::__process_chunk( - __policy1, __first, __chunk, [&](auto __chunk_first, auto __chunk_last) { - auto __thread_num = omp_get_thread_num(); - __f(__chunk_first, __chunk_last, __local_histograms[__thread_num].begin()); - }); - } - - _PSTL_PRAGMA(omp taskloop shared(__local_histograms)) - for (std::size_t __chunk = 0; __chunk < __policy2.__n_chunks; ++__chunk) - { - oneapi::dpl::__omp_backend::__process_chunk( - __policy2, __histogram_first, __chunk, [&](auto __chunk_first, auto __chunk_last) { - __init(__local_histograms[0].begin() + (__chunk_first - __histogram_first), - (__chunk_last - __chunk_first), __chunk_first); - - for (std::size_t __i = 1; __i < __num_threads; ++__i) - { - __accum(__local_histograms[__i].begin() + (__chunk_first - __histogram_first), - (__chunk_last - __chunk_first), __chunk_first); - } - }); - } -} - -template -void -__parallel_histogram(oneapi::dpl::__internal::__omp_backend_tag, _ExecutionPolicy&&, _RandomAccessIterator1 __first, - _RandomAccessIterator1 __last, _Size __num_bins, _RandomAccessIterator2 __histogram_first, - _FpHist __f, _FpInitialize __init, _FpAccum __accum) -{ - if (omp_in_parallel()) - { - // We don't create a nested parallel region in an existing parallel - // region: just create tasks - oneapi::dpl::__omp_backend::__histogram_body(__first, __last, __num_bins, __histogram_first, __f, __init, - __accum); - } - else - { - // Create a parallel region, and a single thread will create tasks - // for the region. - _PSTL_PRAGMA(omp parallel) - _PSTL_PRAGMA(omp single nowait) - { - oneapi::dpl::__omp_backend::__histogram_body(__first, __last, __num_bins, __histogram_first, __f, __init, - __accum); - } - } -} - -} // namespace __omp_backend -} // namespace dpl -} // namespace oneapi -#endif // _ONEDPL_INTERNAL_OMP_PARALLEL_HISTOGRAM_H diff --git a/include/oneapi/dpl/pstl/parallel_backend_omp.h b/include/oneapi/dpl/pstl/parallel_backend_omp.h index 0fd87008c49..f608581b245 100644 --- a/include/oneapi/dpl/pstl/parallel_backend_omp.h +++ b/include/oneapi/dpl/pstl/parallel_backend_omp.h @@ -62,9 +62,4 @@ //------------------------------------------------------------------------ #include "./omp/parallel_merge.h" -//------------------------------------------------------------------------ -// parallel_histogram -//------------------------------------------------------------------------ -#include "./omp/parallel_histogram.h" - #endif //_ONEDPL_PARALLEL_BACKEND_OMP_H diff --git a/include/oneapi/dpl/pstl/parallel_backend_serial.h b/include/oneapi/dpl/pstl/parallel_backend_serial.h index 2df972295ad..298b7447678 100644 --- a/include/oneapi/dpl/pstl/parallel_backend_serial.h +++ b/include/oneapi/dpl/pstl/parallel_backend_serial.h @@ -153,18 +153,6 @@ __parallel_for_each(oneapi::dpl::__internal::__serial_backend_tag, _ExecutionPol __f(*__iter); } -template -void -__parallel_histogram(oneapi::dpl::__internal::__serial_backend_tag, _ExecutionPolicy&& exec, - _RandomAccessIterator1 __first, _RandomAccessIterator1 __last, _Size __num_bins, - _RandomAccessIterator2 __histogram_first, _FpHist __f, _FpInitialize, _FpAccum) -{ - using _HistogramValueT = typename ::std::iterator_traits<_RandomAccessIterator2>::value_type; - ::std::fill(__histogram_first, __histogram_first + __num_bins, _HistogramValueT{0}); - __f(__first, __last, __histogram_first); -} - } // namespace __serial_backend } // namespace dpl } // namespace oneapi diff --git a/include/oneapi/dpl/pstl/parallel_backend_tbb.h b/include/oneapi/dpl/pstl/parallel_backend_tbb.h index b254e359f09..611d455dfe4 100644 --- a/include/oneapi/dpl/pstl/parallel_backend_tbb.h +++ b/include/oneapi/dpl/pstl/parallel_backend_tbb.h @@ -1331,39 +1331,6 @@ struct __thread_enumerable_storage tbb::enumerable_thread_specific> __thread_specific_storage; }; -//------------------------------------------------------------------------ -// parallel_histogram -//------------------------------------------------------------------------ -template -void -__parallel_histogram(oneapi::dpl::__internal::__tbb_backend_tag, _ExecutionPolicy&&, _RandomAccessIterator1 __first, - _RandomAccessIterator1 __last, _Size __num_bins, _RandomAccessIterator2 __histogram_first, - _FpHist __f, _FpInitialize __init, _FpAccum __accum) -{ - using _HistogramValueT = typename ::std::iterator_traits<_RandomAccessIterator2>::value_type; - - tbb::this_task_arena::isolate([&]() { - tbb::enumerable_thread_specific> __thread_local_histogram(__num_bins, - _HistogramValueT{0}); - size_t __n = __last - __first; - tbb::parallel_for(tbb::blocked_range<_Size>(0, __n, 1024), [&](const tbb::blocked_range<_Size>& __range) { - std::vector<_HistogramValueT>& __local_histogram = __thread_local_histogram.local(); - __f(__first + __range.begin(), __first + __range.end(), __local_histogram.begin()); - }); - - tbb::parallel_for(tbb::blocked_range<_Size>(0, __num_bins), [&](const tbb::blocked_range<_Size>& __range) { - auto __local_histogram = __thread_local_histogram.begin(); - __init(__local_histogram->begin() + __range.begin(), __range.size(), __histogram_first + __range.begin()); - ++__local_histogram; - for (; __local_histogram != __thread_local_histogram.end(); ++__local_histogram) - { - __accum(__local_histogram->begin() + __range.begin(), __range.size(), - __histogram_first + __range.begin()); - } - }); - }); -} } // namespace __tbb_backend } // namespace dpl