19 src.materialize_to_uninitialized(range, dst.data());
32 src.materialize_to_uninitialized(selection.slice(range), dst.data());
44 src.materialize_compressed_to_uninitialized(indices.slice(range), dst.slice(range).data());
60 selection.foreach_index(
GrainSize(512), [&](
const int i) {
61 dst.
slice(dst_offsets[i]).copy_from(src.
slice(src_offsets[i]));
74 for (const int i : indices.slice(range)) {
75 atomic_add_and_fetch_int32(&counts[i], 1);
84 for (const int i : range) {
92 mask.foreach_index_optimized<
int64_t>([&](
const int64_t i) { span[i] = !span[i]; });
97 return std::all_of(span.
begin(), span.
end(), [&](
const bool value) { return value == test; });
103 range.begin(), range.end(), [&](
const int64_t i) { return varray[i] == test; });
109 return BooleanMix::None;
112 if (info.
type == CommonVArrayInfo::Type::Single) {
113 return *
static_cast<const bool *
>(info.
data) ? BooleanMix::AllTrue : BooleanMix::AllFalse;
115 if (info.
type == CommonVArrayInfo::Type::Span) {
117 return threading::parallel_reduce(
122 if (
init == BooleanMix::Mixed) {
126 const bool compare = (
init == BooleanMix::None) ? slice.
first() :
127 (
init == BooleanMix::AllTrue);
129 return compare ? BooleanMix::AllTrue : BooleanMix::AllFalse;
131 return BooleanMix::Mixed;
135 return threading::parallel_reduce(
140 if (
init == BooleanMix::Mixed) {
144 const bool compare = (
init == BooleanMix::None) ? varray[range.first()] :
145 (
init == BooleanMix::AllTrue);
147 return compare ? BooleanMix::AllTrue : BooleanMix::AllFalse;
149 return BooleanMix::Mixed;
156 if (varray.
is_empty() || mask.is_empty()) {
160 if (varray.
size() == mask.size()) {
162 if (info.
type == CommonVArrayInfo::Type::Single) {
163 return *
static_cast<const bool *
>(info.
data) ? varray.
size() : 0;
165 if (info.
type == CommonVArrayInfo::Type::Span) {
167 return threading::parallel_reduce(
172 const Span<bool> slice = span.slice(range);
173 return init + std::count(slice.begin(), slice.end(), true);
175 std::plus<int64_t>());
177 return threading::parallel_reduce(
182 int64_t value = init;
184 for (const int64_t i : range) {
185 value += int64_t(varray[i]);
189 std::plus<int64_t>());
192 if (info.
type == CommonVArrayInfo::Type::Single) {
193 return *
static_cast<const bool *
>(info.
data) ? mask.size() : 0;
196 mask.foreach_segment([&](
const IndexMaskSegment segment) {
197 for (
const int64_t i : segment) {
211 if (indices.size() != range.size()) {
214 return threading::parallel_reduce(
218 [&](
const IndexRange part,
const bool is_range) {
219 const Span<int> local_indices = indices.slice(part);
220 const IndexRange local_range = range.slice(part);
222 std::equal(local_indices.begin(), local_indices.end(), local_range.begin());
224 std::logical_and<bool>());
int BLI_system_thread_count(void)
Provides wrapper around system-specific atomic primitives, and some extensions (faked-atomic operatio...
GMutableSpan slice(const int64_t start, int64_t size) const
const CPPType & type() const
GSpan slice(const int64_t start, int64_t size) const
const CPPType & type() const
IndexRange index_range() const
static GVArray ForSpan(GSpan span)
constexpr IndexRange index_range() const
constexpr Span slice(int64_t start, int64_t size) const
constexpr const T & first() const
constexpr const T * end() const
constexpr const T * begin() const
IndexRange index_range() const
CommonVArrayInfo common_info() const
local_group_size(16, 16) .push_constant(Type b
void invert_booleans(MutableSpan< bool > span)
void count_indices(Span< int > indices, MutableSpan< int > counts)
void copy(const GVArray &src, GMutableSpan dst, int64_t grain_size=4096)
bool indices_are_range(Span< int > indices, IndexRange range)
void copy_group_to_group(OffsetIndices< int > src_offsets, OffsetIndices< int > dst_offsets, const IndexMask &selection, GSpan src, GMutableSpan dst)
BooleanMix booleans_mix_calc(const VArray< bool > &varray, IndexRange range_to_check)
void gather(const GVArray &src, const IndexMask &indices, GMutableSpan dst, int64_t grain_size=4096)
static bool all_equal(const Span< bool > span, const bool test)
int64_t count_booleans(const VArray< bool > &varray)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))