Skip to content

Commit

Permalink
Merge #6368 #6371
Browse files Browse the repository at this point in the history
6368: Making sure serialize_buffer properly destroys buffer, if needed. r=hkaiser a=hkaiser

Fixes #6366


6371: Fix jacobi omp examples. r=hkaiser a=rtohid

Makes sure the `HPX_APPLICATION_STRING` is set correctly for non-hpx targets in Jacobi examples when `HPX_WITH_EXAMPLES_OPENMP=ON`.

- We may want to have a testing pipeline for non-hpx examples.
- Thank you `@G-071!`

Co-authored-by: Hartmut Kaiser <[email protected]>
Co-authored-by: R. Tohid <[email protected]>
  • Loading branch information
3 people committed Oct 28, 2023
3 parents 4fa1b61 + c62a6ea + c9f8f3c commit d5345cb
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 72 deletions.
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
4 changes: 2 additions & 2 deletions examples/jacobi_smp/jacobi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ int hpx_main(variables_map& vm)
#endif
}

#if !defined(HPX_APPLICATION_STRING)
#define HPX_APPLICATION_STRING "jacobi"
#if defined(JACOBI_SMP_NO_HPX)
#define HPX_APPLICATION_STRING "jacobi_omp_[static,dynamic]"
#endif

int main(int argc, char** argv)
Expand Down
4 changes: 4 additions & 0 deletions examples/jacobi_smp/jacobi_nonuniform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ int hpx_main(variables_map& vm)
#endif
}

#if defined(JACOBI_SMP_NO_HPX)
#define HPX_APPLICATION_STRING "jacobi_omp_nonuniform_[static,dynamic]"
#endif

int main(int argc, char** argv)
{
options_description desc_cmd("usage: " HPX_APPLICATION_STRING " [options]");
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

0 comments on commit d5345cb

Please sign in to comment.