Skip to content

Commit

Permalink
tests: move to c++
Browse files Browse the repository at this point in the history
stack-info: PR: #568, branch: aws-nslick/stack/15
  • Loading branch information
aws-nslick committed Sep 4, 2024
1 parent f071592 commit e7c5e0c
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 31 deletions.
10 changes: 5 additions & 5 deletions tests/functional/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "config.h"

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

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

#include "config.h"

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

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

int main(int argc, char* argv[])
{
Expand Down Expand Up @@ -57,6 +58,7 @@ int main(int argc, char* argv[])
size_t 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;
Expand Down Expand Up @@ -133,7 +135,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++) {
Expand Down Expand Up @@ -398,7 +399,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;

Expand Down
2 changes: 1 addition & 1 deletion tests/functional/ring.c → tests/functional/ring.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "config.h"

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

#define PROC_NAME_IDX(i) (i * MPI_MAX_PROCESSOR_NAME)

Expand Down
File renamed without changes.
17 changes: 9 additions & 8 deletions tests/unit/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
Expand Up @@ -6,19 +6,18 @@

#include <stdio.h>

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

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;
Expand All @@ -27,7 +26,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);
Expand All @@ -51,7 +50,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);
}
Expand All @@ -62,7 +61,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);
}
Expand Down
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
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/freelist.c → tests/unit/freelist.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

#include <stdio.h>

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

void *simple_base;
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/idpool.c → tests/unit/idpool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/mr.c → tests/unit/mr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/msgbuff.c → tests/unit/msgbuff.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

#include "nccl_ofi_msgbuff.h"

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

int main(int argc, char *argv[])
{
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/scheduler.c → tests/unit/scheduler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions tests/unit/test-common.h → tests/unit/test-common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "nccl_ofi.h"
#include "nccl_ofi_log.h"

namespace {
static inline void logger(ncclDebugLogLevel level, unsigned long flags, const char *filefunc,
int line, const char *fmt, ...)
{
Expand Down Expand Up @@ -39,5 +40,6 @@ static inline void logger(ncclDebugLogLevel level, unsigned long flags, const ch
printf("\n");
va_end(vargs);
}
}

#endif // End TEST_COMMON_H_

0 comments on commit e7c5e0c

Please sign in to comment.