From 16fab3b494c634afbcf617a744f06f80d0153b75 Mon Sep 17 00:00:00 2001 From: Nicholas Sielicki Date: Mon, 12 Aug 2024 12:37:26 -0700 Subject: [PATCH] tree: add static_assert shim macro stack-info: PR: https://github.com/aws/aws-ofi-nccl/pull/556, branch: aws-nslick/stack/3 Signed-off-by: Nicholas Sielicki --- include/nccl_ofi.h | 3 +-- include/nccl_ofi_config_bottom.h | 4 ++++ include/nccl_ofi_freelist.h | 4 ++-- include/nccl_ofi_memcheck.h | 2 +- src/nccl_ofi_api.c | 6 +++--- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/include/nccl_ofi.h b/include/nccl_ofi.h index e502f6cc9..e1e39b2a4 100644 --- a/include/nccl_ofi.h +++ b/include/nccl_ofi.h @@ -192,8 +192,7 @@ typedef struct nccl_ofi_connection_info { nccl_net_ofi_req_t* req; } nccl_ofi_connection_info_t; /* Since this is a message on the wire, check that it has the expected size */ -_Static_assert(sizeof(nccl_ofi_connection_info_t) == 80, - "Wrong size for SENDRECV connect message"); +static_assert(sizeof(nccl_ofi_connection_info_t) == 80, "Wrong size for SENDRECV connect message"); typedef struct nccl_net_ofi_conn_handle { char ep_name[MAX_EP_ADDR]; diff --git a/include/nccl_ofi_config_bottom.h b/include/nccl_ofi_config_bottom.h index 38e0ec9f8..5c18d7c83 100644 --- a/include/nccl_ofi_config_bottom.h +++ b/include/nccl_ofi_config_bottom.h @@ -11,6 +11,10 @@ #define NCCL_OFI_EXPORT_SYMBOL __attribute__((visibility("default"))) +#ifndef __cplusplus +#define static_assert _Static_assert +#endif + /* Maximum length of directory path */ #ifdef HAVE_LINUX_LIMITS_H #include diff --git a/include/nccl_ofi_freelist.h b/include/nccl_ofi_freelist.h index 089128019..b8ee9d63f 100644 --- a/include/nccl_ofi_freelist.h +++ b/include/nccl_ofi_freelist.h @@ -95,9 +95,9 @@ struct nccl_ofi_freelist_reginfo_t { }; typedef struct nccl_ofi_freelist_reginfo_t nccl_ofi_freelist_reginfo_t; -_Static_assert(offsetof(nccl_ofi_freelist_reginfo_t, elem) == 0, +static_assert(offsetof(nccl_ofi_freelist_reginfo_t, elem) == 0, "elem is not the first member of the structure nccl_ofi_freelist_reginfo_t"); -_Static_assert(sizeof(nccl_ofi_freelist_reginfo_t) - offsetof(nccl_ofi_freelist_reginfo_t, redzone) == MEMCHECK_REDZONE_SIZE, +static_assert(sizeof(nccl_ofi_freelist_reginfo_t) - offsetof(nccl_ofi_freelist_reginfo_t, redzone) == MEMCHECK_REDZONE_SIZE, "redzone is not the last member of the structure nccl_ofi_freelist_reginfo_t"); /* diff --git a/include/nccl_ofi_memcheck.h b/include/nccl_ofi_memcheck.h index 20eb8bf46..52247eb25 100644 --- a/include/nccl_ofi_memcheck.h +++ b/include/nccl_ofi_memcheck.h @@ -29,7 +29,7 @@ extern "C" { * MEMCHECK_REDZONE_SIZE defines the size of redzones prefixing each * entry. Redzones are required to be a multiple of 8 due to ASAN * shadow-map granularity */ -_Static_assert(MEMCHECK_REDZONE_SIZE % MEMCHECK_GRANULARITY == 0, +static_assert(MEMCHECK_REDZONE_SIZE % MEMCHECK_GRANULARITY == 0, "Size of redzone is not a multiple of ASAN shadow-map granularity"); /** diff --git a/src/nccl_ofi_api.c b/src/nccl_ofi_api.c index 0bbf1ce01..60ad3f7ff 100644 --- a/src/nccl_ofi_api.c +++ b/src/nccl_ofi_api.c @@ -9,11 +9,11 @@ #include "nccl_ofi_api.h" -_Static_assert(sizeof(nccl_net_ofi_conn_handle_t) <= NCCL_NET_HANDLE_MAXSIZE, +static_assert(sizeof(nccl_net_ofi_conn_handle_t) <= NCCL_NET_HANDLE_MAXSIZE, "Size of OFI Handle is too large"); -_Static_assert(offsetof(nccl_net_ofi_conn_handle_t, state) <= NCCL_NET_HANDLE_MAXSIZE_V4, +static_assert(offsetof(nccl_net_ofi_conn_handle_t, state) <= NCCL_NET_HANDLE_MAXSIZE_V4, "Size of OFI Handle (without state) is too large"); -_Static_assert(NCCL_NET_MAX_REQUESTS <= NCCL_OFI_MAX_REQUESTS, +static_assert(NCCL_NET_MAX_REQUESTS <= NCCL_OFI_MAX_REQUESTS, "Maximum outstanding requests for plugin is less than what NCCL requires");