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

Making sure serialize_buffer properly destroys buffer, if needed. #6368

Merged
merged 1 commit into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/1d_stencil/1d_stencil_6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ struct partition_data

// Create a new (uninitialized) partition of the given size.
explicit partition_data(std::size_t size)
: data_(std::allocator<double>().allocate(size), size, buffer_type::take)
: data_(new double[size], size, buffer_type::take)
, size_(size)
, min_index_(0)
{
}

// Create a new (initialized) partition of the given size.
partition_data(std::size_t size, double initial_value)
: data_(std::allocator<double>().allocate(size), size, buffer_type::take)
: data_(new double[size], size, buffer_type::take)
, size_(size)
, min_index_(0)
{
Expand Down
4 changes: 2 additions & 2 deletions examples/1d_stencil/1d_stencil_7.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ struct partition_data

// Create a new (uninitialized) partition of the given size.
explicit partition_data(std::size_t size)
: data_(std::allocator<double>().allocate(size), size, buffer_type::take)
: data_(new double[size], size, buffer_type::take)
, size_(size)
, min_index_(0)
{
}

// Create a new (initialized) partition of the given size.
partition_data(std::size_t size, double initial_value)
: data_(std::allocator<double>().allocate(size), size, buffer_type::take)
: data_(new double[size], size, buffer_type::take)
, size_(size)
, min_index_(0)
{
Expand Down
4 changes: 2 additions & 2 deletions examples/1d_stencil/1d_stencil_8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,12 +105,12 @@ struct partition_data

struct hold_reference
{
hold_reference(buffer_type const& data)
explicit hold_reference(buffer_type const& data)
: data_(data)
{
}

void operator()(double*) {} // no deletion necessary
void operator()(double const*) const {} // no deletion necessary

buffer_type data_;
};
Expand Down
19 changes: 10 additions & 9 deletions examples/quickstart/zerocopy_rdma.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ class pointer_allocator
{
}

pointer address(reference value) const
static pointer address(reference value)
{
return &value;
}
const_pointer address(const_reference value) const
static const_pointer address(const_reference value)
{
return &value;
}
Expand Down Expand Up @@ -118,7 +118,7 @@ struct zerocopy_server : hpx::components::component_base<zerocopy_server>
}

public:
zerocopy_server(std::size_t size = 0)
explicit zerocopy_server(std::size_t size = 0)
: data_(size, 3.1415)
{
}
Expand All @@ -127,7 +127,7 @@ struct zerocopy_server : hpx::components::component_base<zerocopy_server>
// Retrieve an array of doubles to the given address
transfer_buffer_type get_here(std::size_t size, std::size_t remote_buffer)
{
pointer_allocator<double> allocator(
pointer_allocator<double> const allocator(
reinterpret_cast<double*>(remote_buffer), size);

// lock the mutex, will be unlocked by the transfer buffer's deleter
Expand Down Expand Up @@ -225,9 +225,7 @@ struct zerocopy : hpx::components::client_base<zerocopy, zerocopy_server>
///////////////////////////////////////////////////////////////////////////////
int main()
{
std::vector<hpx::id_type> localities = hpx::find_all_localities();

for (hpx::id_type const& id : localities)
for (hpx::id_type const& id : hpx::find_all_localities())
{
zerocopy zc = hpx::new_<zerocopy_server>(id, ZEROCOPY_DATASIZE);

Expand All @@ -238,7 +236,10 @@ int main()
hpx::chrono::high_resolution_timer t;

for (int i = 0; i != 100; ++i)
zc.get(hpx::launch::sync, ZEROCOPY_DATASIZE);
{
[[maybe_unused]] auto r =
zc.get(hpx::launch::sync, ZEROCOPY_DATASIZE);
}

double d = t.elapsed();
std::cout << "Elapsed time 'get' (locality "
Expand All @@ -252,7 +253,7 @@ int main()
for (int i = 0; i != 100; ++i)
zc.get_here(hpx::launch::sync, buffer);

double d = t.elapsed();
double const d = t.elapsed();
std::cout << "Elapsed time 'get_here' (locality "
<< hpx::naming::get_locality_id_from_id(id) << "): " << d
<< "[s]\n";
Expand Down
Loading
Loading