Skip to content

Commit

Permalink
fix clang-format, cmake-format, and inspect error
Browse files Browse the repository at this point in the history
  • Loading branch information
JiakunYan committed Oct 14, 2023
1 parent 39b1cf2 commit a6d442a
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 52 deletions.
15 changes: 11 additions & 4 deletions libs/core/lci_base/src/lci_environment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,8 @@ namespace hpx { namespace util {
}

void lci_environment::log([[maybe_unused]] log_level_t level,
[[maybe_unused]] const char* tag, [[maybe_unused]] const char* format, ...)
[[maybe_unused]] const char* tag, [[maybe_unused]] const char* format,
...)
{
#ifdef HPX_HAVE_PARCELPORT_LCI_LOG
if (level > log_level)
Expand Down Expand Up @@ -263,20 +264,26 @@ namespace hpx { namespace util {
return 0;
}

void lci_environment::pcounter_add([[maybe_unused]] LCT_pcounter_handle_t handle, [[maybe_unused]] int64_t val)
void lci_environment::pcounter_add(
[[maybe_unused]] LCT_pcounter_handle_t handle,
[[maybe_unused]] int64_t val)
{
#ifdef HPX_HAVE_PARCELPORT_LCI_PCOUNTER
LCT_pcounter_add(pcounter_ctx, handle, val);
#endif
}

void lci_environment::pcounter_start([[maybe_unused]] LCT_pcounter_handle_t handle) {
void lci_environment::pcounter_start(
[[maybe_unused]] LCT_pcounter_handle_t handle)
{
#ifdef HPX_HAVE_PARCELPORT_LCI_PCOUNTER
LCT_pcounter_start(pcounter_ctx, handle);
#endif
}

void lci_environment::pcounter_end([[maybe_unused]] LCT_pcounter_handle_t handle) {
void lci_environment::pcounter_end(
[[maybe_unused]] LCT_pcounter_handle_t handle)
{
#ifdef HPX_HAVE_PARCELPORT_LCI_PCOUNTER
LCT_pcounter_end(pcounter_ctx, handle);
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,18 @@ namespace hpx::parcelset {
LCI_device_t device;
LCI_endpoint_t endpoint_new;
LCI_endpoint_t endpoint_followup;
completion_manager_t *completion_manager_p;
completion_manager_t* completion_manager_p;
};
std::vector<device_t> devices;

// Parcelport objects
static std::atomic<bool> prg_thread_flag;
std::unique_ptr<std::thread> prg_thread_p;
struct completion_manager_t {
struct completion_manager_t
{
std::shared_ptr<completion_manager_base> send;
std::shared_ptr<completion_manager_base>
recv_new;
std::shared_ptr<completion_manager_base>
recv_followup;
std::shared_ptr<completion_manager_base> recv_new;
std::shared_ptr<completion_manager_base> recv_followup;
};
std::vector<completion_manager_t> completion_managers;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ namespace hpx::parcelset::policies::lci {
hpx::chrono::high_resolution_timer timer_;
parcelset::data_point& data = buffer.data_point_;
#endif
util::lci_environment::pcounter_add(util::lci_environment::recv_conn_start, 1);
util::lci_environment::pcounter_add(
util::lci_environment::recv_conn_start, 1);
// decode header
header header_ = header((char*) address);
header_.assert_valid();
Expand All @@ -109,7 +110,8 @@ namespace hpx::parcelset::policies::lci {
int num_non_zero_copy_chunks = header_.num_non_zero_copy_chunks();
buffer.num_chunks_.first = num_zero_copy_chunks;
buffer.num_chunks_.second = num_non_zero_copy_chunks;
util::lci_environment::pcounter_add(util::lci_environment::recv_conn_end, 1);
util::lci_environment::pcounter_add(
util::lci_environment::recv_conn_end, 1);
#if defined(HPX_HAVE_PARCELPORT_COUNTERS)
data.bytes_ = static_cast<std::size_t>(header_.numbytes());
data.time_ = timer_.elapsed_nanoseconds() - data.time_;
Expand All @@ -124,7 +126,8 @@ namespace hpx::parcelset::policies::lci {
parcelset::data_point& data = buffer.data_point_;
data.time_ = timer_.elapsed_nanoseconds();
#endif
util::lci_environment::pcounter_add(util::lci_environment::recv_conn_start, 1);
util::lci_environment::pcounter_add(
util::lci_environment::recv_conn_start, 1);
// decode header
header header_ = header((char*) iovec.piggy_back.address);
header_.assert_valid();
Expand Down Expand Up @@ -183,7 +186,8 @@ namespace hpx::parcelset::policies::lci {
}
}
HPX_ASSERT(i == iovec.count);
util::lci_environment::pcounter_add(util::lci_environment::recv_conn_end, 1);
util::lci_environment::pcounter_add(
util::lci_environment::recv_conn_end, 1);
#if defined(HPX_HAVE_PARCELPORT_COUNTERS)
data.bytes_ = static_cast<std::size_t>(header_.numbytes());
data.time_ = timer_.elapsed_nanoseconds();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ namespace hpx::parcelset::policies::lci {
};

public:
receiver_connection_sendrecv(
int dst, parcelset::parcelport* pp);
receiver_connection_sendrecv(int dst, parcelset::parcelport* pp);
~receiver_connection_sendrecv() {}
void load(char* header_buffer);
return_t receive();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ namespace hpx::parcelset::policies::lci {
auto& device = pp->devices[i];
for (int j = 0; j < config_t::prepost_recv_num; ++j)
{
LCI_comp_t completion = device.completion_manager_p
->recv_new
->alloc_completion();
LCI_comp_t completion =
device.completion_manager_p->recv_new
->alloc_completion();
LCI_recvmn(device.endpoint_new, LCI_RANK_ANY, 0,
completion, (void*) i);
device.completion_manager_p->recv_new
Expand All @@ -61,8 +61,7 @@ namespace hpx::parcelset::policies::lci {

~receiver_sendrecv() {}

connection_ptr create_connection(
int dest, parcelset::parcelport* pp);
connection_ptr create_connection(int dest, parcelset::parcelport* pp);

bool background_work() noexcept;

Expand Down
20 changes: 12 additions & 8 deletions libs/full/parcelport_lci/src/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,18 +120,22 @@ namespace hpx::parcelset::policies::lci {
fprintf(stderr, "WARNING: set progress_type to pthread!\n");
}
#ifndef LCI_ENABLE_MULTITHREAD_PROGRESS
if (progress_type == progress_type_t::worker
|| progress_thread_num > ndevices) {
fprintf(stderr, "WARNING: Thread-safe LCI_progress is needed "
"but not enabled during compilation!\n");
if (progress_type == progress_type_t::worker ||
progress_thread_num > ndevices)
{
fprintf(stderr,
"WARNING: Thread-safe LCI_progress is needed "
"but not enabled during compilation!\n");
}
#endif
if (ncomps > ndevices) {
if (ncomps > ndevices)
{
int old_ncomps = ncomps;
ncomps = ndevices;
fprintf(stderr, "WARNING: the number of completion managers (%d) "
"cannot exceed the number of devices (%d). "
"ncomps is adjusted accordingly (%d).",
fprintf(stderr,
"WARNING: the number of completion managers (%d) "
"cannot exceed the number of devices (%d). "
"ncomps is adjusted accordingly (%d).",
old_ncomps, ndevices, ncomps);
}
}
Expand Down
10 changes: 6 additions & 4 deletions libs/full/parcelport_lci/src/parcelport_lci.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <memory>
#include <string>
#include <type_traits>
#include <vector>

namespace hpx::parcelset::policies::lci {

Expand Down Expand Up @@ -216,9 +217,10 @@ namespace hpx::parcelset::policies::lci {
do_progress_local();
if (config_t::enable_lci_backlog_queue)
// try to send pending messages
has_work = backlog_queue::background_work(
get_tls_device().completion_manager_p
->send.get(), num_thread) ||
has_work =
backlog_queue::background_work(
get_tls_device().completion_manager_p->send.get(),
num_thread) ||
has_work;
}
if (mode & parcelport_background_mode_receive)
Expand Down Expand Up @@ -307,7 +309,7 @@ namespace hpx::parcelset::policies::lci {

// Create completion managers
completion_managers.resize(config_t::ncomps);
for (auto &completion_manager : completion_managers)
for (auto& completion_manager : completion_managers)
{
if (config_t::protocol == config_t::protocol_t::sendrecv &&
config_t::completion_type == LCI_COMPLETION_SYNC)
Expand Down
3 changes: 1 addition & 2 deletions libs/full/parcelport_lci/src/sender_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ namespace hpx::parcelset::policies::lci {
else if (ret.status ==
sender_connection_base::return_status_t::wait)
{
completion_manager_p->send->enqueue_completion(
ret.completion);
completion_manager_p->send->enqueue_completion(ret.completion);
}
util::lci_environment::pcounter_add(
util::lci_environment::useful_bg_work,
Expand Down
13 changes: 8 additions & 5 deletions libs/full/parcelport_lci/src/sender_connection_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ namespace hpx::parcelset::policies::lci {
sender_connection_base::handler_type&& handler,
sender_connection_base::postprocess_handler_type&& parcel_postprocess)
{
LCT_time_t async_write_start_time = util::lci_environment::pcounter_now();
LCT_time_t async_write_start_time =
util::lci_environment::pcounter_now();
device_p = &pp_->get_tls_device();
load(HPX_FORWARD(handler_type, handler),
HPX_FORWARD(postprocess_handler_type, parcel_postprocess));
Expand All @@ -41,8 +42,8 @@ namespace hpx::parcelset::policies::lci {
}
else if (ret.status == return_status_t::wait)
{
device_p->completion_manager_p->send
->enqueue_completion(ret.completion);
device_p->completion_manager_p->send->enqueue_completion(
ret.completion);
}
util::lci_environment::pcounter_add(
util::lci_environment::async_write_timer,
Expand Down Expand Up @@ -106,7 +107,8 @@ namespace hpx::parcelset::policies::lci {

void sender_connection_base::profile_start_hook(const header& header_)
{
util::lci_environment::pcounter_add(util::lci_environment::send_conn_start, 1);
util::lci_environment::pcounter_add(
util::lci_environment::send_conn_start, 1);
if (util::lci_environment::log_level <
util::lci_environment::log_level_t::profile)
return;
Expand Down Expand Up @@ -138,7 +140,8 @@ namespace hpx::parcelset::policies::lci {
util::lci_environment::log(util::lci_environment::log_level_t::profile,
"send", "%d:%lf:send_connection(%p) end\n", LCI_RANK,
hpx::chrono::high_resolution_clock::now() / 1e9, (void*) this);
util::lci_environment::pcounter_add(util::lci_environment::send_conn_end, 1);
util::lci_environment::pcounter_add(
util::lci_environment::send_conn_end, 1);
}
} // namespace hpx::parcelset::policies::lci

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ namespace hpx::parcelset::policies::lci {
void receiver_connection_sendrecv::load(char* header_buffer)
{
conn_start_time = util::lci_environment::pcounter_now();
util::lci_environment::pcounter_add(util::lci_environment::recv_conn_start, 1);
util::lci_environment::pcounter_add(
util::lci_environment::recv_conn_start, 1);
header header_ = header(header_buffer);
header_.assert_valid();
#if defined(HPX_HAVE_PARCELPORT_COUNTERS)
Expand Down Expand Up @@ -148,8 +149,8 @@ namespace hpx::parcelset::policies::lci {
HPX_UNUSED(ret);
util::lci_environment::log(
util::lci_environment::log_level_t::debug, "recv",
"recvm (%d, %d, %d) device %d tag %d size %d\n", dst_rank, LCI_RANK,
original_tag, device_p->idx, tag, length);
"recvm (%d, %d, %d) device %d tag %d size %d\n", dst_rank,
LCI_RANK, original_tag, device_p->idx, tag, length);
tag = (tag + 1) % LCI_MAX_TAG;
}
else
Expand All @@ -172,8 +173,8 @@ namespace hpx::parcelset::policies::lci {
HPX_UNUSED(ret);
util::lci_environment::log(
util::lci_environment::log_level_t::debug, "recv",
"recvl (%d, %d, %d) device %d tag %d size %d\n", dst_rank, LCI_RANK,
original_tag, device_p->idx, tag, length);
"recvl (%d, %d, %d) device %d tag %d size %d\n", dst_rank,
LCI_RANK, original_tag, device_p->idx, tag, length);
tag = (tag + 1) % LCI_MAX_TAG;
if (segment_used != LCI_SEGMENT_ALL)
{
Expand Down Expand Up @@ -353,7 +354,8 @@ namespace hpx::parcelset::policies::lci {

void receiver_connection_sendrecv::done()
{
util::lci_environment::pcounter_add(util::lci_environment::recv_conn_end, 1);
util::lci_environment::pcounter_add(
util::lci_environment::recv_conn_end, 1);
util::lci_environment::log(util::lci_environment::log_level_t::debug,
"recv", "recv connection (%d, %d, %d, %d) done!\n", dst_rank,
LCI_RANK, original_tag, tag - original_tag + 1);
Expand Down
4 changes: 2 additions & 2 deletions libs/full/parcelport_lci/src/sendrecv/receiver_sendrecv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
#include <hpx/parcelport_lci/sendrecv/receiver_sendrecv.hpp>

#include <hpx/assert.hpp>
#include <cstddef>
#include <memory>

namespace hpx::parcelset::policies::lci {
receiver_sendrecv::connection_ptr receiver_sendrecv::create_connection(
int dest, parcelset::parcelport* pp)
{
return std::make_shared<receiver_connection_sendrecv>(
dest, pp);
return std::make_shared<receiver_connection_sendrecv>(dest, pp);
}

bool receiver_sendrecv::background_work() noexcept
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ namespace hpx::parcelset::policies::lci {
{
util::lci_environment::log(
util::lci_environment::log_level_t::debug, "send",
"sendm (%d, %d, %d) device %d tag %d size %d\n", LCI_RANK, dst_rank,
original_tag, device_p->idx, tag, length);
"sendm (%d, %d, %d) device %d tag %d size %d\n", LCI_RANK,
dst_rank, original_tag, device_p->idx, tag, length);
tag = (tag + 1) % LCI_MAX_TAG;
return {return_status_t::done, nullptr};
}
Expand Down Expand Up @@ -218,8 +218,8 @@ namespace hpx::parcelset::policies::lci {
{
util::lci_environment::log(
util::lci_environment::log_level_t::debug, "send",
"sendl (%d, %d, %d) device %d, tag %d size %d\n", LCI_RANK, dst_rank,
original_tag, device_p->idx, tag, length);
"sendl (%d, %d, %d) device %d, tag %d size %d\n", LCI_RANK,
dst_rank, original_tag, device_p->idx, tag, length);
tag = (tag + 1) % LCI_MAX_TAG;
if (segment_used != LCI_SEGMENT_ALL)
{
Expand Down

0 comments on commit a6d442a

Please sign in to comment.