Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,15 @@ compressor/mod/

# emacs temp file
\#*\#
*~
*~

# TBB import libs must be committed so a fresh clone can link.
# The /**/x64/ rule above excludes the *directory*, and git will not
# descend into an excluded directory -- so the directory exclusion must
# be lifted first, then everything re-ignored, then these files re-included.
!/sdk/libraries/x64/
/sdk/libraries/x64/*
!/sdk/libraries/x64/tbb.lib
!/sdk/libraries/x64/tbb12.lib
!/sdk/libraries/x64/tbbmalloc.lib
!/sdk/libraries/x64/tbbmalloc_proxy.lib
Binary file removed sdk/binaries/tbb.dll
Binary file not shown.
Binary file added sdk/binaries/tbb12.dll
Binary file not shown.
Binary file added sdk/binaries/tbbmalloc.dll
Binary file not shown.
Binary file added sdk/binaries/tbbmalloc_proxy.dll
Binary file not shown.
Binary file modified sdk/libraries/x64/tbb.lib
Binary file not shown.
Binary file added sdk/libraries/x64/tbb12.lib
Binary file not shown.
Binary file added sdk/libraries/x64/tbbmalloc.lib
Binary file not shown.
Binary file added sdk/libraries/x64/tbbmalloc_proxy.lib
Binary file not shown.
78 changes: 78 additions & 0 deletions src/3rd party/oneapi/tbb.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
Copyright (c) 2005-2025 Intel Corporation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef __TBB_tbb_H
#define __TBB_tbb_H

/**
This header bulk-includes declarations or definitions of all the functionality
provided by TBB (save for tbbmalloc and 3rd party dependent headers).

If you use only a few TBB constructs, consider including specific headers only.
Any header listed below can be included independently of others.
**/

#include "oneapi/tbb/blocked_range.h"
#include "oneapi/tbb/blocked_range2d.h"
#include "oneapi/tbb/blocked_range3d.h"
#include "oneapi/tbb/blocked_nd_range.h"
#include "oneapi/tbb/cache_aligned_allocator.h"
#include "oneapi/tbb/combinable.h"
#include "oneapi/tbb/concurrent_hash_map.h"
#if TBB_PREVIEW_CONCURRENT_LRU_CACHE
#include "tbb/concurrent_lru_cache.h"
#endif
#include "oneapi/tbb/collaborative_call_once.h"
#include "oneapi/tbb/concurrent_priority_queue.h"
#include "oneapi/tbb/concurrent_queue.h"
#include "oneapi/tbb/concurrent_unordered_map.h"
#include "oneapi/tbb/concurrent_unordered_set.h"
#include "oneapi/tbb/concurrent_map.h"
#include "oneapi/tbb/concurrent_set.h"
#include "oneapi/tbb/concurrent_vector.h"
#include "oneapi/tbb/enumerable_thread_specific.h"
#include "oneapi/tbb/flow_graph.h"
#include "oneapi/tbb/global_control.h"
#include "oneapi/tbb/info.h"
#if TBB_PREVIEW_MEMORY_POOL
#include "oneapi/tbb/memory_pool.h"
#endif
#include "oneapi/tbb/null_mutex.h"
#include "oneapi/tbb/null_rw_mutex.h"
#include "oneapi/tbb/parallel_for.h"
#include "oneapi/tbb/parallel_for_each.h"
#include "oneapi/tbb/parallel_invoke.h"
#include "oneapi/tbb/parallel_pipeline.h"
#include "oneapi/tbb/parallel_reduce.h"
#include "oneapi/tbb/parallel_scan.h"
#include "oneapi/tbb/parallel_sort.h"
#include "oneapi/tbb/partitioner.h"
#include "oneapi/tbb/queuing_mutex.h"
#include "oneapi/tbb/queuing_rw_mutex.h"
#include "oneapi/tbb/scalable_allocator.h"
#include "oneapi/tbb/spin_mutex.h"
#include "oneapi/tbb/spin_rw_mutex.h"
#include "oneapi/tbb/mutex.h"
#include "oneapi/tbb/rw_mutex.h"
#include "oneapi/tbb/task.h"
#include "oneapi/tbb/task_arena.h"
#include "oneapi/tbb/task_group.h"
#include "oneapi/tbb/task_scheduler_observer.h"
#include "oneapi/tbb/tbb_allocator.h"
#include "oneapi/tbb/tick_count.h"
#include "oneapi/tbb/version.h"

#endif /* __TBB_tbb_H */
196 changes: 196 additions & 0 deletions src/3rd party/oneapi/tbb/blocked_nd_range.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
/*
Copyright (c) 2017-2025 Intel Corporation
Copyright (c) 2026 UXL Foundation Contributors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#ifndef __TBB_blocked_nd_range_H
#define __TBB_blocked_nd_range_H

#include <algorithm> // std::any_of
#include <array>
#include <cstddef>
#include <type_traits> // std::is_same, std::enable_if

#include "detail/_config.h"
#include "detail/_template_helpers.h" // index_sequence, make_index_sequence
#include "detail/_namespace_injection.h"
#include "detail/_range_common.h"

#include "blocked_range.h"

namespace tbb {
namespace detail {
namespace d1 {

/*
The blocked_nd_range_impl uses make_index_sequence<N> to automatically generate a ctor with
exactly N arguments of the type tbb::blocked_range<Value>. Such ctor provides an opportunity
to use braced-init-list parameters to initialize each dimension.
Use of parameters, whose representation is a braced-init-list, but they're not
std::initializer_list or a reference to one, produces a non-deduced context
within template argument deduction.

NOTE: blocked_nd_range must be exactly a templated alias to the blocked_nd_range_impl
(and not e.g. a derived class), otherwise it would need to declare its own ctor
facing the same problem that the impl class solves.
*/

template<typename Value, unsigned int N, typename = detail::make_index_sequence<N>>
class blocked_nd_range_impl;

template<typename Value, unsigned int N, std::size_t... Is>
class blocked_nd_range_impl<Value, N, detail::index_sequence<Is...>> {
public:
//! Type of a value.
using value_type = Value;

//! Type of a dimension range.
using dim_range_type = tbb::blocked_range<value_type>;

//! Type for the size of a range.
using size_type = typename dim_range_type::size_type;

blocked_nd_range_impl() = delete;

//! Constructs N-dimensional range over N half-open intervals each represented as tbb::blocked_range<Value>.
blocked_nd_range_impl(const indexed_t<dim_range_type, Is>&... args) : my_dims{ {args...} } {}

#if __clang__ && __TBB_CLANG_VERSION < 140000
// On clang prior to version 14.0.0, passing a single braced init list to the constructor of blocked_nd_range<T, 1>
// matches better on the C array constructor and generates compile-time error because of unexpected size
// Adding constraints for this constructor to force the compiler to drop it from overload resolution if the size is unexpected
template <unsigned int M, typename = typename std::enable_if<M == N>::type>
blocked_nd_range_impl(const value_type (&size)[M], size_type grainsize = 1) :
#else
blocked_nd_range_impl(const value_type (&size)[N], size_type grainsize = 1) :
#endif
my_dims { dim_range_type(0, size[Is], grainsize)... } {}

//! Dimensionality of a range.
static constexpr unsigned int dim_count() { return N; }

//! Range in certain dimension.
const dim_range_type& dim(unsigned int dimension) const {
__TBB_ASSERT(dimension < N, "out of bound");
return my_dims[dimension];
}

//------------------------------------------------------------------------
// Methods that implement Range concept
//------------------------------------------------------------------------

//! True if at least one dimension is empty.
bool empty() const {
return std::any_of(my_dims.begin(), my_dims.end(), [](const dim_range_type& d) {
return d.empty();
});
}

//! True if at least one dimension is divisible.
bool is_divisible() const {
return std::any_of(my_dims.begin(), my_dims.end(), [](const dim_range_type& d) {
return d.is_divisible();
});
}

blocked_nd_range_impl(blocked_nd_range_impl& r, proportional_split proportion) : my_dims(r.my_dims) {
do_split(r, proportion);
}

blocked_nd_range_impl(blocked_nd_range_impl& r, split proportion) : my_dims(r.my_dims) {
do_split(r, proportion);
}

private:
static_assert(N != 0, "zero dimensional blocked_nd_range can't be constructed");

//! Ranges in each dimension.
std::array<dim_range_type, N> my_dims;

template<typename split_type>
void do_split(blocked_nd_range_impl& r, split_type proportion) {
static_assert((std::is_same<split_type, split>::value || std::is_same<split_type, proportional_split>::value),
"type of split object is incorrect");
__TBB_ASSERT(r.is_divisible(), "can't split not divisible range");

auto my_it = std::max_element(my_dims.begin(), my_dims.end(), [](const dim_range_type& first, const dim_range_type& second) {
return (first.size() * double(second.grainsize()) < second.size() * double(first.grainsize()));
});

auto r_it = r.my_dims.begin() + (my_it - my_dims.begin());

my_it->my_begin = dim_range_type::do_split(*r_it, proportion);

// (!(my_it->my_begin < r_it->my_end) && !(r_it->my_end < my_it->my_begin)) equals to
// (my_it->my_begin == r_it->my_end), but we can't use operator== due to Value concept
__TBB_ASSERT(!(my_it->my_begin < r_it->my_end) && !(r_it->my_end < my_it->my_begin),
"blocked_range has been split incorrectly");
}
};

template<typename Value, unsigned int N>
__TBB_requires(blocked_range_value<Value>)
class blocked_nd_range : public blocked_nd_range_impl<Value, N> {
using base = blocked_nd_range_impl<Value, N>;
// Making constructors of base class visible
using base::base;
};

#if __TBB_CPP17_DEDUCTION_GUIDES_PRESENT
// blocked_nd_range(const dim_range_type& dim0, const dim_range_type& dim1, ...)
// while the arguments are passed as braced-init-lists
// Works only for 2 and more arguments since the deduction from
// single braced-init-list or single C-array argument prefers the multi-dimensional range
// Only braced-init-lists of size 2 and 3 are allowed since dim_range_type may only
// be constructed from 2 or 3 arguments
template <typename Value, unsigned int... Ns,
typename = std::enable_if_t<sizeof...(Ns) >= 2>,
typename = std::enable_if_t<(... && (Ns == 2 || Ns == 3))>>
blocked_nd_range(const Value (&... dim)[Ns])
-> blocked_nd_range<Value, sizeof...(Ns)>;

// blocked_nd_range(const dim_range_type& dim0, const dim_range_type& dim1, ...)
// while the arguments are passed as blocked_range objects of the same type
template <typename Value, typename... Values,
typename = std::enable_if_t<(... && std::is_same_v<Value, Values>)>>
blocked_nd_range(blocked_range<Value>, blocked_range<Values>...)
-> blocked_nd_range<Value, 1 + sizeof...(Values)>;

// blocked_nd_range(const value_type (&size)[N], size_type grainsize = 1)
template <typename Value, unsigned int N>
blocked_nd_range(const Value (&)[N], typename blocked_nd_range<Value, N>::size_type = 1)
-> blocked_nd_range<Value, N>;

// blocked_nd_range(blocked_nd_range<Value, N>&, oneapi::tbb::split)
template <typename Value, unsigned int N>
blocked_nd_range(blocked_nd_range<Value, N>, oneapi::tbb::split)
-> blocked_nd_range<Value, N>;

// blocked_nd_range(blocked_nd_range<Value, N>&, oneapi::tbb::proportional_split)
template <typename Value, unsigned int N>
blocked_nd_range(blocked_nd_range<Value, N>, oneapi::tbb::proportional_split)
-> blocked_nd_range<Value, N>;

#endif // __TBB_CPP17_DEDUCTION_GUIDES_PRESENT

} // namespace d1
} // namespace detail

inline namespace v1 {
using detail::d1::blocked_nd_range;
} // namespace v1
} // namespace tbb

#endif /* __TBB_blocked_nd_range_H */
Loading