22 * Copyright (c) 2004-2009 The Trustees of Indiana University and Indiana 
33 *                         University Research and Technology 
44 *                         Corporation.  All rights reserved. 
5-  * Copyright (c) 2010-2012  Cisco Systems, Inc.  All rights reserved. 
5+  * Copyright (c) 2010-2015  Cisco Systems, Inc.  All rights reserved. 
66 * Copyright (c) 2010      Oracle and/or its affiliates.  All rights reserved. 
77 * Copyright (c) 2012      Los Alamos National Security, LLC.  All rights 
88 *                         reserved. 
@@ -38,41 +38,69 @@ static const char FUNC_NAME[] = "OMPI_Affinity";
3838static  const  char  ompi_nobind_str [] =  "Open MPI did not bind this process" ;
3939static  const  char  not_bound_str [] =  "Not bound (i.e., bound to all processors)" ;
4040
41+ /************************************************************************** 
42+  * Utility routine 
43+  **************************************************************************/ 
44+ 
45+ static  no_hwloc_support (char  ompi_bound [OMPI_AFFINITY_STRING_MAX ],
46+                         char  current_binding [OMPI_AFFINITY_STRING_MAX ],
47+                         char  exists [OMPI_AFFINITY_STRING_MAX ])
48+ {
49+     strncpy (ompi_bound , "Not  supported ", OMPI_AFFINITY_STRING_MAX );
50+     strncpy (current_binding , "Not supported" , OMPI_AFFINITY_STRING_MAX );
51+     strncpy (exists , "Not supported" , OMPI_AFFINITY_STRING_MAX );
52+ }
53+ 
54+ /************************************************************************** 
55+  * If we have no hwloc support compiled in, do almost nothing. 
56+  **************************************************************************/ 
57+ 
58+ #if  !OPAL_HAVE_HWLOC 
59+ /* 
60+  * If hwloc support was not compiled in, then just return "Not 
61+  * supported". 
62+  */ 
63+ int  OMPI_Affinity_str (ompi_affinity_fmt_t  fmt_type ,
64+                       char  ompi_bound [OMPI_AFFINITY_STRING_MAX ],
65+                       char  current_binding [OMPI_AFFINITY_STRING_MAX ],
66+                       char  exists [OMPI_AFFINITY_STRING_MAX ])
67+ {
68+     no_hwloc_support (ompi_bound , current_binding , exists );
69+     return  MPI_SUCCESS ;
70+ }
71+ #endif  // !OPAL_HAVE_HWLOC 
72+ 
73+ /************************************************************************** 
74+  * If we have hwloc support compiled in, do the actual work. 
75+  **************************************************************************/ 
76+ 
4177#if  OPAL_HAVE_HWLOC 
78+ 
4279static  int  get_rsrc_ompi_bound (char  str [OMPI_AFFINITY_STRING_MAX ]);
4380static  int  get_rsrc_current_binding (char  str [OMPI_AFFINITY_STRING_MAX ]);
4481static  int  get_rsrc_exists (char  str [OMPI_AFFINITY_STRING_MAX ]);
4582static  int  get_layout_ompi_bound (char  str [OMPI_AFFINITY_STRING_MAX ]);
4683static  int  get_layout_current_binding (char  str [OMPI_AFFINITY_STRING_MAX ]);
4784static  int  get_layout_exists (char  str [OMPI_AFFINITY_STRING_MAX ]);
48- #endif  /* OPAL_HAVE_HWLOC */ 
4985
50- /*---------------------------------------------------------------------------*/ 
5186
5287int  OMPI_Affinity_str (ompi_affinity_fmt_t  fmt_type ,
53- 		       char  ompi_bound [OMPI_AFFINITY_STRING_MAX ],
88+                        char  ompi_bound [OMPI_AFFINITY_STRING_MAX ],
5489                      char  current_binding [OMPI_AFFINITY_STRING_MAX ],
5590                      char  exists [OMPI_AFFINITY_STRING_MAX ])
5691{
57- #if  OPAL_HAVE_HWLOC 
5892    int  ret ;
59- #endif  /* OPAL_HAVE_HWLOC */ 
6093
6194    memset (ompi_bound , 0 , OMPI_AFFINITY_STRING_MAX );
6295    memset (current_binding , 0 , OMPI_AFFINITY_STRING_MAX );
6396
6497    /* If we have no hwloc support, return nothing */ 
65- #if  OPAL_HAVE_HWLOC 
66-     if  (NULL  ==  opal_hwloc_topology )
67- #endif  /* OPAL_HAVE_HWLOC */ 
68-    {
69-         strncpy (ompi_bound , "Not supported" , OMPI_AFFINITY_STRING_MAX );
70-         strncpy (current_binding , "Not supported" , OMPI_AFFINITY_STRING_MAX );
71-         strncpy (exists , "Not supported" , OMPI_AFFINITY_STRING_MAX );
98+     if  (NULL  ==  opal_hwloc_topology ) {
99+         no_hwloc_support (ompi_bound , current_binding , exists );
100+ 
72101        return  MPI_SUCCESS ;
73102    }
74103
75- #if  OPAL_HAVE_HWLOC 
76104    /* Otherwise, return useful information */ 
77105    switch  (fmt_type ) {
78106    case  OMPI_AFFINITY_RSRC_STRING_FMT :
@@ -94,10 +122,8 @@ int OMPI_Affinity_str(ompi_affinity_fmt_t fmt_type,
94122    }
95123
96124    return  MPI_SUCCESS ;
97- #endif  /* OPAL_HAVE_HWLOC */ 
98125}
99126
100- #if  OPAL_HAVE_HWLOC 
101127/*---------------------------------------------------------------------------*/ 
102128
103129/* 
0 commit comments