Skip to content
Snippets Groups Projects
Commit 56494c05 authored by Sonja Happ's avatar Sonja Happ
Browse files

vendor/test/impls: Add session_malleable test.

Add a simple test for the malleable parameter of MPI sessions.
The test will construct and destruct a PMIx Process Group for all
processes in the background.
parent 2e4054c5
No related branches found
No related tags found
No related merge requests found
......@@ -10,4 +10,4 @@ EXTRA_DIST = testlist
## for all programs that are just built from the single corresponding source
## file, we don't need per-target _SOURCES rules, automake will infer them
## correctly
noinst_PROGRAMS = session_strict_finalize
noinst_PROGRAMS = session_strict_finalize session_malleable
/*
* ParaStation
*
* Copyright (C) 2023 ParTec AG, Munich
*
* This file may be distributed under the terms of the Q Public License
* as defined in the file LICENSE.QPL included in the packaging of this
* file.
*/
#include <stdio.h>
#include "mpi.h"
#include "mpitest.h"
/* Test for malleable parameter of MPI Sessions */
/* Macro for MPI error handling */
#define CHECK_MPI_ERR(mpi_errno) \
if (mpi_errno != MPI_SUCCESS) { \
errs++; \
char errstr[MPI_MAX_ERROR_STRING]; \
int len = 0; \
MPI_Error_string(rc, errstr, &len); \
fprintf(stderr, "%s\n", errstr); \
goto fn_fail; \
}
bool is_pmix_4_2_4_err(int mpi_errno)
{
char err_str[MPI_MAX_ERROR_STRING];
const char *version_str = "requires PMIx 4.2.4";
int strlen = MPI_MAX_ERROR_STRING;
MPI_Error_string(mpi_errno, err_str, &strlen);
if (strstr(err_str, version_str) != NULL) {
return true;
} else {
return false;
}
}
/* Get the world rank to be able to exit gracefully in case of PMIx version issue */
int get_rank(void)
{
int rank = 0;
MPI_Session s = MPI_SESSION_NULL;
MPI_Group g = MPI_GROUP_NULL;
MPI_Comm c = MPI_COMM_NULL;
MPI_Session_init(MPI_INFO_NULL, MPI_ERRORS_ARE_FATAL, &s);
MPI_Session_set_errhandler(s, MPI_ERRORS_ARE_FATAL);
MPI_Group_from_session_pset(s, "mpi://WORLD", &g);
MPI_Comm_create_from_group(g, "org.mpi-forum.mpi-v4_0.example-ex10_8",
MPI_INFO_NULL, MPI_ERRORS_ARE_FATAL, &c);
MPI_Comm_rank(c, &rank);
MPI_Comm_free(&c);
MPI_Group_free(&g);
MPI_Session_finalize(&s);
return rank;
}
int main(int argc, char *argv[])
{
int rc;
int errs = 0;
int rank = get_rank();
int size = 0;
MPI_Session shandle = MPI_SESSION_NULL;
MPI_Info sinfo = MPI_INFO_NULL;
MPI_Group ghandle = MPI_GROUP_NULL;
MPI_Comm commhandle = MPI_COMM_NULL;
MPI_Info_create(&sinfo);
MPI_Info_set(sinfo, "malleable", "1");
rc = MPI_Session_init(sinfo, MPI_ERRORS_RETURN, &shandle);
MPI_Info_free(&sinfo);
if (is_pmix_4_2_4_err(rc)) {
/* Exit gracefully, malleable sessions need PMIx 4.2.4 or higher */
goto fn_exit;
}
CHECK_MPI_ERR(rc);
rc = MPI_Session_set_errhandler(shandle, MPI_ERRORS_RETURN);
CHECK_MPI_ERR(rc);
rc = MPI_Group_from_session_pset(shandle, "mpi://WORLD", &ghandle);
CHECK_MPI_ERR(rc);
rc = MPI_Comm_create_from_group(ghandle, "org.mpi-forum.mpi-v4_0.example-ex10_8",
MPI_INFO_NULL, MPI_ERRORS_RETURN, &commhandle);
CHECK_MPI_ERR(rc);
MPI_Comm_rank(commhandle, &rank);
MPI_Comm_size(commhandle, &size);
int sum;
MPI_Reduce(&rank, &sum, 1, MPI_INT, MPI_SUM, 0, commhandle);
if (rank == 0) {
if (sum != (size - 1) * size / 2) {
fprintf(stderr, "MPI_Reduce: expect %d, got %d\n", (size - 1) * size / 2, sum);
errs++;
}
}
MPI_Group_free(&ghandle);
MPI_Comm_free(&commhandle);
rc = MPI_Session_finalize(&shandle);
CHECK_MPI_ERR(rc);
fn_exit:
if (ghandle != MPI_GROUP_NULL) {
MPI_Group_free(&ghandle);
}
if (commhandle != MPI_COMM_NULL) {
MPI_Comm_free(&commhandle);
}
if (rank == 0) {
if (errs == 0) {
fprintf(stdout, " No Errors\n");
} else {
fprintf(stderr, "%d Errors\n", errs);
}
}
return MTestReturnValue(errs);
fn_fail:
goto fn_exit;
}
session_strict_finalize 1
session_strict_finalize 4
session_malleable 1
session_malleable 4
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment