Skip to content

Commit bfb7c66

Browse files
authored
Merge pull request #6795 from STEllAR-GROUP/fast_idle_mode
Fixing problems with scheduler fast-idle mode
2 parents 049a294 + 1b6e453 commit bfb7c66

76 files changed

Lines changed: 1240 additions & 509 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmake/HPX_AddModule.cmake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ function(add_hpx_module libname modulename)
6969
FORCE
7070
)
7171

72-
if(${modulename}_GLOBAL_HEADER_MODULE_GEN OR ${modulename}_MODULE_SOURCE)
72+
if(HPX_WITH_CXX_MODULES AND (${modulename}_GLOBAL_HEADER_MODULE_GEN
73+
OR ${modulename}_MODULE_SOURCE)
74+
)
7375
# Mark the module as exposing C++ modules
7476
set(cxx_modules ${HPX_ENABLED_CXX_MODULES})
7577
list(APPEND cxx_modules ${modulename})
@@ -193,7 +195,7 @@ function(add_hpx_module libname modulename)
193195
set(global_header
194196
"${CMAKE_CURRENT_BINARY_DIR}/include/hpx/modules/${modulename}.hpp"
195197
)
196-
if(${modulename}_GLOBAL_HEADER_MODULE_GEN)
198+
if(HPX_WITH_CXX_MODULES AND ${modulename}_GLOBAL_HEADER_MODULE_GEN)
197199
# generate list of macro headers to #include
198200
list(LENGTH ${modulename}_MACRO_HEADERS macro_headers)
199201
if(macro_headers GREATER 0)
@@ -236,7 +238,7 @@ function(add_hpx_module libname modulename)
236238
)
237239
set(generated_headers ${global_header})
238240

239-
if(${modulename}_GLOBAL_HEADER_MODULE_GEN)
241+
if(HPX_WITH_CXX_MODULES AND ${modulename}_GLOBAL_HEADER_MODULE_GEN)
240242
# collect all standard header files used by this module
241243
set(found_includes)
242244
hpx_collect_std_headers(

components/containers/partitioned_vector/tests/unit/coarray.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ int main()
8585
std::string coarray_name("my_coarray");
8686

8787
hpx::future<void> join = hpx::lcos::define_spmd_block(
88-
"block", 4, bulk_test_action(), height, width, elt_size, coarray_name);
88+
"block", 2, bulk_test_action(), height, width, elt_size, coarray_name);
8989

9090
hpx::wait_all(join);
9191

components/containers/partitioned_vector/tests/unit/coarray_all_reduce.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ int main()
5656
std::string values("values");
5757

5858
hpx::future<void> join =
59-
hpx::lcos::define_spmd_block("block", 4, bulk_test_action(), values);
59+
hpx::lcos::define_spmd_block("block", 2, bulk_test_action(), values);
6060

6161
hpx::wait_all(join);
6262

components/containers/partitioned_vector/tests/unit/partitioned_vector_subview.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ int main()
125125
my_vector.register_as(hpx::launch::sync, vec_name);
126126

127127
hpx::future<void> join = hpx::lcos::define_spmd_block(
128-
"block", 4, bulk_test_action(), N, tile, elt_size, vec_name);
128+
"block", 2, bulk_test_action(), N, tile, elt_size, vec_name);
129129

130130
join.get();
131131

components/containers/partitioned_vector/tests/unit/partitioned_vector_view.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,8 @@ int main()
264264
{
265265
using vector_type = hpx::partitioned_vector<double>;
266266

267-
const std::size_t height = 16;
268-
const std::size_t width = 16;
267+
std::size_t const height = 16;
268+
std::size_t const width = 16;
269269

270270
std::size_t local_height = 16;
271271
std::size_t local_width = 16;
@@ -297,11 +297,11 @@ int main()
297297
out2.register_as(hpx::launch::sync, out2_name);
298298

299299
// Launch tests
300-
hpx::future<void> join1 = hpx::lcos::define_spmd_block("block1", 4,
300+
hpx::future<void> join1 = hpx::lcos::define_spmd_block("block1", 2,
301301
bulk_test_action(), height, width, local_height, local_width,
302302
local_leading_dimension, in1_name, out1_name);
303303

304-
hpx::future<void> join2 = hpx::lcos::define_spmd_block("block2", 4,
304+
hpx::future<void> join2 = hpx::lcos::define_spmd_block("block2", 2,
305305
async_bulk_test_action(), height, width, local_height, local_width,
306306
local_leading_dimension, in2_name, out2_name);
307307

components/containers/partitioned_vector/tests/unit/partitioned_vector_view_iterator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ int main()
137137
std::string vec_name("my_vector");
138138
my_vector.register_as(hpx::launch::sync, vec_name);
139139

140-
hpx::future<void> join = hpx::lcos::define_spmd_block("block", 4,
140+
hpx::future<void> join = hpx::lcos::define_spmd_block("block", 2,
141141
bulk_test_action(), size_x, size_y, size_z, elt_size, vec_name);
142142

143143
join.get();

libs/core/affinity/include/hpx/affinity/affinity_data.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ namespace hpx::threads::policies::detail {
5858
mask_type get_pu_mask(
5959
threads::topology const& topo, std::size_t global_thread_num) const;
6060

61-
mask_type get_used_pus_mask(
62-
threads::topology const& topo, std::size_t pu_num) const;
61+
mask_type get_used_pus_mask(threads::topology const& topo,
62+
std::size_t pu_num = static_cast<std::size_t>(-1)) const;
6363
std::size_t get_thread_occupancy(
6464
threads::topology const& topo, std::size_t pu_num) const;
6565

libs/core/affinity/src/affinity_data.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -234,27 +234,26 @@ namespace hpx::threads::policies::detail {
234234
threads::resize(ret, overall_threads);
235235

236236
// --hpx:bind=none disables all affinity
237-
if (threads::test(no_affinity_, pu_num))
237+
if (static_cast<std::size_t>(-1) != pu_num &&
238+
threads::test(no_affinity_, pu_num))
238239
{
239240
threads::set(ret, pu_num);
240241
return ret;
241242
}
242243

243-
// clang-format off
244244
for (std::size_t thread_num = 0; thread_num != num_threads_;
245245
++thread_num)
246-
// clang-format on
247246
{
248247
auto const thread_mask = get_pu_mask(topo, thread_num);
249248
for (std::size_t i = 0; i != overall_threads; ++i)
250249
{
251-
if (threads::test(thread_mask, i))
250+
if (threads::test(no_affinity_, i) ||
251+
threads::test(thread_mask, i))
252252
{
253253
threads::set(ret, i);
254254
}
255255
}
256256
}
257-
258257
return ret;
259258
}
260259

libs/core/algorithms/include/hpx/parallel/util/foreach_partitioner.hpp

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,18 @@ namespace hpx::parallel::util::detail {
6969
auto&& shape =
7070
detail::get_bulk_iteration_shape_idx(policy, first, count);
7171

72-
return execution::bulk_async_execute(policy.executor(),
73-
partitioner_iteration<Result, F>{HPX_FORWARD(F, f)},
74-
reshape(HPX_MOVE(shape)));
72+
if constexpr (hpx::is_async_execution_policy_v<ExPolicy>)
73+
{
74+
return execution::bulk_async_execute(policy.executor(),
75+
partitioner_iteration<Result, F>{HPX_FORWARD(F, f)},
76+
reshape(HPX_MOVE(shape)));
77+
}
78+
else
79+
{
80+
return execution::bulk_sync_execute(policy.executor(),
81+
partitioner_iteration<Result, F>{HPX_FORWARD(F, f)},
82+
reshape(HPX_MOVE(shape)));
83+
}
7584
}
7685
else
7786
{
@@ -101,8 +110,8 @@ namespace hpx::parallel::util::detail {
101110

102111
template <typename ExPolicy_, typename FwdIter, typename F1,
103112
typename F2, typename ReShape = hpx::identity>
104-
static decltype(auto) call(ExPolicy_&& policy, FwdIter first,
105-
std::size_t count, F1&& f1, F2&& f2, ReShape&& reshape = ReShape{})
113+
static auto call(ExPolicy_&& policy, FwdIter first, std::size_t count,
114+
F1&& f1, F2&& f2, ReShape&& reshape = ReShape{})
106115
{
107116
// inform parameter traits
108117
using scoped_executor_parameters =
@@ -115,14 +124,28 @@ namespace hpx::parallel::util::detail {
115124
FwdIter last = parallel::detail::next(first, count);
116125
try
117126
{
118-
auto&& items = detail::foreach_partition<Result>(
119-
HPX_FORWARD(ExPolicy_, policy), first, count,
120-
HPX_FORWARD(F1, f1), HPX_FORWARD(ReShape, reshape));
127+
if constexpr (std::is_void_v<decltype(foreach_partition<Result>(
128+
policy, first, count, f1, reshape))>)
129+
{
130+
detail::foreach_partition<Result>(
131+
HPX_FORWARD(ExPolicy_, policy), first, count,
132+
HPX_FORWARD(F1, f1), HPX_FORWARD(ReShape, reshape));
121133

122-
scoped_params.mark_end_of_scheduling();
134+
scoped_params.mark_end_of_scheduling();
123135

124-
return reduce(
125-
HPX_MOVE(items), HPX_FORWARD(F2, f2), HPX_MOVE(last));
136+
return HPX_INVOKE(f2, HPX_MOVE(last));
137+
}
138+
else
139+
{
140+
auto&& items = foreach_partition<Result>(
141+
HPX_FORWARD(ExPolicy_, policy), first, count,
142+
HPX_FORWARD(F1, f1), HPX_FORWARD(ReShape, reshape));
143+
144+
scoped_params.mark_end_of_scheduling();
145+
146+
return reduce(
147+
HPX_MOVE(items), HPX_FORWARD(F2, f2), HPX_MOVE(last));
148+
}
126149
}
127150
catch (...)
128151
{

libs/core/algorithms/include/hpx/parallel/util/result_types.hpp

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -416,13 +416,15 @@ namespace hpx::parallel::util {
416416
namespace detail {
417417

418418
template <typename ZipIter>
419-
in_out_result<typename hpx::tuple_element<0,
420-
typename ZipIter::iterator_tuple_type>::type,
419+
in_out_result<
420+
typename hpx::tuple_element<0,
421+
typename std::decay_t<ZipIter>::iterator_tuple_type>::type,
421422
typename hpx::tuple_element<1,
422-
typename ZipIter::iterator_tuple_type>::type>
423+
typename std::decay_t<ZipIter>::iterator_tuple_type>::type>
423424
get_in_out_result(ZipIter&& zipiter)
424425
{
425-
using iterator_tuple_type = typename ZipIter::iterator_tuple_type;
426+
using iterator_tuple_type =
427+
typename std::decay_t<ZipIter>::iterator_tuple_type;
426428

427429
using result_type = in_out_result<
428430
typename hpx::tuple_element<0, iterator_tuple_type>::type,
@@ -433,11 +435,7 @@ namespace hpx::parallel::util {
433435
}
434436

435437
template <typename ZipIterSender>
436-
// clang-format off
437-
requires (
438-
hpx::execution::experimental::is_sender_v<ZipIterSender>
439-
)
440-
// clang-format on
438+
requires(hpx::execution::experimental::is_sender_v<ZipIterSender>)
441439
decltype(auto) get_in_out_result(ZipIterSender&& zipiter_sender)
442440
{
443441
return hpx::execution::experimental::then(
@@ -498,15 +496,17 @@ namespace hpx::parallel::util {
498496
}
499497

500498
template <typename ZipIter>
501-
in_in_out_result<typename hpx::tuple_element<0,
502-
typename ZipIter::iterator_tuple_type>::type,
499+
in_in_out_result<
500+
typename hpx::tuple_element<0,
501+
typename std::decay_t<ZipIter>::iterator_tuple_type>::type,
503502
typename hpx::tuple_element<1,
504-
typename ZipIter::iterator_tuple_type>::type,
503+
typename std::decay_t<ZipIter>::iterator_tuple_type>::type,
505504
typename hpx::tuple_element<2,
506-
typename ZipIter::iterator_tuple_type>::type>
505+
typename std::decay_t<ZipIter>::iterator_tuple_type>::type>
507506
get_in_in_out_result(ZipIter&& zipiter)
508507
{
509-
using iterator_tuple_type = typename ZipIter::iterator_tuple_type;
508+
using iterator_tuple_type =
509+
typename std::decay_t<ZipIter>::iterator_tuple_type;
510510

511511
using result_type = in_in_out_result<
512512
typename hpx::tuple_element<0, iterator_tuple_type>::type,
@@ -518,11 +518,7 @@ namespace hpx::parallel::util {
518518
}
519519

520520
template <typename ZipIterSender>
521-
// clang-format off
522-
requires (
523-
hpx::execution::experimental::is_sender_v<ZipIterSender>
524-
)
525-
// clang-format on
521+
requires(hpx::execution::experimental::is_sender_v<ZipIterSender>)
526522
decltype(auto) get_in_in_out_result(ZipIterSender&& zipiter_sender)
527523
{
528524
return hpx::execution::experimental::then(

0 commit comments

Comments
 (0)