1// Copyright 2009-2021 Intel Corporation
2// SPDX-License-Identifier: Apache-2.0
3
4#pragma once
5
6#include <functional>
7#include "parallel_reduce.h"
8
9namespace embree
10{
11
12 template<typename Index, class UnaryPredicate>
13 __forceinline bool parallel_any_of (Index first, Index last, UnaryPredicate pred)
14 {
15 bool ret = false;
16
17#if defined(TASKING_TBB)
18#if TBB_INTERFACE_VERSION >= 12002
19 tbb::task_group_context context;
20 tbb::parallel_for(tbb::blocked_range<size_t>{first, last}, [&ret,pred,&context](const tbb::blocked_range<size_t>& r) {
21 if (context.is_group_execution_cancelled()) return;
22 for (size_t i = r.begin(); i != r.end(); ++i) {
23 if (pred(i)) {
24 ret = true;
25 context.cancel_group_execution();
26 }
27 }
28 });
29#else
30 tbb::parallel_for(tbb::blocked_range<size_t>{first, last}, [&ret,pred](const tbb::blocked_range<size_t>& r) {
31 if (tbb::task::self().is_cancelled()) return;
32 for (size_t i = r.begin(); i != r.end(); ++i) {
33 if (pred(i)) {
34 ret = true;
35 tbb::task::self().cancel_group_execution();
36 }
37 }
38 });
39#endif
40#else
41 ret = parallel_reduce (first, last, false, [pred](const range<size_t>& r)->bool {
42 bool localret = false;
43 for (auto i=r.begin(); i<r.end(); ++i) {
44 localret |= pred(i);
45 }
46 return localret;
47 },
48 std::bit_or<bool>()
49 );
50#endif
51
52 return ret;
53 }
54
55} // end namespace
56

source code of qtquick3d/src/3rdparty/embree/common/algorithms/parallel_any_of.h