Skip to content

Commit

Permalink
Merge #6344 #6348 #6349
Browse files Browse the repository at this point in the history
6344: uninitialized_relocate w/ type_support primitive r=hkaiser a=isidorostsa

This PR replaces the `type_support::uninitialized_relocate` with a primitive version for uninitialized relocation, named `uninitialized_relocate_n_primitive`. This is used by the parallel and sequenced versions of `algorithms::uninitialized_relocate`.

In contrast to the previous attempt of implementing the relocation functions, #6314, this does not place the primitive in `transfer.hpp`, which is in the `algorithms` module, nor does it modify `loop.hpp` to add the specific exception handling method required by `uninitialized_relocate`. 

The goal of keeping a primitive in type support, which is relatively low level in terms of dependencies, is to use it in the higher level `small_vector` and other data structures. 

6348: Adding --exclusive to launching tests on rostam r=hkaiser a=hkaiser



6349: Moving hpx::threads::run_as_xxx to namespace hpx r=hkaiser a=hkaiser

- run_as_os_thread
- run_as_hpx_thread

Co-authored-by: isidorostsa <[email protected]>
Co-authored-by: Hartmut Kaiser <[email protected]>
  • Loading branch information
3 people committed Sep 25, 2023
4 parents 4a66ce5 + 82f2907 + b894f5e + 496f4ba commit a771096
Show file tree
Hide file tree
Showing 36 changed files with 2,103 additions and 378 deletions.
1 change: 1 addition & 0 deletions .jenkins/lsu-perftests/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ sleep $[(RANDOM % 10) + 1].$[(RANDOM % 10)]s
set +e
sbatch \
--verbose --verbose --verbose --verbose \
--exclusive \
--job-name="${job_name}" \
--nodes="1" \
--partition="${configuration_slurm_partition}" \
Expand Down
1 change: 1 addition & 0 deletions .jenkins/lsu-test-coverage/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ fi
set +e
sbatch \
--verbose --verbose --verbose --verbose \
--exclusive \
--job-name="${job_name}" \
--nodes="1" \
--partition="${configuration_slurm_partition}" \
Expand Down
1 change: 1 addition & 0 deletions .jenkins/lsu/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ sleep $[(RANDOM % 10) + 1].$[(RANDOM % 10)]s
set +e
sbatch \
--verbose --verbose --verbose --verbose \
--exclusive \
--job-name="${job_name}" \
--nodes="${configuration_slurm_num_nodes}" \
--partition="${configuration_slurm_partition}" \
Expand Down
2 changes: 1 addition & 1 deletion components/process/src/server/child_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ namespace hpx { namespace components { namespace process { namespace server
{
int (*f)(process::util::child const&) =
&process::util::wait_for_exit<process::util::child>;
return hpx::threads::run_as_os_thread(f, std::ref(child_)).get();
return hpx::run_as_os_thread(f, std::ref(child_)).get();
}
}}}}

6 changes: 3 additions & 3 deletions examples/quickstart/init_globally.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -270,12 +270,12 @@ void thread_func()

// Create an HPX thread (returning an int) and wait for it to run to
// completion.
int result = hpx::threads::run_as_hpx_thread(&hpx_thread_func2, 42);
int result = hpx::run_as_hpx_thread(&hpx_thread_func2, 42);

// Create an HPX thread (returning void) and wait for it to run to
// completion.
if (result == 42)
hpx::threads::run_as_hpx_thread(&hpx_thread_func1);
hpx::run_as_hpx_thread(&hpx_thread_func1);
}

///////////////////////////////////////////////////////////////////////////////
Expand All @@ -286,7 +286,7 @@ int main()

// The main thread was automatically registered with the HPX runtime,
// no explicit registration for this thread is necessary.
hpx::threads::run_as_hpx_thread(&hpx_thread_func1);
hpx::run_as_hpx_thread(&hpx_thread_func1);

// wait for the (kernel) thread to run to completion
t.join();
Expand Down
1 change: 1 addition & 0 deletions libs/core/algorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ set(algorithms_headers
hpx/parallel/algorithms/uninitialized_default_construct.hpp
hpx/parallel/algorithms/uninitialized_fill.hpp
hpx/parallel/algorithms/uninitialized_move.hpp
hpx/parallel/algorithms/uninitialized_relocate.hpp
hpx/parallel/algorithms/uninitialized_value_construct.hpp
hpx/parallel/algorithms/unique.hpp
hpx/parallel/container_algorithms/adjacent_difference.hpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#pragma once

#include <hpx/iterator_support/traits/is_iterator.hpp>
#include <hpx/type_support/is_contiguous_iterator.hpp>
#include <hpx/type_support/is_relocatable.hpp>

#include <type_traits>
Expand Down Expand Up @@ -145,7 +146,7 @@ namespace hpx::traits {
{
using type = std::conditional_t<
std::is_same_v<iter_value_t<Source>, iter_value_t<Dest>> &&
is_relocatable_v<iter_value_t<Source>>,
hpx::experimental::is_relocatable_v<iter_value_t<Source>>,
relocatable_pointer_tag, general_pointer_tag>;
};

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <hpx/parallel/algorithms/detail/distance.hpp>
#include <hpx/parallel/util/loop.hpp>
#include <hpx/parallel/util/result_types.hpp>
#include <hpx/type_support/is_contiguous_iterator.hpp>

#include <algorithm>
#include <cstddef>
Expand Down
3 changes: 3 additions & 0 deletions libs/core/algorithms/tests/unit/algorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ set(tests
uninitialized_filln
uninitialized_move
uninitialized_moven
uninitialized_relocate
uninitialized_relocaten
uninitialized_relocate_par
uninitialized_value_construct
uninitialized_value_constructn
unique
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@

#include <hpx/init.hpp>
#include <hpx/modules/testing.hpp>
#include <hpx/type_support/uninitialized_relocate.hpp>
#include <hpx/parallel/algorithms/uninitialized_relocate.hpp>

#define N 50
#define K 10

using hpx::experimental::is_trivially_relocatable_v;
using hpx::experimental::uninitialized_relocate;

struct trivially_relocatable_struct
{
static int count;
Expand Down Expand Up @@ -43,7 +46,7 @@ int trivially_relocatable_struct::move_count = 0;
int trivially_relocatable_struct::dtor_count = 0;

HPX_DECLARE_TRIVIALLY_RELOCATABLE(trivially_relocatable_struct);
static_assert(hpx::is_trivially_relocatable_v<trivially_relocatable_struct>);
static_assert(is_trivially_relocatable_v<trivially_relocatable_struct>);

struct non_trivially_relocatable_struct
{
Expand Down Expand Up @@ -78,8 +81,7 @@ int non_trivially_relocatable_struct::count = 0;
int non_trivially_relocatable_struct::move_count = 0;
int non_trivially_relocatable_struct::dtor_count = 0;

static_assert(
!hpx::is_trivially_relocatable_v<non_trivially_relocatable_struct>);
static_assert(!is_trivially_relocatable_v<non_trivially_relocatable_struct>);

struct non_trivially_relocatable_struct_throwing
{
Expand Down Expand Up @@ -121,8 +123,8 @@ int non_trivially_relocatable_struct_throwing::count = 0;
int non_trivially_relocatable_struct_throwing::move_count = 0;
int non_trivially_relocatable_struct_throwing::dtor_count = 0;

static_assert(!hpx::is_trivially_relocatable_v<
non_trivially_relocatable_struct_throwing>);
static_assert(
!is_trivially_relocatable_v<non_trivially_relocatable_struct_throwing>);

int hpx_main()
{
Expand Down Expand Up @@ -150,7 +152,7 @@ int hpx_main()
HPX_TEST(trivially_relocatable_struct::count == N);

// relocate them to ptr2
hpx::experimental::uninitialized_relocate(ptr1, ptr1 + N, ptr2);
uninitialized_relocate(ptr1, ptr1 + N, ptr2);

// All creations - destructions balance out
HPX_TEST(trivially_relocatable_struct::count == N);
Expand All @@ -165,7 +167,6 @@ int hpx_main()
}

std::destroy(ptr2, ptr2 + N);
HPX_TEST(trivially_relocatable_struct::dtor_count == N);

std::free(mem1);
std::free(mem2);
Expand Down Expand Up @@ -194,7 +195,7 @@ int hpx_main()
HPX_TEST(non_trivially_relocatable_struct::count == N);

// relocate them to ptr2
hpx::experimental::uninitialized_relocate(ptr1, ptr1 + N, ptr2);
uninitialized_relocate(ptr1, ptr1 + N, ptr2);

// All creations - destructions balance out
HPX_TEST(non_trivially_relocatable_struct::count == N);
Expand Down Expand Up @@ -241,12 +242,11 @@ int hpx_main()
// relocate them to ptr2
try
{
hpx::experimental::uninitialized_relocate(ptr1, ptr1 + N, ptr2);
HPX_TEST(false); // should never reach this
uninitialized_relocate(ptr1, ptr1 + N, ptr2);
HPX_UNREACHABLE; // should have thrown
}
catch (int forty_two)
catch (...)
{
HPX_TEST(forty_two == 42);
}

// K move constructors were called
Expand Down
Loading

0 comments on commit a771096

Please sign in to comment.