|
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 assumes the
|
|
Packit Service |
c5cf8c |
* presence of two performance variables: "posted_recvq_length" and
|
|
Packit Service |
c5cf8c |
* "unexpected_recvq_length". Some information about these variables
|
|
Packit Service |
c5cf8c |
* is printed to stdout and then a few messages are sent/received to
|
|
Packit Service |
c5cf8c |
* show that theses variables are reporting useful information.
|
|
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 <string.h>
|
|
Packit Service |
c5cf8c |
#include "mpitestconf.h"
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
#if !defined(USE_STRICT_MPI) && defined(MPICH)
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
static int posted_qlen, unexpected_qlen;
|
|
Packit Service |
c5cf8c |
static MPI_Aint posted_queue_match_attempts, unexpected_queue_match_attempts;
|
|
Packit Service |
c5cf8c |
static MPI_T_pvar_handle pq_handle, uq_handle, pqm_handle, uqm_handle;
|
|
Packit Service |
c5cf8c |
static MPI_T_pvar_session session;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
static void print_vars(int idx)
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
MPI_T_pvar_read(session, pq_handle, &posted_qlen);
|
|
Packit Service |
c5cf8c |
MPI_T_pvar_read(session, uq_handle, &unexpected_qlen);
|
|
Packit Service |
c5cf8c |
MPI_T_pvar_read(session, pqm_handle, &posted_queue_match_attempts);
|
|
Packit Service |
c5cf8c |
MPI_T_pvar_read(session, uqm_handle, &unexpected_queue_match_attempts);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
printf("(%d) posted_qlen=%d unexpected_qlen=%d ", idx, posted_qlen, unexpected_qlen);
|
|
Packit Service |
c5cf8c |
printf("posted_queue_match_attempts=%lu unexpected_queue_match_attempts=%lu\n",
|
|
Packit Service |
c5cf8c |
posted_queue_match_attempts, unexpected_queue_match_attempts);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
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 varclass;
|
|
Packit Service |
c5cf8c |
int readonly, continuous, atomic;
|
|
Packit Service |
c5cf8c |
int provided;
|
|
Packit Service |
c5cf8c |
MPI_T_enum enumtype;
|
|
Packit Service |
c5cf8c |
int pq_idx = -1, uq_idx = -1, pqm_idx = -1, uqm_idx = -1;
|
|
Packit Service |
c5cf8c |
int pqm_writable = -1, uqm_writable = -1;
|
|
Packit Service |
c5cf8c |
|
|
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 |
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 |
num = 0xdeadbeef;
|
|
Packit Service |
c5cf8c |
MPI_T_pvar_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_pvar_get_info(i, name, &name_len, &verb, &varclass, &dtype, &enumtype, desc,
|
|
Packit Service |
c5cf8c |
&desc_len, &bind, &readonly, &continuous, &atomic);
|
|
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 varclass=%d dtype=%#x bind=%d readonly=%d continuous=%d atomic=%d\n",
|
|
Packit Service |
c5cf8c |
verb, varclass, dtype, bind, readonly, continuous, atomic);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (0 == strcmp(name, "posted_recvq_length")) {
|
|
Packit Service |
c5cf8c |
pq_idx = i;
|
|
Packit Service |
c5cf8c |
} else if (0 == strcmp(name, "unexpected_recvq_length")) {
|
|
Packit Service |
c5cf8c |
uq_idx = i;
|
|
Packit Service |
c5cf8c |
} else if (0 == strcmp(name, "posted_recvq_match_attempts")) {
|
|
Packit Service |
c5cf8c |
pqm_idx = i;
|
|
Packit Service |
c5cf8c |
pqm_writable = !readonly;
|
|
Packit Service |
c5cf8c |
} else if (0 == strcmp(name, "unexpected_recvq_match_attempts")) {
|
|
Packit Service |
c5cf8c |
uqm_idx = i;
|
|
Packit Service |
c5cf8c |
uqm_writable = !readonly;
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
printf("pq_idx=%d uq_idx=%d pqm_idx=%d uqm_idx=%d\n", pq_idx, uq_idx, pqm_idx, uqm_idx);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* setup a session and handles for the PQ and UQ length variables */
|
|
Packit Service |
c5cf8c |
session = MPI_T_PVAR_SESSION_NULL;
|
|
Packit Service |
c5cf8c |
MPI_T_pvar_session_create(&session);
|
|
Packit Service |
c5cf8c |
assert(session != MPI_T_PVAR_SESSION_NULL);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
pq_handle = MPI_T_PVAR_HANDLE_NULL;
|
|
Packit Service |
c5cf8c |
MPI_T_pvar_handle_alloc(session, pq_idx, NULL, &pq_handle, &count);
|
|
Packit Service |
c5cf8c |
assert(count = 1);
|
|
Packit Service |
c5cf8c |
assert(pq_handle != MPI_T_PVAR_HANDLE_NULL);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
uq_handle = MPI_T_PVAR_HANDLE_NULL;
|
|
Packit Service |
c5cf8c |
MPI_T_pvar_handle_alloc(session, uq_idx, NULL, &uq_handle, &count);
|
|
Packit Service |
c5cf8c |
assert(count = 1);
|
|
Packit Service |
c5cf8c |
assert(uq_handle != MPI_T_PVAR_HANDLE_NULL);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
pqm_handle = MPI_T_PVAR_HANDLE_NULL;
|
|
Packit Service |
c5cf8c |
MPI_T_pvar_handle_alloc(session, pqm_idx, NULL, &pqm_handle, &count);
|
|
Packit Service |
c5cf8c |
assert(count = 1);
|
|
Packit Service |
c5cf8c |
assert(pqm_handle != MPI_T_PVAR_HANDLE_NULL);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
uqm_handle = MPI_T_PVAR_HANDLE_NULL;
|
|
Packit Service |
c5cf8c |
MPI_T_pvar_handle_alloc(session, uqm_idx, NULL, &uqm_handle, &count);
|
|
Packit Service |
c5cf8c |
assert(count = 1);
|
|
Packit Service |
c5cf8c |
assert(uqm_handle != MPI_T_PVAR_HANDLE_NULL);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* now send/recv some messages and track the lengths of the queues */
|
|
Packit Service |
c5cf8c |
{
|
|
Packit Service |
c5cf8c |
int buf1, buf2, buf3, buf4;
|
|
Packit Service |
c5cf8c |
MPI_Request r1, r2, r3, r4;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
buf1 = buf2 = buf3 = buf4 = 0xfeedface;
|
|
Packit Service |
c5cf8c |
r1 = r2 = r3 = r4 = MPI_REQUEST_NULL;
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
posted_qlen = 0x0123abcd;
|
|
Packit Service |
c5cf8c |
unexpected_qlen = 0x0123abcd;
|
|
Packit Service |
c5cf8c |
posted_queue_match_attempts = 0x0123abcd;
|
|
Packit Service |
c5cf8c |
unexpected_queue_match_attempts = 0x0123abcd;
|
|
Packit Service |
c5cf8c |
print_vars(1);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Isend(&buf1, 1, MPI_INT, 0, /*tag= */ 11, MPI_COMM_SELF, &r1;;
|
|
Packit Service |
c5cf8c |
print_vars(2);
|
|
Packit Service |
c5cf8c |
printf("expected (posted_qlen,unexpected_qlen) = (0,1)\n");
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Isend(&buf1, 1, MPI_INT, 0, /*tag= */ 22, MPI_COMM_SELF, &r2;;
|
|
Packit Service |
c5cf8c |
print_vars(3);
|
|
Packit Service |
c5cf8c |
printf("expected (posted_qlen,unexpected_qlen) = (0,2)\n");
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Irecv(&buf2, 1, MPI_INT, 0, /*tag= */ 33, MPI_COMM_SELF, &r3;;
|
|
Packit Service |
c5cf8c |
print_vars(4);
|
|
Packit Service |
c5cf8c |
printf("expected (posted_qlen,unexpected_qlen) = (1,2)\n");
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Recv(&buf3, 1, MPI_INT, 0, /*tag= */ 22, MPI_COMM_SELF, MPI_STATUS_IGNORE);
|
|
Packit Service |
c5cf8c |
MPI_Wait(&r2, MPI_STATUS_IGNORE);
|
|
Packit Service |
c5cf8c |
print_vars(5);
|
|
Packit Service |
c5cf8c |
printf("expected (posted_qlen,unexpected_qlen) = (1,1)\n");
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Recv(&buf3, 1, MPI_INT, 0, /*tag= */ 11, MPI_COMM_SELF, MPI_STATUS_IGNORE);
|
|
Packit Service |
c5cf8c |
MPI_Wait(&r1, MPI_STATUS_IGNORE);
|
|
Packit Service |
c5cf8c |
print_vars(6);
|
|
Packit Service |
c5cf8c |
printf("expected (posted_qlen,unexpected_qlen) = (1,0)\n");
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_Send(&buf3, 1, MPI_INT, 0, /*tag= */ 33, MPI_COMM_SELF);
|
|
Packit Service |
c5cf8c |
MPI_Wait(&r3, MPI_STATUS_IGNORE);
|
|
Packit Service |
c5cf8c |
print_vars(7);
|
|
Packit Service |
c5cf8c |
printf("expected (posted_qlen,unexpected_qlen) = (0,0)\n");
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
if (pqm_writable) {
|
|
Packit Service |
c5cf8c |
posted_queue_match_attempts = 0;
|
|
Packit Service |
c5cf8c |
MPI_T_pvar_write(session, pqm_handle, &posted_queue_match_attempts);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
if (uqm_writable) {
|
|
Packit Service |
c5cf8c |
unexpected_queue_match_attempts = 0;
|
|
Packit Service |
c5cf8c |
MPI_T_pvar_write(session, uqm_handle, &unexpected_queue_match_attempts);
|
|
Packit Service |
c5cf8c |
}
|
|
Packit Service |
c5cf8c |
print_vars(8);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
/* cleanup */
|
|
Packit Service |
c5cf8c |
MPI_T_pvar_handle_free(session, &uqm_handle);
|
|
Packit Service |
c5cf8c |
MPI_T_pvar_handle_free(session, &pqm_handle);
|
|
Packit Service |
c5cf8c |
MPI_T_pvar_handle_free(session, &uq_handle);
|
|
Packit Service |
c5cf8c |
MPI_T_pvar_handle_free(session, &pq_handle);
|
|
Packit Service |
c5cf8c |
MPI_T_pvar_session_free(&session);
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
MPI_T_finalize();
|
|
Packit Service |
c5cf8c |
MPI_Finalize();
|
|
Packit Service |
c5cf8c |
|
|
Packit Service |
c5cf8c |
return 0;
|
|
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
|