[ofa-general] [PATCH] osm: Converting the the C++ code to C in osm_ucast_lash.c
Yevgeny Kliteynik
kliteyn at dev.mellanox.co.il
Tue Mar 6 08:03:16 PST 2007
Hi Hal.
Converting the the C++ code to C.
Please apply both to trunk and to 1.2
Thanks.
Signed-off-by: Yevgeny Kliteynik <kliteyn at dev.mellanox.co.il>
---
osm/opensm/osm_ucast_lash.c | 23 ++++++++++++++++-------
1 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/osm/opensm/osm_ucast_lash.c b/osm/opensm/osm_ucast_lash.c
index 0afa43c..8c9172e 100644
--- a/osm/opensm/osm_ucast_lash.c
+++ b/osm/opensm/osm_ucast_lash.c
@@ -406,7 +406,7 @@ static int get_phys_connection(switch_t
static void shortest_path(lash_t *p_lash, int ir)
{
switch_t **switches = p_lash->switches, *sw, *swi;
- int i;
+ uint16_t i;
cl_list_t bfsq;
cl_list_construct(&bfsq);
@@ -986,11 +986,18 @@ static int lash_core(lash_t *p_lash)
int output_link2, i_next_switch2;
int cycle_found2 = 0;
int status = IB_SUCCESS;
+ int * switch_bitmap = NULL;
OSM_LOG_ENTER(p_log, lash_core);
- //Bitmap to check if we have processed this pair
- int switch_bitmap[num_switches][num_switches];
+ switch_bitmap = (int *)malloc(num_switches * num_switches * sizeof(int));
+ if (!switch_bitmap)
+ {
+ osm_log(p_log, OSM_LOG_ERROR,
+ "lash_core: ERR 4D04: "
+ "Failed allocating switch_bitmap - out of memory\n");
+ goto Exit;
+ }
for(i=0; i<num_switches; i++) {
@@ -1006,7 +1013,7 @@ static int lash_core(lash_t *p_lash)
for(j=0; j<num_switches; j++) {
for(k=0; k<num_switches; k++) {
- switch_bitmap[j][k] = 0;
+ switch_bitmap[j * num_switches + k] = 0;
}
switches[j]->used_channels = 0;
switches[j]->q_state = UNQUEUED;
@@ -1015,7 +1022,7 @@ static int lash_core(lash_t *p_lash)
for(i=0; i<num_switches; i++) {
for(dest_switch=0; dest_switch<num_switches; dest_switch++)
- if(dest_switch != i && switch_bitmap[i][dest_switch] == 0) {
+ if(dest_switch != i && switch_bitmap[i * num_switches + dest_switch] == 0) {
v_lane = 0;
stop = 0;
while(v_lane < lanes_needed && stop == 0) {
@@ -1078,8 +1085,8 @@ static int lash_core(lash_t *p_lash)
p_lash->virtual_location[i][dest_switch][v_lane] = 1;
p_lash->virtual_location[dest_switch][i][v_lane] = 1;
- switch_bitmap[i][dest_switch] = 1;
- switch_bitmap[dest_switch][i] = 1;
+ switch_bitmap[i * num_switches + dest_switch] = 1;
+ switch_bitmap[dest_switch * num_switches + i] = 1;
}
for(j=0; j<num_switches; j++) {
@@ -1115,6 +1122,8 @@ static int lash_core(lash_t *p_lash)
"Lane requirements (%d) exceed available lanes (%d)\n",
p_lash->vl_min, lanes_needed);
Exit:
+ if (switch_bitmap)
+ free(switch_bitmap);
OSM_LOG_EXIT(p_log);
return status;
}
--
1.4.4.1.GIT
More information about the general
mailing list