root/orte/test/system/pmixtool.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. main

   1 /*
   2  * Copyright (c) 2004-2010 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2011 The University of Tennessee and The University
   6  *                         of Tennessee Research Foundation.  All rights
   7  *                         reserved.
   8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
   9  *                         University of Stuttgart.  All rights reserved.
  10  * Copyright (c) 2004-2005 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * Copyright (c) 2006-2013 Los Alamos National Security, LLC.
  13  *                         All rights reserved.
  14  * Copyright (c) 2009-2018 Cisco Systems, Inc.  All rights reserved
  15  * Copyright (c) 2011      Oak Ridge National Labs.  All rights reserved.
  16  * Copyright (c) 2013-2016 Intel, Inc.  All rights reserved.
  17  * Copyright (c) 2015      Mellanox Technologies, Inc.  All rights reserved.
  18  * $COPYRIGHT$
  19  *
  20  * Additional copyrights may follow
  21  *
  22  * $HEADER$
  23  *
  24  */
  25 
  26 #include <stdio.h>
  27 #include <stdlib.h>
  28 #include <unistd.h>
  29 #include <time.h>
  30 
  31 #include "opal/util/string_copy.h"
  32 
  33 #include <pmix_tool.h>
  34 
  35 int main(int argc, char **argv)
  36 {
  37     pmix_status_t rc;
  38     pmix_proc_t myproc;
  39     pmix_info_t *info;
  40     size_t ninfo;
  41 
  42     /* init us */
  43     if (PMIX_SUCCESS != (rc = PMIx_tool_init(&myproc, NULL, 0))) {
  44         fprintf(stderr, "PMIx_tool_init failed: %s\n", PMIx_Error_string(rc));
  45         exit(rc);
  46     }
  47     fprintf(stderr, "Tool ns %s rank %d: Running\n", myproc.nspace, myproc.rank);
  48 
  49     /* query something */
  50     ninfo = 1;
  51     PMIX_INFO_CREATE(info, ninfo);
  52     (void)opal_string_copy(info[0].key, PMIX_QUERY_NAMESPACES, PMIX_MAX_KEYLEN);
  53     if (PMIX_SUCCESS != (rc = PMIx_Query_info(info, ninfo))) {
  54         fprintf(stderr, "Tool ns %s rank %d: PMIx_Query_info failed: %d\n", myproc.nspace, myproc.rank, rc);
  55         goto done;
  56     }
  57     if (0 != strncmp(info[0].key, PMIX_QUERY_NAMESPACES, PMIX_MAX_KEYLEN)) {
  58         fprintf(stderr, "tool ns %s rank %d: PMIx_Query_info key[0] wrong: %s vs %s\n",
  59                     myproc.nspace, myproc.rank, info[0].key, PMIX_QUERY_NAMESPACES);
  60     }
  61     if (PMIX_STRING != info[0].value.type) {
  62         fprintf(stderr, "Tool ns %s rank %d: PMIx_Query_info key[0] wrong type: %d vs %d\n",
  63                     myproc.nspace, myproc.rank, info[0].value.type, PMIX_STRING);
  64     }
  65     fprintf(stderr, "Tool ns %s rank %d: PMIx_Query_info key[0] returned %s\n",
  66             myproc.nspace, myproc.rank,
  67             (NULL == info[0].value.data.string) ? "NULL" : info[0].value.data.string);
  68     PMIX_INFO_FREE(info, ninfo);
  69 
  70  done:
  71     /* finalize us */
  72     fprintf(stderr, "Tool ns %s rank %d: Finalizing\n", myproc.nspace, myproc.rank);
  73     if (PMIX_SUCCESS != (rc = PMIx_tool_finalize())) {
  74         fprintf(stderr, "Tool ns %s rank %d:PMIx_tool_finalize failed: %d\n", myproc.nspace, myproc.rank, rc);
  75     } else {
  76         fprintf(stderr, "Tool ns %s rank %d:PMIx_tool_finalize successfully completed\n", myproc.nspace, myproc.rank);
  77     }
  78     fflush(stderr);
  79     return(rc);
  80 }

/* [<][>][^][v][top][bottom][index][help] */