This source file includes following definitions.
- notification_fn
- op_callbk
- errhandler_reg_callbk
- main
   1 
   2 
   3 
   4 
   5 
   6 
   7 
   8 
   9 
  10 
  11 
  12 
  13 
  14 
  15 
  16 
  17 
  18 
  19 
  20 
  21 
  22 
  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/argv.h"
  36 #include "src/util/output.h"
  37 #include "src/util/printf.h"
  38 
  39 static pmix_proc_t myproc;
  40 static bool completed;
  41 
  42 static void notification_fn(size_t evhdlr_registration_id,
  43                             pmix_status_t status,
  44                             const pmix_proc_t *source,
  45                             pmix_info_t info[], size_t ninfo,
  46                             pmix_info_t results[], size_t nresults,
  47                             pmix_event_notification_cbfunc_fn_t cbfunc,
  48                             void *cbdata)
  49 {
  50     pmix_output(0, "Client %s:%d NOTIFIED with status %d", myproc.nspace, myproc.rank, status);
  51     if (NULL != cbfunc) {
  52         cbfunc(PMIX_SUCCESS, NULL, 0, NULL, NULL, cbdata);
  53     }
  54     completed = true;
  55 }
  56 
  57 static void op_callbk(pmix_status_t status,
  58                       void *cbdata)
  59 {
  60     pmix_output(0, "CLIENT: OP CALLBACK CALLED WITH STATUS %d", status);
  61 }
  62 
  63 static void errhandler_reg_callbk (pmix_status_t status,
  64                                    size_t errhandler_ref,
  65                                    void *cbdata)
  66 {
  67     pmix_output(0, "Client: ERRHANDLER REGISTRATION CALLBACK CALLED WITH STATUS %d, ref=%lu",
  68                 status, (unsigned long)errhandler_ref);
  69 }
  70 
  71 int main(int argc, char **argv)
  72 {
  73     int rc;
  74     pmix_value_t value;
  75     pmix_value_t *val = &value;
  76     pmix_proc_t proc;
  77     uint32_t nprocs;
  78 
  79     
  80     if (PMIX_SUCCESS != (rc = PMIx_Init(&myproc, NULL, 0))) {
  81         pmix_output(0, "Client ns %s rank %d: PMIx_Init failed: %d", myproc.nspace, myproc.rank, rc);
  82         exit(0);
  83     }
  84     pmix_output(0, "Client ns %s rank %d: Running", myproc.nspace, myproc.rank);
  85 
  86     
  87     (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN);
  88     proc.rank = PMIX_RANK_WILDCARD;
  89     if (PMIX_SUCCESS != (rc = PMIx_Get(&proc, PMIX_UNIV_SIZE, NULL, 0, &val))) {
  90         pmix_output(0, "Client ns %s rank %d: PMIx_Get universe size failed: %d", myproc.nspace, myproc.rank, rc);
  91         goto done;
  92     }
  93     nprocs = val->data.uint32;
  94     PMIX_VALUE_RELEASE(val);
  95     pmix_output(0, "Client %s:%d universe size %d", myproc.nspace, myproc.rank, nprocs);
  96     completed = false;
  97 
  98     
  99     PMIx_Register_event_handler(NULL, 0, NULL, 0,
 100                                 notification_fn, errhandler_reg_callbk, NULL);
 101 
 102     
 103     PMIX_PROC_CONSTRUCT(&proc);
 104     (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN);
 105     proc.rank = PMIX_RANK_WILDCARD;
 106     if (PMIX_SUCCESS != (rc = PMIx_Fence(&proc, 1, NULL, 0))) {
 107         pmix_output(0, "Client ns %s rank %d: PMIx_Fence failed: %d", myproc.nspace, myproc.rank, rc);
 108         goto done;
 109     }
 110 
 111     
 112     if (0 == myproc.rank) {
 113         PMIx_Abort(PMIX_ERR_OUT_OF_RESOURCE, "Eat rocks",
 114                    &proc, 1);
 115         pmix_output(0, "Client ns %s rank %d: Abort called", myproc.nspace, myproc.rank);
 116     } else {
 117     
 118         while (!completed) {
 119             struct timespec ts;
 120             ts.tv_sec = 0;
 121             ts.tv_nsec = 100000;
 122             nanosleep(&ts, NULL);
 123         }
 124     }
 125 
 126  done:
 127     
 128     pmix_output(0, "Client ns %s rank %d: Finalizing", myproc.nspace, myproc.rank);
 129     PMIx_Deregister_event_handler(1, op_callbk, NULL);
 130 
 131     if (PMIX_SUCCESS != (rc = PMIx_Finalize(NULL, 0))) {
 132         fprintf(stderr, "Client ns %s rank %d:PMIx_Finalize failed: %d\n", myproc.nspace, myproc.rank, rc);
 133     } else {
 134         fprintf(stderr, "Client ns %s rank %d:PMIx_Finalize successfully completed\n", myproc.nspace, myproc.rank);
 135     }
 136     fflush(stderr);
 137     return(0);
 138 }