|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
* (C) 2001 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
/* Test of info that makes use of the extended handles, including
|
|
Packit Service |
c5cf8c |
inserts and deletes */
|
|
Packit Service |
c5cf8c |
#include "mpi.h"
|
|
Packit Service |
c5cf8c |
#include <stdio.h>
|
|
Packit Service |
c5cf8c |
#include <stdlib.h>
|
|
Packit Service |
c5cf8c |
#include "mpitest.h"
|
|
Packit Service |
c5cf8c |
#include "mpitestconf.h"
|
|
Packit Service |
c5cf8c |
#ifdef HAVE_STRING_H
|
|
Packit Service |
c5cf8c |
#include <string.h>
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#ifndef MAX_INFOS
|
|
Packit Service |
c5cf8c |
#define MAX_INFOS 4000
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
#define MAX_ERRORS 10
|
|
Packit Service |
c5cf8c |
#define info_list 16
|
|
Packit Service |
c5cf8c |
/* #define DBG */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#ifdef DEBUG
|
|
Packit Service |
c5cf8c |
#define DBGPRINTF(a) printf a; fflush(stdout)
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
#define DBGPRINTF(a)
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
int main(int argc, char *argv[])
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPI_Info infos[MAX_INFOS];
|
|
Packit Service |
c5cf8c |
char key[64], value[64];
|
|
Packit Service |
c5cf8c |
int errs = 0;
|
|
Packit Service |
c5cf8c |
int i, j;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Init(&argc, &argv);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* We create max_info items, then delete the middle third of them,
|
|
Packit Service |
c5cf8c |
* then recreate them, then check them, then
|
|
Packit Service |
c5cf8c |
* delete them all. This checks that the MPICH algorithm for
|
|
Packit Service |
c5cf8c |
* handling large numbers of items works correctly; other MPI
|
|
Packit Service |
c5cf8c |
* implementations should also be able to handle this */
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Create them all */
|
|
Packit Service |
c5cf8c |
for (i = 0; i < MAX_INFOS; i++) {
|
|
Packit Service |
c5cf8c |
MPI_Info_create(&infos[i]);
|
|
Packit Service |
c5cf8c |
DBGPRINTF(("Info handle is %x\n", infos[i]));
|
|
Packit Service |
c5cf8c |
for (j = 0; j < info_list; j++) {
|
|
Packit Service |
c5cf8c |
sprintf(key, "key%d-%d", i, j);
|
|
Packit Service |
c5cf8c |
sprintf(value, "value%d-%d", i, j);
|
|
Packit Service |
c5cf8c |
DBGPRINTF(("Creating key/value %s=%s\n", key, value));
|
|
Packit Service |
c5cf8c |
MPI_Info_set(infos[i], key, value);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#ifdef DBG
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int nkeys;
|
|
Packit Service |
c5cf8c |
MPI_Info_get_nkeys(infos[0], &nkeys);
|
|
Packit Service |
c5cf8c |
if (nkeys != info_list) {
|
|
Packit Service |
c5cf8c |
printf("infos[0] changed at %d info\n", i);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#endif
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Delete the middle set */
|
|
Packit Service |
c5cf8c |
for (i = MAX_INFOS / 3; i < (2 * MAX_INFOS / 3); i++) {
|
|
Packit Service |
c5cf8c |
MPI_Info_free(&infos[i]);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Recreate the middle set */
|
|
Packit Service |
c5cf8c |
for (i = MAX_INFOS / 3; i < (2 * MAX_INFOS / 3); i++) {
|
|
Packit Service |
c5cf8c |
MPI_Info_create(&infos[i]);
|
|
Packit Service |
c5cf8c |
DBGPRINTF(("Info handle is %x\n", infos[i]));
|
|
Packit Service |
c5cf8c |
for (j = 0; j < info_list; j++) {
|
|
Packit Service |
c5cf8c |
sprintf(key, "key%d-%d", i, j);
|
|
Packit Service |
c5cf8c |
sprintf(value, "value%d-%d", i, j);
|
|
Packit Service |
c5cf8c |
DBGPRINTF(("Creating key/value %s=%s\n", key, value));
|
|
Packit Service |
c5cf8c |
MPI_Info_set(infos[i], key, value);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* Now, check that they are still valid */
|
|
Packit Service |
c5cf8c |
for (i = 0; i < MAX_INFOS; i++) {
|
|
Packit Service |
c5cf8c |
int nkeys;
|
|
Packit Service |
c5cf8c |
/*printf("info = %x\n", infos[i]);
|
|
Packit Service |
c5cf8c |
* print_handle(infos[i]); printf("\n"); */
|
|
Packit Service |
c5cf8c |
MPI_Info_get_nkeys(infos[i], &nkeys);
|
|
Packit Service |
c5cf8c |
if (nkeys != info_list) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
if (errs < MAX_ERRORS) {
|
|
Packit Service |
c5cf8c |
printf("Wrong number of keys for info %d; got %d, should be %d\n",
|
|
Packit Service |
c5cf8c |
i, nkeys, info_list);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
for (j = 0; j < nkeys; j++) {
|
|
Packit Service |
c5cf8c |
char keystr[64];
|
|
Packit Service |
c5cf8c |
char valstr[64];
|
|
Packit Service |
c5cf8c |
int flag;
|
|
Packit Service |
c5cf8c |
MPI_Info_get_nthkey(infos[i], j, key);
|
|
Packit Service |
c5cf8c |
sprintf(keystr, "key%d-%d", i, j);
|
|
Packit Service |
c5cf8c |
if (strcmp(keystr, key) != 0) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
if (errs < MAX_ERRORS) {
|
|
Packit Service |
c5cf8c |
printf("Wrong key for info %d; got %s expected %s\n", i, key, keystr);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
continue;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPI_Info_get(infos[i], key, 64, value, &flag;;
|
|
Packit Service |
c5cf8c |
if (!flag) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
if (errs < MAX_ERRORS) {
|
|
Packit Service |
c5cf8c |
printf("Get failed to return value for info %d\n", i);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
continue;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
sprintf(valstr, "value%d-%d", i, j);
|
|
Packit Service |
c5cf8c |
if (strcmp(valstr, value) != 0) {
|
|
Packit Service |
c5cf8c |
errs++;
|
|
Packit Service |
c5cf8c |
if (errs < MAX_ERRORS) {
|
|
Packit Service |
c5cf8c |
printf("Wrong value for info %d; got %s expected %s\n", i, value, valstr);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
for (i = 0; i < MAX_INFOS; i++) {
|
|
Packit Service |
c5cf8c |
MPI_Info_free(&infos[i]);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MTest_Finalize(errs);
|
|
Packit Service |
c5cf8c |
return MTestReturnValue(errs);
|
|
Packit Service |
c5cf8c |
}
|