1+ /* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
12/*
23 * Copyright (c) 2012-2013 Los Alamos National Security, LLC.
34 * All rights reserved.
78 * reserved.
89 * Copyright (c) 2014-2018 Cisco Systems, Inc. All rights reserved
910 * Copyright (c) 2018 Amazon.com, Inc. or its affiliates. All Rights reserved.
11+ * Copyright (c) 2018 Triad National Security, LLC. All rights
12+ * reserved.
1013 * $COPYRIGHT$
1114 */
1215#include "ompi_config.h"
@@ -500,7 +503,7 @@ int ompi_rte_init(int *pargc, char ***pargv)
500503 opal_proc_t * myproc ;
501504 int u32 , * u32ptr ;
502505 uint16_t u16 , * u16ptr ;
503- char * * peers = NULL , * mycpuset ;
506+ char * * peers = NULL ;
504507 char * envar , * ev1 , * ev2 ;
505508 opal_value_t * kv ;
506509 char * val ;
@@ -684,9 +687,9 @@ int ompi_rte_init(int *pargc, char ***pargv)
684687 OPAL_MODEX_RECV_VALUE_OPTIONAL (ret , OPAL_PMIX_LOCALITY_STRING ,
685688 & pmix_process_info .my_name , & val , OPAL_STRING );
686689 if (OPAL_SUCCESS == ret && NULL != val ) {
687- mycpuset = val ;
690+ pmix_process_info . cpuset = val ;
688691 } else {
689- mycpuset = NULL ;
692+ pmix_process_info . cpuset = NULL ;
690693 }
691694 pname .jobid = pmix_process_info .my_name .jobid ;
692695 for (i = 0 ; NULL != peers [i ]; i ++ ) {
@@ -699,7 +702,7 @@ int ompi_rte_init(int *pargc, char ***pargv)
699702 OPAL_MODEX_RECV_VALUE_OPTIONAL (ret , OPAL_PMIX_LOCALITY_STRING ,
700703 & pname , & val , OPAL_STRING );
701704 if (OPAL_SUCCESS == ret && NULL != val ) {
702- u16 = opal_hwloc_compute_relative_locality (mycpuset , val );
705+ u16 = opal_hwloc_compute_relative_locality (pmix_process_info . cpuset , val );
703706 free (val );
704707 } else {
705708 /* all we can say is that it shares our node */
@@ -718,24 +721,31 @@ int ompi_rte_init(int *pargc, char ***pargv)
718721 if (OPAL_SUCCESS != ret ) {
719722 error = "local store of locality" ;
720723 opal_argv_free (peers );
721- if (NULL != mycpuset ) {
722- free (mycpuset );
724+ if (NULL != pmix_process_info . cpuset ) {
725+ free (pmix_process_info . cpuset );
723726 }
724727 goto error ;
725728 }
726729 OBJ_RELEASE (kv );
727730 }
728731 opal_argv_free (peers );
729- if (NULL != mycpuset ) {
730- free (mycpuset );
731- }
732732 }
733733
734734 /* poor attempt to detect we are bound */
735735 if (NULL != getenv ("SLURM_CPU_BIND_TYPE" )) {
736736 pmix_proc_is_bound = true;
737737 }
738738
739+ /* set the remaining opal_process_info fields. Note that
740+ * the OPAL layer will have initialized these to NULL, and
741+ * anyone between us would not have strdup'd the string, so
742+ * we cannot free it here */
743+ opal_process_info .job_session_dir = pmix_process_info .job_session_dir ;
744+ opal_process_info .proc_session_dir = pmix_process_info .proc_session_dir ;
745+ opal_process_info .num_local_peers = (int32_t )pmix_process_info .num_local_peers ;
746+ opal_process_info .my_local_rank = (int32_t )pmix_process_info .my_local_rank ;
747+ opal_process_info .cpuset = pmix_process_info .cpuset ;
748+
739749 /* push our hostname so others can find us, if they need to - the
740750 * native PMIx component will ignore this request as the hostname
741751 * is provided by the system */
@@ -807,6 +817,10 @@ int ompi_rte_finalize(void)
807817 false, check_file );
808818 free (pmix_process_info .job_session_dir );
809819 }
820+
821+ free (pmix_process_info .cpuset );
822+ pmix_process_info .cpuset = NULL ;
823+
810824 return OMPI_SUCCESS ;
811825}
812826
0 commit comments