root/opal/mca/pmix/pmix4x/pmix/test/simple/gwclient.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-2012 Cisco Systems, Inc.  All rights reserved.
  15  * Copyright (c) 2011      Oak Ridge National Labs.  All rights reserved.
  16  * Copyright (c) 2013-2018 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 <src/include/pmix_config.h>
  27 #include <pmix.h>
  28 
  29 #include <stdio.h>
  30 #include <stdlib.h>
  31 #include <unistd.h>
  32 #include <time.h>
  33 
  34 #include "src/class/pmix_object.h"
  35 #include "src/util/output.h"
  36 #include "src/util/printf.h"
  37 
  38 static pmix_proc_t myproc;
  39 
  40 int main(int argc, char **argv)
  41 {
  42     pmix_status_t rc;
  43     pmix_value_t value;
  44     pmix_value_t *val = &value;
  45     uint64_t seckey[2];
  46     pmix_proc_t proc;
  47     pmix_info_t *info;
  48     size_t n, ninfo;
  49 
  50     /* init us */
  51     if (PMIX_SUCCESS != (rc = PMIx_Init(&myproc, NULL, 0))) {
  52         pmix_output(0, "Client ns %s rank %d: PMIx_Init failed: %s",
  53                     myproc.nspace, myproc.rank, PMIx_Error_string(rc));
  54         exit(rc);
  55     }
  56     pmix_output(0, "GWClient ns %s rank %d: Running", myproc.nspace, myproc.rank);
  57 
  58     /* look for network data */
  59     memset(&proc, 0, sizeof(pmix_proc_t));
  60     (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN);
  61     proc.rank = PMIX_RANK_WILDCARD;
  62 
  63     if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, "my.net.key", NULL, 0, &val)) ||
  64         PMIX_DATA_ARRAY != val->type ||
  65         NULL == val->data.darray ||
  66         NULL == val->data.darray->array) {
  67         pmix_output(0, "Client ns %s rank %d: PMIx_Get my.net.key failed: %s",
  68                     myproc.nspace, myproc.rank, PMIx_Error_string(rc));
  69         exit(rc);
  70     }
  71     /* the returned value has all the network allocation info in a
  72      * pmix_data_array_t */
  73     info = (pmix_info_t*)val->data.darray->array;
  74     ninfo = val->data.darray->size;
  75     pmix_output(0, "Client ns %s rank %d: got network assignment:",
  76                 myproc.nspace, myproc.rank);
  77     for (n=0; n < ninfo; n++) {
  78         if (PMIX_STRING == info[n].value.type) {
  79             pmix_output(0, "\tKey: %s Value: %s",
  80                         info[n].key, info[n].value.data.string);
  81         } else if (PMIX_BYTE_OBJECT == info[n].value.type) {
  82             memcpy(seckey, info[n].value.data.bo.bytes, info[n].value.data.bo.size);
  83             pmix_output(0, "\tKey: %s sec key: %ld.%ld",
  84                         info[n].key, (long int)seckey[0], (long int)seckey[1]);
  85         }
  86     }
  87     PMIX_VALUE_RELEASE(val);
  88 
  89     /* finalize us */
  90     pmix_output(0, "Client ns %s rank %d: Finalizing", myproc.nspace, myproc.rank);
  91     if (PMIX_SUCCESS != (rc = PMIx_Finalize(NULL, 0))) {
  92         fprintf(stderr, "Client ns %s rank %d:PMIx_Finalize failed: %s\n",
  93                 myproc.nspace, myproc.rank, PMIx_Error_string(rc));
  94     } else {
  95         fprintf(stderr, "Client ns %s rank %d:PMIx_Finalize successfully completed\n", myproc.nspace, myproc.rank);
  96     }
  97     fflush(stderr);
  98     return(rc);
  99 }

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