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

Add utility member functions for partitioned_vector #1913

Merged
merged 6 commits into from
Dec 15, 2015
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -732,6 +732,18 @@ namespace hpx
}

public:

std::vector< hpx::id_type > get_partitions_ids()
{
std::vector< hpx::id_type > ids;

for(auto const part_data : partitions_)
Copy link
Member

Choose a reason for hiding this comment

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

This should probably be: for(auto const& part_data : partitions_)

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 commit 239ed21

Copy link
Member

Choose a reason for hiding this comment

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

Thanks. Just out of curiosity: why do you need this functionality?

Copy link
Author

Choose a reason for hiding this comment

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

It allows my array_view to get all it needs to return the data of a partition. Saving the ids is costless as well.

Copy link
Member

Choose a reason for hiding this comment

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

Hmmm, the idea was for the array_view to access the local data only. Why do you need to get a copy of the local data for this? Wouldn't it be no view anymore?

Copy link
Member

Choose a reason for hiding this comment

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

Sorry, misunderstanding - what I wanted to ask is why you need the get_copied_data() functionality above.

Copy link
Author

Choose a reason for hiding this comment

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

This is for another functionality extending the concept of array_view. If an owner of a array_view needs a data that is not in its locality, make a copy and return it by value.

{
ids.push_back( part_data.partition_);
}
return ids;
}

/// \brief Array subscript operator. This does not throw any exception.
///
/// \param pos Position of the element in the vector [Note the first
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ namespace hpx { namespace server
components::simple_component_base<partitioned_vector<T> > >
base_type;

private:
data_type partition_vector_;

public:
///////////////////////////////////////////////////////////////////////
// Constructors
///////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -119,6 +117,12 @@ namespace hpx { namespace server
return partition_vector_;
}

/// Duplicate the copy method for action naming
data_type get_copied_data() const
{
return partition_vector_;
}

///////////////////////////////////////////////////////////////////////
iterator_type begin()
{
Expand Down Expand Up @@ -361,6 +365,7 @@ namespace hpx { namespace server
HPX_DEFINE_COMPONENT_DIRECT_ACTION(partitioned_vector, set_values);

// HPX_DEFINE_COMPONENT_ACTION(partition_vector, clear);
HPX_DEFINE_COMPONENT_DIRECT_ACTION(partitioned_vector, get_copied_data);
};
}}

Expand Down Expand Up @@ -396,6 +401,9 @@ namespace hpx { namespace server
HPX_REGISTER_ACTION_DECLARATION( \
hpx::server::partitioned_vector<type>::resize_action, \
BOOST_PP_CAT(__vector_resize_action_, name)); \
HPX_REGISTER_ACTION_DECLARATION( \
hpx::server::partitioned_vector<type>::get_copied_data_action, \
BOOST_PP_CAT(__vector_get_copied_data_action_, name)); \
/**/

#define HPX_REGISTER_PARTITIONED_VECTOR(...) \
Expand Down Expand Up @@ -429,6 +437,9 @@ namespace hpx { namespace server
HPX_REGISTER_ACTION( \
hpx::server::partitioned_vector<type>::resize_action, \
BOOST_PP_CAT(__vector_resize_action_, name)); \
HPX_REGISTER_ACTION( \
hpx::server::partitioned_vector<type>::get_copied_data_action, \
BOOST_PP_CAT(__vector_get_copied_data_action_, name)); \
typedef ::hpx::components::simple_component< \
::hpx::server::partitioned_vector<type> \
> BOOST_PP_CAT(__vector_, name); \
Expand All @@ -449,7 +460,6 @@ namespace hpx
typedef hpx::components::client_base<
partition_vector<T>, server::partitioned_vector<T>
> base_type;

public:
partition_vector() {}

Expand Down Expand Up @@ -716,7 +726,29 @@ namespace hpx
// HPX_ASSERT(this->get_id());
// this->base_type::clear_async(this->get_id()).get();
// }
};

/// Returns a copy of the data owned by the partition_vector
/// component.
///
/// \return This returns the data of the partition_vector
///
auto get_copied_data_sync()
{
return get_copied_data().get();
}

/// Returns the data reference of the partition_vector
/// component.
///
/// \return This returns the data as an hpx::future
///
auto get_copied_data() const
{
HPX_ASSERT(this->get_id());
return hpx::async<typename server_type::get_copied_data_action>(
this->get_id());
}
};
}

#endif