Skip to content

Commit

Permalink
fix(tree): use correct __cplusplus guards
Browse files Browse the repository at this point in the history
the canonical token is __cplusplus not _cplusplus. When this is
incorrect, linkage fails as cxx will perform name mangling when
including these headers, resulting in a function with that mangle not
existing.

stack-info: PR: aws#554, branch: aws-nslick/stack/1
Signed-off-by: Nicholas Sielicki <[email protected]>
  • Loading branch information
aws-nslick authored and aws-ofiwg-bot committed Oct 4, 2024
1 parent 841a01c commit 3b0afb0
Show file tree
Hide file tree
Showing 25 changed files with 67 additions and 52 deletions.
4 changes: 2 additions & 2 deletions include/nccl-headers/neuron/error.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#ifndef NCCL_HEADERS_NEURON_ERROR_H_
#define NCCL_HEADERS_NEURON_ERROR_H_

#ifdef _cplusplus
#ifdef __cplusplus
extern "C" {
#endif

Expand All @@ -21,7 +21,7 @@ typedef enum {
ncclRemoteError = 6
} ncclResult_t;

#ifdef _cplusplus
#ifdef __cplusplus
}
#endif

Expand Down
4 changes: 2 additions & 2 deletions include/nccl-headers/neuron/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#ifndef NCCL_HEADERS_NEURON_NET_H_
#define NCCL_HEADERS_NEURON_NET_H_

#ifdef _cplusplus
#ifdef __cplusplus
extern "C" {
#endif

Expand Down Expand Up @@ -100,7 +100,7 @@ typedef struct {
ncclResult_t (*closeListen)(void* listenComm);
} ncclNet_v4_t;

#ifdef _cplusplus
#ifdef __cplusplus
} // End extern "C"
#endif

Expand Down
6 changes: 3 additions & 3 deletions include/nccl_ofi.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#ifndef NCCL_OFI_H_
#define NCCL_OFI_H_

#ifdef _cplusplus

#ifdef __cplusplus
extern "C" {
#endif

Expand All @@ -23,7 +24,6 @@ extern "C" {
#include "nccl_ofi_idpool.h"
#include "nccl_ofi_mr.h"


/*
* NCCL_NET_HANDLE_MAXSIZE is a limited resource (and defined in NCCL).
* An endpoint address buffer of 56 bytes *should* be large enough to hold
Expand Down Expand Up @@ -590,7 +590,7 @@ int nccl_net_ofi_dealloc_mr_buffer(void *ptr, size_t size);
int nccl_net_ofi_query_provider_capabilities(const struct fi_info *selected_provider,
unsigned int num_providers);

#ifdef _cplusplus
#ifdef __cplusplus
} // End extern "C"
#endif

Expand Down
9 changes: 5 additions & 4 deletions include/nccl_ofi_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@
#ifndef NET_OFI_API_H_
#define NET_OFI_API_H_

#include "nccl-headers/net.h"
#include "nccl-headers/error.h"

#ifdef _cplusplus
#ifdef __cplusplus
extern "C" {
#endif

#include "nccl-headers/net.h"
#include "nccl-headers/error.h"

struct nccl_ofi_properties;

ncclResult_t nccl_net_ofi_init(ncclDebugLogger_t logFunction);
Expand Down Expand Up @@ -42,7 +43,7 @@ ncclResult_t nccl_net_ofi_closeSend(void *sendComm);
ncclResult_t nccl_net_ofi_closeRecv(void *recvComm);
ncclResult_t nccl_net_ofi_closeListen(void *listenComm);

#ifdef _cplusplus
#ifdef __cplusplus
}
#endif // End extern "C"

Expand Down
5 changes: 3 additions & 2 deletions include/nccl_ofi_cuda.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#ifndef NCCL_OFI_CUDA_H_
#define NCCL_OFI_CUDA_H_

#ifdef _cplusplus

#ifdef __cplusplus
extern "C" {
#endif

Expand Down Expand Up @@ -41,7 +42,7 @@ extern CUresult (*nccl_net_ofi_cuFlushGPUDirectRDMAWrites)(CUflushGPUDirectRDMAW
extern void *nccl_net_ofi_cuFlushGPUDirectRDMAWrites;
#endif

#ifdef _cplusplus
#ifdef __cplusplus
} // End extern "C"
#endif

Expand Down
5 changes: 3 additions & 2 deletions include/nccl_ofi_deque.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#ifndef NCCL_OFI_DEQUE_H
#define NCCL_OFI_DEQUE_H

#ifdef _cplusplus

#ifdef __cplusplus
extern "C" {
#endif

Expand Down Expand Up @@ -162,7 +163,7 @@ static inline int nccl_ofi_deque_remove_front(nccl_ofi_deque_t *deque, nccl_ofi_
return 0;
}

#ifdef _cplusplus
#ifdef __cplusplus
} // End extern "C"
#endif

Expand Down
8 changes: 8 additions & 0 deletions include/nccl_ofi_ep_addr_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#ifndef NCCL_OFI_EP_ADDR_LIST_H
#define NCCL_OFI_EP_ADDR_LIST_H

#ifdef __cplusplus
extern "C" {
#endif

struct nccl_ofi_ep_addr_list;
typedef struct nccl_ofi_ep_addr_list nccl_ofi_ep_addr_list_t;

Expand Down Expand Up @@ -76,4 +80,8 @@ int nccl_ofi_ep_addr_list_delete(nccl_ofi_ep_addr_list_t *ep_list, nccl_net_ofi_
*/
void nccl_ofi_ep_addr_list_fini(nccl_ofi_ep_addr_list_t *ep_list);

#ifdef __cplusplus
} // End extern "C"
#endif

#endif
5 changes: 3 additions & 2 deletions include/nccl_ofi_freelist.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
#ifndef NCCL_OFI_FREELIST_H
#define NCCL_OFI_FREELIST_H

#ifdef _cplusplus

#ifdef __cplusplus
extern "C" {
#endif

Expand Down Expand Up @@ -313,7 +314,7 @@ static inline void nccl_ofi_freelist_entry_free(nccl_ofi_freelist_t *freelist, v
nccl_net_ofi_mutex_unlock(&freelist->lock);
}

#ifdef _cplusplus
#ifdef __cplusplus
} // End extern "C"
#endif

Expand Down
6 changes: 3 additions & 3 deletions include/nccl_ofi_idpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
#ifndef NCCL_OFI_IDPOOL_H_
#define NCCL_OFI_IDPOOL_H_

#ifdef _cplusplus

#ifdef __cplusplus
extern "C" {
#endif

#include <pthread.h>

#include <stdint.h>

/*
Expand Down Expand Up @@ -87,7 +87,7 @@ int nccl_ofi_idpool_free_id(nccl_ofi_idpool_t *idpool, int id);
*/
int nccl_ofi_idpool_fini(nccl_ofi_idpool_t *idpool);

#ifdef _cplusplus
#ifdef __cplusplus
} // End extern "C"
#endif

Expand Down
4 changes: 2 additions & 2 deletions include/nccl_ofi_log.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#ifndef NCCL_OFI_LOG_H_
#define NCCL_OFI_LOG_H_

#ifdef _cplusplus
#ifdef __cplusplus
extern "C" {
#endif

Expand All @@ -33,7 +33,7 @@ extern ncclDebugLogger_t ofi_log_function;
#define NCCL_OFI_TRACE(flags, fmt, ...)
#endif

#ifdef _cplusplus
#ifdef __cplusplus
} // End extern "C"
#endif

Expand Down
4 changes: 2 additions & 2 deletions include/nccl_ofi_math.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef NCCL_OFI_MATH_H_
#define NCCL_OFI_MATH_H_

#ifdef _cplusplus
#ifdef __cplusplus
extern "C" {
#endif

Expand Down Expand Up @@ -65,7 +65,7 @@ extern "C" {
*/
#define NCCL_OFI_ROUND_UP(x, y) NCCL_OFI_ROUND_DOWN((x) + ((y) - 1), (y))

#ifdef _cplusplus
#ifdef __cplusplus
} // End extern "C"
#endif

Expand Down
4 changes: 2 additions & 2 deletions include/nccl_ofi_memcheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef NCCL_OFI_MEMCHECK_H
#define NCCL_OFI_MEMCHECK_H

#ifdef _cplusplus
#ifdef __cplusplus
extern "C" {
#endif

Expand Down Expand Up @@ -169,7 +169,7 @@ static inline void nccl_net_ofi_mem_mempool_alloc(void *handle, void *data, size
*/
static inline void nccl_net_ofi_mem_mempool_free(void *handle, void *data, size_t size);

#ifdef _cplusplus
#ifdef __cplusplus
} // End extern "C"
#endif

Expand Down
4 changes: 2 additions & 2 deletions include/nccl_ofi_memcheck_asan.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef NCCL_OFI_MEMCHECK_ASAN_H
#define NCCL_OFI_MEMCHECK_ASAN_H

#ifdef _cplusplus
#ifdef __cplusplus
extern "C" {
#endif

Expand Down Expand Up @@ -56,7 +56,7 @@ static inline void nccl_net_ofi_mem_mempool_free(void *handle, void *data, size_
nccl_net_ofi_mem_noaccess(data, size);
}

#ifdef _cplusplus
#ifdef __cplusplus
} // End extern "C"
#endif

Expand Down
4 changes: 2 additions & 2 deletions include/nccl_ofi_memcheck_nop.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef NCCL_OFI_MEMCHECK_NOP_H
#define NCCL_OFI_MEMCHECK_NOP_H

#ifdef _cplusplus
#ifdef __cplusplus
extern "C" {
#endif

Expand Down Expand Up @@ -44,7 +44,7 @@ static inline void nccl_net_ofi_mem_mempool_free(void *handle, void *data, size_
{
}

#ifdef _cplusplus
#ifdef __cplusplus
} // End extern "C"
#endif

Expand Down
4 changes: 2 additions & 2 deletions include/nccl_ofi_memcheck_valgrind.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef NCCL_OFI_MEMCHECK_VALGRIND_H
#define NCCL_OFI_MEMCHECK_VALGRIND_H

#ifdef _cplusplus
#ifdef __cplusplus
extern "C" {
#endif

Expand Down Expand Up @@ -48,7 +48,7 @@ static inline void nccl_net_ofi_mem_mempool_free(void *handle, void *data, size_
VALGRIND_MEMPOOL_FREE(handle, data);
}

#ifdef _cplusplus
#ifdef __cplusplus
} // End extern "C"
#endif

Expand Down
4 changes: 2 additions & 2 deletions include/nccl_ofi_mr.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef NCCL_OFI_MR_H_
#define NCCL_OFI_MR_H_

#ifdef _cplusplus
#ifdef __cplusplus
extern "C" {
#endif

Expand Down Expand Up @@ -80,7 +80,7 @@ int nccl_ofi_mr_cache_insert_entry(nccl_ofi_mr_cache_t *cache,
*/
int nccl_ofi_mr_cache_del_entry(nccl_ofi_mr_cache_t *cache, void *handle);

#ifdef _cplusplus
#ifdef __cplusplus
} // End extern "C"
#endif

Expand Down
5 changes: 2 additions & 3 deletions include/nccl_ofi_msgbuff.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
#ifndef NCCL_OFI_MSGBUFF_H_
#define NCCL_OFI_MSGBUFF_H_

#ifdef _cplusplus
#ifdef __cplusplus
extern "C" {
#endif

#include <pthread.h>

#include <stdbool.h>
#include <stdint.h>

Expand Down Expand Up @@ -183,7 +182,7 @@ nccl_ofi_msgbuff_result_t nccl_ofi_msgbuff_retrieve(nccl_ofi_msgbuff_t *msgbuff,
nccl_ofi_msgbuff_result_t nccl_ofi_msgbuff_complete(nccl_ofi_msgbuff_t *msgbuff,
uint16_t msg_index, nccl_ofi_msgbuff_status_t *msg_idx_status);

#ifdef _cplusplus
#ifdef __cplusplus
} // End extern "C"
#endif

Expand Down
4 changes: 2 additions & 2 deletions include/nccl_ofi_ofiutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef NCCL_OFI_OFIUTILS_H
#define NCCL_OFI_OFIUTILS_H

#ifdef _cplusplus
#ifdef __cplusplus
extern "C" {
#endif

Expand Down Expand Up @@ -43,7 +43,7 @@ void nccl_ofi_ofiutils_free_info_list(struct fi_info *info_list);

int nccl_ofi_mr_keys_need_own_key(struct fi_info* provider, bool *provide_own_mr_key);

#ifdef _cplusplus
#ifdef __cplusplus
} // End extern "C"
#endif

Expand Down
4 changes: 2 additions & 2 deletions include/nccl_ofi_param.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef NCCL_OFI_PARAM_H_
#define NCCL_OFI_PARAM_H_

#ifdef _cplusplus
#ifdef __cplusplus
extern "C" {
#endif

Expand Down Expand Up @@ -240,7 +240,7 @@ OFI_NCCL_PARAM_INT(errorcheck_mutex, "ERRORCHECK_MUTEX",
*/
OFI_NCCL_PARAM_INT(endpoint_per_communicator, "ENDPOINT_PER_COMM", 0);

#ifdef _cplusplus
#ifdef __cplusplus
} // End extern "C"
#endif

Expand Down
6 changes: 5 additions & 1 deletion include/nccl_ofi_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#ifndef NCCL_OFI_PLATFORM_H_
#define NCCL_OFI_PLATFORM_H_

#ifdef _cplusplus
#ifdef __cplusplus
extern "C" {
#endif

Expand Down Expand Up @@ -35,4 +35,8 @@ int platform_config_endpoint(struct fi_info *info, struct fid_ep *ep) __attribut
*/
void platform_sort_rails(struct fi_info **info_list, int num_rails) __attribute__((weak));

#ifdef __cplusplus
}
#endif

#endif // End NCCL_OFI_PLATFORM_H_
Loading

0 comments on commit 3b0afb0

Please sign in to comment.