Skip to content

Commit

Permalink
tree: add static_assert shim macro
Browse files Browse the repository at this point in the history
stack-info: PR: #556, branch: aws-nslick/stack/3
Signed-off-by: Nicholas Sielicki <nslick@amazon.com>
  • Loading branch information
aws-nslick committed Sep 4, 2024
1 parent fa6c418 commit 16fab3b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
3 changes: 1 addition & 2 deletions include/nccl_ofi.h
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
4 changes: 4 additions & 0 deletions include/nccl_ofi_config_bottom.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <linux/limits.h>
Expand Down
4 changes: 2 additions & 2 deletions include/nccl_ofi_freelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -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");

/*
Expand Down
2 changes: 1 addition & 1 deletion include/nccl_ofi_memcheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -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");

/**
Expand Down
6 changes: 3 additions & 3 deletions src/nccl_ofi_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");


Expand Down

0 comments on commit 16fab3b

Please sign in to comment.