root/orte/runtime/data_type_support/orte_dt_copy_fns.c

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

DEFINITIONS

This source file includes following definitions.
  1. orte_dt_copy_std_cntr
  2. orte_dt_copy_job
  3. orte_dt_copy_node
  4. orte_dt_copy_proc
  5. orte_dt_copy_app_context
  6. orte_dt_copy_proc_state
  7. orte_dt_copy_job_state
  8. orte_dt_copy_node_state
  9. orte_dt_copy_exit_code
  10. orte_dt_copy_map
  11. orte_dt_copy_tag
  12. orte_dt_copy_daemon_cmd
  13. orte_dt_copy_iof_tag
  14. orte_dt_copy_attr
  15. orte_dt_copy_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-2016 Intel, Inc. All rights reserved.
  16  * $COPYRIGHT$
  17  *
  18  * Additional copyrights may follow
  19  *
  20  * $HEADER$
  21  */
  22 
  23 #include "orte_config.h"
  24 
  25 #ifdef HAVE_SYS_TYPES_H
  26 #include <sys/types.h>
  27 #endif
  28 #include <string.h>
  29 
  30 #include "opal/util/argv.h"
  31 #include "opal/dss/dss.h"
  32 
  33 #include "orte/mca/errmgr/errmgr.h"
  34 #include "orte/runtime/data_type_support/orte_dt_support.h"
  35 
  36 /* ORTE_STD_CNTR */
  37 int orte_dt_copy_std_cntr(orte_std_cntr_t **dest, orte_std_cntr_t *src, opal_data_type_t type)
  38 {
  39     orte_std_cntr_t *val;
  40 
  41     val = (orte_std_cntr_t*)malloc(sizeof(orte_std_cntr_t));
  42     if (NULL == val) {
  43         ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
  44         return ORTE_ERR_OUT_OF_RESOURCE;
  45     }
  46 
  47     *val = *src;
  48     *dest = val;
  49 
  50     return ORTE_SUCCESS;
  51 }
  52 
  53 /**
  54  * JOB
  55  */
  56 int orte_dt_copy_job(orte_job_t **dest, orte_job_t *src, opal_data_type_t type)
  57 {
  58     (*dest) = src;
  59     OBJ_RETAIN(src);
  60 
  61     return ORTE_SUCCESS;
  62 }
  63 
  64 /**
  65 * NODE
  66  */
  67 int orte_dt_copy_node(orte_node_t **dest, orte_node_t *src, opal_data_type_t type)
  68 {
  69     orte_node_t *node;
  70 
  71     node = OBJ_NEW(orte_node_t);
  72     node->name = strdup(src->name);
  73     node->state = src->state;
  74     node->slots = src->slots;
  75     node->slots_inuse = src->slots_inuse;
  76     node->slots_max = src->slots_max;
  77     node->topology = src->topology;
  78     node->flags = src->flags;
  79     (*dest) = node;
  80 
  81     return ORTE_SUCCESS;
  82 }
  83 
  84 /**
  85  * PROC
  86  */
  87 int orte_dt_copy_proc(orte_proc_t **dest, orte_proc_t *src, opal_data_type_t type)
  88 {
  89     (*dest) = src;
  90     OBJ_RETAIN(src);
  91     return ORTE_SUCCESS;
  92 }
  93 
  94 /*
  95  * APP CONTEXT
  96  */
  97 int orte_dt_copy_app_context(orte_app_context_t **dest, orte_app_context_t *src, opal_data_type_t type)
  98 {
  99     opal_value_t *kv, *kvnew;
 100 
 101     /* create the new object */
 102     *dest = OBJ_NEW(orte_app_context_t);
 103     if (NULL == *dest) {
 104         ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
 105         return ORTE_ERR_OUT_OF_RESOURCE;
 106     }
 107 
 108     /* copy data into it */
 109     (*dest)->idx = src->idx;
 110     if (NULL != src->app) {
 111         (*dest)->app = strdup(src->app);
 112     }
 113     (*dest)->num_procs = src->num_procs;
 114     (*dest)->argv = opal_argv_copy(src->argv);
 115     (*dest)->env = opal_argv_copy(src->env);
 116     if (NULL != src->cwd) {
 117         (*dest)->cwd = strdup(src->cwd);
 118     }
 119 
 120     OPAL_LIST_FOREACH(kv, &src->attributes, opal_value_t) {
 121         opal_dss.copy((void**)&kvnew, kv, OPAL_VALUE);
 122         opal_list_append(&(*dest)->attributes, &kvnew->super);
 123     }
 124 
 125     return ORTE_SUCCESS;
 126 }
 127 
 128 int orte_dt_copy_proc_state(orte_proc_state_t **dest, orte_proc_state_t *src, opal_data_type_t type)
 129 {
 130     orte_proc_state_t *ps;
 131 
 132     ps = (orte_proc_state_t*)malloc(sizeof(orte_proc_state_t));
 133     if (NULL == ps) {
 134         ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
 135         return ORTE_ERR_OUT_OF_RESOURCE;
 136     }
 137 
 138     *ps = *src;
 139     *dest = ps;
 140 
 141     return ORTE_SUCCESS;
 142 }
 143 
 144 int orte_dt_copy_job_state(orte_job_state_t **dest, orte_job_state_t *src, opal_data_type_t type)
 145 {
 146     orte_job_state_t *ps;
 147 
 148     ps = (orte_job_state_t*)malloc(sizeof(orte_job_state_t));
 149     if (NULL == ps) {
 150         ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
 151         return ORTE_ERR_OUT_OF_RESOURCE;
 152     }
 153 
 154     *ps = *src;
 155     *dest = ps;
 156 
 157     return ORTE_SUCCESS;
 158 }
 159 
 160 int orte_dt_copy_node_state(orte_node_state_t **dest, orte_node_state_t *src, opal_data_type_t type)
 161 {
 162     orte_node_state_t *ps;
 163 
 164     ps = (orte_node_state_t*)malloc(sizeof(orte_node_state_t));
 165     if (NULL == ps) {
 166         ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
 167         return ORTE_ERR_OUT_OF_RESOURCE;
 168     }
 169 
 170     *ps = *src;
 171     *dest = ps;
 172 
 173     return ORTE_SUCCESS;
 174 }
 175 
 176 int orte_dt_copy_exit_code(orte_exit_code_t **dest, orte_exit_code_t *src, opal_data_type_t type)
 177 {
 178     orte_exit_code_t *ps;
 179 
 180     ps = (orte_exit_code_t*)malloc(sizeof(orte_exit_code_t));
 181     if (NULL == ps) {
 182         ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
 183         return ORTE_ERR_OUT_OF_RESOURCE;
 184     }
 185 
 186     *ps = *src;
 187     *dest = ps;
 188 
 189     return ORTE_SUCCESS;
 190 }
 191 
 192 /*
 193  * JOB_MAP
 194  */
 195 int orte_dt_copy_map(orte_job_map_t **dest, orte_job_map_t *src, opal_data_type_t type)
 196 {
 197     orte_std_cntr_t i;
 198 
 199     if (NULL == src) {
 200         *dest = NULL;
 201         return ORTE_SUCCESS;
 202     }
 203 
 204     /* create the new object */
 205     *dest = OBJ_NEW(orte_job_map_t);
 206     if (NULL == *dest) {
 207         ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
 208         return ORTE_ERR_OUT_OF_RESOURCE;
 209     }
 210 
 211     /* copy data into it */
 212     (*dest)->mapping = src->mapping;
 213     (*dest)->ranking = src->ranking;
 214     (*dest)->binding = src->binding;
 215     if (NULL != src->ppr) {
 216         (*dest)->ppr = strdup(src->ppr);
 217     }
 218     (*dest)->display_map = src->display_map;
 219     (*dest)->num_new_daemons = src->num_new_daemons;
 220     (*dest)->daemon_vpid_start = src->daemon_vpid_start;
 221     (*dest)->num_nodes = src->num_nodes;
 222 
 223     /* copy the pointer array - have to do this manually
 224         * as no dss.copy function is setup for that object
 225         */
 226     (*dest)->nodes->lowest_free = src->nodes->lowest_free;
 227     (*dest)->nodes->number_free = src->nodes->number_free;
 228     (*dest)->nodes->size = src->nodes->size;
 229     (*dest)->nodes->max_size = src->nodes->max_size;
 230     (*dest)->nodes->block_size = src->nodes->block_size;
 231     for (i=0; i < src->nodes->size; i++) {
 232         (*dest)->nodes->addr[i] = src->nodes->addr[i];
 233     }
 234 
 235     return ORTE_SUCCESS;
 236 }
 237 
 238 /*
 239  * RML tag
 240  */
 241 int orte_dt_copy_tag(orte_rml_tag_t **dest, orte_rml_tag_t *src, opal_data_type_t type)
 242 {
 243     orte_rml_tag_t *tag;
 244 
 245     if (NULL == src) {
 246         *dest = NULL;
 247         return ORTE_SUCCESS;
 248     }
 249 
 250     /* create the new space */
 251     tag = (orte_rml_tag_t*)malloc(sizeof(orte_rml_tag_t));
 252     if (NULL == tag) {
 253         ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
 254         return ORTE_ERR_OUT_OF_RESOURCE;
 255     }
 256 
 257     /* copy data into it */
 258     *tag = *src;
 259     *dest = tag;
 260 
 261     return ORTE_SUCCESS;
 262 }
 263 
 264 int orte_dt_copy_daemon_cmd(orte_daemon_cmd_flag_t **dest, orte_daemon_cmd_flag_t *src, opal_data_type_t type)
 265 {
 266     size_t datasize;
 267 
 268     datasize = sizeof(orte_daemon_cmd_flag_t);
 269 
 270     *dest = (orte_daemon_cmd_flag_t*)malloc(datasize);
 271     if (NULL == *dest) {
 272         ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
 273         return ORTE_ERR_OUT_OF_RESOURCE;
 274     }
 275 
 276     memcpy(*dest, src, datasize);
 277 
 278     return ORTE_SUCCESS;
 279 }
 280 
 281 int orte_dt_copy_iof_tag(orte_iof_tag_t **dest, orte_iof_tag_t *src, opal_data_type_t type)
 282 {
 283     size_t datasize;
 284 
 285     datasize = sizeof(orte_iof_tag_t);
 286 
 287     *dest = (orte_iof_tag_t*)malloc(datasize);
 288     if (NULL == *dest) {
 289         ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
 290         return ORTE_ERR_OUT_OF_RESOURCE;
 291     }
 292 
 293     memcpy(*dest, src, datasize);
 294 
 295     return ORTE_SUCCESS;
 296 }
 297 
 298 int orte_dt_copy_attr(orte_attribute_t **dest, orte_attribute_t *src, opal_data_type_t type)
 299 {
 300     *dest = OBJ_NEW(orte_attribute_t);
 301     if (NULL == *dest) {
 302         ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
 303         return ORTE_ERR_OUT_OF_RESOURCE;
 304     }
 305     (*dest)->key = src->key;
 306     (*dest)->type = src->type;
 307 
 308     memcpy(&(*dest)->data, &src->data, sizeof(src->data));
 309 
 310     return ORTE_SUCCESS;
 311 }
 312 
 313 int orte_dt_copy_sig(orte_grpcomm_signature_t **dest, orte_grpcomm_signature_t *src, opal_data_type_t type)
 314 {
 315     *dest = OBJ_NEW(orte_grpcomm_signature_t);
 316     if (NULL == *dest) {
 317         ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
 318         return ORTE_ERR_OUT_OF_RESOURCE;
 319     }
 320     (*dest)->sz = src->sz;
 321     (*dest)->signature = (orte_process_name_t*)malloc(src->sz * sizeof(orte_process_name_t));
 322     if (NULL == (*dest)->signature) {
 323         ORTE_ERROR_LOG(ORTE_ERR_OUT_OF_RESOURCE);
 324         OBJ_RELEASE(*dest);
 325         return ORTE_ERR_OUT_OF_RESOURCE;
 326     }
 327     memcpy((*dest)->signature, src->signature, src->sz * sizeof(orte_process_name_t));
 328     return ORTE_SUCCESS;
 329 }

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