This source file includes following definitions.
- notification_fn
- 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/output.h"
  36 #include "src/util/printf.h"
  37 
  38 #define MAXCNT 1
  39 
  40 static volatile bool completed = false;
  41 static pmix_proc_t myproc;
  42 
  43 static void notification_fn(size_t evhdlr_registration_id,
  44                             pmix_status_t status,
  45                             const pmix_proc_t *source,
  46                             pmix_info_t info[], size_t ninfo,
  47                             pmix_info_t results[], size_t nresults,
  48                             pmix_event_notification_cbfunc_fn_t cbfunc,
  49                             void *cbdata)
  50 {
  51     pmix_output(0, "Client %s:%d NOTIFIED with status %s", myproc.nspace, myproc.rank, PMIx_Error_string(status));
  52     if (NULL != cbfunc) {
  53         cbfunc(PMIX_SUCCESS, NULL, 0, NULL, NULL, cbdata);
  54     }
  55     completed = true;
  56 }
  57 
  58 static void errhandler_reg_callbk(pmix_status_t status,
  59                                   size_t errhandler_ref,
  60                                   void *cbdata)
  61 {
  62     volatile bool *active = (volatile bool*)cbdata;
  63 
  64     pmix_output(0, "Client: ERRHANDLER REGISTRATION CALLBACK CALLED WITH STATUS %d, ref=%lu",
  65                 status, (unsigned long)errhandler_ref);
  66     *active = false;
  67 }
  68 
  69 #define SIMPIO_MSG_MAX   8192
  70 
  71 int main(int argc, char **argv)
  72 {
  73     pmix_status_t rc;
  74     volatile bool active;
  75     int msgsize;
  76     char msg[SIMPIO_MSG_MAX];
  77     pmix_proc_t proc;
  78     int cnt = 0;
  79 
  80     
  81     if (PMIX_SUCCESS != (rc = PMIx_Init(&myproc, NULL, 0))) {
  82         pmix_output(0, "Client ns %s rank %d: PMIx_Init failed: %s",
  83                     myproc.nspace, myproc.rank, PMIx_Error_string(rc));
  84         exit(rc);
  85     }
  86     pmix_output(0, "Client ns %s rank %d: Running", myproc.nspace, myproc.rank);
  87 
  88     
  89     active = true;
  90     PMIx_Register_event_handler(NULL, 0, NULL, 0,
  91                                 notification_fn, errhandler_reg_callbk, (void*)&active);
  92     while (active) {
  93         usleep(10);
  94     }
  95 
  96     
  97     if (0 == myproc.rank) {
  98         while (0 < (msgsize = read(0, msg, SIMPIO_MSG_MAX))) {
  99             cnt += msgsize;
 100             fprintf(stderr, "Rank %d: read %d bytes\n", myproc.rank, cnt);
 101         }
 102     }
 103 
 104     
 105     PMIX_PROC_CONSTRUCT(&proc);
 106     (void)strncpy(proc.nspace, myproc.nspace, PMIX_MAX_NSLEN);
 107     proc.rank = PMIX_RANK_WILDCARD;
 108     if (PMIX_SUCCESS != (rc = PMIx_Fence(&proc, 1, NULL, 0))) {
 109         pmix_output(0, "Client ns %s rank %d PMIx_Fence failed: %s",
 110                     myproc.nspace, myproc.rank, PMIx_Error_string(rc));
 111     }
 112 
 113     
 114     pmix_output(0, "Client ns %s rank %d: Finalizing", myproc.nspace, myproc.rank);
 115     if (PMIX_SUCCESS != (rc = PMIx_Finalize(NULL, 0))) {
 116         fprintf(stderr, "Client ns %s rank %d:PMIx_Finalize failed: %s\n",
 117                 myproc.nspace, myproc.rank, PMIx_Error_string(rc));
 118     } else {
 119         fprintf(stderr, "Client ns %s rank %d:PMIx_Finalize successfully completed\n", myproc.nspace, myproc.rank);
 120     }
 121     fflush(stderr);
 122     return(rc);
 123 }