Skip to content

Commit 39b44d0

Browse files
committed
Merge pull request #1345 from ggouaillardet/topic/sentinel_proc_name_conversion
Topic/sentinel proc name conversion
2 parents 7850517 + 96310f4 commit 39b44d0

File tree

10 files changed

+81
-18
lines changed

10 files changed

+81
-18
lines changed

ompi/communicator/comm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
* Copyright (c) 2012 Oak Ridge National Labs. All rights reserved.
1919
* Copyright (c) 2012-2015 Los Alamos National Security, LLC.
2020
* All rights reserved.
21-
* Copyright (c) 2014 Research Organization for Information Science
21+
* Copyright (c) 2014-2016 Research Organization for Information Science
2222
* and Technology (RIST). All rights reserved.
2323
* Copyright (c) 2014-2015 Intel, Inc. All rights reserved.
2424
* Copyright (c) 2015 Mellanox Technologies. All rights reserved.
@@ -699,7 +699,7 @@ static int ompi_comm_split_type_get_part (ompi_group_t *group, int *results, int
699699
int include = false;
700700

701701
if (ompi_proc_is_sentinel (proc)) {
702-
opal_process_name_t proc_name = ompi_proc_sentinel_to_name ((intptr_t) proc);
702+
opal_process_name_t proc_name = ompi_proc_sentinel_to_name ((uintptr_t) proc);
703703

704704
u16ptr = &locality;
705705

ompi/dpm/dpm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ int ompi_dpm_connect_accept(ompi_communicator_t *comm, int root,
169169
for (i=0; i < size; i++) {
170170
opal_process_name_t proc_name;
171171
if (ompi_proc_is_sentinel (proc_list[i])) {
172-
proc_name = ompi_proc_sentinel_to_name ((intptr_t) proc_list[i]);
172+
proc_name = ompi_proc_sentinel_to_name ((uintptr_t) proc_list[i]);
173173
} else {
174174
proc_name = proc_list[i]->super.proc_name;
175175
}
@@ -532,7 +532,7 @@ static int construct_peers(ompi_group_t *group, opal_list_t *peers)
532532
return OMPI_ERR_NOT_FOUND;
533533
}
534534
if (ompi_proc_is_sentinel (proct)) {
535-
proc_name = ompi_proc_sentinel_to_name ((intptr_t)proct);
535+
proc_name = ompi_proc_sentinel_to_name ((uintptr_t)proct);
536536
} else {
537537
proc_name = proct->super.proc_name;
538538
}

ompi/group/group.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
* Copyright (c) 2012 Oak Ridge National Labs. All rights reserved.
1717
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
1818
* reserved.
19+
* Copyright (c) 2016 Research Organization for Information Science
20+
* and Technology (RIST). All rights reserved.
1921
* $COPYRIGHT$
2022
*
2123
* Additional copyrights may follow
@@ -352,7 +354,7 @@ static inline struct ompi_proc_t *ompi_group_dense_lookup (ompi_group_t *group,
352354

353355
/* replace sentinel value with an actual ompi_proc_t */
354356
ompi_proc_t *real_proc =
355-
(ompi_proc_t *) ompi_proc_for_name (ompi_proc_sentinel_to_name ((intptr_t) proc));
357+
(ompi_proc_t *) ompi_proc_for_name (ompi_proc_sentinel_to_name ((uintptr_t) proc));
356358

357359
if (opal_atomic_cmpset_ptr (group->grp_proc_pointers + peer_id, proc, real_proc)) {
358360
OBJ_RETAIN(real_proc);

ompi/group/group_plist.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
* Copyright (c) 2007 Cisco Systems, Inc. All rights reserved.
1515
* Copyright (c) 2013-2015 Los Alamos National Security, LLC. All rights
1616
* reserved.
17+
* Copyright (c) 2016 Research Organization for Information Science
18+
* and Technology (RIST). All rights reserved.
1719
* $COPYRIGHT$
1820
*
1921
* Additional copyrights may follow
@@ -61,7 +63,7 @@ static struct ompi_proc_t *ompi_group_dense_lookup_raw (ompi_group_t *group, con
6163
{
6264
if (OPAL_UNLIKELY(ompi_proc_is_sentinel (group->grp_proc_pointers[peer_id]))) {
6365
ompi_proc_t *proc =
64-
(ompi_proc_t *) ompi_proc_lookup (ompi_proc_sentinel_to_name ((intptr_t) group->grp_proc_pointers[peer_id]));
66+
(ompi_proc_t *) ompi_proc_lookup (ompi_proc_sentinel_to_name ((uintptr_t) group->grp_proc_pointers[peer_id]));
6567
if (NULL != proc) {
6668
/* replace sentinel value with an actual ompi_proc_t */
6769
group->grp_proc_pointers[peer_id] = proc;

ompi/mca/pml/monitoring/pml_monitoring.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
* reserved.
55
* Copyright (c) 2013-2015 Inria. All rights reserved.
66
* Copyright (c) 2015 Bull SAS. All rights reserved.
7+
* Copyright (c) 2016 Research Organization for Information Science
8+
* and Technology (RIST). All rights reserved.
79
* $COPYRIGHT$
810
*
911
* Additional copyrights may follow
@@ -77,7 +79,7 @@ int mca_pml_monitoring_add_procs(struct ompi_proc_t **procs,
7779
my_rank = i;
7880
/* Extract the peer procname from the procs array */
7981
if( ompi_proc_is_sentinel(procs[i]) ) {
80-
tmp = ompi_proc_sentinel_to_name((intptr_t)procs[i]);
82+
tmp = ompi_proc_sentinel_to_name((uintptr_t)procs[i]);
8183
} else {
8284
tmp = procs[i]->super.proc_name;
8385
}

ompi/mca/rte/orte/rte_orte.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* All rights reserved.
44
* Copyright (c) 2013-2015 Intel, Inc. All rights reserved
55
* Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
6-
* Copyright (c) 2014 Research Organization for Information Science
6+
* Copyright (c) 2014-2016 Research Organization for Information Science
77
* and Technology (RIST). All rights reserved.
88
* Copyright (c) 2015 Intel, Inc. All rights reserved.
99
* $COPYRIGHT$
@@ -59,6 +59,10 @@ typedef orte_ns_cmp_bitmask_t ompi_rte_cmp_bitmask_t;
5959
#define OMPI_RTE_CMP_JOBID ORTE_NS_CMP_JOBID
6060
#define OMPI_RTE_CMP_VPID ORTE_NS_CMP_VPID
6161
#define OMPI_RTE_CMP_ALL ORTE_NS_CMP_ALL
62+
#define OMPI_LOCAL_JOBID(jobid) ORTE_LOCAL_JOBID(jobid)
63+
#define OMPI_JOB_FAMILY(jobid) ORTE_JOB_FAMILY(jobid)
64+
#define OMPI_CONSTRUCT_JOBID(family,local) ORTE_CONSTRUCT_JOBID(family,local)
65+
6266
/* This is the DSS tag to serialize a proc name */
6367
#define OMPI_NAME ORTE_NAME
6468
#define OMPI_PROCESS_NAME_HTON ORTE_PROCESS_NAME_HTON

ompi/proc/proc.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Copyright (c) 2012-2015 Los Alamos National Security, LLC. All rights
1515
* reserved.
1616
* Copyright (c) 2013-2015 Intel, Inc. All rights reserved
17-
* Copyright (c) 2014-2015 Research Organization for Information Science
17+
* Copyright (c) 2014-2016 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
1919
* Copyright (c) 2015 Mellanox Technologies. All rights reserved.
2020
*
@@ -642,7 +642,7 @@ ompi_proc_pack(ompi_proc_t **proclist, int proclistsize,
642642
ompi_proc_t *proc = proclist[i];
643643

644644
if (ompi_proc_is_sentinel (proc)) {
645-
proc = ompi_proc_for_name_nolock (ompi_proc_sentinel_to_name ((intptr_t) proc));
645+
proc = ompi_proc_for_name_nolock (ompi_proc_sentinel_to_name ((uintptr_t) proc));
646646
}
647647

648648
/* send proc name */

ompi/proc/proc.h

Lines changed: 56 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Copyright (c) 2007-2012 Los Alamos National Security, LLC. All rights
1414
* reserved.
1515
* Copyright (c) 2013-2014 Intel, Inc. All rights reserved
16-
* Copyright (c) 2015 Research Organization for Information Science
16+
* Copyright (c) 2015-2016 Research Organization for Information Science
1717
* and Technology (RIST). All rights reserved.
1818
* $COPYRIGHT$
1919
*
@@ -369,17 +369,66 @@ static inline bool ompi_proc_is_sentinel (ompi_proc_t *proc)
369369
return (intptr_t) proc & 0x1;
370370
}
371371

372-
static inline intptr_t ompi_proc_name_to_sentinel (opal_process_name_t name)
372+
#if OPAL_SIZEOF_PROCESS_NAME_T == SIZEOF_VOID_P
373+
/*
374+
* we assume an ompi_proc_t is at least aligned on two bytes,
375+
* so if the LSB of a pointer to an ompi_proc_t is 1, we have to handle
376+
* this pointer as a sentinel instead of a pointer.
377+
* a sentinel can be seen as an uint64_t with the following format :
378+
* - bit 0 : 1
379+
* - bits 1-15 : local jobid
380+
* - bits 16-31 : job family
381+
* - bits 32-63 : vpid
382+
*/
383+
static inline uintptr_t ompi_proc_name_to_sentinel (opal_process_name_t name)
384+
{
385+
uintptr_t tmp, sentinel = 0;
386+
/* local jobid must fit in 15 bits */
387+
assert(! (OMPI_LOCAL_JOBID(name.jobid) & 0x8000));
388+
sentinel |= 0x1;
389+
tmp = (uintptr_t)OMPI_LOCAL_JOBID(name.jobid);
390+
sentinel |= ((tmp << 1) & 0xfffe);
391+
tmp = (uintptr_t)OMPI_JOB_FAMILY(name.jobid);
392+
sentinel |= ((tmp << 16) & 0xffff0000);
393+
tmp = (uintptr_t)name.vpid;
394+
sentinel |= ((tmp << 32) & 0xffffffff00000000);
395+
return sentinel;
396+
}
397+
398+
static inline opal_process_name_t ompi_proc_sentinel_to_name (uintptr_t sentinel)
399+
{
400+
opal_process_name_t name;
401+
uint32_t local, family;
402+
uint32_t vpid;
403+
assert(sentinel & 0x1);
404+
local = (sentinel >> 1) & 0x7fff;
405+
family = (sentinel >> 16) & 0xffff;
406+
vpid = (sentinel >> 32) & 0xffffffff;
407+
name.jobid = OMPI_CONSTRUCT_JOBID(family,local);
408+
name.vpid = vpid;
409+
return name;
410+
}
411+
#elif 4 == SIZEOF_VOID_P
412+
/*
413+
* currently, a sentinel is only made from the current jobid aka OMPI_PROC_MY_NAME->jobid
414+
* so we only store the first 31 bits of the vpid
415+
*/
416+
static inline uintptr_t ompi_proc_name_to_sentinel (opal_process_name_t name)
373417
{
374-
return (*((intptr_t *) &name) << 1) | 0x1;
418+
assert(OMPI_PROC_MY_NAME->jobid == name.jobid);
419+
return (uintptr_t)((name.vpid <<1) | 0x1);
375420
}
376421

377-
static inline opal_process_name_t ompi_proc_sentinel_to_name (intptr_t sentinel)
422+
static inline opal_process_name_t ompi_proc_sentinel_to_name (uintptr_t sentinel)
378423
{
379-
sentinel >>= 1;
380-
sentinel &= 0x7FFFFFFFFFFFFFFF;
381-
return *((opal_process_name_t *) &sentinel);
424+
opal_process_name_t name;
425+
name.jobid = OMPI_PROC_MY_NAME->jobid;
426+
name.vpid = sentinel >> 1;
427+
return name;
382428
}
429+
#else
430+
#error unsupported pointer size
431+
#endif
383432

384433
END_C_DECLS
385434

opal/dss/dss_types.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* Copyright (c) 2012-2013 Los Alamos National Security, Inc. All rights
1515
* reserved.
1616
* Copyright (c) 2014 Intel, Inc. All rights reserved.
17-
* Copyright (c) 2014 Research Organization for Information Science
17+
* Copyright (c) 2014-2016 Research Organization for Information Science
1818
* and Technology (RIST). All rights reserved.
1919
* $COPYRIGHT$
2020
*
@@ -47,6 +47,7 @@ typedef struct {
4747
opal_jobid_t jobid;
4848
opal_vpid_t vpid;
4949
} opal_process_name_t;
50+
#define OPAL_SIZEOF_PROCESS_NAME_T 8
5051

5152
BEGIN_C_DECLS
5253

orte/util/name_fns.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ ORTE_DECLSPEC char *orte_pretty_print_timing(int64_t secs, int64_t usecs);
9797
#define ORTE_CONSTRUCT_LOCAL_JOBID(local, job) \
9898
( ((local) & 0xffff0000) | ((job) & 0x0000ffff) )
9999

100+
#define ORTE_CONSTRUCT_JOBID(family, local) \
101+
ORTE_CONSTRUCT_LOCAL_JOBID(ORTE_CONSTRUCT_JOB_FAMILY(family), local)
102+
100103
/* a macro for identifying that a proc is a daemon */
101104
#define ORTE_JOBID_IS_DAEMON(n) \
102105
!((n) & 0x0000ffff)

0 commit comments

Comments
 (0)