root/orte/runtime/data_type_support/orte_dt_packing_fns.c

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

DEFINITIONS

This source file includes following definitions.
  1. orte_dt_pack_std_cntr
  2. orte_dt_pack_job
  3. orte_dt_pack_node
  4. orte_dt_pack_proc
  5. orte_dt_pack_app_context
  6. orte_dt_pack_exit_code
  7. orte_dt_pack_node_state
  8. orte_dt_pack_proc_state
  9. orte_dt_pack_job_state
  10. orte_dt_pack_map
  11. orte_dt_pack_tag
  12. orte_dt_pack_daemon_cmd
  13. orte_dt_pack_iof_tag
  14. orte_dt_pack_attr
  15. orte_dt_pack_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      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/util/argv.h"
  29 #include "opal/dss/dss.h"
  30 #include "opal/dss/dss_internal.h"
  31 #include "opal/mca/hwloc/base/base.h"
  32 #include "opal/class/opal_pointer_array.h"
  33 
  34 #include "orte/mca/errmgr/errmgr.h"
  35 #include "opal/dss/dss.h"
  36 #include "opal/dss/dss_internal.h"
  37 #include "orte/runtime/data_type_support/orte_dt_support.h"
  38 
  39 /*
  40  * ORTE_STD_CNTR
  41  */
  42 int orte_dt_pack_std_cntr(opal_buffer_t *buffer, const void *src,
  43                             int32_t num_vals, opal_data_type_t type)
  44 {
  45     int ret;
  46 
  47     /* Turn around and pack the real type */
  48     if (ORTE_SUCCESS != (
  49                          ret = opal_dss_pack_buffer(buffer, src, num_vals, ORTE_STD_CNTR_T))) {
  50         ORTE_ERROR_LOG(ret);
  51     }
  52 
  53     return ret;
  54 }
  55 
  56 /*
  57  * JOB
  58  * NOTE: We do not pack all of the job object's fields as many of them have no
  59  * value in sending them to another location. The only purpose in packing and
  60  * sending a job object is to communicate the data required to dynamically
  61  * spawn another job - so we only pack that limited set of required data
  62  */
  63 int orte_dt_pack_job(opal_buffer_t *buffer, const void *src,
  64                      int32_t num_vals, opal_data_type_t type)
  65 {
  66     int rc;
  67     int32_t i, j, count, bookmark;
  68     orte_job_t **jobs;
  69     orte_app_context_t *app;
  70     orte_proc_t *proc;
  71     orte_attribute_t *kv;
  72     opal_list_t *cache;
  73     opal_value_t *val;
  74 
  75     /* array of pointers to orte_job_t objects - need to pack the objects a set of fields at a time */
  76     jobs = (orte_job_t**) src;
  77 
  78     for (i=0; i < num_vals; i++) {
  79         /* pack the jobid */
  80         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
  81                         (void*)(&(jobs[i]->jobid)), 1, ORTE_JOBID))) {
  82             ORTE_ERROR_LOG(rc);
  83             return rc;
  84         }
  85         /* pack the flags */
  86         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
  87                         (void*)(&(jobs[i]->flags)), 1, ORTE_JOB_FLAGS_T))) {
  88             ORTE_ERROR_LOG(rc);
  89             return rc;
  90         }
  91 
  92         /* pack the attributes that need to be sent */
  93         count = 0;
  94         OPAL_LIST_FOREACH(kv, &jobs[i]->attributes, orte_attribute_t) {
  95             if (ORTE_ATTR_GLOBAL == kv->local) {
  96                 ++count;
  97             }
  98         }
  99         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, (void*)(&count), 1, ORTE_STD_CNTR))) {
 100             ORTE_ERROR_LOG(rc);
 101             return rc;
 102         }
 103         OPAL_LIST_FOREACH(kv, &jobs[i]->attributes, orte_attribute_t) {
 104             if (ORTE_ATTR_GLOBAL == kv->local) {
 105                 if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, (void*)&kv, 1, ORTE_ATTRIBUTE))) {
 106                     ORTE_ERROR_LOG(rc);
 107                     return rc;
 108                 }
 109             }
 110         }
 111         /* check for job info attribute */
 112         cache = NULL;
 113         if (orte_get_attribute(&jobs[i]->attributes, ORTE_JOB_INFO_CACHE, (void**)&cache, OPAL_PTR) &&
 114             NULL != cache) {
 115             /* we need to pack these as well, but they are composed
 116              * of opal_value_t's on a list. So first pack the number
 117              * of list elements */
 118             count = opal_list_get_size(cache);
 119             if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, (void*)(&count), 1, ORTE_STD_CNTR))) {
 120                 ORTE_ERROR_LOG(rc);
 121                 return rc;
 122             }
 123             /* now pack each element on the list */
 124             OPAL_LIST_FOREACH(val, cache, opal_value_t) {
 125                 if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, (void*)&val, 1, OPAL_VALUE))) {
 126                     ORTE_ERROR_LOG(rc);
 127                     return rc;
 128                 }
 129             }
 130         } else {
 131             /* pack a zero to indicate no job info is being passed */
 132             count = 0;
 133             if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, (void*)(&count), 1, ORTE_STD_CNTR))) {
 134                 ORTE_ERROR_LOG(rc);
 135                 return rc;
 136             }
 137         }
 138 
 139         /* pack the personality */
 140         count = opal_argv_count(jobs[i]->personality);
 141         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, &count, 1, OPAL_INT32))) {
 142             ORTE_ERROR_LOG(rc);
 143             return rc;
 144         }
 145         for (j=0; j < count; j++) {
 146             if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, &jobs[i]->personality[j], 1, OPAL_STRING))) {
 147                 ORTE_ERROR_LOG(rc);
 148                 return rc;
 149             }
 150         }
 151 
 152         /* pack the number of apps */
 153         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
 154                          (void*)(&(jobs[i]->num_apps)), 1, ORTE_APP_IDX))) {
 155             ORTE_ERROR_LOG(rc);
 156             return rc;
 157         }
 158 
 159         /* if there are apps, pack the app_contexts */
 160         if (0 < jobs[i]->num_apps) {
 161             for (j=0; j < jobs[i]->apps->size; j++) {
 162                 if (NULL == (app = (orte_app_context_t*)opal_pointer_array_get_item(jobs[i]->apps, j))) {
 163                     continue;
 164                 }
 165                 if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, (void*)&app, 1, ORTE_APP_CONTEXT))) {
 166                     ORTE_ERROR_LOG(rc);
 167                     return rc;
 168                 }
 169             }
 170         }
 171 
 172         /* pack the number of procs and offset */
 173         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
 174                          (void*)(&(jobs[i]->num_procs)), 1, ORTE_VPID))) {
 175             ORTE_ERROR_LOG(rc);
 176             return rc;
 177         }
 178         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
 179                          (void*)(&(jobs[i]->offset)), 1, ORTE_VPID))) {
 180             ORTE_ERROR_LOG(rc);
 181             return rc;
 182         }
 183 
 184         if (0 < jobs[i]->num_procs) {
 185             /* check attributes to see if this job is to be fully
 186              * described in the launch msg */
 187             if (orte_get_attribute(&jobs[i]->attributes, ORTE_JOB_FULLY_DESCRIBED, NULL, OPAL_BOOL)) {
 188                 for (j=0; j < jobs[i]->procs->size; j++) {
 189                     if (NULL == (proc = (orte_proc_t*)opal_pointer_array_get_item(jobs[i]->procs, j))) {
 190                         continue;
 191                     }
 192                     if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, (void*)&proc, 1, ORTE_PROC))) {
 193                         ORTE_ERROR_LOG(rc);
 194                         return rc;
 195                     }
 196                 }
 197             }
 198         }
 199 
 200         /* pack the stdin target */
 201         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
 202                          (void*)(&(jobs[i]->stdin_target)), 1, ORTE_VPID))) {
 203             ORTE_ERROR_LOG(rc);
 204             return rc;
 205         }
 206 
 207         /* pack the total slots allocated to the job */
 208         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
 209                          (void*)(&(jobs[i]->total_slots_alloc)), 1, ORTE_STD_CNTR))) {
 210             ORTE_ERROR_LOG(rc);
 211             return rc;
 212         }
 213 
 214         /* if the map is NULL, then we cannot pack it as there is
 215          * nothing to pack. However, we have to flag whether or not
 216          * the map is included so the unpacking routine can know
 217          * what to do
 218          */
 219         if (NULL == jobs[i]->map) {
 220             /* pack a zero value */
 221             j=0;
 222         } else {
 223             /* pack a one to indicate a map is there */
 224             j = 1;
 225         }
 226         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
 227                             (void*)&j, 1, ORTE_STD_CNTR))) {
 228             ORTE_ERROR_LOG(rc);
 229             return rc;
 230         }
 231 
 232         /* pack the map - this will only pack the fields that control
 233          * HOW a job is to be mapped. We do -not- pack the mapped procs
 234          * or nodes as this info does not need to be transmitted
 235          */
 236         if (NULL != jobs[i]->map) {
 237             if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
 238                              (void*)(&(jobs[i]->map)), 1, ORTE_JOB_MAP))) {
 239                 ORTE_ERROR_LOG(rc);
 240                 return rc;
 241             }
 242         }
 243 
 244         /* pack the bookmark */
 245         if (NULL == jobs[i]->bookmark) {
 246             bookmark = -1;
 247         } else {
 248             bookmark = jobs[i]->bookmark->index;
 249         }
 250         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, &bookmark, 1, OPAL_INT32))) {
 251             ORTE_ERROR_LOG(rc);
 252             return rc;
 253         }
 254 
 255         /* pack the job state */
 256         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
 257                          (void*)(&(jobs[i]->state)), 1, ORTE_JOB_STATE))) {
 258             ORTE_ERROR_LOG(rc);
 259             return rc;
 260         }
 261     }
 262     return ORTE_SUCCESS;
 263 }
 264 
 265 /*
 266  *  NODE
 267  */
 268 int orte_dt_pack_node(opal_buffer_t *buffer, const void *src,
 269                       int32_t num_vals, opal_data_type_t type)
 270 {
 271     int rc;
 272     int32_t i, count;
 273     orte_node_t **nodes;
 274     uint8_t flag;
 275     orte_attribute_t *kv;
 276 
 277     /* array of pointers to orte_node_t objects - need to pack the objects a set of fields at a time */
 278     nodes = (orte_node_t**) src;
 279 
 280     for (i=0; i < num_vals; i++) {
 281         /* do not pack the index - it is meaningless on the other end */
 282 
 283         /* pack the node name */
 284         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, (void*)(&(nodes[i]->name)), 1, OPAL_STRING))) {
 285             ORTE_ERROR_LOG(rc);
 286             return rc;
 287         }
 288 
 289         /* do not pack the daemon name or launch id */
 290 
 291         /* pack the number of procs on the node */
 292         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, (void*)(&(nodes[i]->num_procs)), 1, ORTE_VPID))) {
 293             ORTE_ERROR_LOG(rc);
 294             return rc;
 295         }
 296 
 297         /* do not pack the procs */
 298 
 299         /* pack whether we are oversubscribed or not */
 300         flag = ORTE_FLAG_TEST(nodes[i], ORTE_NODE_FLAG_OVERSUBSCRIBED);
 301         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, (void*)(&flag), 1, OPAL_UINT8))) {
 302             ORTE_ERROR_LOG(rc);
 303             return rc;
 304         }
 305 
 306         /* pack the state */
 307         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, (void*)(&(nodes[i]->state)), 1, ORTE_NODE_STATE))) {
 308             ORTE_ERROR_LOG(rc);
 309             return rc;
 310         }
 311 
 312         /* pack any shared attributes */
 313         count = 0;
 314         OPAL_LIST_FOREACH(kv, &nodes[i]->attributes, orte_attribute_t) {
 315             if (ORTE_ATTR_GLOBAL == kv->local) {
 316                 ++count;
 317             }
 318         }
 319         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, (void*)(&count), 1, ORTE_STD_CNTR))) {
 320             ORTE_ERROR_LOG(rc);
 321             return rc;
 322         }
 323         OPAL_LIST_FOREACH(kv, &nodes[i]->attributes, orte_attribute_t) {
 324             if (ORTE_ATTR_GLOBAL == kv->local) {
 325                 if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, (void*)&kv, 1, ORTE_ATTRIBUTE))) {
 326                     ORTE_ERROR_LOG(rc);
 327                     return rc;
 328                 }
 329             }
 330         }
 331     }
 332     return ORTE_SUCCESS;
 333 }
 334 
 335 /*
 336  * PROC
 337  */
 338 int orte_dt_pack_proc(opal_buffer_t *buffer, const void *src,
 339                       int32_t num_vals, opal_data_type_t type)
 340 {
 341     int rc;
 342     int32_t i, count;
 343     orte_proc_t **procs;
 344     orte_attribute_t *kv;
 345 
 346     /* array of pointers to orte_proc_t objects - need to pack the objects a set of fields at a time */
 347     procs = (orte_proc_t**) src;
 348 
 349     for (i=0; i < num_vals; i++) {
 350         /* pack the name */
 351         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
 352                          (void*)(&(procs[i]->name)), 1, ORTE_NAME))) {
 353             ORTE_ERROR_LOG(rc);
 354             return rc;
 355         }
 356 
 357         /* pack the daemon/node it is on */
 358         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
 359                          (void*)(&(procs[i]->parent)), 1, ORTE_VPID))) {
 360             ORTE_ERROR_LOG(rc);
 361             return rc;
 362         }
 363 
 364         /* pack the local rank */
 365         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
 366                          (void*)(&(procs[i]->local_rank)), 1, ORTE_LOCAL_RANK))) {
 367             ORTE_ERROR_LOG(rc);
 368             return rc;
 369         }
 370 
 371         /* pack the node rank */
 372         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
 373                          (void*)(&(procs[i]->node_rank)), 1, ORTE_NODE_RANK))) {
 374             ORTE_ERROR_LOG(rc);
 375             return rc;
 376         }
 377 
 378         /* pack the state */
 379         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
 380                          (void*)(&(procs[i]->state)), 1, ORTE_PROC_STATE))) {
 381             ORTE_ERROR_LOG(rc);
 382             return rc;
 383         }
 384 
 385         /* pack the app context index */
 386         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
 387                          (void*)(&(procs[i]->app_idx)), 1, ORTE_STD_CNTR))) {
 388             ORTE_ERROR_LOG(rc);
 389             return rc;
 390         }
 391 
 392         /* pack the app rank */
 393         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
 394                          (void*)(&(procs[i]->app_rank)), 1, OPAL_UINT32))) {
 395             ORTE_ERROR_LOG(rc);
 396             return rc;
 397         }
 398 
 399         /* pack the attributes that will go */
 400         count = 0;
 401         OPAL_LIST_FOREACH(kv, &procs[i]->attributes, orte_attribute_t) {
 402             if (ORTE_ATTR_GLOBAL == kv->local) {
 403                 ++count;
 404             }
 405         }
 406         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, (void*)(&count), 1, ORTE_STD_CNTR))) {
 407             ORTE_ERROR_LOG(rc);
 408             return rc;
 409         }
 410         OPAL_LIST_FOREACH(kv, &procs[i]->attributes, orte_attribute_t) {
 411             if (ORTE_ATTR_GLOBAL == kv->local) {
 412                 if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, (void*)&kv, 1, ORTE_ATTRIBUTE))) {
 413                     ORTE_ERROR_LOG(rc);
 414                     return rc;
 415                 }
 416             }
 417         }
 418     }
 419 
 420     return ORTE_SUCCESS;
 421 }
 422 
 423 /*
 424  * APP CONTEXT
 425  */
 426 int orte_dt_pack_app_context(opal_buffer_t *buffer, const void *src,
 427                              int32_t num_vals, opal_data_type_t type)
 428 {
 429     int rc;
 430     int32_t i, count;
 431     orte_app_context_t **app_context;
 432     orte_attribute_t *kv;
 433 
 434     /* array of pointers to orte_app_context objects - need to pack the objects a set of fields at a time */
 435     app_context = (orte_app_context_t**) src;
 436 
 437     for (i=0; i < num_vals; i++) {
 438         /* pack the application index (for multiapp jobs) */
 439         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
 440                                                        (void*)(&(app_context[i]->idx)), 1, ORTE_STD_CNTR))) {
 441             ORTE_ERROR_LOG(rc);
 442             return rc;
 443         }
 444 
 445         /* pack the application name */
 446         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
 447                                                        (void*)(&(app_context[i]->app)), 1, OPAL_STRING))) {
 448             ORTE_ERROR_LOG(rc);
 449             return rc;
 450         }
 451 
 452         /* pack the number of processes */
 453         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
 454                                                        (void*)(&(app_context[i]->num_procs)), 1, ORTE_STD_CNTR))) {
 455             ORTE_ERROR_LOG(rc);
 456             return rc;
 457         }
 458 
 459         /* pack the first rank for this app */
 460         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
 461                                                        (void*)(&(app_context[i]->first_rank)), 1, ORTE_VPID))) {
 462             ORTE_ERROR_LOG(rc);
 463             return rc;
 464         }
 465 
 466         /* pack the number of entries in the argv array */
 467         count = opal_argv_count(app_context[i]->argv);
 468         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, (void*)(&count), 1, ORTE_STD_CNTR))) {
 469             ORTE_ERROR_LOG(rc);
 470             return rc;
 471         }
 472 
 473         /* if there are entries, pack the argv entries */
 474         if (0 < count) {
 475             if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
 476                                                            (void*)(app_context[i]->argv), count, OPAL_STRING))) {
 477                 ORTE_ERROR_LOG(rc);
 478                 return rc;
 479             }
 480         }
 481 
 482         /* pack the number of entries in the enviro array */
 483         count = opal_argv_count(app_context[i]->env);
 484         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, (void*)(&count), 1, ORTE_STD_CNTR))) {
 485             ORTE_ERROR_LOG(rc);
 486             return rc;
 487         }
 488 
 489         /* if there are entries, pack the enviro entries */
 490         if (0 < count) {
 491             if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
 492                                                            (void*)(app_context[i]->env), count, OPAL_STRING))) {
 493                 ORTE_ERROR_LOG(rc);
 494                 return rc;
 495             }
 496         }
 497 
 498         /* pack the cwd */
 499         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer,
 500                                                        (void*)(&(app_context[i]->cwd)), 1, OPAL_STRING))) {
 501             ORTE_ERROR_LOG(rc);
 502             return rc;
 503         }
 504 
 505         /* pack attributes */
 506         count = 0;
 507         OPAL_LIST_FOREACH(kv, &app_context[i]->attributes, orte_attribute_t) {
 508             if (ORTE_ATTR_GLOBAL == kv->local) {
 509                 ++count;
 510             }
 511         }
 512         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, (void*)(&count), 1, ORTE_STD_CNTR))) {
 513             ORTE_ERROR_LOG(rc);
 514             return rc;
 515         }
 516         OPAL_LIST_FOREACH(kv, &app_context[i]->attributes, orte_attribute_t) {
 517             if (ORTE_ATTR_GLOBAL == kv->local) {
 518                 if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, (void*)&kv, 1, ORTE_ATTRIBUTE))) {
 519                     ORTE_ERROR_LOG(rc);
 520                     return rc;
 521                 }
 522             }
 523         }
 524     }
 525 
 526     return ORTE_SUCCESS;
 527 }
 528 
 529 /*
 530  * EXIT CODE
 531  */
 532 int orte_dt_pack_exit_code(opal_buffer_t *buffer, const void *src,
 533                                  int32_t num_vals, opal_data_type_t type)
 534 {
 535     int rc;
 536 
 537     if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, src, num_vals, ORTE_EXIT_CODE_T))) {
 538         ORTE_ERROR_LOG(rc);
 539     }
 540 
 541     return rc;
 542 }
 543 
 544 /*
 545  * NODE STATE
 546  */
 547 int orte_dt_pack_node_state(opal_buffer_t *buffer, const void *src,
 548                                   int32_t num_vals, opal_data_type_t type)
 549 {
 550     int rc;
 551 
 552     if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, src, num_vals, ORTE_NODE_STATE_T))) {
 553         ORTE_ERROR_LOG(rc);
 554     }
 555 
 556     return rc;
 557 }
 558 
 559 /*
 560  * PROC STATE
 561  */
 562 int orte_dt_pack_proc_state(opal_buffer_t *buffer, const void *src,
 563                                   int32_t num_vals, opal_data_type_t type)
 564 {
 565     int rc;
 566 
 567     if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, src, num_vals, ORTE_PROC_STATE_T))) {
 568         ORTE_ERROR_LOG(rc);
 569     }
 570 
 571     return rc;
 572 }
 573 
 574 /*
 575  * JOB STATE
 576  */
 577 int orte_dt_pack_job_state(opal_buffer_t *buffer, const void *src,
 578                                  int32_t num_vals, opal_data_type_t type)
 579 {
 580     int rc;
 581 
 582     if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, src, num_vals, ORTE_JOB_STATE_T))) {
 583         ORTE_ERROR_LOG(rc);
 584     }
 585 
 586     return rc;
 587 }
 588 
 589 /*
 590  * JOB_MAP
 591  * NOTE: There is no obvious reason to include all the node information when
 592  * sending a map
 593  */
 594 int orte_dt_pack_map(opal_buffer_t *buffer, const void *src,
 595                              int32_t num_vals, opal_data_type_t type)
 596 {
 597     int rc;
 598     int32_t i;
 599     orte_job_map_t **maps;
 600 
 601     /* array of pointers to orte_job_map_t objects - need to pack the objects a set of fields at a time */
 602     maps = (orte_job_map_t**) src;
 603 
 604     for (i=0; i < num_vals; i++) {
 605         /* pack the requested mapper */
 606         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, &(maps[i]->req_mapper), 1, OPAL_STRING))) {
 607             ORTE_ERROR_LOG(rc);
 608             return rc;
 609         }
 610         /* pack the last mapper */
 611         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, &(maps[i]->last_mapper), 1, OPAL_STRING))) {
 612             ORTE_ERROR_LOG(rc);
 613             return rc;
 614         }
 615         /* pack the policies */
 616         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, &(maps[i]->mapping), 1, ORTE_MAPPING_POLICY))) {
 617             ORTE_ERROR_LOG(rc);
 618             return rc;
 619         }
 620         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, &(maps[i]->ranking), 1, ORTE_RANKING_POLICY))) {
 621             ORTE_ERROR_LOG(rc);
 622             return rc;
 623         }
 624         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, &(maps[i]->binding), 1, OPAL_BINDING_POLICY))) {
 625             ORTE_ERROR_LOG(rc);
 626             return rc;
 627         }
 628         /* pack any ppr */
 629         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, &(maps[i]->ppr), 1, OPAL_STRING))) {
 630             ORTE_ERROR_LOG(rc);
 631             return rc;
 632         }
 633         /* pack the cpus/rank */
 634         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, &(maps[i]->cpus_per_rank), 1, OPAL_INT16))) {
 635             ORTE_ERROR_LOG(rc);
 636             return rc;
 637         }
 638         /* pack the display map flag */
 639         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, &(maps[i]->display_map), 1, OPAL_BOOL))) {
 640             ORTE_ERROR_LOG(rc);
 641             return rc;
 642         }
 643         /* pack the number of nodes involved in the job */
 644         if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, &(maps[i]->num_nodes), 1, OPAL_UINT32))) {
 645             ORTE_ERROR_LOG(rc);
 646             return rc;
 647         }
 648 
 649     }
 650 
 651     return ORTE_SUCCESS;
 652 }
 653 
 654 /*
 655  * RML TAG
 656  */
 657 int orte_dt_pack_tag(opal_buffer_t *buffer, const void *src,
 658                            int32_t num_vals, opal_data_type_t type)
 659 {
 660     int rc;
 661 
 662     /* Turn around and pack the real type */
 663     if (ORTE_SUCCESS != (rc = opal_dss_pack_buffer(buffer, src, num_vals, ORTE_RML_TAG_T))) {
 664         ORTE_ERROR_LOG(rc);
 665     }
 666 
 667     return rc;
 668 }
 669 
 670 /*
 671  * ORTE_DAEMON_CMD
 672  */
 673 int orte_dt_pack_daemon_cmd(opal_buffer_t *buffer, const void *src, int32_t num_vals,
 674                               opal_data_type_t type)
 675 {
 676     int ret;
 677 
 678     /* Turn around and pack the real type */
 679     if (ORTE_SUCCESS != (ret = opal_dss_pack_buffer(buffer, src, num_vals, ORTE_DAEMON_CMD_T))) {
 680         ORTE_ERROR_LOG(ret);
 681     }
 682 
 683     return ret;
 684 }
 685 
 686 /*
 687  * ORTE_IOF_TAG
 688  */
 689 int orte_dt_pack_iof_tag(opal_buffer_t *buffer, const void *src, int32_t num_vals,
 690                          opal_data_type_t type)
 691 {
 692     int ret;
 693 
 694     /* Turn around and pack the real type */
 695     if (ORTE_SUCCESS != (ret = opal_dss_pack_buffer(buffer, src, num_vals, ORTE_IOF_TAG_T))) {
 696         ORTE_ERROR_LOG(ret);
 697     }
 698 
 699     return ret;
 700 }
 701 
 702 
 703 /*
 704  * ORTE_ATTR
 705  */
 706 int orte_dt_pack_attr(opal_buffer_t *buffer, const void *src, int32_t num_vals,
 707                       opal_data_type_t type)
 708 {
 709     orte_attribute_t **ptr;
 710     int32_t i, n;
 711     int ret;
 712 
 713     ptr = (orte_attribute_t **) src;
 714 
 715     for (i = 0; i < num_vals; ++i) {
 716         /* pack the key and type */
 717         if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->key, 1, ORTE_ATTR_KEY_T))) {
 718             return ret;
 719         }
 720         if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->type, 1, OPAL_DATA_TYPE))) {
 721             return ret;
 722         }
 723         /* now pack the right field */
 724         switch (ptr[i]->type) {
 725         case OPAL_BOOL:
 726             if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.flag, 1, OPAL_BOOL))) {
 727                 return ret;
 728             }
 729             break;
 730         case OPAL_BYTE:
 731             if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.byte, 1, OPAL_BYTE))) {
 732                 return ret;
 733             }
 734             break;
 735         case OPAL_STRING:
 736             if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.string, 1, OPAL_STRING))) {
 737                 return ret;
 738             }
 739             break;
 740         case OPAL_SIZE:
 741             if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.size, 1, OPAL_SIZE))) {
 742                 return ret;
 743             }
 744             break;
 745         case OPAL_PID:
 746             if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.pid, 1, OPAL_PID))) {
 747                 return ret;
 748             }
 749             break;
 750         case OPAL_INT:
 751             if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.integer, 1, OPAL_INT))) {
 752                 return ret;
 753             }
 754             break;
 755         case OPAL_INT8:
 756             if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.int8, 1, OPAL_INT8))) {
 757                 return ret;
 758             }
 759             break;
 760         case OPAL_INT16:
 761             if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.int16, 1, OPAL_INT16))) {
 762                 return ret;
 763             }
 764             break;
 765         case OPAL_INT32:
 766             if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.int32, 1, OPAL_INT32))) {
 767                 return ret;
 768             }
 769             break;
 770         case OPAL_INT64:
 771             if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.int64, 1, OPAL_INT64))) {
 772                 return ret;
 773             }
 774             break;
 775         case OPAL_UINT:
 776             if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.uint, 1, OPAL_UINT))) {
 777                 return ret;
 778             }
 779             break;
 780         case OPAL_UINT8:
 781             if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.uint8, 1, OPAL_UINT8))) {
 782                 return ret;
 783             }
 784             break;
 785         case OPAL_UINT16:
 786             if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.uint16, 1, OPAL_UINT16))) {
 787                 return ret;
 788             }
 789             break;
 790         case OPAL_UINT32:
 791             if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.uint32, 1, OPAL_UINT32))) {
 792                 return ret;
 793             }
 794             break;
 795         case OPAL_UINT64:
 796             if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.uint64, 1, OPAL_UINT64))) {
 797                 return ret;
 798             }
 799             break;
 800         case OPAL_BYTE_OBJECT:
 801             /* have to pack by hand so we can match unpack without allocation */
 802             n = ptr[i]->data.bo.size;
 803             if (OPAL_SUCCESS != (ret = opal_dss_pack_int32(buffer, &n, 1, OPAL_INT32))) {
 804                 return ret;
 805             }
 806             if (0 < n) {
 807                 if (OPAL_SUCCESS != (ret = opal_dss_pack_byte(buffer, ptr[i]->data.bo.bytes, n, OPAL_BYTE))) {
 808                     return ret;
 809                 }
 810             }
 811             break;
 812         case OPAL_FLOAT:
 813             if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.fval, 1, OPAL_FLOAT))) {
 814                 return ret;
 815             }
 816             break;
 817         case OPAL_TIMEVAL:
 818             if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.tv, 1, OPAL_TIMEVAL))) {
 819                 return ret;
 820             }
 821             break;
 822         case OPAL_PTR:
 823             /* just ignore these values */
 824             break;
 825         case OPAL_VPID:
 826             if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.vpid, 1, ORTE_VPID))) {
 827                 return ret;
 828             }
 829             break;
 830         case OPAL_JOBID:
 831             if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.jobid, 1, ORTE_JOBID))) {
 832                 return ret;
 833             }
 834             break;
 835         case OPAL_NAME:
 836             if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.name, 1, ORTE_NAME))) {
 837                 return ret;
 838             }
 839             break;
 840         case OPAL_ENVAR:
 841             if (OPAL_SUCCESS != (ret = opal_dss_pack_buffer(buffer, &ptr[i]->data.envar, 1, OPAL_ENVAR))) {
 842                 return ret;
 843             }
 844             break;
 845 
 846         default:
 847             opal_output(0, "PACK-ORTE-ATTR: UNSUPPORTED TYPE %d", (int)ptr[i]->type);
 848             return OPAL_ERROR;
 849         }
 850     }
 851 
 852     return OPAL_SUCCESS;
 853 }
 854 
 855 /*
 856  * ORTE_SIGNATURE
 857  */
 858 int orte_dt_pack_sig(opal_buffer_t *buffer, const void *src, int32_t num_vals,
 859                      opal_data_type_t type)
 860 {
 861     orte_grpcomm_signature_t **ptr;
 862     int32_t i;
 863     int rc;
 864 
 865     ptr = (orte_grpcomm_signature_t **) src;
 866 
 867     for (i = 0; i < num_vals; ++i) {
 868         /* pack the #procs */
 869         if (OPAL_SUCCESS != (rc = opal_dss.pack(buffer, &ptr[i]->sz, 1, OPAL_SIZE))) {
 870             ORTE_ERROR_LOG(rc);
 871             return rc;
 872         }
 873         if (0 < ptr[i]->sz) {
 874             /* pack the array */
 875             if (OPAL_SUCCESS != (rc = opal_dss.pack(buffer, ptr[i]->signature, ptr[i]->sz, ORTE_NAME))) {
 876                 ORTE_ERROR_LOG(rc);
 877                 return rc;
 878             }
 879         }
 880     }
 881 
 882     return ORTE_SUCCESS;
 883 }

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