From 31f62c0628de7fa3dd4cdf203767cffa2894b2d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yannik=20M=C3=BCller?= <y.mueller@fz-juelich.de> Date: Fri, 1 Mar 2024 16:13:12 +0100 Subject: [PATCH] ISO C++20 conformity --- benchmark/Makefile | 2 +- benchmark/cmdline.cc | 27 +++++++++++---------------- benchmark/error.h | 10 +++++----- benchmark/vcluster.cc | 8 ++++---- benchmark/vcluster_ibverbs.cc | 4 +--- 5 files changed, 22 insertions(+), 29 deletions(-) diff --git a/benchmark/Makefile b/benchmark/Makefile index f0b7c10..7adb4a0 100644 --- a/benchmark/Makefile +++ b/benchmark/Makefile @@ -28,7 +28,7 @@ SYSTEM = generic GIT_HASH = $(shell git rev-parse --verify HEAD) GIT_HASH_SHORT= $(shell git rev-parse --verify --short HEAD) CXX = mpicxx -CXXFLAGS = -std=c++17 -Wall -g -rdynamic +CXXFLAGS = -std=c++20 -Wall -g -rdynamic CPPFLAGS = -D_GNU_SOURCE \ -DLINKTEST_LINUX=1 \ -DLINKTEST_SYSTEM="\"$(SYSTEM)\"" \ diff --git a/benchmark/cmdline.cc b/benchmark/cmdline.cc index 53c182b..cca3998 100644 --- a/benchmark/cmdline.cc +++ b/benchmark/cmdline.cc @@ -723,22 +723,17 @@ const struct linktest_args *bcast_cmdline_args(VirtualCluster* cl, cl->bcast(root,&tmp->seed_randomize_steps ,1); cl->bcast(root,&tmp->seed_randomize_tasks ,1); - /* Broadcast Output Filename */ - std::uint64_t buf_size; - if(cl->rank()==root) buf_size=tmp->output.size()+1; - cl->bcast(root,&buf_size,1); - char buf_output[buf_size]; - if(cl->rank()==root) std::snprintf(buf_output, sizeof(buf_output), "%s", tmp->output.c_str()); - cl->bcast(root, buf_output, buf_size); - tmp->output = buf_output; - - /* Broadcast VirtualCluster Implementation */ - if(cl->rank()==root) buf_size=tmp->virtual_cluster_implementation.size()+1; - cl->bcast(root,&buf_size,1); - char buf_virtual_cluster_implementation[buf_size]; - if(cl->rank()==root) std::snprintf(buf_virtual_cluster_implementation, sizeof(buf_virtual_cluster_implementation), "%s", tmp->virtual_cluster_implementation.c_str()); - cl->bcast(root, buf_virtual_cluster_implementation, buf_size); - tmp->virtual_cluster_implementation = buf_virtual_cluster_implementation; + auto bcastString = [&](std::string& str){ + std::uint64_t str_size = str.size(); // only root has correct value + cl->bcast(root, &str_size, 1); + if(cl->rank() != root) { + str.resize(str_size); + } + cl->bcast(root, str.data(), str.size()); + }; + + bcastString(tmp->output); + bcastString(tmp->virtual_cluster_implementation); return(tmp); } diff --git a/benchmark/error.h b/benchmark/error.h index e1db667..8203450 100644 --- a/benchmark/error.h +++ b/benchmark/error.h @@ -36,10 +36,10 @@ void linktest_debug(const char* file, const char* func, long line, const char* f * that result in hard to understand compiler errors. */ // NOLINTBEGIN -#define fatal(fmt, ...) linktest_fatal(__FILE__, __func__, __LINE__, fmt, ## __VA_ARGS__) -#define error(fmt, ...) linktest_error(__FILE__, __func__, __LINE__, fmt, ## __VA_ARGS__) -#define warn(fmt, ...) linktest_warn(__FILE__, __func__, __LINE__, fmt, ## __VA_ARGS__) -#define info(fmt, ...) linktest_info(__FILE__, __func__, __LINE__, fmt, ## __VA_ARGS__) -#define debug(fmt, ...) linktest_debug(__FILE__, __func__, __LINE__, fmt, ## __VA_ARGS__) +#define fatal(...) linktest_fatal(__FILE__, __func__, __LINE__, __VA_ARGS__) +#define error(...) linktest_error(__FILE__, __func__, __LINE__, __VA_ARGS__) +#define warn(...) linktest_warn(__FILE__, __func__, __LINE__, __VA_ARGS__) +#define info(...) linktest_info(__FILE__, __func__, __LINE__, __VA_ARGS__) +#define debug(...) linktest_debug(__FILE__, __func__, __LINE__, __VA_ARGS__) // NOLINTEND #endif \ No newline at end of file diff --git a/benchmark/vcluster.cc b/benchmark/vcluster.cc index 214bd9e..15f8dee 100644 --- a/benchmark/vcluster.cc +++ b/benchmark/vcluster.cc @@ -582,10 +582,10 @@ void VirtualCluster::getHostAndLocalRank(){ gather(0, hostnameLengths.data(), &tmp32, 1); //Gather hostname lengths hostnames.resize(size()); hostnames[0]=hostname(); - for(int i=1;i<size();i++){ - char buf[hostnameLengths[i]]; //We need an intermediate buffer because we cannot receive directly into the buffer of std::string - recv(i, buf, hostnameLengths[i]); - hostnames[i]=buf; + for(int rank = 1; rank < size(); rank++){ + std::vector<char> buf(hostnameLengths[rank]); + recv(rank, buf.data(), hostnameLengths[rank]); + hostnames[rank] = std::string(buf.begin(), buf.end()); } /***************************************************/ diff --git a/benchmark/vcluster_ibverbs.cc b/benchmark/vcluster_ibverbs.cc index b9711d9..faa0eff 100644 --- a/benchmark/vcluster_ibverbs.cc +++ b/benchmark/vcluster_ibverbs.cc @@ -533,9 +533,7 @@ int VirtualClusterImpl::kpingpong_isend_segment(Connection& conn, int bufi, #endif // Since we set qp_sig_all = 0 we have to specify IBV_SEND_SIGNALED here .send_flags = static_cast<unsigned int>(sendFlags), - { - .imm_data = MAGIC_IMM_DATA - }, + .imm_data = MAGIC_IMM_DATA, .wr = { .rdma = { .remote_addr = (std::uint64_t)((char*)conn.mem_remote(bufi)->p() + offset), -- GitLab