Browse Source

Do not assume that there is always a host PCI bridge

Samuel Thibault 10 years ago
parent
commit
2b29d02cf1
1 changed files with 30 additions and 0 deletions
  1. 30 0
      src/core/perfmodel/perfmodel_bus.c

+ 30 - 0
src/core/perfmodel/perfmodel_bus.c

@@ -1766,6 +1766,10 @@ static void update_bandwidth_through(hwloc_obj_t obj, double bandwidth)
  * updating uplink downstream bandwidth along the way */
 static void find_platform_backward_path(hwloc_obj_t obj, double bandwidth)
 {
+	if (!obj)
+		/* Oops, we should have seen a host bridge. Well, too bad. */
+		return;
+
 	/* Update uplink bandwidth of PCI Hub */
 	update_bandwidth_down(obj, bandwidth);
 	/* Update internal bandwidth of PCI Hub */
@@ -1781,6 +1785,10 @@ static void find_platform_backward_path(hwloc_obj_t obj, double bandwidth)
 /* Same, but update uplink upstream bandwidth */
 static void find_platform_forward_path(hwloc_obj_t obj, double bandwidth)
 {
+	if (!obj)
+		/* Oops, we should have seen a host bridge. Well, too bad. */
+		return;
+
 	/* Update uplink bandwidth of PCI Hub */
 	update_bandwidth_up(obj, bandwidth);
 	/* Update internal bandwidth of PCI Hub */
@@ -1823,6 +1831,13 @@ static int find_platform_path_up(hwloc_obj_t obj1, hwloc_obj_t obj2, double band
 	int ret;
 	hwloc_obj_t parent = obj1->parent;
 
+	if (!parent)
+	{
+		/* Oops, we should have seen a host bridge. Act as if we had seen it.  */
+		find_platform_backward_path(obj2, bandwidth);
+		return 1;
+	}
+
 	if (find_platform_path_down(parent, obj1, obj2, bandwidth))
 		/* obj2 was a mere (sub)child of our parent */
 		return 1;
@@ -1969,6 +1984,10 @@ static void emit_pci_link_through(FILE *f, hwloc_obj_t obj)
  * using uplink downstream along the way */
 static void emit_platform_backward_path(FILE *f, hwloc_obj_t obj)
 {
+	if (!obj)
+		/* Oops, we should have seen a host bridge. Well, too bad. */
+		return;
+
 	/* Go through PCI Hub */
 	emit_pci_link_through(f, obj);
 	/* Go through uplink */
@@ -1987,6 +2006,10 @@ static void emit_platform_backward_path(FILE *f, hwloc_obj_t obj)
 /* Same, but use upstream link */
 static void emit_platform_forward_path(FILE *f, hwloc_obj_t obj)
 {
+	if (!obj)
+		/* Oops, we should have seen a host bridge. Well, too bad. */
+		return;
+
 	/* Go through PCI Hub */
 	emit_pci_link_through(f, obj);
 	/* Go through uplink */
@@ -2031,6 +2054,13 @@ static int emit_platform_path_up(FILE *f, hwloc_obj_t obj1, hwloc_obj_t obj2)
 	int ret;
 	hwloc_obj_t parent = obj1->parent;
 
+	if (!parent)
+	{
+		/* Oops, we should have seen a host bridge. Act as if we had seen it.  */
+		emit_platform_backward_path(f, obj2);
+		return 1;
+	}
+
 	if (emit_platform_path_down(f, parent, obj1, obj2))
 		/* obj2 was a mere (sub)child of our parent */
 		return 1;