Open MPI logo

PLPA Users' Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all PLPA Users mailing list

Subject: [PLPA users] [PATCH 3/5] introduce min_socket_id to remove empty gap in socket arrays
From: Bert Wesarg (bert.wesarg_at_[hidden])
Date: 2009-07-23 17:47:48


---
 src/libplpa/plpa_map.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)
diff --git a/src/libplpa/plpa_map.c b/src/libplpa/plpa_map.c
index c66f859..d3e8f62 100644
--- a/src/libplpa/plpa_map.c
+++ b/src/libplpa/plpa_map.c
@@ -137,6 +137,7 @@ static int supported = 0;
 static int num_processors = -1;
 static int max_processor_id = -1;
 static int num_sockets = -1;
+static int min_socket_id = INT_MAX;
 static int max_socket_id = -1;
 static int socket_index_extent = 0;
 static int *max_core_id = NULL;
@@ -148,12 +149,12 @@ static PLPA_NAME(cache_behavior_t) cache_behavior = PLPA_NAME_CAPS(CACHE_IGNORE)
 
 static inline int socket_id_to_index(int socket_id)
 {
-    return socket_id;
+    return socket_id - min_socket_id;
 }
 
 static inline int socket_index_to_id(int socket_index)
 {
-    return socket_index;
+    return socket_index + min_socket_id;
 }
 
 static void clear_cache(void)
@@ -177,6 +178,7 @@ static void clear_cache(void)
 
     num_processors = max_processor_id = -1;
     num_sockets = max_socket_id = -1;
+    min_socket_id = INT_MAX;
     socket_index_extent = 0;
     max_core_id_overall = -1;
 }
@@ -349,6 +351,9 @@ static void load_cache(void)
         if (map_processor_id_to_tuple[i].socket_id > max_socket_id) {
             max_socket_id = map_processor_id_to_tuple[i].socket_id;
         }
+        if (map_processor_id_to_tuple[i].socket_id < min_socket_id) {
+            min_socket_id = map_processor_id_to_tuple[i].socket_id;
+        }
     }
 
     /* If we didn't find any core_id/physical_package_id's, then we
@@ -359,7 +364,7 @@ static void load_cache(void)
     }
 
     /* index range for sockets, [0, socket_index_extent) */
-    socket_index_extent = max_socket_id + 1;
+    socket_index_extent = max_socket_id - min_socket_id + 1;
 
     /* Now that we know the max number of sockets, allocate some
        arrays */
@@ -557,7 +562,7 @@ int PLPA_NAME(map_to_processor_id)(int socket_id, int core_id,
     }
 
     /* Check for some invalid entries */
-    if (socket_id < 0 || socket_id > max_socket_id) {
+    if (socket_id < min_socket_id || socket_id > max_socket_id) {
         return ENOENT;
     }
     socket_index = socket_id_to_index(socket_id);
@@ -939,7 +944,7 @@ int PLPA_NAME(get_core_info)(int socket_id, int *num_cores_arg,
     }
 
     /* Check for some invalid entries */
-    if (socket_id < 0 || socket_id > max_socket_id) {
+    if (socket_id < min_socket_id || socket_id > max_socket_id) {
         return ENOENT;
     }
     socket_index = socket_id_to_index(socket_id);
@@ -989,7 +994,7 @@ int PLPA_NAME(get_core_id)(int socket_id, int core_num, int *core_id)
     }
 
     /* Check for out of range params */
-    if (socket_id < 0 || socket_id > max_socket_id ||
+    if (socket_id < min_socket_id || socket_id > max_socket_id ||
         core_num < 0 || core_num > max_core_id_overall) {
         return EINVAL;
     }
@@ -1041,7 +1046,7 @@ int PLPA_NAME(get_core_flags)(int socket_id, int core_id,
     }
 
     /* Check for out of range params */
-    if (socket_id < 0 || socket_id > max_socket_id ||
+    if (socket_id < min_socket_id || socket_id > max_socket_id ||
         core_id < 0 || core_id > max_core_id_overall) {
         return EINVAL;
     }
-- 
1.6.3.3.618.gce7bf