Skip to content
This repository was archived by the owner on Sep 30, 2022. It is now read-only.

Commit 7ecbfcc

Browse files
committed
sentinel: use type uintptr_t for sentinel
MSB is now automatically cleared when right shifting Thanks George for pointing this (cherry picked from commit open-mpi/ompi@030a5f2)
1 parent ab8b9ec commit 7ecbfcc

File tree

6 files changed

+16
-13
lines changed

6 files changed

+16
-13
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
@@ -170,7 +170,7 @@ int ompi_dpm_connect_accept(ompi_communicator_t *comm, int root,
170170
for (i=0; i < size; i++) {
171171
opal_process_name_t proc_name;
172172
if (ompi_proc_is_sentinel (proc_list[i])) {
173-
proc_name = ompi_proc_sentinel_to_name ((intptr_t) proc_list[i]);
173+
proc_name = ompi_proc_sentinel_to_name ((uintptr_t) proc_list[i]);
174174
} else {
175175
proc_name = proc_list[i]->super.proc_name;
176176
}
@@ -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
@@ -353,7 +355,7 @@ static inline struct ompi_proc_t *ompi_group_dense_lookup (ompi_group_t *group,
353355

354356
/* replace sentinel value with an actual ompi_proc_t */
355357
ompi_proc_t *real_proc =
356-
(ompi_proc_t *) ompi_proc_for_name (ompi_proc_sentinel_to_name ((intptr_t) proc));
358+
(ompi_proc_t *) ompi_proc_for_name (ompi_proc_sentinel_to_name ((uintptr_t) proc));
357359

358360
if (opal_atomic_cmpset_ptr (group->grp_proc_pointers + peer_id, proc, real_proc)) {
359361
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/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
*
@@ -643,7 +643,7 @@ ompi_proc_pack(ompi_proc_t **proclist, int proclistsize,
643643
ompi_proc_t *proc = proclist[i];
644644

645645
if (ompi_proc_is_sentinel (proc)) {
646-
proc = ompi_proc_for_name_nolock (ompi_proc_sentinel_to_name ((intptr_t) proc));
646+
proc = ompi_proc_for_name_nolock (ompi_proc_sentinel_to_name ((uintptr_t) proc));
647647
}
648648

649649
/* send proc name */

ompi/proc/proc.h

Lines changed: 4 additions & 5 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,15 +369,14 @@ 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+
static inline uintptr_t ompi_proc_name_to_sentinel (opal_process_name_t name)
373373
{
374-
return (*((intptr_t *) &name) << 1) | 0x1;
374+
return (*((uintptr_t *) &name) << 1) | 0x1;
375375
}
376376

377-
static inline opal_process_name_t ompi_proc_sentinel_to_name (intptr_t sentinel)
377+
static inline opal_process_name_t ompi_proc_sentinel_to_name (uintptr_t sentinel)
378378
{
379379
sentinel >>= 1;
380-
sentinel &= 0x7FFFFFFFFFFFFFFF;
381380
return *((opal_process_name_t *) &sentinel);
382381
}
383382

0 commit comments

Comments
 (0)