|
Packit Service |
c5cf8c |
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
|
|
Packit Service |
c5cf8c |
/*
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* (C) 2011 by Argonne National Laboratory.
|
|
Packit Service |
c5cf8c |
* See COPYRIGHT in top-level directory.
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* A simple test of the proposed MPI_T_ interface that queries all of
|
|
Packit Service |
c5cf8c |
* the control variables exposed by the MPI implememtation and prints
|
|
Packit Service |
c5cf8c |
* them to stdout.
|
|
Packit Service |
c5cf8c |
*
|
|
Packit Service |
c5cf8c |
* Author: Dave Goodell
|
|
Packit Service |
c5cf8c |
*/
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#include "mpi.h"
|
|
Packit Service |
c5cf8c |
#include <stdlib.h>
|
|
Packit Service |
c5cf8c |
#include <stdio.h>
|
|
Packit Service |
c5cf8c |
#include <assert.h>
|
|
Packit Service |
c5cf8c |
#include <math.h>
|
|
Packit Service |
c5cf8c |
#include "mpitestconf.h"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#if !defined(USE_STRICT_MPI) && defined(MPICH)
|
|
Packit Service |
c5cf8c |
int main(int argc, char **argv)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int i;
|
|
Packit Service |
c5cf8c |
int num;
|
|
Packit Service |
c5cf8c |
int rank, size;
|
|
Packit Service |
c5cf8c |
/*#define STR_SZ (15)*/
|
|
Packit Service |
c5cf8c |
#define STR_SZ (50)
|
|
Packit Service |
c5cf8c |
int name_len = STR_SZ;
|
|
Packit Service |
c5cf8c |
char name[STR_SZ] = "";
|
|
Packit Service |
c5cf8c |
int desc_len = STR_SZ;
|
|
Packit Service |
c5cf8c |
char desc[STR_SZ] = "";
|
|
Packit Service |
c5cf8c |
int verb;
|
|
Packit Service |
c5cf8c |
MPI_Datatype dtype;
|
|
Packit Service |
c5cf8c |
int count;
|
|
Packit Service |
c5cf8c |
int bind;
|
|
Packit Service |
c5cf8c |
int scope;
|
|
Packit Service |
c5cf8c |
int provided;
|
|
Packit Service |
c5cf8c |
int initialize_mpi = 0;
|
|
Packit Service |
c5cf8c |
MPI_T_cvar_handle handle;
|
|
Packit Service |
c5cf8c |
MPI_T_enum enumtype;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
provided = 0xdeadbeef;
|
|
Packit Service |
c5cf8c |
MPI_T_init_thread(MPI_THREAD_SINGLE, &provided);
|
|
Packit Service |
c5cf8c |
assert(provided != 0xdeadbeef);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (initialize_mpi) {
|
|
Packit Service |
c5cf8c |
MPI_Init(&argc, &argv);
|
|
Packit Service |
c5cf8c |
MPI_Comm_rank(MPI_COMM_WORLD, &rank;;
|
|
Packit Service |
c5cf8c |
MPI_Comm_size(MPI_COMM_WORLD, &size);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
num = 0xdeadbeef;
|
|
Packit Service |
c5cf8c |
MPI_T_cvar_get_num(&num);
|
|
Packit Service |
c5cf8c |
printf("get_num=%d\n", num);
|
|
Packit Service |
c5cf8c |
assert(num != 0xdeadbeef);
|
|
Packit Service |
c5cf8c |
for (i = 0; i < num; ++i) {
|
|
Packit Service |
c5cf8c |
name_len = desc_len = STR_SZ;
|
|
Packit Service |
c5cf8c |
MPI_T_cvar_get_info(i, name, &name_len, &verb, &dtype, &enumtype, desc, &desc_len, &bind,
|
|
Packit Service |
c5cf8c |
&scope);
|
|
Packit Service |
c5cf8c |
printf("index=%d\n", i);
|
|
Packit Service |
c5cf8c |
printf("--> name='%s' name_len=%d desc='%s' desc_len=%d\n", name, name_len, desc, desc_len);
|
|
Packit Service |
c5cf8c |
printf("--> verb=%d dtype=%#x bind=%d scope=%d\n", verb, dtype, bind, scope);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_T_cvar_handle_alloc(i, NULL, &handle, &count);
|
|
Packit Service |
c5cf8c |
printf("--> handle allocated: handle=%p count=%d\n", handle, count);
|
|
Packit Service |
c5cf8c |
if (dtype == MPI_INT) {
|
|
Packit Service |
c5cf8c |
int val = 0xdeadbeef;
|
|
Packit Service |
c5cf8c |
MPI_T_cvar_read(handle, &val;;
|
|
Packit Service |
c5cf8c |
printf("--> val=%d\n", val);
|
|
Packit Service |
c5cf8c |
++val;
|
|
Packit Service |
c5cf8c |
MPI_T_cvar_write(handle, &val;;
|
|
Packit Service |
c5cf8c |
val = 0xdeadbeef;
|
|
Packit Service |
c5cf8c |
MPI_T_cvar_read(handle, &val;;
|
|
Packit Service |
c5cf8c |
printf("--> incremented val=%d\n", val);
|
|
Packit Service |
c5cf8c |
} else if (dtype == MPI_DOUBLE) {
|
|
Packit Service |
c5cf8c |
double val = NAN;
|
|
Packit Service |
c5cf8c |
MPI_T_cvar_read(handle, &val;;
|
|
Packit Service |
c5cf8c |
printf("--> val=%f\n", val);
|
|
Packit Service |
c5cf8c |
val *= 2.0;
|
|
Packit Service |
c5cf8c |
MPI_T_cvar_write(handle, &val;;
|
|
Packit Service |
c5cf8c |
val = NAN;
|
|
Packit Service |
c5cf8c |
MPI_T_cvar_read(handle, &val;;
|
|
Packit Service |
c5cf8c |
printf("--> doubled val=%f\n", val);
|
|
Packit Service |
c5cf8c |
} else if (dtype == MPI_CHAR) {
|
|
Packit Service |
c5cf8c |
char *str = malloc(count + 1);
|
|
Packit Service |
c5cf8c |
MPI_T_cvar_read(handle, str);
|
|
Packit Service |
c5cf8c |
printf("--> str='%s'\n", str);
|
|
Packit Service |
c5cf8c |
/* just write the string back unmodified for now */
|
|
Packit Service |
c5cf8c |
MPI_T_cvar_write(handle, str);
|
|
Packit Service |
c5cf8c |
MPI_T_cvar_read(handle, str);
|
|
Packit Service |
c5cf8c |
printf("--> written-then-read str='%s'\n", str);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
MPI_T_cvar_handle_free(&handle);
|
|
Packit Service |
c5cf8c |
printf("\n");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (initialize_mpi) {
|
|
Packit Service |
c5cf8c |
MPI_Finalize();
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_T_finalize();
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
return 0;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#else
|
|
Packit Service |
c5cf8c |
/* Simple null program to allow building this file with non-MPICH
|
|
Packit Service |
c5cf8c |
implementations */
|
|
Packit Service |
c5cf8c |
int main(int argc, char **argv)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPI_Init(&argc, &argv);
|
|
Packit Service |
c5cf8c |
printf(" No Errors\n");
|
|
Packit Service |
c5cf8c |
MPI_Finalize();
|
|
Packit Service |
c5cf8c |
return 0;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
#endif
|