Skip to content

Commit cf015e2

Browse files
committed
Apply clang-format and cmake-format, fix inspect issues
Include the standard headers used, keep comments ASCII and within the line length. Signed-off-by: Hartmut Kaiser <hartmut.kaiser@gmail.com>
1 parent 33f1d54 commit cf015e2

9 files changed

Lines changed: 86 additions & 79 deletions

File tree

‎libs/core/gasnet_base/include/hpx/gasnet_base/gasnet_environment.hpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ namespace hpx::util {
103103

104104
// RMA: blocking get of 'nbytes' from remote 'raddr' on 'rank' into
105105
// local 'laddr'.
106-
static void get(int rank, void* laddr, void const* raddr,
107-
std::size_t nbytes);
106+
static void get(
107+
int rank, void* laddr, void const* raddr, std::size_t nbytes);
108108

109109
// Data-only batch of n pages, non-blocking: the caller publishes the
110110
// credit with put_uint32_nb() once the returned event has completed.

‎libs/core/gasnet_base/src/gasnet_environment.cpp‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <algorithm>
1616
#include <atomic>
1717
#include <bit>
18+
#include <cstddef>
19+
#include <cstdint>
1820
#include <cstdlib>
1921
#include <cstring>
2022
#include <iostream>

‎libs/full/parcelport_gasnet/CMakeLists.txt‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ add_hpx_module(
3939
GLOBAL_HEADER_GEN ON
4040
SOURCES ${parcelport_gasnet_sources}
4141
HEADERS ${parcelport_gasnet_headers}
42-
DEPENDENCIES hpx_core PkgConfig::GASNET
43-
${gasnet_additional_dependencies}
42+
DEPENDENCIES hpx_core PkgConfig::GASNET ${gasnet_additional_dependencies}
4443
MODULE_DEPENDENCIES hpx_actions hpx_command_line_handling hpx_parcelset_base
4544
hpx_parcelset hpx_plugin_factories
4645
CMAKE_SUBDIRS examples tests

‎libs/full/parcelport_gasnet/include/hpx/parcelport_gasnet/mailbox_array.hpp‎

Lines changed: 41 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ namespace hpx::parcelset::policies::gasnet {
9393
// progress (one io_service driver per arena plus any HPX thread that runs
9494
// the background-works callback), the arena scan may read a source's
9595
// consumed mirror while the thread delivering that source's pages writes
96-
// it. Relaxed ordering suffices — they are local-only watermarks used to
96+
// it. Relaxed ordering suffices, they are local-only watermarks used to
9797
// derive slot indices and to decide "published vs consumed".
9898
//
9999
// One MTU-sized page == one chunk (message_header + payload), matching
@@ -129,7 +129,7 @@ namespace hpx::parcelset::policies::gasnet {
129129
// CRC32, table-driven, over the payload bytes only. The header
130130
// fields are validated structurally (exact geometry) and by
131131
// message-id/sequence cross-checks, so the checksum does not need
132-
// to cover the header itself — which keeps the sender and receiver
132+
// to cover the header itself, which keeps the sender and receiver
133133
// able to recompute it over a single contiguous byte range (the
134134
// transferred payload region).
135135
//
@@ -192,8 +192,8 @@ namespace hpx::parcelset::policies::gasnet {
192192
// below gives bit-identical results to the instruction path).
193193
template <bool Hw, typename Step>
194194
inline std::uint32_t crc_pages_impl(unsigned char const* data,
195-
std::size_t size, Step step, std::uint32_t (*byte_step)(
196-
std::uint32_t, unsigned char))
195+
std::size_t size, Step step,
196+
std::uint32_t (*byte_step)(std::uint32_t, unsigned char))
197197
{
198198
std::uint32_t a = 0xFFFFFFFFu, b = 0xFFFFFFFFu, c = 0xFFFFFFFFu;
199199
while (size >= 24)
@@ -294,7 +294,8 @@ namespace hpx::parcelset::policies::gasnet {
294294
return page_checksum_sw(data, size);
295295
}
296296

297-
inline std::uint64_t message_total_size(message_header const& h) noexcept
297+
inline std::uint64_t message_total_size(
298+
message_header const& h) noexcept
298299
{
299300
return (std::uint64_t(h.total_size_high) << 32) | h.total_size_low;
300301
}
@@ -346,9 +347,8 @@ namespace hpx::parcelset::policies::gasnet {
346347
if (offset > total_size)
347348
return false;
348349

349-
if (chunk_size_for(
350-
h.chunk_index, h.num_chunks, total_size, payload_size) >
351-
payload_size)
350+
if (chunk_size_for(h.chunk_index, h.num_chunks, total_size,
351+
payload_size) > payload_size)
352352
return false;
353353

354354
std::uint64_t const expected_chunks =
@@ -379,8 +379,8 @@ namespace hpx::parcelset::policies::gasnet {
379379
chunk_size = chunk_size_for(header.chunk_index, header.num_chunks,
380380
total_size, payload_size);
381381

382-
return !use_checksum || header.checksum ==
383-
crc32(page + header_size, chunk_size);
382+
return !use_checksum ||
383+
header.checksum == crc32(page + header_size, chunk_size);
384384
}
385385

386386
// Set by parcelport::do_stop(): by then the HPX scheduler and AGAS are
@@ -424,8 +424,9 @@ namespace hpx::parcelset::policies::gasnet {
424424
//
425425
// 2 * npes * slots * mtu + 2 * npes^2 * 4 + npes * 4 bytes
426426
//
427-
// With the defaults (slots=8, mtu=64 KiB, the smallest automatic value) the footprint is ~1 MiB per
428-
// added PE, so a 1024-PE run occupies ~1 GiB of registered memory.
427+
// With the defaults (slots=8, mtu=64 KiB, the smallest automatic
428+
// value) the footprint is ~1 MiB per added PE, so a 1024-PE run
429+
// occupies ~1 GiB of registered memory.
429430
// The constructor asserts the carve fits the segment attached in
430431
// hpx::util::gasnet_environment::init().
431432
static constexpr std::size_t symmetric_bytes(
@@ -437,8 +438,8 @@ namespace hpx::parcelset::policies::gasnet {
437438

438439
mailbox_array() = default;
439440

440-
mailbox_array(std::size_t num_pes, std::size_t my_pe,
441-
std::size_t mtu, std::size_t slots_per_dst, bool checksum = true,
441+
mailbox_array(std::size_t num_pes, std::size_t my_pe, std::size_t mtu,
442+
std::size_t slots_per_dst, bool checksum = true,
442443
std::size_t probe_window = default_probe_window)
443444
: num_pes_(num_pes)
444445
, my_pe_(my_pe)
@@ -475,12 +476,13 @@ namespace hpx::parcelset::policies::gasnet {
475476
"gasnet::mailbox_array::mailbox_array",
476477
"mailbox carve of " + std::to_string(bytes) +
477478
" bytes does not fit the registered segment (" +
478-
std::to_string(hpx::util::gasnet_environment::segment_size()) +
479+
std::to_string(
480+
hpx::util::gasnet_environment::segment_size()) +
479481
" bytes) on PE " + std::to_string(my_pe_));
480482
}
481483

482-
unsigned char* base =
483-
static_cast<unsigned char*>(hpx::util::gasnet_environment::segment_addr());
484+
unsigned char* base = static_cast<unsigned char*>(
485+
hpx::util::gasnet_environment::segment_addr());
484486
base_ = base;
485487
carved_bytes_ = bytes;
486488

@@ -723,12 +725,12 @@ namespace hpx::parcelset::policies::gasnet {
723725
// Each probe is a single local relaxed load of src's produced counter
724726
// (produced_beg_[src*npes+my_pe]): GASNet RDMA leaves the sender's
725727
// put of the data page *and* that counter directly in our registered
726-
// segment, so no remote read is needed to "pull" delivery — the bytes
728+
// segment, so no remote read is needed to "pull" delivery, the bytes
727729
// are already visible. This is the GASNet counterpart of the
728730
// openshmem code's shmem_uint32_atomic_fetch ping-pong, and it costs
729731
// zero remote round-trips.
730-
int try_detect_pe_notification(std::size_t arena_idx = 0,
731-
std::size_t arena_cnt = 0) const noexcept
732+
int try_detect_pe_notification(
733+
std::size_t arena_idx = 0, std::size_t arena_cnt = 0) const noexcept
732734
{
733735
if (arena_cnt == 0)
734736
{
@@ -743,9 +745,8 @@ namespace hpx::parcelset::policies::gasnet {
743745
return -1;
744746
}
745747

746-
std::size_t const window = probe_window_ == 0 ?
747-
width :
748-
(std::min)(width, probe_window_);
748+
std::size_t const window =
749+
probe_window_ == 0 ? width : (std::min) (width, probe_window_);
749750

750751
// Rotate the scan start point so no single (lowest-index) ready
751752
// source can hog this arena. A fixed low-to-high scan always
@@ -757,9 +758,8 @@ namespace hpx::parcelset::policies::gasnet {
757758
// ready source is probed within 'width' consecutive calls.
758759
std::size_t const slot =
759760
arena_idx < num_pes_ ? arena_idx : num_pes_ - 1;
760-
std::size_t start =
761-
lo + (scan_rotate_[slot].fetch_add(1,
762-
std::memory_order_relaxed) %
761+
std::size_t start = lo +
762+
(scan_rotate_[slot].fetch_add(1, std::memory_order_relaxed) %
763763
width);
764764

765765
for (std::size_t k = 0; k < window; ++k)
@@ -780,8 +780,7 @@ namespace hpx::parcelset::policies::gasnet {
780780
// data memcpy precedes a release fence), and the acquire
781781
// then orders our downstream reads of the landing page.
782782
std::uint32_t const produced =
783-
std::atomic_ref<std::uint32_t>(
784-
produced_beg_[w])
783+
std::atomic_ref<std::uint32_t>(produced_beg_[w])
785784
.load(std::memory_order_acquire);
786785
std::uint32_t const consumed =
787786
consumed_locals_[src].load(std::memory_order_relaxed);
@@ -907,8 +906,8 @@ namespace hpx::parcelset::policies::gasnet {
907906
note_send_stall(dst_pe);
908907
return 0;
909908
}
910-
return (std::min)(
911-
slots_per_dst_ - static_cast<std::size_t>(in_flight),
909+
return (
910+
std::min) (slots_per_dst_ - static_cast<std::size_t>(in_flight),
912911
max_batch);
913912
}
914913

@@ -940,7 +939,8 @@ namespace hpx::parcelset::policies::gasnet {
940939
for (std::size_t k = 0; k < n; ++k)
941940
{
942941
std::size_t const slot = (produced + k) % slots_per_dst_;
943-
std::memcpy(rx_beg_ + (my_pe_ * slots_per_dst_ + slot) * mtu_,
942+
std::memcpy(
943+
rx_beg_ + (my_pe_ * slots_per_dst_ + slot) * mtu_,
944944
tx_page_at(dst_pe, k), counts[k]);
945945
}
946946
std::atomic_ref<std::uint32_t>(produced_beg_[w])
@@ -1016,8 +1016,7 @@ namespace hpx::parcelset::policies::gasnet {
10161016
// credit put's visibility (remote path): once we observe the
10171017
// page published, the landing-page bytes are safe to memcpy.
10181018
std::uint32_t produced =
1019-
std::atomic_ref<std::uint32_t>(
1020-
produced_beg_[w])
1019+
std::atomic_ref<std::uint32_t>(produced_beg_[w])
10211020
.load(std::memory_order_acquire);
10221021
// Modular (wrap-safe) comparison, symmetric with send_batch(): the
10231022
// in-flight page count is (produced - consumed) mod 2^32 and is
@@ -1072,10 +1071,9 @@ namespace hpx::parcelset::policies::gasnet {
10721071
// receive reservation, since draining is what advances 'consumed'.
10731072
bool page_ready(std::size_t const src) const noexcept
10741073
{
1075-
std::uint32_t const produced =
1076-
std::atomic_ref<std::uint32_t>(
1077-
produced_beg_[src * num_pes_ + my_pe_])
1078-
.load(std::memory_order_acquire);
1074+
std::uint32_t const produced = std::atomic_ref<std::uint32_t>(
1075+
produced_beg_[src * num_pes_ + my_pe_])
1076+
.load(std::memory_order_acquire);
10791077
std::uint32_t const consumed =
10801078
consumed_locals_[src].load(std::memory_order_relaxed);
10811079
return produced != consumed;
@@ -1205,7 +1203,8 @@ namespace hpx::parcelset::policies::gasnet {
12051203
// that the chunks it collects all belong to one message.
12061204
std::uint64_t next_message_id() noexcept
12071205
{
1208-
return message_sequence_.fetch_add(1, std::memory_order_relaxed) + 1;
1206+
return message_sequence_.fetch_add(1, std::memory_order_relaxed) +
1207+
1;
12091208
}
12101209

12111210
private:
@@ -1222,7 +1221,8 @@ namespace hpx::parcelset::policies::gasnet {
12221221
std::fprintf(stderr,
12231222
"gasnet::mailbox_array: PE %zu has had %llu back-pressure "
12241223
"polls (window full or NB region in flight) to PE %zu\n",
1225-
my_pe_, static_cast<unsigned long long>(stall_warn_interval),
1224+
my_pe_,
1225+
static_cast<unsigned long long>(stall_warn_interval),
12261226
dst_pe);
12271227
}
12281228
}
@@ -1235,7 +1235,8 @@ namespace hpx::parcelset::policies::gasnet {
12351235
std::fprintf(stderr,
12361236
"gasnet::mailbox_array: PE %zu has had %llu back-pressure "
12371237
"polls (credit-return region in flight) from PE %zu\n",
1238-
my_pe_, static_cast<unsigned long long>(stall_warn_interval),
1238+
my_pe_,
1239+
static_cast<unsigned long long>(stall_warn_interval),
12391240
src_pe);
12401241
}
12411242
}

‎libs/full/parcelport_gasnet/include/hpx/parcelport_gasnet/receiver.hpp‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
#include <hpx/parcelport_gasnet/receiver_connection.hpp>
1616

1717
#include <atomic>
18-
#include <cstdint>
1918
#include <cstddef>
19+
#include <cstdint>
2020
#include <cstdio>
2121
#include <deque>
2222
#include <memory>
@@ -74,7 +74,8 @@ namespace hpx::parcelset::policies::gasnet {
7474
std::fprintf(stderr, "\n");
7575
}
7676

77-
bool background_work(std::size_t arena_idx, std::size_t arena_cnt) noexcept
77+
bool background_work(
78+
std::size_t arena_idx, std::size_t arena_cnt) noexcept
7879
{
7980
bool has_work = false;
8081

@@ -128,7 +129,8 @@ namespace hpx::parcelset::policies::gasnet {
128129
}
129130
}
130131

131-
connection_ptr accept(std::size_t arena_idx, std::size_t arena_cnt) noexcept
132+
connection_ptr accept(
133+
std::size_t arena_idx, std::size_t arena_cnt) noexcept
132134
{
133135
auto& mailboxes = pp_.get_mailboxes();
134136

@@ -158,7 +160,6 @@ namespace hpx::parcelset::policies::gasnet {
158160
active_connections_.erase(src);
159161
pending_.fetch_sub(1, std::memory_order_acq_rel);
160162
return connection_ptr();
161-
162163
}
163164

164165
return std::make_shared<connection_type>(pe, mailboxes, &pp_);

‎libs/full/parcelport_gasnet/include/hpx/parcelport_gasnet/receiver_connection.hpp‎

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ namespace hpx::parcelset::policies::gasnet {
120120
std::memcpy(&header, page, sizeof(header));
121121

122122
// The page is consumed on every path below (credit returned to
123-
// the sender), so a failure must not lead to 'retry this page' —
123+
// the sender), so a failure must not lead to 'retry this page',
124124
// that would read the next page and silently lose the transfer.
125125
// Handle it as a terminal/loud failure instead.
126126
std::size_t chunk_size = 0;
@@ -198,7 +198,7 @@ namespace hpx::parcelset::policies::gasnet {
198198

199199
// Sequence cross-checks: every continuation chunk must belong to
200200
// the same message and arrive strictly in order. Any mismatch
201-
// means the stream lost or reordered pages — fail loudly.
201+
// means the stream lost or reordered pages: fail loudly.
202202
if (header.message_id != expected_message_id_ ||
203203
header.num_chunks != expected_chunks_ ||
204204
header.chunk_index != received_chunks_)
@@ -246,8 +246,7 @@ namespace hpx::parcelset::policies::gasnet {
246246
"gasnet: PE %zu: dropping malformed message from src %d "
247247
"(num_chunks=%u chunk_index=%u message_id=%llu "
248248
"size=%llu checksum=%08x, draining %zu remaining page(s))\n",
249-
mailboxes_.my_pe(), src_, header.num_chunks,
250-
header.chunk_index,
249+
mailboxes_.my_pe(), src_, header.num_chunks, header.chunk_index,
251250
static_cast<unsigned long long>(header.message_id),
252251
static_cast<unsigned long long>(header.size), header.checksum,
253252
remaining);
@@ -344,7 +343,7 @@ namespace hpx::parcelset::policies::gasnet {
344343
case stream_stage::counts:
345344
{
346345
std::size_t const take =
347-
(std::min)(sizeof(counts_) - stage_got_, n);
346+
(std::min) (sizeof(counts_) - stage_got_, n);
348347
std::memcpy(
349348
reinterpret_cast<unsigned char*>(counts_) + stage_got_,
350349
p, take);
@@ -368,9 +367,10 @@ namespace hpx::parcelset::policies::gasnet {
368367
}
369368
case stream_stage::tchunks:
370369
{
371-
std::size_t const total = buffer_.transmission_chunks_.size() *
370+
std::size_t const total =
371+
buffer_.transmission_chunks_.size() *
372372
sizeof(buffer_type::transmission_chunk_type);
373-
std::size_t const take = (std::min)(total - stage_got_, n);
373+
std::size_t const take = (std::min) (total - stage_got_, n);
374374
std::memcpy(reinterpret_cast<unsigned char*>(
375375
buffer_.transmission_chunks_.data()) +
376376
stage_got_,
@@ -389,7 +389,7 @@ namespace hpx::parcelset::policies::gasnet {
389389
case stream_stage::data:
390390
{
391391
std::size_t const take =
392-
(std::min)(buffer_.data_.size() - stage_got_, n);
392+
(std::min) (buffer_.data_.size() - stage_got_, n);
393393
std::memcpy(buffer_.data_.data() + stage_got_, p, take);
394394
stage_got_ += take;
395395
p += take;
@@ -405,10 +405,10 @@ namespace hpx::parcelset::policies::gasnet {
405405
{
406406
auto& c = buffer_.chunks_[zc_idx_];
407407
std::size_t const total = c.size();
408-
std::size_t const take = (std::min)(total - stage_got_, n);
409-
std::memcpy(static_cast<unsigned char*>(c.data()) +
410-
stage_got_,
411-
p, take);
408+
std::size_t const take = (std::min) (total - stage_got_, n);
409+
std::memcpy(
410+
static_cast<unsigned char*>(c.data()) + stage_got_, p,
411+
take);
412412
stage_got_ += take;
413413
p += take;
414414
n -= take;
@@ -454,7 +454,6 @@ namespace hpx::parcelset::policies::gasnet {
454454
return stream_stage::data;
455455
}
456456

457-
458457
// data_ is complete. With zero-copy chunks: allocate their buffers
459458
// (directly in the deserialized parcels if the zero-copy receive
460459
// optimization is on) and continue with the chunk bytes.
@@ -474,9 +473,10 @@ namespace hpx::parcelset::policies::gasnet {
474473
buffer_.chunks_.resize(nzc);
475474
for (std::size_t i = 0; i != nzc; ++i)
476475
{
477-
buffer_.chunks_[i] = serialization::create_pointer_chunk(
478-
nullptr, static_cast<std::size_t>(
479-
buffer_.transmission_chunks_[i].second));
476+
buffer_.chunks_[i] =
477+
serialization::create_pointer_chunk(nullptr,
478+
static_cast<std::size_t>(
479+
buffer_.transmission_chunks_[i].second));
480480
}
481481
try
482482
{

0 commit comments

Comments
 (0)