root/orte/runtime/data_type_support/orte_dt_unpacking_fns.c

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

DEFINITIONS

This source file includes following definitions.
  1. orte_dt_unpack_std_cntr
  2. orte_dt_unpack_job
  3. orte_dt_unpack_node
  4. orte_dt_unpack_proc
  5. orte_dt_unpack_app_context
  6. orte_dt_unpack_exit_code
  7. orte_dt_unpack_node_state
  8. orte_dt_unpack_proc_state
  9. orte_dt_unpack_job_state
  10. orte_dt_unpack_map
  11. orte_dt_unpack_tag
  12. orte_dt_unpack_daemon_cmd
  13. orte_dt_unpack_iof_tag
  14. orte_dt_unpack_attr
  15. orte_dt_unpack_sig

   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) 2011-2017 Cisco Systems, Inc.  All rights reserved
  13  * Copyright (c) 2011-2013 Los Alamos National Security, LLC.
  14  *                         All rights reserved.
  15  * Copyright (c) 2014-2018 Intel, Inc. All rights reserved.
  16  * $COPYRIGHT$
  17  *
  18  * Additional copyrights may follow
  19  *
  20  * $HEADER$
  21  */
  22 
  23 #include "orte_config.h"
  24 #include "orte/types.h"
  25 
  26 #include <sys/types.h>
  27 
  28 #include "opal/dss/dss.h"
  29 #include "opal/dss/dss_internal.h"
  30 #include "opal/mca/hwloc/hwloc-internal.h"
  31 #include "opal/util/argv.h"
  32 
  33 #include "orte/mca/errmgr/errmgr.h"
  34 #include "orte/runtime/data_type_support/orte_dt_support.h"
  35 
  36 /*
  37  * ORTE_STD_CNTR
  38  */
  39 int orte_dt_unpack_std_cntr(opal_buffer_t *buffer, void *dest,
  40                              int32_t *num_vals, opal_data_type_t type)
  41 {
  42     int ret;
  43 
  44     /* Turn around and unpack the real type */
  45     if (ORTE_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, dest, num_vals, ORTE_STD_CNTR_T))) {
  46         ORTE_ERROR_LOG(ret);
  47     }
  48 
  49     return ret;
  50 }
  51 
  52 /*
  53  * JOB
  54  * NOTE: We do not pack all of the job object's fields as many of them have no
  55  * value in sending them to another location. The only purpose in packing and
  56  * sending a job object is to communicate the data required to dynamically
  57  * spawn another job - so we only pack that limited set of required data.
  58  * Therefore, only unpack what was packed
  59  */
  60 int orte_dt_unpack_job(opal_buffer_t *buffer, void *dest,
  61                        int32_t *num_vals, opal_data_type_t type)
  62 {
  63     int rc;
  64     int32_t i, k, n, count, bookmark;
  65     orte_job_t **jobs;
  66     orte_app_idx_t j;
  67     orte_attribute_t *kv;
  68     char *tmp;
  69     opal_value_t *val;
  70     opal_list_t *cache;
  71 
  72     /* unpack into array of orte_job_t objects */
  73     jobs = (orte_job_t**) dest;
  74     for (i=0; i < *num_vals; i++) {
  75 
  76         /* create the orte_job_t object */
  77         jobs[i] = OBJ_NEW(orte_job_t);
  78         if (NULL == jobs[i]) {
  79             ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
  80             return ORTE_ERR_OUT_OF_RESOURCE;
  81         }
  82 
  83         /* unpack the jobid */
  84         n = 1;
  85         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
  86                                 &(jobs[i]->jobid), &n, ORTE_JOBID))) {
  87             ORTE_ERROR_LOG(rc);
  88             return rc;
  89         }
  90         /* unpack the flags */
  91         n = 1;
  92         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
  93                          (&(jobs[i]->flags)), &n, ORTE_JOB_FLAGS_T))) {
  94             ORTE_ERROR_LOG(rc);
  95             return rc;
  96         }
  97 
  98         /* unpack the attributes */
  99         n=1;
 100         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, &count,
 101                                                          &n, ORTE_STD_CNTR))) {
 102             ORTE_ERROR_LOG(rc);
 103             return rc;
 104         }
 105         for (k=0; k < count; k++) {
 106             n=1;
 107             if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, &kv,
 108                                                              &n, ORTE_ATTRIBUTE))) {
 109                 ORTE_ERROR_LOG(rc);
 110                 return rc;
 111             }
 112             kv->local = ORTE_ATTR_GLOBAL;  // obviously not a local value
 113             opal_list_append(&jobs[i]->attributes, &kv->super);
 114         }
 115         /* unpack any job info */
 116         n=1;
 117         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, &count,
 118                                                          &n, ORTE_STD_CNTR))) {
 119             ORTE_ERROR_LOG(rc);
 120             return rc;
 121         }
 122         if (0 < count){
 123             cache = OBJ_NEW(opal_list_t);
 124             orte_set_attribute(&jobs[i]->attributes, ORTE_JOB_INFO_CACHE, ORTE_ATTR_LOCAL, (void*)cache, OPAL_PTR);
 125             for (k=0; k < count; k++) {
 126                 n=1;
 127                 if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, &val,
 128                                                                  &n, OPAL_VALUE))) {
 129                     ORTE_ERROR_LOG(rc);
 130                     return rc;
 131                 }
 132                 opal_list_append(cache, &val->super);
 133             }
 134         }
 135 
 136         /* unpack the personality */
 137         n=1;
 138         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, &count, &n, OPAL_INT32))) {
 139             ORTE_ERROR_LOG(rc);
 140             return rc;
 141         }
 142         for (k=0; k < count; k++) {
 143             n=1;
 144             if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, &tmp, &n, OPAL_STRING))) {
 145                 ORTE_ERROR_LOG(rc);
 146                 return rc;
 147             }
 148             opal_argv_append_nosize(&jobs[i]->personality, tmp);
 149             free(tmp);
 150         }
 151 
 152         /* unpack the num apps */
 153         n = 1;
 154         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 155                                 (&(jobs[i]->num_apps)), &n, ORTE_APP_IDX))) {
 156             ORTE_ERROR_LOG(rc);
 157             return rc;
 158         }
 159 
 160         /* if there are apps, unpack them */
 161         if (0 < jobs[i]->num_apps) {
 162             orte_app_context_t *app;
 163             for (j=0; j < jobs[i]->num_apps; j++) {
 164                 n = 1;
 165                 if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 166                                &app, &n, ORTE_APP_CONTEXT))) {
 167                     ORTE_ERROR_LOG(rc);
 168                     return rc;
 169                 }
 170                 opal_pointer_array_add(jobs[i]->apps, app);
 171             }
 172         }
 173 
 174         /* unpack num procs and offset */
 175         n = 1;
 176         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 177                                 (&(jobs[i]->num_procs)), &n, ORTE_VPID))) {
 178             ORTE_ERROR_LOG(rc);
 179             return rc;
 180         }
 181         n = 1;
 182         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 183                                 (&(jobs[i]->offset)), &n, ORTE_VPID))) {
 184             ORTE_ERROR_LOG(rc);
 185             return rc;
 186         }
 187 
 188         if (0 < jobs[i]->num_procs) {
 189             /* check attributes to see if this job was fully
 190              * described in the launch msg */
 191             if (orte_get_attribute(&jobs[i]->attributes, ORTE_JOB_FULLY_DESCRIBED, NULL, OPAL_BOOL)) {
 192                 orte_proc_t *proc;
 193                 for (j=0; j < jobs[i]->num_procs; j++) {
 194                     n = 1;
 195                     if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 196                                    &proc, &n, ORTE_PROC))) {
 197                         ORTE_ERROR_LOG(rc);
 198                         return rc;
 199                     }
 200                     opal_pointer_array_add(jobs[i]->procs, proc);
 201                 }
 202             }
 203         }
 204 
 205         /* unpack stdin target */
 206         n = 1;
 207         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 208                             (&(jobs[i]->stdin_target)), &n, ORTE_VPID))) {
 209             ORTE_ERROR_LOG(rc);
 210             return rc;
 211         }
 212 
 213         /* unpack the total slots allocated to the job */
 214         n = 1;
 215         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 216                          (&(jobs[i]->total_slots_alloc)), &n, ORTE_STD_CNTR))) {
 217             ORTE_ERROR_LOG(rc);
 218             return rc;
 219         }
 220 
 221         /* if the map is NULL, then we didn't pack it as there was
 222          * nothing to pack. Instead, we packed a flag to indicate whether or not
 223          * the map is included */
 224         n = 1;
 225         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 226                                             &j, &n, ORTE_STD_CNTR))) {
 227             ORTE_ERROR_LOG(rc);
 228             return rc;
 229         }
 230         if (0 < j) {
 231             /* unpack the map */
 232             n = 1;
 233             if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 234                                             (&(jobs[i]->map)), &n, ORTE_JOB_MAP))) {
 235                 ORTE_ERROR_LOG(rc);
 236                 return rc;
 237             }
 238         }
 239 
 240         /* unpack the bookmark */
 241         n = 1;
 242         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 243                                             &bookmark, &n, OPAL_INT32))) {
 244             ORTE_ERROR_LOG(rc);
 245             return rc;
 246         }
 247         if (0 <= bookmark) {
 248             /* retrieve it */
 249             jobs[i]->bookmark = (orte_node_t*)opal_pointer_array_get_item(orte_node_pool, bookmark);
 250         }
 251 
 252         /* unpack the job state */
 253         n = 1;
 254         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 255                          (&(jobs[i]->state)), &n, ORTE_JOB_STATE))) {
 256             ORTE_ERROR_LOG(rc);
 257             return rc;
 258         }
 259     }
 260 
 261     return ORTE_SUCCESS;
 262 }
 263 
 264 /*
 265  * NODE
 266  */
 267 int orte_dt_unpack_node(opal_buffer_t *buffer, void *dest,
 268                         int32_t *num_vals, opal_data_type_t type)
 269 {
 270     int rc;
 271     int32_t i, n, k, count;
 272     orte_node_t **nodes;
 273     uint8_t flag;
 274     orte_attribute_t *kv;
 275 
 276     /* unpack into array of orte_node_t objects */
 277     nodes = (orte_node_t**) dest;
 278     for (i=0; i < *num_vals; i++) {
 279 
 280         /* create the node object */
 281         nodes[i] = OBJ_NEW(orte_node_t);
 282         if (NULL == nodes[i]) {
 283             ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
 284             return ORTE_ERR_OUT_OF_RESOURCE;
 285         }
 286 
 287         /* do not unpack the index - meaningless here */
 288 
 289         /* unpack the node name */
 290         n = 1;
 291         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 292                          &(nodes[i]->name), &n, OPAL_STRING))) {
 293             ORTE_ERROR_LOG(rc);
 294             return rc;
 295         }
 296 
 297         /* do not unpack the daemon name or launch id */
 298 
 299         /* unpack the number of procs on the node */
 300         n = 1;
 301         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 302                          (&(nodes[i]->num_procs)), &n, ORTE_VPID))) {
 303             ORTE_ERROR_LOG(rc);
 304             return rc;
 305         }
 306 
 307         /* do not unpack the proc info */
 308 
 309         /* unpack whether we are oversubscribed */
 310         n = 1;
 311         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 312                          (&flag), &n, OPAL_UINT8))) {
 313             ORTE_ERROR_LOG(rc);
 314             return rc;
 315         }
 316         if (flag) {
 317             ORTE_FLAG_SET(nodes[i], ORTE_NODE_FLAG_OVERSUBSCRIBED);
 318         }
 319 
 320         /* unpack the state */
 321         n = 1;
 322         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 323                          (&(nodes[i]->state)), &n, ORTE_NODE_STATE))) {
 324             ORTE_ERROR_LOG(rc);
 325             return rc;
 326         }
 327 
 328         /* unpack the attributes */
 329         n=1;
 330         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, &count,
 331                                                          &n, ORTE_STD_CNTR))) {
 332             ORTE_ERROR_LOG(rc);
 333             return rc;
 334         }
 335         for (k=0; k < count; k++) {
 336             n=1;
 337             if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, &kv,
 338                                                              &n, ORTE_ATTRIBUTE))) {
 339                 ORTE_ERROR_LOG(rc);
 340                 return rc;
 341             }
 342             kv->local = ORTE_ATTR_GLOBAL;  // obviously not a local value
 343             opal_list_append(&nodes[i]->attributes, &kv->super);
 344         }
 345     }
 346     return ORTE_SUCCESS;
 347 }
 348 
 349 /*
 350  * PROC
 351  */
 352 int orte_dt_unpack_proc(opal_buffer_t *buffer, void *dest,
 353                         int32_t *num_vals, opal_data_type_t type)
 354 {
 355     int rc;
 356     int32_t i, n, count, k;
 357     orte_attribute_t *kv;;
 358     orte_proc_t **procs;
 359 
 360     /* unpack into array of orte_proc_t objects */
 361     procs = (orte_proc_t**) dest;
 362     for (i=0; i < *num_vals; i++) {
 363 
 364         /* create the orte_proc_t object */
 365         procs[i] = OBJ_NEW(orte_proc_t);
 366         if (NULL == procs[i]) {
 367             ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
 368             return ORTE_ERR_OUT_OF_RESOURCE;
 369         }
 370 
 371         /* unpack the name */
 372         n = 1;
 373         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 374                          &(procs[i]->name), &n, ORTE_NAME))) {
 375             ORTE_ERROR_LOG(rc);
 376             return rc;
 377         }
 378 
 379         /* unpack the node it is on */
 380         n = 1;
 381         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 382                          (&(procs[i]->parent)), &n, ORTE_VPID))) {
 383             ORTE_ERROR_LOG(rc);
 384             return rc;
 385         }
 386 
 387        /* unpack the local rank */
 388         n = 1;
 389         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 390                          (&(procs[i]->local_rank)), &n, ORTE_LOCAL_RANK))) {
 391             ORTE_ERROR_LOG(rc);
 392             return rc;
 393         }
 394 
 395         /* unpack the node rank */
 396         n = 1;
 397         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 398                           (&(procs[i]->node_rank)), &n, ORTE_NODE_RANK))) {
 399             ORTE_ERROR_LOG(rc);
 400             return rc;
 401         }
 402 
 403         /* unpack the state */
 404         n = 1;
 405         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 406                          (&(procs[i]->state)), &n, ORTE_PROC_STATE))) {
 407             ORTE_ERROR_LOG(rc);
 408             return rc;
 409         }
 410 
 411         /* unpack the app context index */
 412         n = 1;
 413         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 414                          (&(procs[i]->app_idx)), &n, ORTE_STD_CNTR))) {
 415             ORTE_ERROR_LOG(rc);
 416             return rc;
 417         }
 418 
 419         /* unpack the app_rank */
 420         n = 1;
 421         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 422                          (&(procs[i]->app_rank)), &n, OPAL_UINT32))) {
 423             ORTE_ERROR_LOG(rc);
 424             return rc;
 425         }
 426 
 427         /* unpack the attributes */
 428         n=1;
 429         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, &count,
 430                                                          &n, ORTE_STD_CNTR))) {
 431             ORTE_ERROR_LOG(rc);
 432             return rc;
 433         }
 434         for (k=0; k < count; k++) {
 435             n=1;
 436             if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, &kv,
 437                                                              &n, ORTE_ATTRIBUTE))) {
 438                 ORTE_ERROR_LOG(rc);
 439                 return rc;
 440             }
 441             kv->local = ORTE_ATTR_GLOBAL;  // obviously not a local value
 442             opal_list_append(&procs[i]->attributes, &kv->super);
 443         }
 444     }
 445     return ORTE_SUCCESS;
 446 }
 447 
 448 /*
 449  * APP_CONTEXT
 450  */
 451 int orte_dt_unpack_app_context(opal_buffer_t *buffer, void *dest,
 452                                int32_t *num_vals, opal_data_type_t type)
 453 {
 454     int rc;
 455     orte_app_context_t **app_context;
 456     int32_t i, max_n=1, count, k;
 457     orte_attribute_t *kv;
 458 
 459     /* unpack into array of app_context objects */
 460     app_context = (orte_app_context_t**) dest;
 461     for (i=0; i < *num_vals; i++) {
 462 
 463         /* create the app_context object */
 464         app_context[i] = OBJ_NEW(orte_app_context_t);
 465         if (NULL == app_context[i]) {
 466             ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
 467             return ORTE_ERR_OUT_OF_RESOURCE;
 468         }
 469 
 470         /* get the app index number */
 471         max_n = 1;
 472         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, &(app_context[i]->idx),
 473                                                          &max_n, ORTE_STD_CNTR))) {
 474             ORTE_ERROR_LOG(rc);
 475             return rc;
 476         }
 477 
 478         /* unpack the application name */
 479         max_n = 1;
 480         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, &(app_context[i]->app),
 481                                                          &max_n, OPAL_STRING))) {
 482             ORTE_ERROR_LOG(rc);
 483             return rc;
 484         }
 485 
 486         /* get the number of processes */
 487         max_n = 1;
 488         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, &(app_context[i]->num_procs),
 489                                                          &max_n, ORTE_STD_CNTR))) {
 490             ORTE_ERROR_LOG(rc);
 491             return rc;
 492         }
 493 
 494         /* get the first rank for this app */
 495         max_n = 1;
 496         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, &(app_context[i]->first_rank),
 497                                                          &max_n, ORTE_VPID))) {
 498             ORTE_ERROR_LOG(rc);
 499             return rc;
 500         }
 501 
 502         /* get the number of argv strings that were packed */
 503         max_n = 1;
 504         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, &count, &max_n, ORTE_STD_CNTR))) {
 505             ORTE_ERROR_LOG(rc);
 506             return rc;
 507         }
 508 
 509         /* if there are argv strings, allocate the required space for the char * pointers */
 510         if (0 < count) {
 511             app_context[i]->argv = (char **)malloc((count+1) * sizeof(char*));
 512             if (NULL == app_context[i]->argv) {
 513                 ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
 514                 return ORTE_ERR_OUT_OF_RESOURCE;
 515             }
 516             app_context[i]->argv[count] = NULL;
 517 
 518             /* and unpack them */
 519             max_n = count;
 520             if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, app_context[i]->argv, &max_n, OPAL_STRING))) {
 521                 ORTE_ERROR_LOG(rc);
 522                 return rc;
 523             }
 524         }
 525 
 526         /* get the number of env strings */
 527         max_n = 1;
 528         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, &count, &max_n, ORTE_STD_CNTR))) {
 529             ORTE_ERROR_LOG(rc);
 530             return rc;
 531         }
 532 
 533         /* if there are env strings, allocate the required space for the char * pointers */
 534         if (0 < count) {
 535             app_context[i]->env = (char **)malloc((count+1) * sizeof(char*));
 536             if (NULL == app_context[i]->env) {
 537                 ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
 538                 return ORTE_ERR_OUT_OF_RESOURCE;
 539             }
 540             app_context[i]->env[count] = NULL;
 541 
 542             /* and unpack them */
 543             max_n = count;
 544             if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, app_context[i]->env, &max_n, OPAL_STRING))) {
 545                 ORTE_ERROR_LOG(rc);
 546                 return rc;
 547             }
 548         }
 549 
 550         /* unpack the cwd */
 551         max_n = 1;
 552         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, &app_context[i]->cwd,
 553                                                          &max_n, OPAL_STRING))) {
 554             ORTE_ERROR_LOG(rc);
 555             return rc;
 556         }
 557 
 558         /* unpack the attributes */
 559         max_n=1;
 560         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, &count,
 561                                                          &max_n, ORTE_STD_CNTR))) {
 562             ORTE_ERROR_LOG(rc);
 563             return rc;
 564         }
 565         for (k=0; k < count; k++) {
 566             max_n=1;
 567             if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, &kv,
 568                                                              &max_n, ORTE_ATTRIBUTE))) {
 569                 ORTE_ERROR_LOG(rc);
 570                 return rc;
 571             }
 572             /* obviously, this isn't a local value */
 573             kv->local = false;
 574             opal_list_append(&app_context[i]->attributes, &kv->super);
 575         }
 576     }
 577 
 578     return ORTE_SUCCESS;
 579 }
 580 
 581 /*
 582  * EXIT CODE
 583  */
 584 int orte_dt_unpack_exit_code(opal_buffer_t *buffer, void *dest,
 585                                    int32_t *num_vals, opal_data_type_t type)
 586 {
 587     int rc;
 588 
 589     if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, dest, num_vals, ORTE_EXIT_CODE_T))) {
 590         ORTE_ERROR_LOG(rc);
 591     }
 592 
 593     return rc;
 594 }
 595 
 596 /*
 597  * NODE STATE
 598  */
 599 int orte_dt_unpack_node_state(opal_buffer_t *buffer, void *dest,
 600                                     int32_t *num_vals, opal_data_type_t type)
 601 {
 602     int rc;
 603 
 604     if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, dest, num_vals, ORTE_NODE_STATE_T))) {
 605         ORTE_ERROR_LOG(rc);
 606     }
 607 
 608     return rc;
 609 }
 610 
 611 /*
 612  * PROC STATE
 613  */
 614 int orte_dt_unpack_proc_state(opal_buffer_t *buffer, void *dest,
 615                                     int32_t *num_vals, opal_data_type_t type)
 616 {
 617     int rc;
 618 
 619     if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, dest, num_vals, ORTE_PROC_STATE_T))) {
 620         ORTE_ERROR_LOG(rc);
 621     }
 622 
 623     return rc;
 624 }
 625 
 626 /*
 627  * JOB STATE
 628  */
 629 int orte_dt_unpack_job_state(opal_buffer_t *buffer, void *dest,
 630                                    int32_t *num_vals, opal_data_type_t type)
 631 {
 632     int rc;
 633 
 634     if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer, dest, num_vals, ORTE_JOB_STATE_T))) {
 635         ORTE_ERROR_LOG(rc);
 636     }
 637 
 638     return rc;
 639 }
 640 
 641 /*
 642  * JOB_MAP
 643  * NOTE: There is no obvious reason to include all the node information when
 644  * sending a map - hence, we do not pack that field, so don't unpack it here
 645  */
 646 int orte_dt_unpack_map(opal_buffer_t *buffer, void *dest,
 647                        int32_t *num_vals, opal_data_type_t type)
 648 {
 649     int rc;
 650     int32_t i, n;
 651     orte_job_map_t **maps;
 652 
 653     /* unpack into array of orte_job_map_t objects */
 654     maps = (orte_job_map_t**) dest;
 655     for (i=0; i < *num_vals; i++) {
 656 
 657         /* create the orte_rmaps_base_map_t object */
 658         maps[i] = OBJ_NEW(orte_job_map_t);
 659         if (NULL == maps[i]) {
 660             ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
 661             return ORTE_ERR_OUT_OF_RESOURCE;
 662         }
 663 
 664         /* unpack the requested mapper */
 665         n = 1;
 666         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 667                                                          &(maps[i]->req_mapper), &n, OPAL_STRING))) {
 668             ORTE_ERROR_LOG(rc);
 669             return rc;
 670         }
 671 
 672         /* unpack the last mapper */
 673         n = 1;
 674         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 675                                                          &(maps[i]->last_mapper), &n, OPAL_STRING))) {
 676             ORTE_ERROR_LOG(rc);
 677             return rc;
 678         }
 679 
 680         /* unpack the policies */
 681         n = 1;
 682         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 683                                                          &(maps[i]->mapping), &n, ORTE_MAPPING_POLICY))) {
 684             ORTE_ERROR_LOG(rc);
 685             return rc;
 686         }
 687         n = 1;
 688         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 689                                                          &(maps[i]->ranking), &n, ORTE_RANKING_POLICY))) {
 690             ORTE_ERROR_LOG(rc);
 691             return rc;
 692         }
 693         n = 1;
 694         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 695                                                          &(maps[i]->binding), &n, OPAL_BINDING_POLICY))) {
 696             ORTE_ERROR_LOG(rc);
 697             return rc;
 698         }
 699         /* unpack the ppr */
 700         n = 1;
 701         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 702                                                          &(maps[i]->ppr), &n, OPAL_STRING))) {
 703             ORTE_ERROR_LOG(rc);
 704             return rc;
 705         }
 706         /* unpack the cpus/rank */
 707         n = 1;
 708         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 709                                                          &(maps[i]->cpus_per_rank), &n, OPAL_INT16))) {
 710             ORTE_ERROR_LOG(rc);
 711             return rc;
 712         }
 713         /* unpack the display map flag */
 714         n = 1;
 715         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 716                                                          &(maps[i]->display_map), &n, OPAL_BOOL))) {
 717             ORTE_ERROR_LOG(rc);
 718             return rc;
 719         }
 720         /* unpack the number of nodes involved in the job */
 721         n = 1;
 722         if (ORTE_SUCCESS != (rc = opal_dss_unpack_buffer(buffer,
 723                                                          &(maps[i]->num_nodes), &n, OPAL_UINT32))) {
 724             ORTE_ERROR_LOG(rc);
 725             return rc;
 726         }
 727     }
 728 
 729     return ORTE_SUCCESS;
 730 }
 731 
 732 /*
 733  * RML_TAG
 734  */
 735 int orte_dt_unpack_tag(opal_buffer_t *buffer, void *dest,
 736                        int32_t *num_vals, opal_data_type_t type)
 737 {
 738     int ret;
 739 
 740     /* Turn around and unpack the real type */
 741     if (ORTE_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, dest, num_vals, ORTE_RML_TAG_T))) {
 742         ORTE_ERROR_LOG(ret);
 743     }
 744 
 745     return ret;
 746 }
 747 
 748 /*
 749  * ORTE_DAEMON_CMD
 750  */
 751 int orte_dt_unpack_daemon_cmd(opal_buffer_t *buffer, void *dest, int32_t *num_vals,
 752                               opal_data_type_t type)
 753 {
 754     int ret;
 755 
 756     /* turn around and unpack the real type */
 757     ret = opal_dss_unpack_buffer(buffer, dest, num_vals, ORTE_DAEMON_CMD_T);
 758 
 759     return ret;
 760 }
 761 
 762 /*
 763  * ORTE_IOF_TAG
 764  */
 765 int orte_dt_unpack_iof_tag(opal_buffer_t *buffer, void *dest, int32_t *num_vals,
 766                            opal_data_type_t type)
 767 {
 768     int ret;
 769 
 770     /* turn around and unpack the real type */
 771     ret = opal_dss_unpack_buffer(buffer, dest, num_vals, ORTE_IOF_TAG_T);
 772 
 773     return ret;
 774 }
 775 
 776 /*
 777  * ORTE_ATTR
 778  */
 779 
 780 int orte_dt_unpack_attr(opal_buffer_t *buffer, void *dest, int32_t *num_vals,
 781                         opal_data_type_t type)
 782 {
 783     orte_attribute_t **ptr;
 784     int32_t i, n, m;
 785     int ret;
 786 
 787     ptr = (orte_attribute_t **) dest;
 788     n = *num_vals;
 789 
 790     for (i = 0; i < n; ++i) {
 791         /* allocate the new object */
 792         ptr[i] = OBJ_NEW(orte_attribute_t);
 793         if (NULL == ptr[i]) {
 794             return OPAL_ERR_OUT_OF_RESOURCE;
 795         }
 796         /* unpack the key and type */
 797         m=1;
 798         if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->key, &m, ORTE_ATTR_KEY_T))) {
 799             return ret;
 800         }
 801         m=1;
 802         if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->type, &m, OPAL_DATA_TYPE))) {
 803             return ret;
 804         }
 805         /* now unpack the right field */
 806         m=1;
 807         switch (ptr[i]->type) {
 808         case OPAL_BOOL:
 809             if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.flag, &m, OPAL_BOOL))) {
 810                 return ret;
 811             }
 812             break;
 813         case OPAL_BYTE:
 814             if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.byte, &m, OPAL_BYTE))) {
 815                 return ret;
 816             }
 817             break;
 818         case OPAL_STRING:
 819             if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.string, &m, OPAL_STRING))) {
 820                 return ret;
 821             }
 822             break;
 823         case OPAL_SIZE:
 824             if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.size, &m, OPAL_SIZE))) {
 825                 return ret;
 826             }
 827             break;
 828         case OPAL_PID:
 829             if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.pid, &m, OPAL_PID))) {
 830                 return ret;
 831             }
 832             break;
 833         case OPAL_INT:
 834             if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.integer, &m, OPAL_INT))) {
 835                 return ret;
 836             }
 837             break;
 838         case OPAL_INT8:
 839             if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.int8, &m, OPAL_INT8))) {
 840                 return ret;
 841             }
 842             break;
 843         case OPAL_INT16:
 844             if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.int16, &m, OPAL_INT16))) {
 845                 return ret;
 846             }
 847             break;
 848         case OPAL_INT32:
 849             if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.int32, &m, OPAL_INT32))) {
 850                 return ret;
 851             }
 852             break;
 853         case OPAL_INT64:
 854             if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.int64, &m, OPAL_INT64))) {
 855                 return ret;
 856             }
 857             break;
 858         case OPAL_UINT:
 859             if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.uint, &m, OPAL_UINT))) {
 860                 return ret;
 861             }
 862             break;
 863         case OPAL_UINT8:
 864             if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.uint8, &m, OPAL_UINT8))) {
 865                 return ret;
 866             }
 867             break;
 868         case OPAL_UINT16:
 869             if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.uint16, &m, OPAL_UINT16))) {
 870                 return ret;
 871             }
 872             break;
 873         case OPAL_UINT32:
 874             if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.uint32, &m, OPAL_UINT32))) {
 875                 return ret;
 876             }
 877             break;
 878         case OPAL_UINT64:
 879             if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.uint64, &m, OPAL_UINT64))) {
 880                 return ret;
 881             }
 882             break;
 883         case OPAL_BYTE_OBJECT:
 884             /* cannot use byte object unpack as it allocates memory, so unpack object size in bytes */
 885             if (OPAL_SUCCESS != (ret = opal_dss_unpack_int32(buffer, &(ptr[i]->data.bo.size), &m, OPAL_INT32))) {
 886                 return ret;
 887             }
 888             if (0 < ptr[i]->data.bo.size) {
 889                 ptr[i]->data.bo.bytes = (uint8_t*)malloc(ptr[i]->data.bo.size);
 890                 if (NULL == ptr[i]->data.bo.bytes) {
 891                     return OPAL_ERR_OUT_OF_RESOURCE;
 892                 }
 893                 if (OPAL_SUCCESS != (ret = opal_dss_unpack_byte(buffer, ptr[i]->data.bo.bytes,
 894                                                                 &(ptr[i]->data.bo.size), OPAL_BYTE))) {
 895                     return ret;
 896                 }
 897             } else {
 898                 ptr[i]->data.bo.bytes = NULL;
 899             }
 900             break;
 901         case OPAL_FLOAT:
 902             if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.fval, &m, OPAL_FLOAT))) {
 903                 return ret;
 904             }
 905             break;
 906         case OPAL_TIMEVAL:
 907             if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.tv, &m, OPAL_TIMEVAL))) {
 908                 return ret;
 909             }
 910             break;
 911         case OPAL_VPID:
 912             if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.vpid, &m, ORTE_VPID))) {
 913                 return ret;
 914             }
 915             break;
 916         case OPAL_JOBID:
 917             if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.jobid, &m, ORTE_JOBID))) {
 918                 return ret;
 919             }
 920             break;
 921         case OPAL_NAME:
 922             if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.name, &m, ORTE_NAME))) {
 923                 return ret;
 924             }
 925             break;
 926         case OPAL_ENVAR:
 927             if (OPAL_SUCCESS != (ret = opal_dss_unpack_buffer(buffer, &ptr[i]->data.envar, &m, OPAL_ENVAR))) {
 928                 return ret;
 929             }
 930             break;
 931 
 932         default:
 933             opal_output(0, "PACK-ORTE-ATTR: UNSUPPORTED TYPE");
 934             return OPAL_ERROR;
 935         }
 936     }
 937 
 938     return OPAL_SUCCESS;
 939 }
 940 
 941 int orte_dt_unpack_sig(opal_buffer_t *buffer, void *dest, int32_t *num_vals,
 942                        opal_data_type_t type)
 943 {
 944     orte_grpcomm_signature_t **ptr;
 945     int32_t i, n, cnt;
 946     int rc;
 947 
 948     ptr = (orte_grpcomm_signature_t **) dest;
 949     n = *num_vals;
 950 
 951     for (i = 0; i < n; ++i) {
 952         /* allocate the new object */
 953         ptr[i] = OBJ_NEW(orte_grpcomm_signature_t);
 954         if (NULL == ptr[i]) {
 955             return OPAL_ERR_OUT_OF_RESOURCE;
 956         }
 957         /* unpack the #procs */
 958         cnt = 1;
 959         if (OPAL_SUCCESS != (rc = opal_dss.unpack(buffer, &ptr[i]->sz, &cnt, OPAL_SIZE))) {
 960             ORTE_ERROR_LOG(rc);
 961             return rc;
 962         }
 963         if (0 < ptr[i]->sz) {
 964             /* allocate space for the array */
 965             ptr[i]->signature = (orte_process_name_t*)malloc(ptr[i]->sz * sizeof(orte_process_name_t));
 966             /* unpack the array - the array is our signature for the collective */
 967             cnt = ptr[i]->sz;
 968             if (OPAL_SUCCESS != (rc = opal_dss.unpack(buffer, ptr[i]->signature, &cnt, ORTE_NAME))) {
 969                 ORTE_ERROR_LOG(rc);
 970                 OBJ_RELEASE(ptr[i]);
 971                 return rc;
 972             }
 973         }
 974     }
 975     return ORTE_SUCCESS;
 976 }

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