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

Hal Rosenstock hal.rosenstock at gmail.com
Wed Aug 5 10:03:55 PDT 2009


On Wed, Aug 5, 2009 at 12:22 PM, Sasha Khapyorsky <sashak at voltaire.com>wrote:

> On 10:21 Wed 05 Aug     , Hal Rosenstock wrote:
> >
> > Is this what you mean or am I missing your idea on how the
> p_lash->switches
> > array is to be reordered ?
>
> 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 ? That seems
to be what is being optimized to me. Also, couldn't this be a subsequent
step in the evolution of this code ?

-- Hal


>
>
> Sasha
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openfabrics.org/pipermail/general/attachments/20090805/0c7297fa/attachment.html>


More information about the general mailing list