diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f59ea3c..3359cf12 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,4 @@ +# -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- # # Copyright (c) 2020-2024 Triad National Security, LLC # All rights reserved. @@ -191,6 +192,7 @@ add_subdirectory(src) add_subdirectory(src/fortran) # Conditionally add test source if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING) + add_subdirectory(tests/internal) add_subdirectory(tests) endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 77f855e9..26b2a194 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,4 @@ +# -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- # # Copyright (c) 2020-2024 Triad National Security, LLC # All rights reserved. diff --git a/src/fortran/CMakeLists.txt b/src/fortran/CMakeLists.txt index 46d08399..25d82280 100644 --- a/src/fortran/CMakeLists.txt +++ b/src/fortran/CMakeLists.txt @@ -1,5 +1,6 @@ +# -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- # -# Copyright (c) 2020-2022 Triad National Security, LLC +# Copyright (c) 2020-2024 Triad National Security, LLC # All rights reserved. # # Copyright (c) 2020-2021 Lawrence Livermore National Security, LLC diff --git a/src/qvi-macros.h b/src/qvi-macros.h index 82214a07..07568f74 100644 --- a/src/qvi-macros.h +++ b/src/qvi-macros.h @@ -1,6 +1,6 @@ /* -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- */ /* - * Copyright (c) 2020-2021 Triad National Security, LLC + * Copyright (c) 2020-2024 Triad National Security, LLC * All rights reserved. * * Copyright (c) 2020-2021 Lawrence Livermore National Security, LLC diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 2ff03931..ed648f53 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,5 +1,6 @@ +# -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- # -# Copyright (c) 2020-2023 Triad National Security, LLC +# Copyright (c) 2020-2024 Triad National Security, LLC # All rights reserved. # # Copyright (c) 2020-2021 Lawrence Livermore National Security, LLC @@ -9,75 +10,10 @@ # top-level directory of this distribution. # -# TODO(skg) Add valgrind tests. -################################################################################ -################################################################################ -add_executable( - test-hwloc - qvi-test-common.h - test-hwloc.c -) - -target_link_libraries( - test-hwloc - quo-vadis -) - -add_test( - hwloc - test-hwloc -) - -################################################################################ -################################################################################ -add_executable( - test-rmi-server - test-rmi-server.cc -) - -target_link_libraries( - test-rmi-server - quo-vadis -) - -add_test( - NAME - rmi-server - COMMAND - bash -c "export URL=\"tcp://127.0.0.1:55995\" && \ - ${CMAKE_CURRENT_BINARY_DIR}/test-rmi-server $URL" -) - -################################################################################ -################################################################################ -add_executable( - test-rmi - test-rmi.cc -) - -target_link_libraries( - test-rmi - quo-vadis -) - -add_test( - NAME - rmi - COMMAND - bash -c "export URL=\"tcp://127.0.0.1:55995\" && \ - ( ${CMAKE_SOURCE_DIR}/tests/exec-timeout.sh \ - \"${CMAKE_CURRENT_BINARY_DIR}/test-rmi $URL -s\" 5 & ) && \ - ( ${CMAKE_CURRENT_BINARY_DIR}/test-rmi $URL -c & ) && \ - ( ${CMAKE_CURRENT_BINARY_DIR}/test-rmi $URL -c & ) && \ - ( ${CMAKE_CURRENT_BINARY_DIR}/test-rmi $URL -c & ) && \ - ${CMAKE_CURRENT_BINARY_DIR}/test-rmi $URL -c" -) - ################################################################################ ################################################################################ add_executable( test-process-scopes - qvi-test-common.h test-process-scopes.c ) @@ -95,6 +31,12 @@ add_test( ${CMAKE_CURRENT_BINARY_DIR}/test-process-scopes" ) +# Use the C linker to test for C/C++ linkage problems. +set_target_properties( + test-process-scopes + PROPERTIES LINKER_LANGUAGE C +) + ################################################################################ ################################################################################ if (OPENMP_FOUND) @@ -119,6 +61,12 @@ if (OPENMP_FOUND) OpenMP::OpenMP_C ) + set_target_properties( + test-threads + test-openmp + PROPERTIES LINKER_LANGUAGE C + ) + add_test( NAME threads @@ -141,20 +89,8 @@ endif() ################################################################################ ################################################################################ if(MPI_FOUND) - add_executable( - test-mpi - qvi-test-common.h - test-mpi.c - ) - - target_link_libraries( - test-mpi - quo-vadis-mpi - ) - add_executable( test-mpi-init - qvi-test-common.h test-mpi-init.c ) @@ -165,7 +101,6 @@ if(MPI_FOUND) add_executable( test-mpi-api - qvi-test-common.h test-mpi-api.c ) @@ -176,7 +111,6 @@ if(MPI_FOUND) add_executable( test-mpi-scopes - qvi-test-common.h test-mpi-scopes.c ) @@ -187,7 +121,6 @@ if(MPI_FOUND) add_executable( test-mpi-scopes-affinity-preserving - qvi-test-common.h test-mpi-scopes-affinity-preserving.c ) @@ -198,7 +131,6 @@ if(MPI_FOUND) add_executable( test-mpi-phases - qvi-test-common.h test-mpi-phases.c ) @@ -209,19 +141,17 @@ if(MPI_FOUND) add_executable( test-progress-thread - qvi-test-common.h test-progress-thread.c ) target_link_libraries( test-progress-thread - quo-vadis + quo-vadis quo-vadis-mpi ) add_executable( test-mpi-scope-create - qvi-test-common.h test-mpi-scope-create.c ) @@ -230,20 +160,8 @@ if(MPI_FOUND) quo-vadis-mpi ) - add_executable( - test-mpi-scope-ksplit - qvi-test-common.h - test-mpi-scope-ksplit.cc - ) - - target_link_libraries( - test-mpi-scope-ksplit - quo-vadis-mpi - ) - add_executable( test-mpi-getdev - qvi-test-common.h test-mpi-getdev.c ) @@ -252,6 +170,20 @@ if(MPI_FOUND) quo-vadis-mpi ) + # Use the C linker to test for C/C++ linkage problems. + set_target_properties( + test-mpi-init + test-mpi-api + test-mpi-scopes + test-mpi-scopes-affinity-preserving + test-mpi-phases + test-progress-thread + test-mpi-scope-create + test-mpi-getdev + #test-mpi-pthreads-layout + PROPERTIES LINKER_LANGUAGE C + ) + # TODO(skg) Automate adding MPI tests. add_test( NAME @@ -277,7 +209,6 @@ if(MPI_FOUND) ################################################################################ #add_executable( #test-mpi-pthreads-layout - #qvi-test-common.h #test-mpi-pthreads-layout.c #) @@ -293,7 +224,6 @@ if(MPI_FOUND) if(OPENMP_FOUND) add_executable( test-mpi-threads - qvi-test-common.h test-mpi-threads.c ) @@ -306,7 +236,6 @@ if(MPI_FOUND) #add_executable( # test-mpi-threads-layout - # qvi-test-common.h # test-mpi-threads-layout.c #) @@ -318,6 +247,11 @@ if(MPI_FOUND) # OpenMP::OpenMP_C #) + set_target_properties( + test-mpi-threads + #test-mpi-threads-layout + PROPERTIES LINKER_LANGUAGE C + ) endif() endif() @@ -373,47 +307,4 @@ if(QV_FORTRAN_HAPPY) endif() endif() -################################################################################ -################################################################################ -# Use the C linker to test for C/C++ linkage problems. -# TODO(skg) Add other C programs below. -set_target_properties( - test-hwloc - PROPERTIES LINKER_LANGUAGE C -) - -if(MPI_FOUND) - set_target_properties( - test-mpi - test-mpi-init - test-mpi-api - test-mpi-getdev - test-mpi-scopes - #test-mpi-pthreads-layout - PROPERTIES LINKER_LANGUAGE C - ) - - if (OPENMP_FOUND) - set_target_properties( - test-mpi-threads - PROPERTIES LINKER_LANGUAGE C - ) - #set_target_properties( - # test-mpi-threads-layout - # PROPERTIES LINKER_LANGUAGE C - #) - endif() -endif() - -# Set core test properties. -# TODO(skg) Add rmi and process-scopes -set_tests_properties( - hwloc - rmi-server - rmi - PROPERTIES - TIMEOUT 60 - LABELS "core" -) - # vim: ts=4 sts=4 sw=4 expandtab diff --git a/tests/internal/CMakeLists.txt b/tests/internal/CMakeLists.txt new file mode 100644 index 00000000..98c2eae6 --- /dev/null +++ b/tests/internal/CMakeLists.txt @@ -0,0 +1,109 @@ +# -*- Mode: C++; c-basic-offset:4; indent-tabs-mode:nil -*- +# +# Copyright (c) 2020-2024 Triad National Security, LLC +# All rights reserved. +# +# Copyright (c) 2020-2021 Lawrence Livermore National Security, LLC +# All rights reserved. +# +# This file is part of the quo-vadis project. See the LICENSE file at the +# top-level directory of this distribution. +# + +include_directories( + $ +) + +################################################################################ +################################################################################ +add_executable( + test-hwloc + test-hwloc.c +) + +target_link_libraries( + test-hwloc + quo-vadis +) + +add_test( + hwloc + test-hwloc +) + +################################################################################ +################################################################################ +add_executable( + test-rmi-server + test-rmi-server.cc +) + +target_link_libraries( + test-rmi-server + quo-vadis +) + +add_test( + NAME + rmi-server + COMMAND + bash -c "export URL=\"tcp://127.0.0.1:55995\" && \ + ${CMAKE_CURRENT_BINARY_DIR}/test-rmi-server $URL" +) + +################################################################################ +################################################################################ +add_executable( + test-rmi + test-rmi.cc +) + +target_link_libraries( + test-rmi + quo-vadis +) + +add_test( + NAME + rmi + COMMAND + bash -c "export URL=\"tcp://127.0.0.1:55995\" && \ + ( ${CMAKE_SOURCE_DIR}/tests/exec-timeout.sh \ + \"${CMAKE_CURRENT_BINARY_DIR}/test-rmi $URL -s\" 5 & ) && \ + ( ${CMAKE_CURRENT_BINARY_DIR}/test-rmi $URL -c & ) && \ + ( ${CMAKE_CURRENT_BINARY_DIR}/test-rmi $URL -c & ) && \ + ( ${CMAKE_CURRENT_BINARY_DIR}/test-rmi $URL -c & ) && \ + ${CMAKE_CURRENT_BINARY_DIR}/test-rmi $URL -c" +) + +# Use the C linker to test for C/C++ linkage problems. +set_target_properties( + test-hwloc + PROPERTIES LINKER_LANGUAGE C +) + +################################################################################ +################################################################################ +if(MPI_FOUND) + add_executable( + test-mpi-scope-ksplit + test-mpi-scope-ksplit.cc + ) + + target_link_libraries( + test-mpi-scope-ksplit + quo-vadis-mpi + ) +endif() + +# Set core test properties. +set_tests_properties( + hwloc + rmi-server + rmi + PROPERTIES + TIMEOUT 60 + LABELS "core" +) + +# vim: ts=4 sts=4 sw=4 expandtab diff --git a/tests/test-hwloc.c b/tests/internal/test-hwloc.c similarity index 100% rename from tests/test-hwloc.c rename to tests/internal/test-hwloc.c diff --git a/tests/test-mpi-scope-ksplit.cc b/tests/internal/test-mpi-scope-ksplit.cc similarity index 100% rename from tests/test-mpi-scope-ksplit.cc rename to tests/internal/test-mpi-scope-ksplit.cc diff --git a/tests/test-rmi-server.cc b/tests/internal/test-rmi-server.cc similarity index 100% rename from tests/test-rmi-server.cc rename to tests/internal/test-rmi-server.cc diff --git a/tests/test-rmi.cc b/tests/internal/test-rmi.cc similarity index 100% rename from tests/test-rmi.cc rename to tests/internal/test-rmi.cc diff --git a/tests/test-mpi.c b/tests/test-mpi.c deleted file mode 100644 index 74384e6d..00000000 --- a/tests/test-mpi.c +++ /dev/null @@ -1,147 +0,0 @@ -/* -*- Mode: C; c-basic-offset:4; indent-tabs-mode:nil -*- */ -/* - * Copyright (c) 2020-2023 Triad National Security, LLC - * All rights reserved. - * - * Copyright (c) 2020-2021 Lawrence Livermore National Security, LLC - * All rights reserved. - * - * This file is part of the quo-vadis project. See the LICENSE file at the - * top-level directory of this distribution. - */ - -/** - * @file test-mpi.c - */ - -#include "qvi-task.h" -#include "qvi-mpi.h" -#include "qvi-utils.h" - -#include "quo-vadis.h" -#include "qvi-test-common.h" - -int -main( - int argc, - char **argv -) { - char const *ers = NULL; - int *evens = NULL; - - MPI_Comm comm = MPI_COMM_WORLD; - - int rc = MPI_Init(&argc, &argv); - if (rc != MPI_SUCCESS) { - ers = "MPI_Init() failed"; - qvi_test_panic("%s (rc=%d)", ers, rc); - } - - int wsize; - rc = MPI_Comm_size(comm, &wsize); - if (rc != MPI_SUCCESS) { - ers = "MPI_Comm_size() failed"; - qvi_test_panic("%s (rc=%d)", ers, rc); - } - - qvi_mpi_t *mpi = NULL; - rc = qvi_mpi_new(&mpi); - if (rc != QV_SUCCESS) { - ers = "qvi_mpi_new() failed"; - qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc)); - } - - rc = qvi_mpi_init(mpi, comm); - if (rc != QV_SUCCESS) { - ers = "qvi_mpi_init() failed"; - qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc)); - } - - qvi_mpi_group_t *node_group; - rc = qvi_mpi_group_new(&node_group); - if (rc != QV_SUCCESS) { - ers = "qvi_mpi_group_new() failed"; - qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc)); - } - - rc = qvi_mpi_group_lookup_by_id(mpi, QVI_MPI_GROUP_NODE, node_group); - if (rc != QV_SUCCESS) { - ers = "qvi_mpi_group_lookup_by_id() failed"; - qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc)); - } - - int nsize = qvi_mpi_group_size(node_group); - int group_id = qvi_mpi_group_id(node_group); - - qvi_task_t *task = qvi_mpi_task_get(mpi); - int64_t task_gid = qvi_task_gid(task); - int task_lid = qvi_task_lid(task); - - printf( - "Hello from %s gid=%" PRId64 - " (lid=%d, nsize=%d, node_gid=%d) of wsize=%d\n", - qvi_task_type(task) == QV_TASK_TYPE_PROCESS ? "process" : "thread", - task_gid, task_lid, nsize, group_id, wsize - ); - - qvi_mpi_group_t *node_even_group = NULL; - const int n_evens = (wsize + 1) / 2; - evens = calloc(n_evens, sizeof(*evens)); - if (!evens) { - ers = "calloc() failed"; - qvi_test_panic("%s", ers); - } - - for (int r = 0, i = 0; r < wsize; ++r) { - if (r % 2 == 0) evens[i++] = r; - } - - rc = qvi_mpi_group_create_from_ids( - mpi, node_group, n_evens, evens, &node_even_group - ); - if (rc != QV_SUCCESS) { - ers = "qvi_mpi_group_create_from_ids() failed"; - qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc)); - } - - if (node_even_group) { - printf( - "GID=%" PRId64 " Task %d says hello from node even group!\n", - task_gid, task_lid - ); - } - - qvi_mpi_group_t *world_group; - rc = qvi_mpi_group_create_from_mpi_comm(mpi, comm, &world_group); - if (rc != QV_SUCCESS) { - ers = "qvi_mpi_group_create_from_mpi_comm() failed"; - qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc)); - } - - int world_group_id = qvi_mpi_group_id(world_group); - int world_group_size = qvi_mpi_group_size(world_group); - printf( - "GID=%" PRId64 " World group task %d of %d says hello!\n", - task_gid, world_group_id, world_group_size - ); - - rc = qvi_mpi_finalize(mpi); - if (rc != QV_SUCCESS) { - ers = "qvi_mpi_finalize() failed"; - qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc)); - } - - qvi_mpi_group_free(&node_even_group); - qvi_mpi_group_free(&node_group); - qvi_mpi_group_free(&world_group); - qvi_mpi_free(&mpi); - if (evens) free(evens); - - MPI_Finalize(); - - return EXIT_SUCCESS; -} - -/* - * vim: ft=cpp ts=4 sts=4 sw=4 expandtab - */