Hi Sasha,<br><br>
<div class="gmail_quote">On Wed, Aug 5, 2009 at 5:32 AM, Sasha Khapyorsky <span dir="ltr"><<a href="mailto:sashak@voltaire.com">sashak@voltaire.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">Hi Hal,<br>
<div>
<div></div>
<div class="h5"><br>On 11:16 Wed 22 Jul     , Hal Rosenstock wrote:<br>><br>> +/*<br>> + * sort_switches - reorder switch array<br>> + */<br>> +static void sort_switches(lash_t *p_lash, mesh_t *mesh)<br>> +{<br>
> +     int i, j;<br>> +     int num_switches = p_lash->num_switches;<br>> +     sort_ctx_t sort_ctx;<br>> +     comp_t *index;<br>> +     int *reverse;<br>> +     switch_t *s;<br>> +     switch_t **switches;<br>
> +<br>> +     index = malloc(num_switches * sizeof(comp_t));<br>> +     reverse = malloc(num_switches * sizeof(int));<br>> +     switches = malloc(num_switches * sizeof(switch_t *));<br>> +     if (!index || !reverse || !switches) {<br>
> +             OSM_LOG(&p_lash->p_osm->log, OSM_LOG_ERROR,<br>> +                     "Failed memory allocation - switches not sorted!\n");<br>> +             goto Exit;<br>> +     }<br>> +<br>
> +     sort_ctx.mesh = mesh;<br>> +     sort_ctx.p_lash = p_lash;<br>> +<br>> +     for (i = 0; i < num_switches; i++) {<br>> +             index[i].index = i;<br>> +             index[i].ctx = &sort_ctx;<br>
> +     }<br>> +<br>> +     qsort(index, num_switches, sizeof(comp_t), compare_switch);<br>> +<br>> +     for (i = 0; i < num_switches; i++)<br>> +             reverse[index[i].index] = i;<br>> +<br>
> +     for (i = 0; i < num_switches; i++) {<br>> +             s = p_lash->switches[index[i].index];<br>> +             switches[i] = s;<br>> +             s->id = i;<br>> +             for (j = 0; j < s->node->num_links; j++)<br>
> +                     s->node->links[j]->switch_id =<br>> +                             reverse[s->node->links[j]->switch_id];<br><br></div></div>Isn't it the same as:<br>
<div class="im"><br>       s->node->links[j]->switch_id =<br></div>           index[s->node->links[j]->switch_id].index;</blockquote>
<div> </div>
<div>No.</div>
<div> </div>
<div>-- Hal</div>
<div> </div>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid"><span id=""></span><br>(and then reverse array is obsolete)?<br><font color="#888888"><br>Sasha<br></font>
<div>
<div></div>
<div class="h5"><br>> +     }<br>> +<br>> +     for (i = 0; i < num_switches; i++)<br>> +             p_lash->switches[i] = switches[i];<br>> +<br>> +Exit:<br>> +     if (switches)<br>> +             free(switches);<br>
> +     if (index)<br>> +             free(index);<br>> +     if (reverse)<br>> +             free(reverse);<br>> +}<br>> +<br>> +/*<br>>   * osm_mesh_delete - free per mesh resources<br>>   */<br>
>  static void mesh_delete(mesh_t *mesh)<br>> @@ -1470,6 +1561,8 @@ int osm_do_mesh_analysis(lash_t *p_lash)<br>>               if (reorder_links(p_lash, mesh))<br>>                       goto err;<br>><br>
> +             sort_switches(p_lash, mesh);<br>> +<br>>               p = buf;<br>>               p += sprintf(p, "found ");<br>>               for (i = 0; i < mesh->dimension; i++)<br>><br>
_______________________________________________<br>general mailing list<br><a href="mailto:general@lists.openfabrics.org">general@lists.openfabrics.org</a><br><a href="http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general" target="_blank">http://lists.openfabrics.org/cgi-bin/mailman/listinfo/general</a><br>
<br>To unsubscribe, please visit <a href="http://openib.org/mailman/listinfo/openib-general" target="_blank">http://openib.org/mailman/listinfo/openib-general</a><br></div></div></blockquote></div><br>