~ubuntu-branches/ubuntu/vivid/slurm-llnl/vivid

« back to all changes in this revision

Viewing changes to src/plugins/select/bluegene/block_allocator/block_allocator.c

  • Committer: Bazaar Package Importer
  • Author(s): Gennaro Oliva
  • Date: 2009-09-24 23:28:15 UTC
  • mfrom: (1.1.11 upstream) (3.2.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090924232815-enh65jn32q1ebg07
Tags: 2.0.5-1
* New upstream release 
* Changed dependecy from lib-mysqlclient15 to lib-mysqlclient 
* Added Default-Start for runlevel 2 and 4 and $remote_fs requirement in
  init.d scripts (Closes: #541252)
* Postinst checks for wrong runlevels 2 and 4 links
* Upgraded to standard version 3.8.3
* Add lintian overrides for missing slurm-llnl-configurator.html in doc
  base registration
* modified postrm scripts to ignore pkill return value in order to avoid
  postrm failure when no slurm process is running
* Checking for slurmctld.pid before cancelling running and pending
  jobs during package removal 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************\
2
2
 *  block_allocator.c - Assorted functions for layout of bluegene blocks, 
3
3
 *       wiring, mapping for smap, etc.
4
 
 *  $Id: block_allocator.c 17225 2009-04-10 19:25:52Z da $
 
4
 *  $Id: block_allocator.c 18612 2009-09-02 19:00:21Z da $
5
5
 *****************************************************************************
6
6
 *  Copyright (C) 2004 The Regents of the University of California.
7
7
 *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
8
8
 *  Written by Dan Phung <phung4@llnl.gov>, Danny Auble <da@llnl.gov>
9
9
 *  
10
10
 *  This file is part of SLURM, a resource management program.
11
 
 *  For details, see <http://www.llnl.gov/linux/slurm/>.
 
11
 *  For details, see <https://computing.llnl.gov/linux/slurm/>.
 
12
 *  Please also read the included file: DISCLAIMER.
12
13
 *  
13
14
 *  SLURM is free software; you can redistribute it and/or modify it under
14
15
 *  the terms of the GNU General Public License as published by the Free
200
201
/*                           List nodes, int dim,  */
201
202
/*                           int count, int highest_phys_x);  */
202
203
/* */
203
 
static int _finish_torus(ba_switch_t *curr_switch, int source_port, 
 
204
static int _finish_torus(List results, 
 
205
                         ba_switch_t *curr_switch, int source_port, 
204
206
                         int dim, int count, int *start);
205
207
/* */
206
208
static int *_set_best_path();
398
400
                                image_group->name = xmalloc(i-j+2);
399
401
                                snprintf(image_group->name,
400
402
                                         (i-j)+1, "%s", tmp+j);
401
 
                                image_group->gid =
402
 
                                        gid_from_string(image_group->name);
 
403
                                gid_from_string (image_group->name,
 
404
                                                &image_group->gid);
403
405
                                debug3("adding group %s %d", image_group->name,
404
406
                                       image_group->gid);
405
407
                                list_append(n->groups, image_group);
411
413
                        image_group = xmalloc(sizeof(image_group_t));
412
414
                        image_group->name = xmalloc(i-j+2);
413
415
                        snprintf(image_group->name, (i-j)+1, "%s", tmp+j);
414
 
                        image_group->gid = gid_from_string(image_group->name);
415
 
                        if (image_group->gid == (gid_t) -1) {
 
416
                        if (gid_from_string (image_group->name,
 
417
                                             &image_group->gid) < 0)
416
418
                                fatal("Invalid bluegene.conf parameter "
417
419
                                      "Groups=%s", 
418
420
                                      image_group->name);
419
 
                        } else {
 
421
                        else
420
422
                                debug3("adding group %s %d", image_group->name,
421
423
                                       image_group->gid);
422
 
                        }
423
424
                        list_append(n->groups, image_group);
424
425
                }
425
426
                xfree(tmp);
500
501
#ifdef HAVE_BG
501
502
        float sz=1;
502
503
        int geo[BA_SYSTEM_DIMENSIONS] = {0,0,0};
503
 
        int i2, i3, picked, total_sz=1 , size2, size3;
504
 
        ListIterator itr;
505
 
        int checked[8];
 
504
        int i2, i3, picked, total_sz=1, size2=0;
 
505
        int checked[DIM_SIZE[X]];
506
506
        int *geo_ptr;
507
507
        int messed_with = 0;
508
 
        
 
508
 
509
509
        ba_request->save_name= NULL;
510
510
        ba_request->rotate_count= 0;
511
511
        ba_request->elongate_count = 0;
583
583
                                    ba_request->rotate);
584
584
                }
585
585
        
586
 
                if(ba_request->size>total_sz || ba_request->size<1) {
 
586
                if(ba_request->size > total_sz || ba_request->size < 1) {
587
587
                        return 0;                       
588
588
                }
589
589
                sz = ba_request->size % (DIM_SIZE[Y] * DIM_SIZE[Z]);
593
593
                      geo[Y] = DIM_SIZE[Y];
594
594
                      geo[Z] = DIM_SIZE[Z];
595
595
                      sz=ba_request->size;
596
 
                      _append_geo(geo,
597
 
                                  ba_request->elongate_geos,
598
 
                                  ba_request->rotate);
 
596
                      if((geo[X]*geo[Y]*geo[Z]) == ba_request->size)
 
597
                              _append_geo(geo,
 
598
                                          ba_request->elongate_geos,
 
599
                                          ba_request->rotate);
 
600
                      else
 
601
                              error("%d I was just trying to add a "
 
602
                                    "geo of %d%d%d "
 
603
                                    "while I am trying to request %d midplanes",
 
604
                                    __LINE__, geo[X], geo[Y], geo[Z],
 
605
                                    ba_request->size);
599
606
                }       
600
607
//      startagain:             
601
608
                picked=0;
602
 
                for(i=0;i<8;i++)
 
609
                for(i=0; i<DIM_SIZE[X]; i++)
603
610
                        checked[i]=0;
604
611
                
605
 
                size3=ba_request->size;
606
 
                
607
612
                for (i=0; i<BA_SYSTEM_DIMENSIONS; i++) {
608
613
                        total_sz *= DIM_SIZE[i];
609
614
                        geo[i] = 1;
610
615
                }
611
 
        
 
616
               
612
617
                sz = 1;
613
 
                size3=ba_request->size;
614
618
                picked=0;
615
619
        tryagain:       
616
 
                if(size3!=ba_request->size)
617
 
                        size2=size3;
618
 
                else
619
 
                        size2=ba_request->size;
 
620
                size2 = ba_request->size;
620
621
                //messedup:
621
 
 
622
622
                for (i=picked; i<BA_SYSTEM_DIMENSIONS; i++) { 
623
 
                        if(size2<=1) 
 
623
                        if(size2 <= 1) 
624
624
                                break;
625
 
                        sz = size2%DIM_SIZE[i];
 
625
        
 
626
                        sz = size2 % DIM_SIZE[i];
626
627
                        if(!sz) {
627
628
                                geo[i] = DIM_SIZE[i];   
628
629
                                size2 /= DIM_SIZE[i];
629
 
                        } else if (size2 > DIM_SIZE[i]){
630
 
                                for(i2=(DIM_SIZE[i]-1);i2>1;i2--) {
 
630
                        } else if (size2 > DIM_SIZE[i]) {
 
631
                                for(i2=(DIM_SIZE[i]-1); i2 > 1; i2--) {
631
632
                                        /* go through each number to see if 
632
633
                                           the size is divisable by a smaller 
633
634
                                           number that is 
634
635
                                           good in the other dims. */
635
636
                                        if (!(size2%i2) && !checked[i2]) {
636
637
                                                size2 /= i2;
637
 
                                                                        
 
638
                                        
638
639
                                                if(i==0)
639
640
                                                        checked[i2]=1;
640
641
                                                        
641
 
                                                if(i2<DIM_SIZE[i]) 
 
642
                                                if(i2<DIM_SIZE[i]) {
642
643
                                                        geo[i] = i2;
643
 
                                                else {
 
644
                                                } else {
644
645
                                                        goto tryagain;
645
646
                                                }
646
647
                                                if((i2-1)!=1 && 
657
658
                                   run.  
658
659
                                */
659
660
                                if(i2==1) {
660
 
                                        error("Can't make a block of "
661
 
                                              "%d into a cube.",
662
 
                                              ba_request->size);
663
 
                                        return 0;
 
661
                                        if(!list_count(
 
662
                                                   ba_request->elongate_geos))
 
663
                                                error("Can't make a block of "
 
664
                                                      "%d into a cube.",
 
665
                                                      ba_request->size);
 
666
                                        goto endit;
664
667
/*                                      ba_request->size +=1; */
665
668
/*                                      goto startagain; */
666
669
                                }
667
 
                                                
668
670
                        } else {
669
671
                                geo[i] = sz;    
670
672
                                break;
671
673
                        }                                       
672
674
                }
673
 
                
 
675
 
674
676
                if((geo[X]*geo[Y]) <= DIM_SIZE[Y]) {
675
677
                        ba_request->geometry[X] = 1;
676
678
                        ba_request->geometry[Y] = geo[X] * geo[Y];
689
691
                                    ba_request->rotate);                
690
692
        
691
693
                }
692
 
                if((geo[X]/2) <= DIM_SIZE[Y]) {
 
694
 
 
695
                /* Make sure geo[X] is even and then see if we can get
 
696
                   it into the Y or Z dim. */
 
697
                if(!(geo[X]%2) && ((geo[X]/2) <= DIM_SIZE[Y])) {
693
698
                        if(geo[Y] == 1) {
694
699
                                ba_request->geometry[Y] = geo[X]/2;
695
700
                                messed_with = 1;
746
751
                        }
747
752
                }
748
753
                
749
 
                _append_geo(geo, 
750
 
                            ba_request->elongate_geos, 
751
 
                            ba_request->rotate);
 
754
                if((geo[X]*geo[Y]*geo[Z]) == ba_request->size)
 
755
                        _append_geo(geo, 
 
756
                                    ba_request->elongate_geos, 
 
757
                                    ba_request->rotate);
 
758
                else
 
759
                        error("%d I was just trying to add a geo of %d%d%d "
 
760
                              "while I am trying to request %d midplanes",
 
761
                               __LINE__, geo[X], geo[Y], geo[Z],
 
762
                              ba_request->size);
752
763
        
753
764
                /* see if We can find a cube or square root of the 
754
765
                   size to make an easy cube */
771
782
                                else
772
783
                                        goto endit;
773
784
                                
774
 
                        _append_geo(geo, 
775
 
                                    ba_request->elongate_geos, 
776
 
                                    ba_request->rotate);
 
785
                        if((geo[X]*geo[Y]*geo[Z]) == ba_request->size)
 
786
                                _append_geo(geo, 
 
787
                                            ba_request->elongate_geos, 
 
788
                                            ba_request->rotate);
 
789
                        else
 
790
                                error("%d I was just trying to add "
 
791
                                      "a geo of %d%d%d "
 
792
                                      "while I am trying to request "
 
793
                                      "%d midplanes",
 
794
                                      __LINE__, geo[X], geo[Y], geo[Z],
 
795
                                      ba_request->size);                        
777
796
                } 
778
797
        }
779
798
        
780
799
endit:
781
 
        itr = list_iterator_create(ba_request->elongate_geos);
782
 
        geo_ptr = list_next(itr);
783
 
        list_iterator_destroy(itr);
784
 
        
785
 
        if(geo_ptr == NULL)
 
800
        if(!(geo_ptr = list_peek(ba_request->elongate_geos)))
786
801
                return 0;
787
802
 
788
803
        ba_request->elongate_count++;
1036
1051
                                          % (HOSTLIST_BASE * HOSTLIST_BASE))
1037
1052
                                        / HOSTLIST_BASE;
1038
1053
                                end[Z] = (number % HOSTLIST_BASE);
 
1054
                                j += 3;
 
1055
 
1039
1056
                                DIM_SIZE[X] = MAX(DIM_SIZE[X], end[X]);
1040
1057
                                DIM_SIZE[Y] = MAX(DIM_SIZE[Y], end[Y]);
1041
1058
                                DIM_SIZE[Z] = MAX(DIM_SIZE[Z], end[Z]);
1042
 
                                break;
1043
 
                        }
1044
 
                                
 
1059
 
 
1060
                                if(node->nodenames[j] != ',')
 
1061
                                        break;
 
1062
                        }                       
1045
1063
                }
1046
1064
                if ((DIM_SIZE[X]==0) && (DIM_SIZE[Y]==0) && (DIM_SIZE[Z]==0)) 
1047
1065
                        info("are you sure you only have 1 midplane? %s",
1204
1222
        bridge_fini();
1205
1223
#endif
1206
1224
        _delete_ba_system();
1207
 
//      debug2("pa system destroyed");
 
1225
//      debug3("pa system destroyed");
1208
1226
}
1209
1227
 
1210
1228
 
1237
1255
 
1238
1256
        /* basically set the node as used */
1239
1257
        if((node_base_state == NODE_STATE_DOWN)
1240
 
           || (ba_node->state & NODE_STATE_DRAIN)) 
 
1258
           || (state & NODE_STATE_DRAIN)) 
1241
1259
                ba_node->used = true;
1242
1260
        else
1243
1261
                ba_node->used = false;
 
1262
 
1244
1263
        ba_node->state = state;
1245
1264
}
1246
1265
 
1294
1313
                list_iterator_destroy(itr2);
1295
1314
        
1296
1315
                if(!new_ba_node) {
1297
 
                        debug2("adding %c%c%c as a new node",
 
1316
                        debug3("adding %c%c%c as a new node",
1298
1317
                               alpha_num[ba_node->coord[X]], 
1299
1318
                               alpha_num[ba_node->coord[Y]],
1300
1319
                               alpha_num[ba_node->coord[Z]]);
1488
1507
                        grid[ba_node->coord[X]]
1489
1508
                        [ba_node->coord[Y]]
1490
1509
                        [ba_node->coord[Z]];
 
1510
                
1491
1511
                if(ba_node->used && curr_ba_node->used) {
1492
 
                        debug3("I have already been to "
1493
 
                               "this node %c%c%c",
1494
 
                               alpha_num[ba_node->coord[X]], 
1495
 
                               alpha_num[ba_node->coord[Y]],
1496
 
                               alpha_num[ba_node->coord[Z]]);
1497
 
                        rc = SLURM_ERROR;
1498
 
                        goto end_it;
 
1512
                        /* Only error if the midplane isn't already
 
1513
                         * marked down or in a error state outside of
 
1514
                         * the bluegene block.
 
1515
                         */
 
1516
                        uint16_t base_state, node_flags;
 
1517
                        base_state = curr_ba_node->state & NODE_STATE_BASE;
 
1518
                        node_flags = curr_ba_node->state & NODE_STATE_FLAGS;
 
1519
                        if (!(node_flags & (NODE_STATE_DRAIN | NODE_STATE_FAIL))
 
1520
                            && (base_state != NODE_STATE_DOWN)) {
 
1521
                                debug4("I have already been to "
 
1522
                                       "this node %c%c%c %s",
 
1523
                                       alpha_num[ba_node->coord[X]], 
 
1524
                                       alpha_num[ba_node->coord[Y]],
 
1525
                                       alpha_num[ba_node->coord[Z]],
 
1526
                                       node_state_string(curr_ba_node->state));
 
1527
                                rc = SLURM_ERROR;
 
1528
                                goto end_it;
 
1529
                        }
1499
1530
                }
1500
1531
                
1501
1532
                if(ba_node->used) 
1512
1543
                                   && curr_ba_switch->int_wire[j].used
1513
1544
                                        && j != curr_ba_switch->
1514
1545
                                   int_wire[j].port_tar) {
1515
 
                                        debug3("%c%c%c dim %d port %d "
 
1546
                                        debug4("%c%c%c dim %d port %d "
1516
1547
                                               "is already in use to %d",
1517
1548
                                               alpha_num[ba_node->coord[X]], 
1518
1549
                                               alpha_num[ba_node->coord[Y]],
1615
1646
                if(ba_node->letter == '.') {
1616
1647
                        ba_node->letter = letters[color_count%62];
1617
1648
                        ba_node->color = colors[color_count%6];
1618
 
                        debug3("count %d setting letter = %c "
 
1649
                        debug4("count %d setting letter = %c "
1619
1650
                               "color = %d",
1620
1651
                               color_count,
1621
1652
                               ba_node->letter,
2173
2204
                        check[4] = '\0';
2174
2205
                }
2175
2206
        }
 
2207
        
 
2208
        if((check[1] < '0' || check[1] > '9')
 
2209
           || (check[2] < '0' || check[2] > '9')
 
2210
           || (check[3] < '0' || check[3] > '9')) {
 
2211
                error("%s is not a valid Rack-Midplane (i.e. R000)", bp_id);
 
2212
                goto cleanup;
 
2213
        }
 
2214
                        
2176
2215
#else
2177
2216
        if(check[3] != '-') {
2178
2217
                xfree(check);
2179
2218
                check = xstrdup_printf("R%c%c-M%c",
2180
2219
                                       bp_id[1], bp_id[2], bp_id[3]);
2181
2220
        }
 
2221
 
 
2222
        if((check[1] < '0' || check[1] > '9')
 
2223
           || (check[2] < '0' || check[2] > '9')
 
2224
           || (check[5] < '0' || check[5] > '9')) {
 
2225
                error("%s is not a valid Rack-Midplane (i.e. R00-M0)", bp_id);
 
2226
                goto cleanup;
 
2227
        }
2182
2228
#endif
2183
 
 
 
2229
        
2184
2230
        itr = list_iterator_create(bp_map_list);
2185
2231
        while ((bp_map = list_next(itr)))  
2186
2232
                if (!strcasecmp(bp_map->bp_id, check)) 
2187
2233
                        break;  /* we found it */
2188
2234
        list_iterator_destroy(itr);
2189
2235
 
 
2236
cleanup:
2190
2237
        xfree(check);
2191
2238
 
2192
2239
        if(bp_map != NULL)
2213
2260
        len -= 3;
2214
2261
        if(len<0)
2215
2262
                return NULL;
 
2263
 
 
2264
        if((xyz[len] < '0' || xyz[len] > '9')
 
2265
           || (xyz[len+1] < '0' || xyz[len+1] > '9')
 
2266
           || (xyz[len+2] < '0' || xyz[len+2] > '9')) {
 
2267
                error("%s is not a valid Location (i.e. 000)", xyz);
 
2268
                return NULL;
 
2269
        }
 
2270
 
 
2271
 
2216
2272
        number = xstrntol(&xyz[X]+len, NULL,
2217
2273
                          BA_SYSTEM_DIMENSIONS, HOSTLIST_BASE);
2218
2274
        coord[X] = number / (HOSTLIST_BASE * HOSTLIST_BASE);
2219
2275
        coord[Y] = (number % (HOSTLIST_BASE * HOSTLIST_BASE)) / HOSTLIST_BASE;
2220
2276
        coord[Z] = (number % HOSTLIST_BASE);
 
2277
 
 
2278
 
2221
2279
        if(!bp_map_list) {
2222
2280
                if(set_bp_map() == -1)
2223
2281
                        return NULL;
2259
2317
        ba_switch_t *ba_switch = NULL; 
2260
2318
        int *geo = NULL;
2261
2319
        
2262
 
        debug2("getting info for block %s\n", bg_block_id);
 
2320
        debug3("getting info for block %s\n", bg_block_id);
2263
2321
        
2264
2322
        if ((rc = bridge_get_block(bg_block_id,  &block_ptr)) != STATUS_OK) {
2265
2323
                error("bridge_get_block(%s): %s", 
2275
2333
                return SLURM_ERROR;
2276
2334
        } 
2277
2335
        if(!switch_cnt) {
2278
 
                debug3("no switch_cnt");
 
2336
                debug4("no switch_cnt");
2279
2337
                if ((rc = bridge_get_data(block_ptr, 
2280
2338
                                          RM_PartitionFirstBP, 
2281
2339
                                          &curr_bp)) 
2348
2406
                              bg_err_str(rc));
2349
2407
                        return SLURM_ERROR;
2350
2408
                }
2351
 
                debug2("switch id = %s dim %d conns = %d", 
 
2409
                debug3("switch id = %s dim %d conns = %d", 
2352
2410
                       switchid, dim, cnt);
2353
2411
                ba_switch = &ba_system_ptr->
2354
2412
                        grid[geo[X]][geo[Y]][geo[Z]].axis_switch[dim];
2421
2479
                                ba_system_ptr->grid[geo[X]][geo[Y]][geo[Z]].
2422
2480
                                        used = true;            
2423
2481
                        }
2424
 
                        debug3("connection going from %d -> %d",
 
2482
                        debug4("connection going from %d -> %d",
2425
2483
                              curr_conn.p1, curr_conn.p2);
2426
2484
                        
2427
2485
                        if(ba_switch->int_wire[curr_conn.p1].used) {
2483
2541
        List results = list_create(destroy_ba_node);
2484
2542
        ListIterator itr = NULL;
2485
2543
        
2486
 
        debug2("getting info for block %s\n", bg_block_id);
 
2544
        debug3("getting info for block %s\n", bg_block_id);
2487
2545
        
2488
2546
        if ((rc = bridge_get_block(bg_block_id,  &block_ptr)) != STATUS_OK) {
2489
2547
                error("bridge_get_block(%s): %s", 
2499
2557
                goto end_it;
2500
2558
        } 
2501
2559
        if(!switch_cnt) {
2502
 
                debug3("no switch_cnt");
 
2560
                debug4("no switch_cnt");
2503
2561
                if ((rc = bridge_get_data(block_ptr, 
2504
2562
                                          RM_PartitionFirstBP, 
2505
2563
                                          &curr_bp)) 
2578
2636
                              bg_err_str(rc));
2579
2637
                        goto end_it;
2580
2638
                }
2581
 
                debug2("switch id = %s dim %d conns = %d", 
 
2639
                debug3("switch id = %s dim %d conns = %d", 
2582
2640
                       switchid, dim, cnt);
2583
2641
                
2584
2642
                itr = list_iterator_create(results);
2665
2723
                                }
2666
2724
                                ba_node->used = true;           
2667
2725
                        }
2668
 
                        debug3("connection going from %d -> %d",
 
2726
                        debug4("connection going from %d -> %d",
2669
2727
                              curr_conn.p1, curr_conn.p2);
2670
2728
                        
2671
2729
                        if(ba_switch->int_wire[curr_conn.p1].used) {
2890
2948
                
2891
2949
        }
2892
2950
        list_iterator_destroy(itr);
2893
 
        
 
2951
 
2894
2952
        if(geo_ptr == NULL) { 
2895
2953
                geo = xmalloc(sizeof(int)*BA_SYSTEM_DIMENSIONS);
2896
2954
                geo[X] = geometry[X];
2897
2955
                geo[Y] = geometry[Y];
2898
2956
                geo[Z] = geometry[Z];
2899
 
                debug3("adding geo %c%c%c",
 
2957
                debug4("adding geo %c%c%c",
2900
2958
                       alpha_num[geo[X]], alpha_num[geo[Y]],
2901
2959
                       alpha_num[geo[Z]]);
2902
2960
                list_append(geos, geo);
2960
3018
                                        continue;
2961
3019
 
2962
3020
                                if (!_node_used(ba_node, geometry[X])) {
2963
 
                                        debug3("here Adding %c%c%c",
 
3021
                                        debug4("here Adding %c%c%c",
2964
3022
                                               alpha_num[ba_node->coord[X]],
2965
3023
                                               alpha_num[ba_node->coord[Y]],
2966
3024
                                               alpha_num[ba_node->coord[Z]]);
3064
3122
        node_curr = curr_switch->ext_wire[0].node_tar;
3065
3123
        node_tar = curr_switch->ext_wire[port_tar].node_tar;
3066
3124
        if(mark_switch->int_wire[source].used)
3067
 
                debug2("setting dim %d %c%c%c %d-> %c%c%c %d",
 
3125
                debug3("setting dim %d %c%c%c %d-> %c%c%c %d",
3068
3126
                       dim,
3069
3127
                       alpha_num[node_curr[X]],
3070
3128
                       alpha_num[node_curr[Y]],
3092
3150
           && node_curr[Z] == node_tar[Z]) {
3093
3151
                /* We are going to the same node! this should never
3094
3152
                   happen */
3095
 
                debug4("something bad happened!! "
 
3153
                debug5("something bad happened!! "
3096
3154
                       "we are on %c%c%c and are going to it "
3097
3155
                       "from port %d - > %d", 
3098
3156
                       alpha_num[node_curr[X]],
3132
3190
                                               [mark_node_tar[Z]]);
3133
3191
                        _new_ba_node(ba_node, mark_node_tar, false);
3134
3192
                        list_push(nodes, ba_node);
3135
 
                        debug3("haven't seen %c%c%c adding it",
 
3193
                        debug4("haven't seen %c%c%c adding it",
3136
3194
                               alpha_num[ba_node->coord[X]], 
3137
3195
                               alpha_num[ba_node->coord[Y]],
3138
3196
                               alpha_num[ba_node->coord[Z]]);
3158
3216
 
3159
3217
        for(i2=1;i2<=2;i2++) {
3160
3218
                if(geometry[i2] > 1) {
3161
 
                        debug3("%d node %c%c%c port 2 -> ",
 
3219
                        debug4("%d node %c%c%c port 2 -> ",
3162
3220
                               i2,
3163
3221
                               alpha_num[ba_node->coord[X]],
3164
3222
                               alpha_num[ba_node->coord[Y]],
3166
3224
                                                               
3167
3225
                        dim_curr_switch = &ba_node->axis_switch[i2];
3168
3226
                        if(dim_curr_switch->int_wire[2].used) {
3169
 
                                debug4("returning here");
 
3227
                                debug5("returning here");
3170
3228
                                return 0;
3171
3229
                        }
3172
3230
                                                        
3175
3233
                        next_node = &ba_system_ptr->
3176
3234
                                grid[node_tar[X]][node_tar[Y]][node_tar[Z]];
3177
3235
                        dim_next_switch = &next_node->axis_switch[i2];
3178
 
                        debug3("%c%c%c port 5",
 
3236
                        debug4("%c%c%c port 5",
3179
3237
                               alpha_num[next_node->coord[X]],
3180
3238
                               alpha_num[next_node->coord[Y]],
3181
3239
                               alpha_num[next_node->coord[Z]]);
3182
3240
                                                          
3183
3241
                        if(dim_next_switch->int_wire[5].used) {
3184
 
                                debug2("returning here 2");
 
3242
                                debug3("returning here 2");
3185
3243
                                return 0;
3186
3244
                        }
3187
 
                        debug4("%d %d %d %d",i2, node_tar[i2],
 
3245
                        debug5("%d %d %d %d",i2, node_tar[i2],
3188
3246
                               first[i2], geometry[i2]);
3189
3247
 
3190
3248
                        /* Here we need to see where we are in
3201
3259
                                count = (node_tar[i2]-first[i2]);
3202
3260
 
3203
3261
                        if(count == geometry[i2]) {
3204
 
                                debug4("found end of me %c%c%c",
 
3262
                                debug5("found end of me %c%c%c",
3205
3263
                                       alpha_num[node_tar[X]],
3206
3264
                                       alpha_num[node_tar[Y]],
3207
3265
                                       alpha_num[node_tar[Z]]);
3224
3282
                                                                PASS_FOUND_Z;
3225
3283
                                        }
3226
3284
                                        while(node_tar[i2] != first[i2]) {
3227
 
                                                debug3("on dim %d at %d "
 
3285
                                                debug4("on dim %d at %d "
3228
3286
                                                       "looking for %d",
3229
3287
                                                       i2,
3230
3288
                                                       node_tar[i2],
3232
3290
                                                
3233
3291
                                                if(dim_curr_switch->
3234
3292
                                                   int_wire[2].used) {
3235
 
                                                        debug3("returning "
 
3293
                                                        debug4("returning "
3236
3294
                                                               "here 3");
3237
3295
                                                        return 0;
3238
3296
                                                } 
3262
3320
                                                        axis_switch[i2];
3263
3321
                                        }
3264
3322
                                                                        
3265
 
                                        debug3("back to first on dim %d "
 
3323
                                        debug4("back to first on dim %d "
3266
3324
                                               "at %d looking for %d",
3267
3325
                                               i2,
3268
3326
                                               node_tar[i2],
3333
3391
                        */
3334
3392
 
3335
3393
                        dim_curr_switch = &ba_node->axis_switch[i2];
3336
 
                        debug3("%d node %c%c%c port 0 -> 1",
 
3394
                        debug4("%d node %c%c%c port 0 -> 1",
3337
3395
                               i2,
3338
3396
                               alpha_num[ba_node->coord[X]],
3339
3397
                               alpha_num[ba_node->coord[Y]],
3459
3517
                      port_tar);
3460
3518
                return 0;
3461
3519
        }
3462
 
        debug4("from %c%c%c %d %d -> %c%c%c %d",
 
3520
        debug5("from %c%c%c %d %d -> %c%c%c %d",
3463
3521
               alpha_num[node_curr[X]],
3464
3522
               alpha_num[node_curr[Y]],
3465
3523
               alpha_num[node_curr[Z]],
3472
3530
        if(node_curr[X] == node_tar[X]
3473
3531
           && node_curr[Y] == node_tar[Y]
3474
3532
           && node_curr[Z] == node_tar[Z]) {
3475
 
                debug4("%d something bad happened!!", dim);
 
3533
                debug5("%d something bad happened!!", dim);
3476
3534
                return 0;
3477
3535
        }
3478
3536
        next_switch = &ba_system_ptr->
3633
3691
                x = startx-1;
3634
3692
        while(x!=startx) {
3635
3693
                x++;
3636
 
                debug3("finding %c%c%c try %d",
 
3694
                debug4("finding %c%c%c try %d",
3637
3695
                       alpha_num[ba_request->geometry[X]],
3638
3696
#ifdef HAVE_3D
3639
3697
                       alpha_num[ba_request->geometry[Y]],
3643
3701
#ifdef HAVE_3D
3644
3702
        new_node:
3645
3703
#endif
3646
 
                debug2("starting at %c%c%c",
 
3704
                debug3("starting at %c%c%c",
3647
3705
                       alpha_num[start[X]]
3648
3706
#ifdef HAVE_3D
3649
3707
                       , alpha_num[start[Y]],
3660
3718
                        ;
3661
3719
 
3662
3720
                if (!_node_used(ba_node, ba_request->geometry[X])) {
3663
 
                        debug3("trying this node %c%c%c %c%c%c %d",
 
3721
                        debug4("trying this node %c%c%c %c%c%c %d",
3664
3722
                               alpha_num[start[X]],
3665
3723
                               alpha_num[start[Y]],
3666
3724
                               alpha_num[start[Z]],
3742
3800
static bool _node_used(ba_node_t* ba_node, int x_size)
3743
3801
{
3744
3802
        ba_switch_t* ba_switch = NULL;
3745
 
        
3746
3803
        /* if we've used this node in another block already */
3747
3804
        if (!ba_node || ba_node->used) {
3748
 
                debug3("node %c%c%c used", 
 
3805
                debug4("node %c%c%c used", 
3749
3806
                       alpha_num[ba_node->coord[X]],
3750
3807
                       alpha_num[ba_node->coord[Y]],
3751
3808
                       alpha_num[ba_node->coord[Z]]);
3767
3824
                   other they must be connected to the other ports.
3768
3825
                */
3769
3826
                if(ba_switch->int_wire[3].used && ba_switch->int_wire[5].used) {
3770
 
                        debug3("switch full in the X dim on node %c%c%c!",
 
3827
                        debug4("switch full in the X dim on node %c%c%c!",
3771
3828
                               alpha_num[ba_node->coord[X]],
3772
3829
                               alpha_num[ba_node->coord[Y]],
3773
3830
                               alpha_num[ba_node->coord[Z]]);
3774
3831
                        return true;
3775
3832
                }
3776
3833
        }
3777
 
                
 
3834
        
3778
3835
        return false;
3779
3836
 
3780
3837
}
3952
4009
                               _port_enum(from_port),
3953
4010
                               _port_enum(to_port));    
3954
4011
                
3955
 
                debug2("dim %d from %c%c%c %d -> %c%c%c %d",
 
4012
                debug3("dim %d from %c%c%c %d -> %c%c%c %d",
3956
4013
                       dim,
3957
4014
                       alpha_num[source->coord[X]],
3958
4015
                       alpha_num[source->coord[Y]],
3981
4038
 
3982
4039
        /* set up split x */
3983
4040
        if(DIM_SIZE[X] == 1) {
 
4041
        } else if(DIM_SIZE[X] == 4) {
 
4042
                switch(count) {
 
4043
                case 0:
 
4044
                case 3:
 
4045
                        /* 0 and 3rd Node */
 
4046
                        /* nothing */
 
4047
                        break;
 
4048
                case 1:
 
4049
                        /* 1st Node */
 
4050
                        target = &ba_system_ptr->grid[0]
 
4051
                                [source->coord[Y]]
 
4052
                                [source->coord[Z]];
 
4053
                        /* 4->3 of 0th */
 
4054
                        _switch_config(source, target, dim, 4, 3);
 
4055
                        break;  
 
4056
                case 2:
 
4057
                        /* 2nd Node */
 
4058
                        target = &ba_system_ptr->grid[3]
 
4059
                                [source->coord[Y]]
 
4060
                                [source->coord[Z]];
 
4061
                        /* 4->3 of 3rd and back */
 
4062
                        _switch_config(source, target, dim, 4, 3);
 
4063
                        _switch_config(source, target, dim, 3, 4);
 
4064
                        break;
 
4065
                default:
 
4066
                        fatal("got %d for a count on a %d X-dim system",
 
4067
                              count, DIM_SIZE[X]);
 
4068
                        break;
 
4069
                }
3984
4070
        } else if(DIM_SIZE[X] == 5) {
3985
4071
                /* 4 X dim fixes for wires */
3986
4072
                switch(count) {
4076
4162
                              count, DIM_SIZE[X]);
4077
4163
                        break;
4078
4164
                }
 
4165
        } else if(DIM_SIZE[X] == 9) {
 
4166
                switch(count) {
 
4167
                case 0:
 
4168
                case 4:
 
4169
                        /* 0 and 4th Node */
 
4170
                        /* nothing */
 
4171
                case 5:
 
4172
                case 6:
 
4173
                case 7:
 
4174
                        /*already handled below */
 
4175
                        break;
 
4176
                case 1:
 
4177
                        /* 1st Node */
 
4178
                        target = &ba_system_ptr->grid[7]
 
4179
                                [source->coord[Y]]
 
4180
                                [source->coord[Z]];
 
4181
                        /* 4->3 of 7th and back */
 
4182
                        _switch_config(source, target, dim, 4, 3);
 
4183
                        _switch_config(target, source, dim, 4, 3);
 
4184
                        break;  
 
4185
                case 2:
 
4186
                        /* 2nd Node */
 
4187
                        target = &ba_system_ptr->grid[6]
 
4188
                                [source->coord[Y]]
 
4189
                                [source->coord[Z]];
 
4190
                        /* 4->3 of 6th and back */
 
4191
                        _switch_config(source, target, dim, 4, 3);
 
4192
                        _switch_config(target, source, dim, 4, 3);
 
4193
                        break;
 
4194
                case 3:
 
4195
                        /* 3rd Node */
 
4196
                        target = &ba_system_ptr->grid[5]
 
4197
                                [source->coord[Y]]
 
4198
                                [source->coord[Z]];
 
4199
                        /* 4->3 of 5th and back */
 
4200
                        _switch_config(source, target, dim, 4, 3);
 
4201
                        _switch_config(target, source, dim, 4, 3);
 
4202
                        break;
 
4203
                case 8:
 
4204
                        /* 8th Node */
 
4205
                        target = &ba_system_ptr->grid[0]
 
4206
                                [source->coord[Y]]
 
4207
                                [source->coord[Z]];
 
4208
                        /* 4->3 of 0th */
 
4209
                        _switch_config(source, target, dim, 4, 3);      
 
4210
                        break;
 
4211
                default:
 
4212
                        fatal("got %d for a count on a %d X-dim system",
 
4213
                              count, DIM_SIZE[X]);
 
4214
                        break;
 
4215
                }
4079
4216
        } else if(DIM_SIZE[X] == 13) {
4080
4217
                int temp_num = 0;
4081
4218
 
4099
4236
                case 5:
4100
4237
                        /* get the node count - 1 then subtract it
4101
4238
                         * from 12 to get the new target and then go
4102
 
                         * from 3->4 and back again
 
4239
                         * from 4->3 and back again
4103
4240
                         */
4104
4241
                        temp_num = 12 - (count - 1);
4105
4242
                        if(temp_num < 5) 
4109
4246
                        target = &ba_system_ptr->grid[temp_num]
4110
4247
                                [source->coord[Y]]
4111
4248
                                [source->coord[Z]];
4112
 
                        /* 3->4 */
4113
 
                        _switch_config(source, target, dim, 3, 4);
4114
 
                        /* and back 3->4 */
4115
 
                        _switch_config(target, source, dim, 3, 4);
 
4249
                        /* 4->3 */
 
4250
                        _switch_config(source, target, dim, 4, 3);
 
4251
                        /* and back 4->3 */
 
4252
                        _switch_config(target, source, dim, 4, 3);
4116
4253
                        break;
4117
4254
                case 7:
4118
4255
                        /* 7th Node */
4167
4304
                         alpha_num[ba_node[count]->coord[X]],
4168
4305
                         alpha_num[ba_node[count]->coord[Y]],
4169
4306
                         alpha_num[ba_node[count]->coord[Z]]);
4170
 
                debug3("name = %s", temp_name);
 
4307
                debug4("name = %s", temp_name);
4171
4308
                count++;
4172
4309
                hostlist_push(hostlist, temp_name);
4173
4310
        }
4184
4321
                        if(ba_node[i]->letter == '.') {
4185
4322
                                ba_node[i]->letter = letters[color_count%62];
4186
4323
                                ba_node[i]->color = colors[color_count%6];
4187
 
                                debug3("count %d setting letter = %c "
 
4324
                                debug4("count %d setting letter = %c "
4188
4325
                                       "color = %d",
4189
4326
                                       color_count,
4190
4327
                                       ba_node[i]->letter,
4281
4418
                return 0;
4282
4419
        }                       
4283
4420
        
4284
 
        debug3("Algo(%d) found - %d", algo, found);
 
4421
        debug4("Algo(%d) found - %d", algo, found);
4285
4422
 
4286
4423
        /* Check the 2 ports we can leave though in ports_to_try */
4287
4424
        for(i=0;i<2;i++) {
4321
4458
                           already been before */
4322
4459
                        itr = list_iterator_create(results);
4323
4460
                        while((next_node = list_next(itr))) {
4324
 
                                debug3("Algo(%d) looking at %c%c%c and %c%c%c",
 
4461
                                debug4("Algo(%d) looking at %c%c%c and %c%c%c",
4325
4462
                                       algo,
4326
4463
                                       alpha_num[next_node->coord[X]],
4327
4464
                                       alpha_num[next_node->coord[Y]],
4338
4475
                        }
4339
4476
                        list_iterator_destroy(itr);
4340
4477
                        if(not_first && found < DIM_SIZE[X]) {
4341
 
                                debug2("Algo(%d) already been there before",
 
4478
                                debug3("Algo(%d) already been there before",
4342
4479
                                       algo);
4343
4480
                                not_first = 0;
4344
4481
                                continue;
4355
4492
                        next_switch = &next_node->axis_switch[X];
4356
4493
 
4357
4494
                        if((conn_type == SELECT_MESH) && (found == (x_size))) {
4358
 
                                debug2("Algo(%d) we found the end of the mesh",
 
4495
                                debug3("Algo(%d) we found the end of the mesh",
4359
4496
                                       algo);
4360
4497
                                return 1;
4361
4498
                        }
4362
 
                        debug3("Algo(%d) Broke = %d Found = %d x_size = %d",
 
4499
                        debug4("Algo(%d) Broke = %d Found = %d x_size = %d",
4363
4500
                               algo, broke, found, x_size);
4364
4501
 
4365
4502
                        if(broke && (found == x_size)) {
4366
4503
                                goto found_path;
4367
4504
                        } else if(found == x_size) {
4368
 
                                debug2("Algo(%d) finishing the torus!", algo);
 
4505
                                debug3("Algo(%d) finishing the torus!", algo);
4369
4506
 
4370
4507
                                if(deny_pass && (*deny_pass & PASS_DENY_X)) {
4371
4508
                                        info("we don't allow passthroughs 1");
4383
4520
                                else
4384
4521
                                        path = list_create(_delete_path_list);
4385
4522
                                
4386
 
                                _finish_torus(curr_switch, 0, X, 0, start);
 
4523
                                _finish_torus(results, 
 
4524
                                              curr_switch, 0, X, 0, start);
4387
4525
 
4388
4526
                                if(best_count < BEST_COUNT_INIT) {
4389
 
                                        debug2("Algo(%d) Found a best path "
 
4527
                                        debug3("Algo(%d) Found a best path "
4390
4528
                                               "with %d steps.",
4391
4529
                                               algo, best_count);
4392
4530
                                        _set_best_path();
4401
4539
 
4402
4540
                        if (!_node_used(next_node, x_size)) {
4403
4541
#ifdef HAVE_BG
4404
 
                                debug2("Algo(%d) found %d looking at %c%c%c "
 
4542
                                debug3("Algo(%d) found %d looking at %c%c%c "
4405
4543
                                       "%d going to %c%c%c %d",
4406
4544
                                       algo,
4407
4545
                                       found,
4427
4565
                                list_iterator_destroy(itr);
4428
4566
                                if(!check_node) {
4429
4567
#ifdef HAVE_BG
4430
 
                                        debug2("Algo(%d) add %c%c%c",
 
4568
                                        debug3("Algo(%d) add %c%c%c",
4431
4569
                                               algo,
4432
4570
                                               alpha_num[next_node->coord[X]],
4433
4571
                                               alpha_num[next_node->coord[Y]],
4436
4574
                                        list_append(results, next_node);
4437
4575
                                } else {
4438
4576
#ifdef HAVE_BG
4439
 
                                        debug2("Algo(%d) Hey this is already "
 
4577
                                        debug3("Algo(%d) Hey this is already "
4440
4578
                                               "added %c%c%c",
4441
4579
                                               algo,
4442
4580
                                               alpha_num[node_tar[X]],
4457
4595
                                } else {
4458
4596
                                found_path:
4459
4597
#ifdef HAVE_BG
4460
 
                                        debug2("Algo(%d) added node %c%c%c "
 
4598
                                        debug3("Algo(%d) added node %c%c%c "
4461
4599
                                               "%d %d -> %c%c%c %d %d",
4462
4600
                                               algo,
4463
4601
                                               alpha_num[ba_node->coord[X]],
4498
4636
        }
4499
4637
 
4500
4638
        if(algo == BLOCK_ALGO_FIRST) {
4501
 
                debug2("Algo(%d) couldn't find path", algo);
 
4639
                debug3("Algo(%d) couldn't find path", algo);
4502
4640
                return 0;
4503
4641
        } else if(algo == BLOCK_ALGO_SECOND) {
4504
4642
#ifdef HAVE_BG
4505
 
                debug2("Algo(%d) looking for the next free node "
 
4643
                debug3("Algo(%d) looking for the next free node "
4506
4644
                       "starting at %c%c%c",
4507
4645
                       algo,
4508
4646
                       alpha_num[ba_node->coord[X]],
4523
4661
                _find_next_free_using_port_2(curr_switch, 0, results, X, 0);
4524
4662
                
4525
4663
                if(best_count < BEST_COUNT_INIT) {
4526
 
                        debug2("Algo(%d) yes found next free %d", algo,
 
4664
                        debug3("Algo(%d) yes found next free %d", algo,
4527
4665
                               best_count);
4528
4666
                        node_tar = _set_best_path();
4529
4667
 
4543
4681
                        next_switch = &next_node->axis_switch[X];
4544
4682
                        
4545
4683
#ifdef HAVE_BG
4546
 
                        debug2("Algo(%d) found %d looking at %c%c%c "
 
4684
                        debug3("Algo(%d) found %d looking at %c%c%c "
4547
4685
                               "going to %c%c%c %d",
4548
4686
                               algo, found,
4549
4687
                               alpha_num[ba_node->coord[X]],
4564
4702
                                found--;
4565
4703
                                _reset_the_path(curr_switch, 0, 1, X);
4566
4704
                                _remove_node(results, next_node->coord);
4567
 
                                debug2("Algo(%d) couldn't finish "
 
4705
                                debug3("Algo(%d) couldn't finish "
4568
4706
                                       "the path off this one", algo);
4569
4707
                        }
4570
4708
                } 
4571
4709
                
4572
 
                debug2("Algo(%d) couldn't find path", algo);
 
4710
                debug3("Algo(%d) couldn't find path", algo);
4573
4711
                return 0;
4574
4712
        }
4575
4713
 
4590
4728
                if(node_tar[X] == ba_node->coord[X] 
4591
4729
                   && node_tar[Y] == ba_node->coord[Y] 
4592
4730
                   && node_tar[Z] == ba_node->coord[Z]) {
4593
 
                        debug2("removing %c%c%c from list",
 
4731
                        debug3("removing %c%c%c from list",
4594
4732
                               alpha_num[node_tar[X]],
4595
4733
                               alpha_num[node_tar[Y]],
4596
4734
                               alpha_num[node_tar[Z]]);
4599
4737
                }
4600
4738
#else
4601
4739
                if(node_tar[X] == ba_node->coord[X]) {
4602
 
                        debug2("removing %d from list",
 
4740
                        debug3("removing %d from list",
4603
4741
                               node_tar[X]);
4604
4742
                        list_remove (itr);
4605
4743
                        break;
4669
4807
           .used) {
4670
4808
                
4671
4809
#ifdef HAVE_BG
4672
 
                debug2("this one not found %c%c%c",
 
4810
                debug3("this one not found %c%c%c",
4673
4811
                       alpha_num[node_tar[X]],
4674
4812
                       alpha_num[node_tar[Y]],
4675
4813
                       alpha_num[node_tar[Z]]);
4730
4868
                }
4731
4869
                list_iterator_destroy(itr);
4732
4870
                        
 
4871
                /* check to see if wire 0 is used with this port */
4733
4872
                if(curr_switch->
4734
4873
                   ext_wire[port_to_try].node_tar[X]
4735
4874
                   == curr_switch->ext_wire[0].node_tar[X]  
4767
4906
                                        dim, count);
4768
4907
                        while((temp_switch = list_pop(path)) != path_add){
4769
4908
                                xfree(temp_switch);
4770
 
                                debug3("something here 1");
 
4909
                                debug4("something here 1");
4771
4910
                        }
4772
4911
                }
4773
4912
        }
4793
4932
 * to apply this path to the main system (ba_system_ptr)
4794
4933
 */
4795
4934
 
4796
 
static int _finish_torus(ba_switch_t *curr_switch, int source_port,
 
4935
static int _finish_torus(List results, 
 
4936
                         ba_switch_t *curr_switch, int source_port,
4797
4937
                         int dim, int count, int *start)
4798
4938
{
4799
4939
        ba_switch_t *next_switch = NULL;
4890
5030
                                }
4891
5031
                        }
4892
5032
                        list_iterator_destroy(itr);
 
5033
 
 
5034
                        /* check to see if wire 0 is used with this port */
4893
5035
                        if((curr_switch->
4894
5036
                            ext_wire[ports_to_try[i]].node_tar[X] ==
4895
5037
                            curr_switch->ext_wire[0].node_tar[X] &&
4901
5043
                            curr_switch->ext_wire[0].node_tar[Z])) {
4902
5044
                                continue;
4903
5045
                        }
 
5046
 
 
5047
 
4904
5048
                        if(!used) {
 
5049
                                ba_node_t *next_node = NULL;
4905
5050
                                port_tar = curr_switch->
4906
5051
                                        ext_wire[ports_to_try[i]].port_tar;
4907
5052
                                node_tar = curr_switch->
4908
5053
                                        ext_wire[ports_to_try[i]].node_tar;
4909
 
                                
 
5054
 
 
5055
                                /* Check to see if I am going to a place I have
 
5056
                                   already been before, because even
 
5057
                                   though we may be able to do this
 
5058
                                   electrically this doesn't mean the
 
5059
                                   under lying infrastructure will
 
5060
                                   allow it. */
 
5061
                                itr = list_iterator_create(results);
 
5062
                                while((next_node = list_next(itr))) {
 
5063
                                        debug4("finishing_torus: "
 
5064
                                               "looking at %c%c%c and %c%c%c",
 
5065
                                               alpha_num[next_node->coord[X]],
 
5066
                                               alpha_num[next_node->coord[Y]],
 
5067
                                               alpha_num[next_node->coord[Z]],
 
5068
                                               alpha_num[node_tar[X]],
 
5069
                                               alpha_num[node_tar[Y]],
 
5070
                                               alpha_num[node_tar[Z]]);
 
5071
                                        if((node_tar[X] == next_node->coord[X]) 
 
5072
                                           && (node_tar[Y] 
 
5073
                                               == next_node->coord[Y])
 
5074
                                           && (node_tar[Z] 
 
5075
                                               == next_node->coord[Z])) {
 
5076
                                                break;
 
5077
                                        }                               
 
5078
                                }
 
5079
                                list_iterator_destroy(itr);
 
5080
                                if(next_node) {
 
5081
                                        debug3("finishing_torus: "
 
5082
                                               "Can't finish torus with "
 
5083
                                               "%c%c%c we already were there.",
 
5084
                                               alpha_num[next_node->coord[X]],
 
5085
                                               alpha_num[next_node->coord[Y]],
 
5086
                                               alpha_num[next_node->coord[Z]]);
 
5087
                                        continue;
 
5088
                                }
 
5089
 
4910
5090
                                next_switch = &ba_system_ptr->grid[node_tar[X]]
4911
5091
#ifdef HAVE_3D
4912
5092
                                        [node_tar[Y]]
4918
5098
                                count++;
4919
5099
                                path_add->out = ports_to_try[i];
4920
5100
                                list_push(path, path_add);
4921
 
                                _finish_torus(next_switch, port_tar, 
 
5101
                                _finish_torus(results, next_switch, port_tar, 
4922
5102
                                              dim, count, start);
4923
5103
                                while((temp_switch = list_pop(path))
4924
5104
                                      != path_add){
4925
5105
                                        xfree(temp_switch);
4926
 
                                        debug3("something here 3");
 
5106
                                        debug4("something here 3");
4927
5107
                                }
4928
5108
                        }
4929
5109
                }
4955
5135
                        debug2("got a passthrough in X");
4956
5136
                }
4957
5137
#ifdef HAVE_3D
4958
 
                debug3("mapping %c%c%c %d->%d",
 
5138
                debug4("mapping %c%c%c %d->%d",
4959
5139
                       alpha_num[path_switch->geometry[X]],
4960
5140
                       alpha_num[path_switch->geometry[Y]],
4961
5141
                       alpha_num[path_switch->geometry[Z]],
5016
5196
        int *geo_ptr = (int *)object;
5017
5197
        xfree(geo_ptr);
5018
5198
}
5019
 
 
5020
 
//#define BUILD_EXE
5021
 
#ifdef BUILD_EXE
5022
 
/** */
5023
 
int main(int argc, char** argv)
5024
 
{
5025
 
        ba_request_t *request = (ba_request_t*) xmalloc(sizeof(ba_request_t)); 
5026
 
        log_options_t log_opts = LOG_OPTS_INITIALIZER;
5027
 
        int debug_level = 6;
5028
 
        node_info_msg_t *new_node_ptr = NULL;
5029
 
 
5030
 
        List results;
5031
 
//      List results2;
5032
 
//      int i,j;
5033
 
        log_opts.stderr_level  = debug_level;
5034
 
        log_opts.logfile_level = debug_level;
5035
 
        log_opts.syslog_level  = debug_level;
5036
 
        
5037
 
        log_alter(log_opts, LOG_DAEMON, 
5038
 
                  "/dev/null");
5039
 
        
5040
 
        DIM_SIZE[X]=0;
5041
 
        DIM_SIZE[Y]=0;
5042
 
        DIM_SIZE[Z]=0;
5043
 
        while (slurm_load_node((time_t) NULL, &new_node_ptr, SHOW_ALL)) { 
5044
 
                
5045
 
                sleep(10);      /* keep trying to reconnect */
5046
 
        }
5047
 
        
5048
 
        ba_init(new_node_ptr);
5049
 
        init_wires(NULL);
5050
 
                                                
5051
 
        results = list_create(NULL);
5052
 
        request->geometry[0] = 1;
5053
 
        request->geometry[1] = 1;
5054
 
        request->geometry[2] = 1;
5055
 
        request->start[0] = 6;
5056
 
        request->start[1] = 3;
5057
 
        request->start[2] = 2;
5058
 
        request->start_req = 1;
5059
 
//      request->size = 1;
5060
 
        request->rotate = 0;
5061
 
        request->elongate = 0;
5062
 
        request->conn_type = SELECT_TORUS;
5063
 
        new_ba_request(request);
5064
 
        print_ba_request(request);
5065
 
        if(!allocate_block(request, results)) {
5066
 
                debug("couldn't allocate %c%c%c",
5067
 
                       request->geometry[0],
5068
 
                       request->geometry[1],
5069
 
                       request->geometry[2]);
5070
 
        }
5071
 
        list_destroy(results);
5072
 
 
5073
 
        results = list_create(NULL);
5074
 
        request->geometry[0] = 2;
5075
 
        request->geometry[1] = 4;
5076
 
        request->geometry[2] = 1;
5077
 
        request->start[0] = 3;
5078
 
        request->start[1] = 0;
5079
 
        request->start[2] = 2;
5080
 
        request->start_req = 1;
5081
 
//      request->size = 16;
5082
 
        request->rotate = 0;
5083
 
        request->elongate = 0;
5084
 
        request->conn_type = SELECT_TORUS;
5085
 
        new_ba_request(request);
5086
 
        print_ba_request(request);
5087
 
        if(!allocate_block(request, results)) {
5088
 
                debug("couldn't allocate %c%c%c",
5089
 
                       alpha_num[request->geometry[0]],
5090
 
                       alpha_num[request->geometry[1]],
5091
 
                       alpha_num[request->geometry[2]]);
5092
 
        }
5093
 
        list_destroy(results);
5094
 
 
5095
 
        results = list_create(NULL);
5096
 
        request->geometry[0] = 2;
5097
 
        request->geometry[1] = 1;
5098
 
        request->geometry[2] = 4;
5099
 
        request->start[0] = 5;
5100
 
        request->start[1] = 2;
5101
 
        request->start[2] = 0;
5102
 
        request->start_req = 1;
5103
 
        request->rotate = 0;
5104
 
        request->elongate = 0;
5105
 
        request->conn_type = SELECT_TORUS;
5106
 
        new_ba_request(request);
5107
 
        print_ba_request(request);
5108
 
        if(!allocate_block(request, results)) {
5109
 
                debug("couldn't allocate %c%c%c",
5110
 
                       alpha_num[request->geometry[0]],
5111
 
                       alpha_num[request->geometry[1]],
5112
 
                       alpha_num[request->geometry[2]]);
5113
 
        }
5114
 
        list_destroy(results);
5115
 
        
5116
 
/*      results = list_create(NULL); */
5117
 
/*      request->geometry[0] = 4; */
5118
 
/*      request->geometry[1] = 4; */
5119
 
/*      request->geometry[2] = 4; */
5120
 
/*      //request->size = 2; */
5121
 
/*      request->conn_type = SELECT_TORUS; */
5122
 
/*      new_ba_request(request); */
5123
 
/*      print_ba_request(request); */
5124
 
/*      if(!allocate_block(request, results)) { */
5125
 
/*                      printf("couldn't allocate %c%c%c\n", */
5126
 
/*                     request->geometry[0], */
5127
 
/*                     request->geometry[1], */
5128
 
/*                     request->geometry[2]); */
5129
 
/*      } */
5130
 
 
5131
 
/*      results = list_create(NULL); */
5132
 
/*      request->geometry[0] = 1; */
5133
 
/*      request->geometry[1] = 4; */
5134
 
/*      request->geometry[2] = 4; */
5135
 
/*      //request->size = 2; */
5136
 
/*      request->conn_type = SELECT_TORUS; */
5137
 
/*      new_ba_request(request); */
5138
 
/*      print_ba_request(request); */
5139
 
/*      if(!allocate_block(request, results)) { */
5140
 
/*                      printf("couldn't allocate %c%c%c\n", */
5141
 
/*                     request->geometry[0], */
5142
 
/*                     request->geometry[1], */
5143
 
/*                     request->geometry[2]); */
5144
 
/*      } */
5145
 
        
5146
 
        int dim,j;
5147
 
        int x,y,z;
5148
 
        int startx=0;
5149
 
        int starty=0;
5150
 
        int startz=0;
5151
 
        int endx=DIM_SIZE[X];
5152
 
        int endy=1;//DIM_SIZE[Y];
5153
 
        int endz=1;//DIM_SIZE[Z];
5154
 
 
5155
 
        for(x=startx;x<endx;x++) {
5156
 
                for(y=starty;y<endy;y++) {
5157
 
                        for(z=startz;z<endz;z++) {
5158
 
                                ba_node_t *curr_node = 
5159
 
                                        &(ba_system_ptr->grid[x][y][z]);
5160
 
                                info("Node %c%c%c Used = %d Letter = %c",
5161
 
                                     alpha_num[x],alpha_num[y],alpha_num[z],
5162
 
                                     curr_node->used,
5163
 
                                     curr_node->letter);
5164
 
                                for(dim=0;dim<1;dim++) {
5165
 
                                        info("Dim %d",dim);
5166
 
                                        ba_switch_t *wire =
5167
 
                                                &curr_node->axis_switch[dim];
5168
 
                                        for(j=0;j<NUM_PORTS_PER_NODE;j++)
5169
 
                                                info("\t%d -> %d -> %c%c%c %d "
5170
 
                                                     "Used = %d",
5171
 
                                                     j, wire->int_wire[j].
5172
 
                                                     port_tar,
5173
 
                                                     alpha_num[wire->ext_wire[
5174
 
                                                             wire->int_wire[j].
5175
 
                                                             port_tar].
5176
 
                                                               node_tar[X]],
5177
 
                                                     alpha_num[wire->ext_wire[
5178
 
                                                             wire->int_wire[j].
5179
 
                                                             port_tar].
5180
 
                                                     node_tar[Y]],
5181
 
                                                     alpha_num[wire->ext_wire[
5182
 
                                                             wire->int_wire[j].
5183
 
                                                             port_tar].
5184
 
                                                     node_tar[Z]],
5185
 
                                                     wire->ext_wire[
5186
 
                                                             wire->int_wire[j].
5187
 
                                                             port_tar].
5188
 
                                                     port_tar,
5189
 
                                                     wire->int_wire[j].used);
5190
 
                                }
5191
 
                        }
5192
 
                }
5193
 
        }
5194
 
        /* list_destroy(results); */
5195
 
 
5196
 
/*      ba_fini(); */
5197
 
 
5198
 
/*      delete_ba_request(request); */
5199
 
        
5200
 
        return 0;
5201
 
}
5202
 
 
5203
 
 
5204
 
#endif