[ofa-general] Re: [PATCHv2] opensm/osm_mesh.c: Reorder switches for lash

Sasha Khapyorsky sashak at voltaire.com
Wed Aug 5 10:50:00 PDT 2009


On 13:03 Wed 05 Aug     , Hal Rosenstock wrote:
> >
> > Thinking more about this I suppose that an original structure is good
> > enough for doing what you need without intermediate buffers. It could be
> > something like this:
> >
> >        qsort(index....);
> >
> >        for (i = 0; i < num_switches; i++)
> >                lash->switches[index[i].index]->id = i;
> >
> >        for (i = 0; i < num_switches; i++) {
> >                s = lash->switches[i];
> >                for (j = 0; j < s->num_links; j++)
> >                        s->links[j]->switch_id =
> >                            lash->switches[s->links[j]->switch_id]->id;
> >        }
> >
> >        for (i = 0; i < num_switches; i++) {
> >                s = lash->switches[i];
> >                while (s->id != i) {
> >                        s1 = lash->switches[s->id];
> >                        lash->switches[s->id] = s;
> >                        s = s1;
> >                }
> >        }
> >
> > Would it work?
> 
> 
> Even if something like this works (haven't played with it yet), is it worth
> iterating over lash->switches array to save a memory allocation ?

It is single pass finally - just put everything in the places. I don't
think that this introduces more calculations than the original code did.

> Also, couldn't this be a subsequent
> step in the evolution of this code ?

Yes, I think it could.

Sasha



More information about the general mailing list