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
Integrate C++ Co-arrays #2732
Integrate C++ Co-arrays #2732
Conversation
d631b60
to
cbca594
Compare
35b7caf
to
43e8412
Compare
/////////////////////////////////////////////////////////////////////////////// | ||
/// \cond NOINTERNAL | ||
|
||
#define HPX_REGISTER_COARRAY(T) HPX_REGISTER_PARTITIONED_VECTOR(T) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HPX_REGISTER_PARTITIONED_VECTOR
is a variadic macro. Should HPX_REGISTER_COARRAY
be variadic as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 8ba579d
} | ||
|
||
// Used for "automatic" coarray subscript and "automatic" coarray size | ||
constexpr hpx::detail::auto_subscript _; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we move _
into its own namespace? hpx::coarray::placeholders::_
perhaps?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hpx::coarray
is already use for the class. I momentarily put it in hpx::container
namespace
bools<true, std::is_integral<T>::value ...>, | ||
bools<std::is_integral<T>::value ...,true > >::value > | ||
{}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be simpler to just use hpx::util::detail::all_of<std::is_integral<T>::value...>
instead (see https://github.com/STEllAR-GROUP/hpx/blob/master/hpx/util/detail/pack.hpp#L62-L81)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 8ba579d
{ | ||
using type = typename last_element<R...>::type; | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the rationale to use an unrolled implementation instead of a simple variadic one:
template <typename ... Ts>
struct last_element
{
using type = typename util::detail::at_index<sizeof...(Ts)-1, Ts...>::type;
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... or even:
template <typename ... Ts>
using last_element<Ts...> = util::detail::at_index<sizeof...(Ts)-1, Ts...> {};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 8ba579d
a4a2de2
to
8ba579d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This all looks very promising!
iterator end() | ||
{ | ||
return sizes_.end(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be const
versions of begin
and end
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix done in bbde6b3
} | ||
|
||
template<typename View, typename Iterator, std::size_t ... I> | ||
void update_view( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this return the updated view instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix done in bbde6b3
std::size_t num_segments, | ||
std::size_t unroll) | ||
{ | ||
using iterator = typename |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix done in bbde6b3
using iterator = typename | ||
std::vector<hpx::naming::id_type>::iterator; | ||
|
||
using const_iterator = typename |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation problem?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix done in bbde6b3
this->set_data(hpx::launch::sync, Data(other) ); | ||
} | ||
|
||
return std::move(*this); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks dangerous... Could you remind me what's the rationale for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix done in bbde6b3
@@ -182,7 +176,7 @@ namespace hpx | |||
iterator end() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same question as above: should this expose const
versions of begin
and end
as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It implies to duplicate some code, I think similarly to partitioned_vector
segmented iterators.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in d345eed
bb5750e
to
0c3ef18
Compare
a2c638a
to
79dba18
Compare
6e2d65d
to
97bebac
Compare
97bebac
to
7c9f374
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
This PR proposes to integrate C++ Co-arrays into hpx. It is a combination of the recently merged spmd multidimensionnal views and
partitioned_vector
.A Co-array:
partitioned_vector_view
and owns apartitioned_vector
as a variable memberpartitioned_vector_view
since its last dimension size cannot be defined by the user (equal to the current number of images)partitioned_vector
layout since partitions that share the same last dimension index lives in the same runtime locality.Features of Co-arrays (with
_
aconstexpr
variable) :a(i,j,k) = b(i,j,k) or a(i,j,k) = some_std_vector
std::vector<T> v = ( std::vector<T> ) a(i,j,k)
a(i,j,_)
(_
means the rank of the current image)