Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loop and transform_loop unseq adaptation #6017

Closed
wants to merge 3 commits into from

Conversation

akcube
Copy link
Contributor

@akcube akcube commented Sep 20, 2022

Proposed Changes

  • Implements the unseq adaptation of util::loop and transform_loop. Will affect transform, for_each and for_loop.
  • Added tests for both.

Any background context you want to provide?

This is based on #6016

@jenkins-cscs
Copy link

Can one of the admins verify this patch?

@aurianer
Copy link
Contributor

ok to test

Copy link
Member

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could reduce the amount of code duplication in loop.hpp et.al. by enabling the tag_invoke overloads for unseq for random_access iterators only.

Comment on lines +93 to +102
template <typename Begin, typename End, typename F>
HPX_HOST_DEVICE HPX_FORCEINLINE static typename std::enable_if<
!hpx::traits::is_random_access_iterator_v<Begin>, Begin>::type
call(Begin it, End end, F&& f)
{
for (/* */; it != end; it++)
{
HPX_INVOKE(f, it);
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make this fall back to the existing non-vectorized implementation?

Comment on lines +115 to +129
template <typename Begin, typename End, typename CancelToken,
typename F>
HPX_HOST_DEVICE HPX_FORCEINLINE static typename std::enable_if<
!hpx::traits::is_random_access_iterator_v<Begin>, Begin>::type
call(Begin it, End end, CancelToken& tok,
F&& f)
{
for (/* */; it != end; ++it)
{
HPX_INVOKE(f, it);
if (tok.was_cancelled())
return it;
}
return it;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here: Could we make this fall back to the existing non-vectorized implementation?

Comment on lines +143 to +153
template <typename Begin, typename End, typename F>
HPX_HOST_DEVICE HPX_FORCEINLINE static typename std::enable_if<
!hpx::traits::is_random_access_iterator_v<Begin>, Begin>::type
call(Begin it, End end, F&& f)
{
for (/* */; it != end; ++it)
{
HPX_INVOKE(f, *it);
}
return it;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we make this fall back to the existing non-vectorized implementation? This comment applies to many more places in this file below.

@hkaiser
Copy link
Member

hkaiser commented Sep 21, 2022

This PR is superseded by #6018. Closing without merging. All comments here should be addressed in #6018.

@hkaiser hkaiser closed this Sep 21, 2022
@hkaiser hkaiser added this to the 1.9.0 milestone Sep 21, 2022
bors bot pushed a commit that referenced this pull request Feb 13, 2023
6018: transform_reduce unseq adaptation r=hkaiser a=akcube

## Proposed Changes
- New `unseq_reduce` CPOs to accept `unseq` overloads from `transform_reduce`, `reduce` and `transform_reduce_binary` algorithms.
- Adds overloads to accept `unseq` and `par_unseq` overloads for the same algorithms. 
- Unit tests for all three algorithms

## Any background context you want to provide?
This is based off of #6017 


Co-authored-by: akcube <a.kishorekumar@students.iiit.ac.in>
Co-authored-by: Hartmut Kaiser <hartmut.kaiser@gmail.com>
@Johan511
Copy link
Contributor

Johan511 commented Mar 9, 2023

@akcube can you please help me out with how I can run the algorithms using the par_unseq execution policy? I am not able to be unseq/loop.hpp in my hpx installation

sudo find . -name "*loop.hpp*" -print

./include/parallel_for_loop.hpp
./thread_pools/scheduling_loop.hpp
./execution/algorithms/run_loop.hpp
./parallel/container_algorithms/for_loop.hpp
./parallel/util/transform_loop.hpp
./parallel/util/loop.hpp
./parallel/algorithms/for_loop.hpp
./parallel/datapar/transform_loop.hpp
./parallel/datapar/loop.hpp

also I did place a breakpoint at loop.hpp and did find the execution breaking over here. Was this the expected behaviour?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants