Repository navigation
Size the builtin operations from the types of their arguments - #7946
Merged
Merged
Conversation
Contributor
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Up to standards ✅🟢 Issues
|
A transparent function object such as std::less<> names no operand type, so its size depends on the arguments it is called with. Add get_task_size_for<F, Args...>, which gives the size of a call of f with arguments of the types Args. Unless it is specialized, it is the size of f itself, so a size given to f always wins. The standard function objects (std::plus, std::less, ..., and the std::ranges comparisons) and the predicates in hpx::parallel::detail are registered as builtin operations. A transparent one called with arithmetic, enum or pointer arguments is a nano task. A typed one (std::less<int>, min_of<int>, ...) is a nano task if it names such a type. In all other cases the size stays unknown. detail::with_task_size_of takes the argument types, which reduce, transform_reduce and merge now pass. merge does that only if both projections are hpx::identity. Signed-off-by: Hartmut Kaiser <[email protected]>
hkaiser
force-pushed
the
task-size-for-args
branch
from
October 31, 2026 01:31
bf27831 to
ba9d496
Compare
…ecks Add task_size_argument_t<Iter, Proj>, the type of the argument an algorithm calls its function with for an element of Iter: the reference of the element if it is not projected, and a type of unknown size if it is, since a projection may do any amount of work. merge uses it instead of distinguishing the projections itself. transform gives its iterations the size of the transformation of one or two elements. The get_task_size specializations of the transform iterations are no longer used and removed. The checks of the task sizes of the algorithms move from the threading_base tests to the new algorithms/tests/unit/task_sizes, with the counting scheduler in task_size_checks.hpp, so that the checks of further algorithms can be added in files of their own. Signed-off-by: Hartmut Kaiser <[email protected]>
This was referenced Oct 31, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This builds on #7926 and should be merged after it.
A transparent function object such as
std::less<>names no operand type, so its task size can be known only from the arguments it is called with. This addshpx::traits::get_task_size_for<F, Args...>, which gives the size of a call offwith arguments of the typesArgs. Unless it is specialized, it is the size offitself (get_task_size), so a size given tofbynano_task(f),with_task_size<Size>(f), etc. always wins.The function objects of the standard library (
std::plus,std::minus,std::multiplies,std::divides,std::modulus,std::negate, the comparisons, the logical and the bitwise operations) and the comparisons instd::rangesare registered as builtin operations. So are the predicates inhpx::parallel::detail(equal_to,less,plus, ...,min_of,max_of). A transparent operation called with arithmetic, enum or pointer arguments is a nano task. A typed operation (std::less<int>,min_of<int>, ...) is a nano task if the type it names is such a type. In all other cases the size stays unknown, for instancestd::plus<>onstd::complex<double>.detail::with_task_size_oftakes the argument types.reduce,transform_reduceandmergenow pass them,mergeonly if both projections arehpx::identity, since a projection may do any amount of work.transformgives its iterations the size of the transformation of one or two elements, sized the same way through the newtask_size_argument_t<Iter, Proj>: the reference of the element if it is not projected, a type of unknown size otherwise.mergeuses it too.Other algorithms are to follow, as are the sizes for datapar execution policies, where the function is called once per pack.
Tests: new compile-time and run-time checks in
sized_function.cpp. The checks of the sizes the algorithms pass to the scheduler move fromtask_size_hint.cppto the newlibs/core/algorithms/tests/unit/task_sizes, with the counting scheduler intask_size_checks.hpp, so that the following PRs for the other algorithms can add their checks in files of their own.