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

Integrate C++ Co-arrays #2732

Merged
merged 15 commits into from Jul 27, 2017
Merged

Conversation

atrantan
Copy link

@atrantan atrantan commented Jun 30, 2017

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:

  • Is a derived class of partitioned_vector_view and owns a partitioned_vector as a variable member
  • Is a constrained partitioned_vector_view since its last dimension size cannot be defined by the user (equal to the current number of images)
  • Implies some constrained partitioned_vector layout since partitions that share the same last dimension index lives in the same runtime locality.

Features of Co-arrays (with _ a constexpr variable) :

  • Put operations (in MPI sense) allowed via the expression a(i,j,k) = b(i,j,k) or a(i,j,k) = some_std_vector
  • Get operations (in MPI sense) allowed via an explicit conversion : std::vector<T> v = ( std::vector<T> ) a(i,j,k)
  • Local reference retrieving via the expression : a(i,j,_) (_ means the rank of the current image)
  • Iterators to iterate globally (or locally) over the segments owned by the Co-array

@atrantan atrantan force-pushed the from_view_to_coarray branch 2 times, most recently from d631b60 to cbca594 Compare July 1, 2017 01:35
@hkaiser hkaiser added this to the 1.1.0 milestone Jul 1, 2017
@atrantan atrantan force-pushed the from_view_to_coarray branch 6 times, most recently from 35b7caf to 43e8412 Compare July 3, 2017 15:52
///////////////////////////////////////////////////////////////////////////////
/// \cond NOINTERNAL

#define HPX_REGISTER_COARRAY(T) HPX_REGISTER_PARTITIONED_VECTOR(T)
Copy link
Member

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?

Copy link
Author

@atrantan atrantan Jul 4, 2017

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 _;
Copy link
Member

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?

Copy link
Author

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 >
{};

Copy link
Member

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)?

Copy link
Author

@atrantan atrantan Jul 4, 2017

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;
};

Copy link
Member

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;
 };

Copy link
Member

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...> {};

Copy link
Author

@atrantan atrantan Jul 4, 2017

Choose a reason for hiding this comment

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

Done in 8ba579d

@atrantan atrantan force-pushed the from_view_to_coarray branch 2 times, most recently from a4a2de2 to 8ba579d Compare July 5, 2017 16:39
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.

This all looks very promising!

iterator end()
{
return sizes_.end();
}
Copy link
Member

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?

Copy link
Author

@atrantan atrantan Jul 10, 2017

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(
Copy link
Member

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?

Copy link
Author

@atrantan atrantan Jul 10, 2017

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
Copy link
Member

Choose a reason for hiding this comment

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

Indentation problem?

Copy link
Author

@atrantan atrantan Jul 10, 2017

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
Copy link
Member

Choose a reason for hiding this comment

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

Indentation problem?

Copy link
Author

@atrantan atrantan Jul 10, 2017

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);
Copy link
Member

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?

Copy link
Author

@atrantan atrantan Jul 10, 2017

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()
Copy link
Member

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?

Copy link
Author

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.

Copy link
Author

Choose a reason for hiding this comment

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

Done in d345eed

@atrantan atrantan force-pushed the from_view_to_coarray branch 5 times, most recently from bb5750e to 0c3ef18 Compare July 17, 2017 16:08
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.

LGTM, thanks!

@hkaiser hkaiser merged commit 2bd90f0 into STEllAR-GROUP:master Jul 27, 2017
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.

None yet

2 participants