|
Packit |
0848f5 |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit |
0848f5 |
/*
|
|
Packit |
0848f5 |
* (C) 2015 by Argonne National Laboratory.
|
|
Packit |
0848f5 |
* See COPYRIGHT in top-level directory.
|
|
Packit |
0848f5 |
*/
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* Test MPI_T_xxx_get_index() for cvars, pvars and categories.
|
|
Packit |
0848f5 |
*/
|
|
Packit |
0848f5 |
#include <stdio.h>
|
|
Packit |
0848f5 |
#include "mpi.h"
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
static int verbose = 0;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
int main(int argc, char *argv[])
|
|
Packit |
0848f5 |
{
|
|
Packit |
0848f5 |
int i;
|
|
Packit |
0848f5 |
int required, provided, namelen;
|
|
Packit |
0848f5 |
int num_cvar, num_pvar, num_cat;
|
|
Packit |
0848f5 |
int cvar_index, pvar_index, cat_index;
|
|
Packit |
0848f5 |
int pvar_class;
|
|
Packit |
0848f5 |
char name[128];
|
|
Packit |
0848f5 |
int errno, errs = 0;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
required = MPI_THREAD_SINGLE;
|
|
Packit |
0848f5 |
MPI_T_init_thread(required, &provided);
|
|
Packit |
0848f5 |
MPI_Init(&argc, &argv);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* Test MPI_T_cvar_get_index with both valid and bogus names */
|
|
Packit |
0848f5 |
MPI_T_cvar_get_num(&num_cvar);
|
|
Packit |
0848f5 |
if (verbose)
|
|
Packit |
0848f5 |
fprintf(stdout, "%d MPI Control Variables\n", num_cvar);
|
|
Packit |
0848f5 |
for (i = 0; i < num_cvar; i++) {
|
|
Packit |
0848f5 |
namelen = sizeof(name);
|
|
Packit |
0848f5 |
MPI_T_cvar_get_info(i, name, &namelen, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
|
|
Packit |
0848f5 |
if (namelen <= 128) {
|
|
Packit |
0848f5 |
errno = MPI_T_cvar_get_index(name, &cvar_index);
|
|
Packit |
0848f5 |
if (errno != MPI_SUCCESS || cvar_index != i)
|
|
Packit |
0848f5 |
errs++;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
errno = MPI_T_cvar_get_index("AN INVALID CVAR NAME FOR TEST", &cvar_index);
|
|
Packit |
0848f5 |
if (errno != MPI_T_ERR_INVALID_NAME)
|
|
Packit |
0848f5 |
errs++;
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
if (errs)
|
|
Packit |
0848f5 |
fprintf(stdout, "Errors found in MPI_T_cvar_get_index\n");
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* Test MPI_T_pvar_get_index with both valid and bogus names */
|
|
Packit |
0848f5 |
MPI_T_pvar_get_num(&num_pvar);
|
|
Packit |
0848f5 |
if (verbose)
|
|
Packit |
0848f5 |
fprintf(stdout, "%d MPI Performance Variables\n", num_pvar);
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
for (i = 0; i < num_pvar; i++) {
|
|
Packit |
0848f5 |
namelen = sizeof(name);
|
|
Packit |
0848f5 |
MPI_T_pvar_get_info(i, name, &namelen, NULL, &pvar_class, NULL, NULL, NULL,
|
|
Packit |
0848f5 |
NULL, NULL, NULL, NULL, NULL);
|
|
Packit |
0848f5 |
if (namelen <= 128) {
|
|
Packit |
0848f5 |
errno = MPI_T_pvar_get_index(name, pvar_class, &pvar_index);
|
|
Packit |
0848f5 |
if (errno != MPI_SUCCESS || pvar_index != i)
|
|
Packit |
0848f5 |
errs++;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
errno =
|
|
Packit |
0848f5 |
MPI_T_pvar_get_index("AN INVALID PVAR NAME FOR TEST", MPI_T_PVAR_CLASS_COUNTER,
|
|
Packit |
0848f5 |
&cvar_index);
|
|
Packit |
0848f5 |
if (errno != MPI_T_ERR_INVALID_NAME)
|
|
Packit |
0848f5 |
errs++;
|
|
Packit |
0848f5 |
if (errs)
|
|
Packit |
0848f5 |
fprintf(stdout, "Errors found in MPI_T_cvar_get_index\n");
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
/* Test MPI_T_category_get_index with both valid and bogus names */
|
|
Packit |
0848f5 |
MPI_T_category_get_num(&num_cat);
|
|
Packit |
0848f5 |
if (verbose)
|
|
Packit |
0848f5 |
fprintf(stdout, "%d MPI_T categories\n", num_cat);
|
|
Packit |
0848f5 |
for (i = 0; i < num_cat; i++) {
|
|
Packit |
0848f5 |
namelen = sizeof(name);
|
|
Packit |
0848f5 |
MPI_T_category_get_info(i, name, &namelen, NULL, NULL, NULL, NULL, NULL);
|
|
Packit |
0848f5 |
if (namelen <= 128) {
|
|
Packit |
0848f5 |
errno = MPI_T_category_get_index(name, &cat_index);
|
|
Packit |
0848f5 |
if (errno != MPI_SUCCESS || cat_index != i)
|
|
Packit |
0848f5 |
errs++;
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
}
|
|
Packit |
0848f5 |
errno = MPI_T_category_get_index("AN INVALID CATEGORY NAME FOR TEST", &cat_index);
|
|
Packit |
0848f5 |
if (errno != MPI_T_ERR_INVALID_NAME)
|
|
Packit |
0848f5 |
errs++;
|
|
Packit |
0848f5 |
if (errs)
|
|
Packit |
0848f5 |
fprintf(stdout, "Errors found in MPI_T_cvar_get_index\n");
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
MPI_T_finalize();
|
|
Packit |
0848f5 |
MPI_Finalize();
|
|
Packit |
0848f5 |
|
|
Packit |
0848f5 |
if (errs == 0)
|
|
Packit |
0848f5 |
fprintf(stdout, " No Errors\n");
|
|
Packit |
0848f5 |
return 0;
|
|
Packit |
0848f5 |
}
|