Skip to content

Commit

Permalink
Start testing qvi_scope_ksplit().
Browse files Browse the repository at this point in the history
Signed-off-by: Samuel K. Gutierrez <samuel@lanl.gov>
  • Loading branch information
samuelkgutierrez committed Apr 19, 2024
1 parent 37931e3 commit 38568fe
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 3 deletions.
13 changes: 13 additions & 0 deletions src/qvi-scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,19 @@ qvi_scope_split(
qv_scope_t **child
);

/**
*
*/
int
qvi_scope_ksplit(
qv_scope_t *parent,
int npieces,
int *colors,
uint_t k,
qv_hw_obj_type_t maybe_obj_type,
qv_scope_t ***kchildren
);

/**
*
*/
Expand Down
12 changes: 12 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,17 @@ 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
Expand Down Expand Up @@ -365,6 +376,7 @@ 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
Expand Down
139 changes: 139 additions & 0 deletions tests/test-mpi-scope-ksplit.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/* -*- Mode: C; c-basic-offset:4; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2020-2024 Triad 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-scope-ksplit.cc
*/

#include "mpi.h"
#include "quo-vadis-mpi.h"
#include "qvi-scope.h"
#include "qvi-test-common.h"
#include <numeric>

int
main(void)
{
char const *ers = NULL;
MPI_Comm comm = MPI_COMM_WORLD;

/* Initialization */
int rc = MPI_Init(nullptr, nullptr);
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);
}

int wrank;
rc = MPI_Comm_rank(comm, &wrank);
if (rc != MPI_SUCCESS) {
ers = "MPI_Comm_rank() failed";
qvi_test_panic("%s (rc=%d)", ers, rc);
}

setbuf(stdout, NULL);

qv_context_t *ctx;
rc = qv_mpi_context_create(comm, &ctx);
if (rc != QV_SUCCESS) {
ers = "qv_mpi_context_create() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
}

qv_scope_t *base_scope;
rc = qv_scope_get(
ctx,
QV_SCOPE_USER,
&base_scope
);
if (rc != QV_SUCCESS) {
ers = "qv_scope_get() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
}

qvi_test_bind_push(
ctx, base_scope
);
qvi_test_bind_pop(
ctx, base_scope
);

int ncores;
rc = qv_scope_nobjs(
ctx, base_scope, QV_HW_OBJ_CORE, &ncores
);
if (rc != QV_SUCCESS) {
ers = "qv_scope_nobjs() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
}

// Test internal APIs
const int npieces = ncores / 2;
std::vector<int> colors(npieces);
std::iota(colors.begin(), colors.end(), 0);

qv_scope_t **subscopes = nullptr;
rc = qvi_scope_ksplit(
base_scope, npieces, colors.data(),
colors.size(), QV_HW_OBJ_MACHINE, &subscopes
);
if (rc != QV_SUCCESS) {
ers = "qvi_scope_ksplit() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
}

for (uint_t i = 0; i < colors.size(); ++i) {
qvi_test_scope_report(
ctx, subscopes[i], std::to_string(i).c_str()
);
qvi_test_bind_push(
ctx, subscopes[i]
);
qvi_test_bind_pop(
ctx, subscopes[i]
);
}

for (uint_t i = 0; i < colors.size(); ++i) {
rc = qv_scope_free(ctx, subscopes[i]);
if (rc != QV_SUCCESS) {
ers = "qv_scope_free() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
}
}
// TODO(skg) This isn't nice, fix by adding to internal API.
free(subscopes);

rc = qv_scope_free(ctx, base_scope);
if (rc != QV_SUCCESS) {
ers = "qv_scope_free() failed";
qvi_test_panic("%s (rc=%s)", ers, qv_strerr(rc));
}

rc = qv_mpi_context_free(ctx);
if (rc != QV_SUCCESS) {
ers = "qv_mpi_context_free() failed";
qvi_test_panic("%s", ers);
}

MPI_Finalize();

return EXIT_SUCCESS;
}

/*
* vim: ft=cpp ts=4 sts=4 sw=4 expandtab
*/
5 changes: 2 additions & 3 deletions tests/test-rmi.cc
Original file line number Diff line number Diff line change
@@ -1,6 +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
Expand All @@ -19,7 +19,6 @@
#include "qvi-utils.h"
#include "qvi-hwloc.h"
#include "qvi-rmi.h"
#include "qvi-test-common.h"

static int
server(
Expand Down Expand Up @@ -115,7 +114,7 @@ client(
printf("# [%d] Starting Client (%s)\n", getpid(), url);

char const *ers = NULL;
qvi_task_id_t who = { QV_TASK_TYPE_PROCESS, getpid()};
qvi_task_id_t who = { QV_TASK_TYPE_PROCESS, getpid() };
hwloc_bitmap_t bitmap = NULL;

qvi_rmi_client_t *client = NULL;
Expand Down

0 comments on commit 38568fe

Please sign in to comment.