[libcxx-commits] [PATCH] D155531: [libc++][PSTL] Simplify the partitioning algorithm until we have better data to know how to chunk better
Nikolas Klauser via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Aug 14 09:39:45 PDT 2023
philnik added inline comments.
================
Comment at: libcxx/src/pstl/libdispatch.cpp:26
partitions.__chunk_size_ = element_count / partitions.__chunk_count_;
- partitions.__first_chunk_size_ = partitions.__chunk_size_;
-
- const ptrdiff_t leftover_item_count = element_count - (partitions.__chunk_count_ * partitions.__chunk_size_);
-
- if (leftover_item_count == 0)
- return partitions;
-
- if (leftover_item_count == partitions.__chunk_size_) {
- partitions.__chunk_count_ += 1;
- return partitions;
- }
-
- const ptrdiff_t n_extra_items_per_chunk = leftover_item_count / partitions.__chunk_count_;
- const ptrdiff_t n_final_leftover_items = leftover_item_count - (n_extra_items_per_chunk * partitions.__chunk_count_);
-
- partitions.__chunk_size_ += n_extra_items_per_chunk;
- partitions.__first_chunk_size_ = partitions.__chunk_size_ + n_final_leftover_items;
+ partitions.__first_chunk_size_ = element_count - (partitions.__chunk_count_ - 1) * partitions.__chunk_size_;
return partitions;
----------------
ldionne wrote:
> Can you add tests that check the exact values for `element_count` == 0 and 1?
We already have that.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155531/new/
https://reviews.llvm.org/D155531
More information about the libcxx-commits
mailing list