From edf01a2f194fea5752c46fb812c0b969996818cd Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Mon, 8 Jan 2024 15:18:48 +0000 Subject: [PATCH 1/6] IWYU for std::exchange --- cpp/python/src/python_future.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cpp/python/src/python_future.cpp b/cpp/python/src/python_future.cpp index cb50d052..217bd2b4 100644 --- a/cpp/python/src/python_future.cpp +++ b/cpp/python/src/python_future.cpp @@ -4,6 +4,7 @@ */ #include #include +#include #include From 9a663b555cc1e15accb24567c64834928331ff29 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Mon, 8 Jan 2024 15:56:58 +0000 Subject: [PATCH 2/6] Fix some issues spotted by clang-tidy --- cpp/include/ucxx/request_am.h | 2 +- cpp/src/request_am.cpp | 6 +++--- cpp/src/request_tag_multi.cpp | 4 ++-- cpp/src/utils/sockaddr.cpp | 4 ++-- cpp/src/worker.cpp | 6 +++++- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/cpp/include/ucxx/request_am.h b/cpp/include/ucxx/request_am.h index 586abd89..3023c813 100644 --- a/cpp/include/ucxx/request_am.h +++ b/cpp/include/ucxx/request_am.h @@ -90,7 +90,7 @@ class RequestAm : public Request { RequestCallbackUserFunction callbackFunction, RequestCallbackUserData callbackData); - virtual void populateDelayedSubmission(); + void populateDelayedSubmission() override; /** * @brief Create and submit an active message send request. diff --git a/cpp/src/request_am.cpp b/cpp/src/request_am.cpp index 3a6fc455..c9767aed 100644 --- a/cpp/src/request_am.cpp +++ b/cpp/src/request_am.cpp @@ -145,7 +145,7 @@ ucs_status_t RequestAm::recvCallback(void* arg, // recvAmMessage.callback(nullptr, UCS_ERR_UNSUPPORTED); // return UCS_ERR_UNSUPPORTED; - ucxx_trace_req("No allocator registered for memory type %lu, falling back to host memory.", + ucxx_trace_req("No allocator registered for memory type %u, falling back to host memory.", allocatorType); allocatorType = UCS_MEMORY_TYPE_HOST; } @@ -292,7 +292,7 @@ void RequestAm::populateDelayedSubmission() ucxx_trace_req_f(_ownerString.c_str(), _request, _operationName.c_str(), - "buffer %p, size %lu, memoryType: %lu, future %p, future handle %p, " + "buffer %p, size %lu, memoryType: %u, future %p, future handle %p, " "populateDelayedSubmission", buffer, length, @@ -303,7 +303,7 @@ void RequestAm::populateDelayedSubmission() ucxx_trace_req_f(_ownerString.c_str(), _request, _operationName.c_str(), - "buffer %p, size %lu, memoryType: %lu, populateDelayedSubmission", + "buffer %p, size %lu, memoryType: %u, populateDelayedSubmission", buffer, length, memoryType); diff --git a/cpp/src/request_tag_multi.cpp b/cpp/src/request_tag_multi.cpp index ae9b4485..54807c0c 100644 --- a/cpp/src/request_tag_multi.cpp +++ b/cpp/src/request_tag_multi.cpp @@ -273,8 +273,8 @@ void RequestTagMulti::recvCallback(ucs_status_t status) ucxx_trace_req( "RequestTagMulti::recvCallback failed receiving header with status %d (%s), multi request: " "%p, " - "tag: 0x%lx", - "tagMask: 0x%lx", + "tag: 0x%lx, " + "tagMask: 0x%lx,", status, ucs_status_string(status), this, diff --git a/cpp/src/utils/sockaddr.cpp b/cpp/src/utils/sockaddr.cpp index 3d501b6f..8d2b8f23 100644 --- a/cpp/src/utils/sockaddr.cpp +++ b/cpp/src/utils/sockaddr.cpp @@ -56,8 +56,8 @@ void sockaddr_get_ip_port_str(const struct sockaddr_storage* sockaddr, inet_ntop(AF_INET6, &addr_in6->sin6_addr, ip_str, max_str_size); snprintf(port_str, max_str_size, "%u", ntohs(addr_in6->sin6_port)); default: - ip_str = const_cast(reinterpret_cast("Invalid address family")); - port_str = const_cast(reinterpret_cast("Invalid address family")); + snprintf(ip_str, max_str_size, "Invalid address family"); + snprintf(port_str, max_str_size, "Invalid address family"); } } diff --git a/cpp/src/worker.cpp b/cpp/src/worker.cpp index 8ccf8a89..8e04ee25 100644 --- a/cpp/src/worker.cpp +++ b/cpp/src/worker.cpp @@ -204,7 +204,11 @@ void Worker::initBlockingProgressMode() }}; err = epoll_ctl(_epollFileDescriptor, EPOLL_CTL_ADD, _workerFileDescriptor, &workerEvent); - if (err != 0) throw std::ios_base::failure(std::string("epoll_ctl() returned " + err)); + if (err != 0) { + std::stringstream ss; + ss << "epoll_ctl() returned " << err; + throw std::ios_base::failure(ss.str()); + } } bool Worker::arm() From fdaa6a04921b3e1d3d6378c67dfd4249ddc59fd2 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Mon, 8 Jan 2024 15:58:25 +0000 Subject: [PATCH 3/6] Copyright year --- LICENSE | 2 +- cpp/include/ucxx/request_am.h | 2 +- cpp/python/src/python_future.cpp | 2 +- cpp/src/request_am.cpp | 2 +- cpp/src/request_tag_multi.cpp | 2 +- cpp/src/utils/sockaddr.cpp | 2 +- cpp/src/worker.cpp | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/LICENSE b/LICENSE index 08c6047f..6cc301f3 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ BSD 3-Clause License -Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved. +Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: diff --git a/cpp/include/ucxx/request_am.h b/cpp/include/ucxx/request_am.h index 3023c813..e952bfa6 100644 --- a/cpp/include/ucxx/request_am.h +++ b/cpp/include/ucxx/request_am.h @@ -1,5 +1,5 @@ /** - * SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. + * SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. * SPDX-License-Identifier: BSD-3-Clause */ #pragma once diff --git a/cpp/python/src/python_future.cpp b/cpp/python/src/python_future.cpp index 217bd2b4..b13d048b 100644 --- a/cpp/python/src/python_future.cpp +++ b/cpp/python/src/python_future.cpp @@ -1,5 +1,5 @@ /** - * SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. + * SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. * SPDX-License-Identifier: BSD-3-Clause */ #include diff --git a/cpp/src/request_am.cpp b/cpp/src/request_am.cpp index c9767aed..8b6122fb 100644 --- a/cpp/src/request_am.cpp +++ b/cpp/src/request_am.cpp @@ -1,5 +1,5 @@ /** - * SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. + * SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. * SPDX-License-Identifier: BSD-3-Clause */ #include diff --git a/cpp/src/request_tag_multi.cpp b/cpp/src/request_tag_multi.cpp index 54807c0c..38bf2cea 100644 --- a/cpp/src/request_tag_multi.cpp +++ b/cpp/src/request_tag_multi.cpp @@ -1,5 +1,5 @@ /** - * SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. + * SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. * SPDX-License-Identifier: BSD-3-Clause */ #include "ucxx/delayed_submission.h" diff --git a/cpp/src/utils/sockaddr.cpp b/cpp/src/utils/sockaddr.cpp index 8d2b8f23..7fe56585 100644 --- a/cpp/src/utils/sockaddr.cpp +++ b/cpp/src/utils/sockaddr.cpp @@ -1,5 +1,5 @@ /** - * SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. + * SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. * SPDX-License-Identifier: BSD-3-Clause */ #include diff --git a/cpp/src/worker.cpp b/cpp/src/worker.cpp index 8e04ee25..bf644242 100644 --- a/cpp/src/worker.cpp +++ b/cpp/src/worker.cpp @@ -1,5 +1,5 @@ /** - * SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. + * SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. * SPDX-License-Identifier: BSD-3-Clause */ #include From 3f58c5a4837bd8c6bc01b3f8b14c132c1a75818b Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Mon, 8 Jan 2024 16:02:52 +0000 Subject: [PATCH 4/6] A bit more --- cpp/include/ucxx/constructors.h | 4 ++-- cpp/python/include/ucxx/python/constructors.h | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cpp/include/ucxx/constructors.h b/cpp/include/ucxx/constructors.h index 847aa6e1..bd020b05 100644 --- a/cpp/include/ucxx/constructors.h +++ b/cpp/include/ucxx/constructors.h @@ -1,13 +1,13 @@ /** - * SPDX-FileCopyrightText: Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. + * SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. * SPDX-License-Identifier: BSD-3-Clause */ #pragma once #include #include -#include +#include #include #include diff --git a/cpp/python/include/ucxx/python/constructors.h b/cpp/python/include/ucxx/python/constructors.h index 53ea6b38..cb2286ed 100644 --- a/cpp/python/include/ucxx/python/constructors.h +++ b/cpp/python/include/ucxx/python/constructors.h @@ -1,11 +1,13 @@ /** - * SPDX-FileCopyrightText: Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. + * SPDX-FileCopyrightText: Copyright (c) 2023-2024, NVIDIA CORPORATION & AFFILIATES. * SPDX-License-Identifier: BSD-3-Clause */ #pragma once #include +#include + #include namespace ucxx { From 543562f985e3a0b124690c966d59719061de0ca5 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Mon, 8 Jan 2024 17:34:46 +0000 Subject: [PATCH 5/6] Review fixes --- cpp/src/request_tag_multi.cpp | 4 +--- cpp/src/worker.cpp | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/cpp/src/request_tag_multi.cpp b/cpp/src/request_tag_multi.cpp index 38bf2cea..e3fd2eb8 100644 --- a/cpp/src/request_tag_multi.cpp +++ b/cpp/src/request_tag_multi.cpp @@ -2,8 +2,6 @@ * SPDX-FileCopyrightText: Copyright (c) 2022-2024, NVIDIA CORPORATION & AFFILIATES. * SPDX-License-Identifier: BSD-3-Clause */ -#include "ucxx/delayed_submission.h" -#include #include #include #include @@ -274,7 +272,7 @@ void RequestTagMulti::recvCallback(ucs_status_t status) "RequestTagMulti::recvCallback failed receiving header with status %d (%s), multi request: " "%p, " "tag: 0x%lx, " - "tagMask: 0x%lx,", + "tagMask: 0x%lx", status, ucs_status_string(status), this, diff --git a/cpp/src/worker.cpp b/cpp/src/worker.cpp index bf644242..2bf86006 100644 --- a/cpp/src/worker.cpp +++ b/cpp/src/worker.cpp @@ -205,9 +205,7 @@ void Worker::initBlockingProgressMode() err = epoll_ctl(_epollFileDescriptor, EPOLL_CTL_ADD, _workerFileDescriptor, &workerEvent); if (err != 0) { - std::stringstream ss; - ss << "epoll_ctl() returned " << err; - throw std::ios_base::failure(ss.str()); + throw std::ios_base::failure(std::string("epoll_ctl() returned ") + std::to_string(err)); } } From c13d8cf215aada2a6592a3d778a0a510eb3ec0f6 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Mon, 8 Jan 2024 17:47:51 +0000 Subject: [PATCH 6/6] Avoid fallthrough switch behaviour --- cpp/src/utils/sockaddr.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cpp/src/utils/sockaddr.cpp b/cpp/src/utils/sockaddr.cpp index 7fe56585..fd3d7528 100644 --- a/cpp/src/utils/sockaddr.cpp +++ b/cpp/src/utils/sockaddr.cpp @@ -51,13 +51,16 @@ void sockaddr_get_ip_port_str(const struct sockaddr_storage* sockaddr, addr_in = reinterpret_cast(sockaddr); inet_ntop(AF_INET, &addr_in->sin_addr, ip_str, max_str_size); snprintf(port_str, max_str_size, "%u", ntohs(addr_in->sin_port)); + break; case AF_INET6: addr_in6 = reinterpret_cast(sockaddr); inet_ntop(AF_INET6, &addr_in6->sin6_addr, ip_str, max_str_size); snprintf(port_str, max_str_size, "%u", ntohs(addr_in6->sin6_port)); + break; default: snprintf(ip_str, max_str_size, "Invalid address family"); snprintf(port_str, max_str_size, "Invalid address family"); + break; } }