1
1

sentinel: fix sentinel to proc_name conversion

converting an opal_process_name_t means the loss of one bit,
it was decided to restrict the local job id to 15 bits, so the
useful information of an opal_process_name_t can fit in 63 bits.
Этот коммит содержится в:
Gilles Gouaillardet 2016-02-06 20:23:08 +09:00
родитель 030a5f2054
Коммит b55b9e6aee
3 изменённых файлов: 39 добавлений и 4 удалений

Просмотреть файл

@ -3,7 +3,7 @@
* All rights reserved. * All rights reserved.
* Copyright (c) 2013-2015 Intel, Inc. All rights reserved * Copyright (c) 2013-2015 Intel, Inc. All rights reserved
* Copyright (c) 2014 Cisco Systems, Inc. All rights reserved. * Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
* Copyright (c) 2014 Research Organization for Information Science * Copyright (c) 2014-2016 Research Organization for Information Science
* and Technology (RIST). All rights reserved. * and Technology (RIST). All rights reserved.
* Copyright (c) 2015 Intel, Inc. All rights reserved. * Copyright (c) 2015 Intel, Inc. All rights reserved.
* $COPYRIGHT$ * $COPYRIGHT$
@ -59,6 +59,10 @@ typedef orte_ns_cmp_bitmask_t ompi_rte_cmp_bitmask_t;
#define OMPI_RTE_CMP_JOBID ORTE_NS_CMP_JOBID #define OMPI_RTE_CMP_JOBID ORTE_NS_CMP_JOBID
#define OMPI_RTE_CMP_VPID ORTE_NS_CMP_VPID #define OMPI_RTE_CMP_VPID ORTE_NS_CMP_VPID
#define OMPI_RTE_CMP_ALL ORTE_NS_CMP_ALL #define OMPI_RTE_CMP_ALL ORTE_NS_CMP_ALL
#define OMPI_LOCAL_JOBID(jobid) ORTE_LOCAL_JOBID(jobid)
#define OMPI_JOB_FAMILY(jobid) ORTE_JOB_FAMILY(jobid)
#define OMPI_CONSTRUCT_JOBID(family,local) ORTE_CONSTRUCT_JOBID(family,local)
/* This is the DSS tag to serialize a proc name */ /* This is the DSS tag to serialize a proc name */
#define OMPI_NAME ORTE_NAME #define OMPI_NAME ORTE_NAME
#define OMPI_PROCESS_NAME_HTON ORTE_PROCESS_NAME_HTON #define OMPI_PROCESS_NAME_HTON ORTE_PROCESS_NAME_HTON

Просмотреть файл

@ -369,15 +369,43 @@ static inline bool ompi_proc_is_sentinel (ompi_proc_t *proc)
return (intptr_t) proc & 0x1; return (intptr_t) proc & 0x1;
} }
/*
* we assume an ompi_proc_t is at least aligned on two bytes,
* so if the LSB of a pointer to an ompi_proc_t is 1, we have to handle
* this pointer as a sentinel instead of a pointer.
* a sentinel can be seen as an uint64_t with the following format :
* - bit 0 : 1
* - bits 1-15 : local jobid
* - bits 16-31 : job family
* - bits 32-63 : vpid
*/
static inline uintptr_t ompi_proc_name_to_sentinel (opal_process_name_t name) static inline uintptr_t ompi_proc_name_to_sentinel (opal_process_name_t name)
{ {
return (*((uintptr_t *) &name) << 1) | 0x1; uintptr_t tmp, sentinel = 0;
/* local jobid must fit in 15 bits */
assert(! (OMPI_LOCAL_JOBID(name.jobid) & 0x8000));
sentinel |= 0x1;
tmp = (uintptr_t)OMPI_LOCAL_JOBID(name.jobid);
sentinel |= ((tmp << 1) & 0xfffe);
tmp = (uintptr_t)OMPI_JOB_FAMILY(name.jobid);
sentinel |= ((tmp << 16) & 0xffff0000);
tmp = (uintptr_t)name.vpid;
sentinel |= ((tmp << 32) & 0xffffffff00000000);
return sentinel;
} }
static inline opal_process_name_t ompi_proc_sentinel_to_name (uintptr_t sentinel) static inline opal_process_name_t ompi_proc_sentinel_to_name (uintptr_t sentinel)
{ {
sentinel >>= 1; opal_process_name_t name;
return *((opal_process_name_t *) &sentinel); uint32_t local, family;
uint32_t vpid;
assert(sentinel & 0x1);
local = (sentinel >> 1) & 0x7fff;
family = (sentinel >> 16) & 0xffff;
vpid = (sentinel >> 32) & 0xffffffff;
name.jobid = OMPI_CONSTRUCT_JOBID(family,local);
name.vpid = vpid;
return name;
} }
END_C_DECLS END_C_DECLS

Просмотреть файл

@ -97,6 +97,9 @@ ORTE_DECLSPEC char *orte_pretty_print_timing(int64_t secs, int64_t usecs);
#define ORTE_CONSTRUCT_LOCAL_JOBID(local, job) \ #define ORTE_CONSTRUCT_LOCAL_JOBID(local, job) \
( ((local) & 0xffff0000) | ((job) & 0x0000ffff) ) ( ((local) & 0xffff0000) | ((job) & 0x0000ffff) )
#define ORTE_CONSTRUCT_JOBID(family, local) \
ORTE_CONSTRUCT_LOCAL_JOBID(ORTE_CONSTRUCT_JOB_FAMILY(family), local)
/* a macro for identifying that a proc is a daemon */ /* a macro for identifying that a proc is a daemon */
#define ORTE_JOBID_IS_DAEMON(n) \ #define ORTE_JOBID_IS_DAEMON(n) \
!((n) & 0x0000ffff) !((n) & 0x0000ffff)