[ofa-general] Re: [PATCH][5] opensm: compute local geometry

Sasha Khapyorsky sashak at voltaire.com
Sun Nov 30 09:59:29 PST 2008


On 17:28 Sun 30 Nov     , Sasha Khapyorsky wrote:
> > +
> > +	do {
> > +		if (!(m = m_alloc(p_lash, num_links)))
> > +			break;
> > +
> > +		for (i = 0; i < num_links; i++) {
> > +			sw1 = node->links[i]->switch_id;
> > +			s1 = p_lash->switches[sw1];
> > +
> > +			/* make all distances big except s1 to itself */
> > +			for (sw2 = 0; sw2 < p_lash->num_switches; sw2++)
> > +				p_lash->switches[sw2]->node->temp =
> > 0x7fffffff;
> > +
> > +			s1->node->temp = 0;
> > +
> > +			do {
> > +				change = 0;
> > +
> > +				for (sw2 = 0; sw2 < p_lash->num_switches;
> > sw2++) {
> > +					s2 = p_lash->switches[sw2];
> > +					if (s2->node->temp == 0x7fffffff)
> > +						continue;
> > +					for (j = 0; j < s2->node->num_links;
> > j++) {
> > +						sw3 =
> > s2->node->links[j]->switch_id;
> > +						s3 = p_lash->switches[sw3];
> > +
> > +						if (sw3 == sw)
> > +							continue;
> > +
> > +						if ((s2->node->temp + 1) <
> > s3->node->temp) {
> > +							s3->node->temp =
> > s2->node->temp + 1;
> > +							change++;
> > +						}
> > +					}
> > +				}
> > +			} while(change);
> 
> As far as I can understand it is minimal hops calculation.
> 
> We already have this information in OpenSM switches lmx mtrices. Using
> this matrix 'm' could be created as:
> 
> 	for (i = 0; i < num_links; i++) {
> 		sw1 = node->links[i]->switch_id;
> 		s1 = p_lash->switches[sw1];
> 
> 		for (i = 0; i < num_links; i++) {
> 			unsigned lid;
> 			sw2 = node->links[i]->switch_id;
> 			s2 = p_lash->switches[sw2];
> 			lid = cl_ntoh16(osm_node_get_base_lid(s2->p_sw->p_node, 0));
> 
> 			m[i][j] = osm_switch_get_least_hops(s1->p_sw, lid);
> 		}
> 	}

Actually this my assumption is wrong. 'm' matrix contains min hops except
paths which can cross the original switch. So it should be done
differently, maybe something like this:


	for (i = 0; i < num_links; i++) {
		sw1 = node->links[i]->switch_id;
		s1 = p_lash->switches[sw1];

		for (j = 0; j < num_links; j++) {
			unsigned lid, p, h, hops = 0xff;

			sw2 = node->links[j]->switch_id;

			if (sw1 == sw2) {
				m1[i][j] = 0;
				continue;
			}

			s2 = p_lash->switches[sw2];
			lid = cl_ntoh16(osm_node_get_base_lid(s2->p_sw->p_node, 0));
			for (p = 1 ; p < s1->p_sw->num_ports; p++) {
				h = osm_switch_get_hop_count(s1->p_sw, lid, p);
				osm_physp_t *physp = osm_node_get_physp_ptr(s1->p_sw->p_node, p);
				if (h < hops &&
				    physp->p_remote_physp->p_node->sw != s->p_sw)
					hops = h;
			}
			m1[i][j] = hops;
		}
	}

Sasha



More information about the general mailing list