Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(test): parse as c++ source #568

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions tests/functional/Makefile.am
Original file line number Diff line number Diff line change
@@ -11,18 +11,18 @@ LDADD = $(top_builddir)/src/libinternal_net_plugin.la $(MPI_LIBS) $(CUDA_LIBS)
CC = $(MPICC)
CXX = $(MPICXX)

noinst_HEADERS = test-common.h
noinst_HEADERS = test-common.hpp

if ENABLE_TESTS
bin_PROGRAMS = nccl_connection nccl_message_transfer ring
noinst_PROGRAMS = cuda_check
endif

nccl_connection_SOURCES = nccl_connection.c
nccl_message_transfer_SOURCES = nccl_message_transfer.c
ring_SOURCES = ring.c
nccl_connection_SOURCES = nccl_connection.cc
nccl_message_transfer_SOURCES = nccl_message_transfer.cc
ring_SOURCES = ring.cc

cuda_check_SOURCES = cuda_check.c
cuda_check_SOURCES = cuda_check.cc
# Override the LDADD for this check to avoid the -lcudart used by the
# other tests, since the purpose of this test is to make sure we
# didn't leak direct cuda dependencies into the plugin.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@

#include "config.h"

#include "test-common.h"
#include "test-common.hpp"

int main(int argc, char* argv[])
{
Original file line number Diff line number Diff line change
@@ -9,9 +9,7 @@

#include "config.h"

#include "test-common.h"

#define PROC_NAME_IDX(i) (i * MPI_MAX_PROCESSOR_NAME)
#include "test-common.hpp"

int main(int argc, char* argv[])
{
@@ -57,6 +55,7 @@ int main(int argc, char* argv[])
int recv_sizes[] = {4 * 1024, 16 * 1024, 1024 * 1024,
4 * 1024, 16 * 1024, 1024 * 1024,
5 * 1024, 17 * 1024, 2 * 1024 * 1024};
test_nccl_properties_t props = {};

/* For grouped recvs */
int tag = 1;
@@ -133,7 +132,6 @@ int main(int argc, char* argv[])
goto exit;
}

test_nccl_properties_t props = {};

/* Get Properties for the device */
for (int dev = 0; dev < ndev; dev++) {
@@ -398,7 +396,7 @@ int main(int argc, char* argv[])
MPI_Finalize();
NCCL_OFI_INFO(NCCL_NET, "Test completed successfully for rank %d", rank);

exit:;
exit:

ncclResult_t close_res = ncclSuccess;

4 changes: 1 addition & 3 deletions tests/functional/ring.c → tests/functional/ring.cc
Original file line number Diff line number Diff line change
@@ -4,9 +4,7 @@

#include "config.h"

#include "test-common.h"

#define PROC_NAME_IDX(i) (i * MPI_MAX_PROCESSOR_NAME)
#include "test-common.hpp"

int main(int argc, char *argv[])
{
Original file line number Diff line number Diff line change
@@ -20,6 +20,10 @@
#include <stdarg.h>
#include <cuda.h>


template <typename T>
constexpr T PROC_NAME_IDX(T i) { return i * MPI_MAX_PROCESSOR_NAME; };

#define STR2(v) #v
#define STR(v) STR2(v)

17 changes: 9 additions & 8 deletions tests/unit/Makefile.am
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
AM_CPPFLAGS = -I$(top_srcdir)/include
LDADD = $(top_builddir)/src/libinternal_net_plugin.la

noinst_HEADERS = test-common.h
noinst_HEADERS = test-common.hpp

noinst_PROGRAMS = \
deque \
@@ -21,12 +21,13 @@ noinst_PROGRAMS = \

TESTS = $(noinst_PROGRAMS)

show_tuner_decisions_SOURCES = show_tuner_decisions.c
show_tuner_decisions_SOURCES = show_tuner_decisions.cc
show_tuner_decisions_LDADD = $(top_builddir)/src/libinternal_tuner_plugin.la

deque_SOURCES = deque.c
freelist_SOURCES = freelist.c
msgbuff_SOURCES = msgbuff.c
scheduler_SOURCES = scheduler.c
ep_addr_list_SOURCES = ep_addr_list.c
mr_SOURCES = mr.c
idpool_SOURCES = idpool.cc
deque_SOURCES = deque.cc
freelist_SOURCES = freelist.cc
msgbuff_SOURCES = msgbuff.cc
scheduler_SOURCES = scheduler.cc
ep_addr_list_SOURCES = ep_addr_list.cc
mr_SOURCES = mr.cc
11 changes: 5 additions & 6 deletions tests/unit/deque.c → tests/unit/deque.cc
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

#include <stdio.h>

#include "test-common.h"
#include "test-common.hpp"
#include "nccl_ofi_deque.h"

#define test_get_front(deque, expected) \
@@ -32,14 +32,13 @@

int main(int argc, char *argv[])
{
const size_t num_elem = 11;
constexpr size_t num_elem = 11;
struct elem_t {
nccl_ofi_deque_elem_t de;
int v;
} elems[num_elem];

nccl_ofi_deque_elem_t *deque_elem;
int ret;
size_t i;
for (i = 0; i < num_elem; ++i) {
elems[i].v = i;
@@ -48,7 +47,7 @@ int main(int argc, char *argv[])
ofi_log_function = logger;

nccl_ofi_deque_t *deque;
ret = nccl_ofi_deque_init(&deque);
int ret = nccl_ofi_deque_init(&deque);
if (ret) {
NCCL_OFI_WARN("deque_init failed: %d", ret);
exit(1);
@@ -72,7 +71,7 @@ int main(int argc, char *argv[])
for (i = 0; i < num_elem; ++i) {
int expected = (i == 0 ? elems[num_elem-1].v : elems[i-1].v);
ret = nccl_ofi_deque_remove_front(deque, &deque_elem);
if (ret || deque_elem == NULL) {
if (ret || deque_elem == nullptr) {
NCCL_OFI_WARN("remove_front unexpectedly failed: %d", ret);
exit(1);
}
@@ -83,7 +82,7 @@ int main(int argc, char *argv[])
}
}
ret = nccl_ofi_deque_remove_front(deque, &deque_elem);
if (ret != 0 || deque_elem != NULL) {
if (ret != 0 || deque_elem != nullptr) {
NCCL_OFI_WARN("remove_front from empty deque unexpectedly succeeded");
exit(1);
}
2 changes: 1 addition & 1 deletion tests/unit/ep_addr_list.c → tests/unit/ep_addr_list.cc
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

#include <stdio.h>

#include "test-common.h"
#include "test-common.hpp"
#include "nccl_ofi_ep_addr_list.h"

static void insert_addresses(nccl_ofi_ep_addr_list_t *ep_addr_list, size_t num_addr, int ep_num)
2 changes: 1 addition & 1 deletion tests/unit/freelist.c → tests/unit/freelist.cc
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

#include <stdio.h>

#include "test-common.h"
#include "test-common.hpp"
#include "nccl_ofi_freelist.h"

void *simple_base;
2 changes: 1 addition & 1 deletion tests/unit/idpool.c → tests/unit/idpool.cc
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

#include <stdio.h>

#include "test-common.h"
#include "test-common.hpp"
#include "nccl_ofi_idpool.h"
#include "nccl_ofi_math.h"

2 changes: 1 addition & 1 deletion tests/unit/mr.c → tests/unit/mr.cc
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@

#include <stdlib.h>

#include "test-common.h"
#include "test-common.hpp"
#include "nccl_ofi_mr.h"

bool test_lookup_impl(nccl_ofi_mr_cache_t *cache, void *addr, size_t size,
2 changes: 1 addition & 1 deletion tests/unit/msgbuff.c → tests/unit/msgbuff.cc
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@

#include "nccl_ofi_msgbuff.h"

#include "test-common.h"
#include "test-common.hpp"

int main(int argc, char *argv[])
{
2 changes: 1 addition & 1 deletion tests/unit/scheduler.c → tests/unit/scheduler.cc
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@

#include "nccl-headers/net.h"

#include "test-common.h"
#include "test-common.hpp"
#include "nccl_ofi_scheduler.h"

int create_multiplexed(size_t size,
File renamed without changes.
12 changes: 9 additions & 3 deletions tests/unit/test-common.h → tests/unit/test-common.hpp
Original file line number Diff line number Diff line change
@@ -5,14 +5,18 @@
#ifndef TEST_COMMON_H_
#define TEST_COMMON_H_

#include "config.h"

#include <stdarg.h>
#include <stdio.h>

#include "nccl_ofi.h"
#include "nccl_ofi_log.h"

static inline void logger(ncclDebugLogLevel level, unsigned long flags, const char *filefunc,
int line, const char *fmt, ...)
namespace {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this function is static, why is a namespace needed?


void logger(ncclDebugLogLevel level, unsigned long flags, const char *filefunc,
int line, const char *fmt, ...)
{
va_list vargs;

@@ -24,7 +28,7 @@ static inline void logger(ncclDebugLogLevel level, unsigned long flags, const ch
printf("INFO: Function: %s Line: %d: ", filefunc, line);
break;
case NCCL_LOG_TRACE:
#if OFI_NCCL_TRACE
#if defined(OFI_NCCL_TRACE) && OFI_NCCL_TRACE
printf("TRACE: Function: %s Line: %d: ", filefunc, line);
break;
#else
@@ -40,4 +44,6 @@ static inline void logger(ncclDebugLogLevel level, unsigned long flags, const ch
va_end(vargs);
}

}

#endif // End TEST_COMMON_H_