~ubuntu-branches/ubuntu/saucy/slurm-llnl/saucy

« back to all changes in this revision

Viewing changes to src/plugins/select/bluegene/plugin/bg_record_functions.c

  • Committer: Bazaar Package Importer
  • Author(s): Gennaro Oliva
  • Date: 2008-12-03 11:56:28 UTC
  • mfrom: (1.1.8 upstream) (3.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20081203115628-93t417da6wkazmo5
Tags: 1.3.11-1
New upstream release 

Show diffs side-by-side

added added

removed removed

Lines of Context:
100
100
                FREE_NULL_BITMAP(bg_record->bitmap);
101
101
                FREE_NULL_BITMAP(bg_record->ionode_bitmap);
102
102
 
 
103
#ifdef HAVE_BGL
103
104
                xfree(bg_record->blrtsimage);
 
105
#endif
104
106
                xfree(bg_record->linuximage);
105
107
                xfree(bg_record->mloaderimage);
106
108
                xfree(bg_record->ramdiskimage);
363
365
        xfree(sec_record->target_name);
364
366
        sec_record->target_name = xstrdup(fir_record->target_name);
365
367
 
 
368
#ifdef HAVE_BGL
366
369
        xfree(sec_record->blrtsimage);
367
370
        sec_record->blrtsimage = xstrdup(fir_record->blrtsimage);
 
371
#endif
368
372
        xfree(sec_record->linuximage);
369
373
        sec_record->linuximage = xstrdup(fir_record->linuximage);
370
374
        xfree(sec_record->mloaderimage);
375
379
        sec_record->user_uid = fir_record->user_uid;
376
380
        sec_record->state = fir_record->state;
377
381
        sec_record->conn_type = fir_record->conn_type;
 
382
#ifdef HAVE_BGL
378
383
        sec_record->node_use = fir_record->node_use;
 
384
#endif
379
385
        sec_record->bp_count = fir_record->bp_count;
380
386
        sec_record->switch_count = fir_record->switch_count;
381
387
        sec_record->boot_state = fir_record->boot_state;
408
414
                itr = list_iterator_create(fir_record->bg_block_list);
409
415
                while((ba_node = list_next(itr))) {
410
416
                        new_ba_node = ba_copy_node(ba_node);
411
 
                        list_push(sec_record->bg_block_list, new_ba_node);
 
417
                        list_append(sec_record->bg_block_list, new_ba_node);
412
418
                }
413
419
                list_iterator_destroy(itr);
414
420
        }
416
422
        sec_record->job_ptr = fir_record->job_ptr;
417
423
        sec_record->cpus_per_bp = fir_record->cpus_per_bp;
418
424
        sec_record->node_cnt = fir_record->node_cnt;
 
425
#ifdef HAVE_BGL
419
426
        sec_record->quarter = fir_record->quarter;
420
427
        sec_record->nodecard = fir_record->nodecard;
 
428
#endif
 
429
}
 
430
 
 
431
/* 
 
432
 * Comparator used for sorting blocks smallest to largest
 
433
 * 
 
434
 * returns: -1: rec_a >rec_b   0: rec_a == rec_b   1: rec_a < rec_b
 
435
 * 
 
436
 */
 
437
extern int bg_record_cmpf_inc(bg_record_t* rec_a, bg_record_t* rec_b)
 
438
{
 
439
        int size_a = rec_a->node_cnt;
 
440
        int size_b = rec_b->node_cnt;
 
441
        if (size_a < size_b)
 
442
                return -1;
 
443
        else if (size_a > size_b)
 
444
                return 1;
 
445
        if(rec_a->nodes && rec_b->nodes) {
 
446
                size_a = strcmp(rec_a->nodes, rec_b->nodes);
 
447
                if (size_a < 0)
 
448
                        return -1;
 
449
                else if (size_a > 0)
 
450
                        return 1;
 
451
        }
 
452
#ifdef HAVE_BGL
 
453
        if (rec_a->quarter < rec_b->quarter)
 
454
                return -1;
 
455
        else if (rec_a->quarter > rec_b->quarter)
 
456
                return 1;
 
457
 
 
458
        if(rec_a->nodecard < rec_b->nodecard)
 
459
                return -1;
 
460
        else if(rec_a->nodecard > rec_b->nodecard)
 
461
                return 1;
 
462
#else
 
463
        if(bit_ffs(rec_a->ionode_bitmap) < bit_ffs(rec_b->ionode_bitmap))
 
464
                return -1;
 
465
        else
 
466
                return 1;
 
467
#endif
 
468
        return 0;
421
469
}
422
470
 
423
471
extern bg_record_t *find_bg_record_in_list(List my_list, char *bg_block_id)
463
511
        }
464
512
        if(!bg_record->user_name) {
465
513
                error("No user_name");
466
 
                bg_record->user_name = xstrdup(slurmctld_conf.slurm_user_name);
 
514
                bg_record->user_name = xstrdup(bg_slurm_user_name);
467
515
        }
468
516
#ifdef HAVE_BG_FILES
469
517
        int rc=0;       
477
525
                        return -1;
478
526
                } else if (rc == REMOVE_USER_NONE) {
479
527
                        if (strcmp(bg_record->target_name, 
480
 
                                   slurmctld_conf.slurm_user_name)) {
 
528
                                   bg_slurm_user_name)) {
481
529
                                info("Adding user %s to Block %s",
482
530
                                     bg_record->target_name, 
483
531
                                     bg_record->bg_block_id);
571
619
        return;
572
620
}
573
621
 
 
622
#ifdef HAVE_BGL
 
623
 
574
624
extern int set_ionodes(bg_record_t *bg_record)
575
625
{
576
626
        int i = 0;
610
660
 
611
661
        return SLURM_SUCCESS;
612
662
}
 
663
#endif
613
664
 
614
665
extern int add_bg_record(List records, List used_nodes, blockreq_t *blockreq)
615
666
{
616
667
        bg_record_t *bg_record = NULL;
617
 
        bg_record_t *found_record = NULL;
618
668
        ba_node_t *ba_node = NULL;
619
669
        ListIterator itr;
620
670
        uid_t pw_uid;
621
671
        int i, len;
622
 
        int small_size = 0;
623
672
        int small_count = 0;
 
673
#ifdef HAVE_BGL
 
674
        int node_cnt = 0;
624
675
        uint16_t quarter = 0;
625
676
        uint16_t nodecard = 0;
626
 
        int node_cnt = 0;
627
 
        
 
677
        int small_size = 0;
 
678
        bg_record_t *found_record = NULL;
 
679
#endif
628
680
        if(!records) {
629
681
                fatal("add_bg_record: no records list given");
630
682
        }
631
683
        bg_record = (bg_record_t*) xmalloc(sizeof(bg_record_t));
632
684
        
633
 
        slurm_conf_lock();
 
685
        
634
686
        bg_record->user_name = 
635
 
                xstrdup(slurmctld_conf.slurm_user_name);
 
687
                xstrdup(bg_slurm_user_name);
636
688
        bg_record->target_name = 
637
 
                xstrdup(slurmctld_conf.slurm_user_name);
638
 
        slurm_conf_unlock();
 
689
                xstrdup(bg_slurm_user_name);
 
690
        
639
691
        pw_uid = uid_from_string(bg_record->user_name);
640
692
        if(pw_uid == (uid_t) -1) {
641
693
                error("No such user: %s", bg_record->user_name);
650
702
                        error("couldn't copy the path for the allocation");
651
703
                bg_record->bp_count = list_count(used_nodes);
652
704
        }
 
705
        /* bg_record->boot_state = 0;   Implicit */
 
706
        /* bg_record->state = 0;        Implicit */
 
707
#ifdef HAVE_BGL
653
708
        bg_record->quarter = (uint16_t)NO_VAL;
654
709
        bg_record->nodecard = (uint16_t)NO_VAL;
655
 
        if(set_ionodes(bg_record) == SLURM_ERROR) {
656
 
                fatal("add_bg_record: problem creating ionodes");
657
 
        }
658
 
        /* bg_record->boot_state = 0;   Implicit */
659
 
        /* bg_record->state = 0;        Implicit */
660
710
        debug2("asking for %s %d %d %s", 
661
 
               blockreq->block, blockreq->quarters, blockreq->nodecards,
662
 
               convert_conn_type(blockreq->conn_type));
 
711
               blockreq->block, blockreq->small128, blockreq->small32,
 
712
               convert_conn_type(blockreq->conn_type));
 
713
#else
 
714
        debug2("asking for %s %d %d %d %d %d %s", 
 
715
               blockreq->block, blockreq->small256, 
 
716
               blockreq->small128, blockreq->small64,
 
717
               blockreq->small32, blockreq->small16, 
 
718
               convert_conn_type(blockreq->conn_type));
 
719
#endif
 
720
        /* Set the bitmap blank here if it is a full node we don't
 
721
           want anything set we also don't want the bg_record->ionodes set.
 
722
        */
 
723
        bg_record->ionode_bitmap = bit_alloc(bluegene_numpsets);
 
724
 
663
725
        len = strlen(blockreq->block);
664
726
        i=0;
665
727
        while(i<len 
670
732
        
671
733
        if(i<len) {
672
734
                len -= i;
673
 
                slurm_conf_lock();
674
 
                len += strlen(slurmctld_conf.node_prefix)+1;
 
735
                
 
736
                len += strlen(bg_slurm_node_prefix)+1;
675
737
                bg_record->nodes = xmalloc(len);
676
738
                snprintf(bg_record->nodes, len, "%s%s", 
677
 
                        slurmctld_conf.node_prefix, blockreq->block+i);
678
 
                slurm_conf_unlock();
679
 
                        
 
739
                        bg_slurm_node_prefix, blockreq->block+i);
680
740
        } else 
681
741
                fatal("BPs=%s is in a weird format", blockreq->block); 
682
742
        
683
743
        process_nodes(bg_record, false);
684
744
        
 
745
#ifdef HAVE_BGL
685
746
        bg_record->node_use = SELECT_COPROCESSOR_MODE;
 
747
#endif
686
748
        bg_record->conn_type = blockreq->conn_type;
687
749
        bg_record->cpus_per_bp = procs_per_node;
688
750
        bg_record->node_cnt = bluegene_bp_node_cnt * bg_record->bp_count;
689
751
        bg_record->job_running = NO_JOB_RUNNING;
690
752
 
 
753
#ifdef HAVE_BGL
691
754
        if(blockreq->blrtsimage)
692
755
                bg_record->blrtsimage = xstrdup(blockreq->blrtsimage);
693
756
        else
694
757
                bg_record->blrtsimage = xstrdup(default_blrtsimage);
695
 
 
 
758
#endif
696
759
        if(blockreq->linuximage)
697
760
                bg_record->linuximage = xstrdup(blockreq->linuximage);
698
761
        else
722
785
                }
723
786
        } else {
724
787
                debug("adding a small block");
725
 
                /* if the ionode cnt for nodecards is 0 then don't
 
788
#ifdef HAVE_BGL // remove this clause when other works.  Only here to
 
789
                // perserve old code 
 
790
 
 
791
                /* if the ionode cnt for small32 is 0 then don't
726
792
                   allow a nodecard allocation 
727
793
                */
728
794
                if(!bluegene_nodecard_ionode_cnt) {
729
 
                        if(blockreq->nodecards) 
 
795
                        if(blockreq->small32) 
730
796
                                fatal("There is an error in your "
731
797
                                      "bluegene.conf file.\n"
732
798
                                      "Can't create a 32 node block with "
734
800
                                      bluegene_numpsets);
735
801
                }
736
802
 
737
 
                if(blockreq->nodecards==0 && blockreq->quarters==0) {
 
803
                if(blockreq->small32==0 && blockreq->small128==0) {
738
804
                        info("No specs given for this small block, "
739
 
                             "I am spliting this block into 4 quarters");
740
 
                        blockreq->quarters=4;
 
805
                             "I am spliting this block into 4 128CnBlocks");
 
806
                        blockreq->small128=4;
741
807
                }               
742
808
 
743
 
                i = (blockreq->nodecards*bluegene_nodecard_node_cnt) + 
744
 
                        (blockreq->quarters*bluegene_quarter_node_cnt);
 
809
                i = (blockreq->small32*bluegene_nodecard_node_cnt) + 
 
810
                        (blockreq->small128*bluegene_quarter_node_cnt);
745
811
                if(i != bluegene_bp_node_cnt)
746
812
                        fatal("There is an error in your bluegene.conf file.\n"
747
813
                              "I am unable to request %d nodes consisting of "
748
 
                              "%u nodecards and\n%u quarters in one "
 
814
                              "%u 32CnBlocks and\n%u 128CnBlocks in one "
749
815
                              "base partition with %u nodes.", 
750
816
                              i, bluegene_bp_node_cnt, 
751
 
                              blockreq->nodecards, blockreq->quarters);
752
 
                small_count = blockreq->nodecards+blockreq->quarters; 
753
 
                
 
817
                              blockreq->small32, blockreq->small128);
 
818
                small_count = blockreq->small32+blockreq->small128; 
754
819
                /* Automatically create 4-way split if 
755
820
                 * conn_type == SELECT_SMALL in bluegene.conf
756
821
                 * Here we go through each node listed and do the same thing
759
824
                itr = list_iterator_create(bg_record->bg_block_list);
760
825
                while ((ba_node = list_next(itr)) != NULL) {
761
826
                        /* break base partition up into 16 parts */
762
 
                        small_size = 16;
 
827
                        small_size = bluegene_bp_nodecard_cnt;
763
828
                        node_cnt = 0;
764
829
                        quarter = 0;
765
830
                        nodecard = 0;
766
831
                        for(i=0; i<small_count; i++) {
767
 
                                if(i == blockreq->nodecards) {
 
832
                                if(i == blockreq->small32) {
768
833
                                        /* break base partition 
769
834
                                           up into 4 parts */
770
835
                                        small_size = 4;
791
856
                }
792
857
                list_iterator_destroy(itr);
793
858
                destroy_bg_record(bg_record);
 
859
#else // remove this when testing.  Only here to perserve old code the
 
860
      // code below is already for bgl
 
861
                /* if the ionode cnt for small32 is 0 then don't
 
862
                   allow a sub quarter allocation 
 
863
                */
 
864
                if(bluegene_nodecard_ionode_cnt < 2) {
 
865
                        if(!bluegene_nodecard_ionode_cnt && blockreq->small32) 
 
866
                                fatal("There is an error in your "
 
867
                                      "bluegene.conf file.\n"
 
868
                                      "Can't create a 32 node block with "
 
869
                                      "Numpsets=%u. (Try setting it "
 
870
                                      "to at least 16)",
 
871
                                      bluegene_numpsets);
 
872
#ifndef HAVE_BGL
 
873
                        if(blockreq->small16) 
 
874
                                fatal("There is an error in your "
 
875
                                      "bluegene.conf file.\n"
 
876
                                      "Can't create a 16 node block with "
 
877
                                      "Numpsets=%u. (Try setting it to "
 
878
                                      "at least 32)",
 
879
                                      bluegene_numpsets);
 
880
                        if((bluegene_io_ratio < 0.5) && blockreq->small64) 
 
881
                                fatal("There is an error in your "
 
882
                                      "bluegene.conf file.\n"
 
883
                                      "Can't create a 64 node block with "
 
884
                                      "Numpsets=%u. (Try setting it "
 
885
                                      "to at least 8)",
 
886
                                      bluegene_numpsets);
 
887
#endif
 
888
                }
 
889
 
 
890
#ifdef HAVE_BGL
 
891
                if(blockreq->small32==0 && blockreq->small128==0) {
 
892
                        info("No specs given for this small block, "
 
893
                             "I am spliting this block into 4 128CnBlocks");
 
894
                        blockreq->small128=4;
 
895
                }               
 
896
 
 
897
                i = (blockreq->small32*bluegene_nodecard_node_cnt) + 
 
898
                        (blockreq->small128*bluegene_quarter_node_cnt);
 
899
                if(i != bluegene_bp_node_cnt)
 
900
                        fatal("There is an error in your bluegene.conf file.\n"
 
901
                              "I am unable to request %d nodes consisting of "
 
902
                              "%u 32CnBlocks and\n%u 128CnBlocks in one "
 
903
                              "base partition with %u nodes.", 
 
904
                              i, blockreq->small32, blockreq->small128,
 
905
                              bluegene_bp_node_cnt);
 
906
                small_count = blockreq->small32+blockreq->small128; 
 
907
#else
 
908
                if(!blockreq->small16 && !blockreq->small32 
 
909
                   && !blockreq->small64 && !blockreq->small128 
 
910
                   && !blockreq->small256) {
 
911
                        info("No specs given for this small block, "
 
912
                             "I am spliting this block into 2 256CnBlocks");
 
913
                        blockreq->small256=2;
 
914
                }               
 
915
 
 
916
                i = (blockreq->small16*16) 
 
917
                        + (blockreq->small32*32) 
 
918
                        + (blockreq->small64*64) 
 
919
                        + (blockreq->small128*128)
 
920
                        + (blockreq->small256*256);
 
921
                if(i != bluegene_bp_node_cnt)
 
922
                        fatal("There is an error in your bluegene.conf file.\n"
 
923
                              "I am unable to request %d nodes consisting of "
 
924
                              "%u 16CNBlocks, %u 32CNBlocks,\n"
 
925
                              "%u 64CNBlocks, %u 128CNBlocks, "
 
926
                              "and %u 256CNBlocks\n"
 
927
                              "in one base partition with %u nodes.", 
 
928
                              i, blockreq->small16, blockreq->small32, 
 
929
                              blockreq->small64, blockreq->small128, 
 
930
                              blockreq->small256, bluegene_bp_node_cnt);
 
931
                small_count = blockreq->small16
 
932
                        + blockreq->small32
 
933
                        + blockreq->small64
 
934
                        + blockreq->small128
 
935
                        + blockreq->small256; 
 
936
#endif
 
937
                /* Automatically create 2-way split if 
 
938
                 * conn_type == SELECT_SMALL in bluegene.conf
 
939
                 * Here we go through each node listed and do the same thing
 
940
                 * for each node.
 
941
                 */
 
942
                itr = list_iterator_create(bg_record->bg_block_list);
 
943
                while ((ba_node = list_next(itr)) != NULL) {
 
944
                        handle_small_record_request(records, blockreq,
 
945
                                                    bg_record, 0);
 
946
                }
 
947
                list_iterator_destroy(itr);
 
948
                destroy_bg_record(bg_record);
 
949
#endif // remove this when done testing
794
950
        } 
795
 
        return SLURM_SUCCESS;
796
 
}
 
951
        
 
952
        return SLURM_SUCCESS;
 
953
}
 
954
 
 
955
#ifndef HAVE_BGL
 
956
extern int handle_small_record_request(List records, blockreq_t *blockreq,
 
957
                                       bg_record_t *bg_record, bitoff_t start)
 
958
{
 
959
        bitstr_t *ionodes = bit_alloc(bluegene_numpsets);
 
960
        int i=0, ionode_cnt = 0;
 
961
        bg_record_t *found_record = NULL;
 
962
 
 
963
        xassert(records);
 
964
        xassert(blockreq);
 
965
        xassert(bg_record);
 
966
 
 
967
#ifndef HAVE_BGL
 
968
        for(i=0; i<blockreq->small16; i++) {
 
969
                bit_nset(ionodes, start, start);
 
970
                found_record = create_small_record(bg_record, ionodes, 16);
 
971
                /* this needs to be an append so we
 
972
                   keep things in the order we got
 
973
                   them, they will be sorted later */
 
974
                list_append(records, found_record);
 
975
                bit_nclear(ionodes, start, start);
 
976
                start++;
 
977
        }
 
978
#endif
 
979
        if((ionode_cnt = bluegene_nodecard_ionode_cnt))
 
980
                ionode_cnt--;
 
981
        for(i=0; i<blockreq->small32; i++) {
 
982
                bit_nset(ionodes, start, start+ionode_cnt);
 
983
                found_record = create_small_record(bg_record, ionodes, 32);
 
984
                /* this needs to be an append so we
 
985
                   keep things in the order we got
 
986
                   them, they will be sorted later */
 
987
                list_append(records, found_record);
 
988
                bit_nclear(ionodes, start, start+ionode_cnt);
 
989
                start+=ionode_cnt+1;
 
990
        }
 
991
        
 
992
#ifndef HAVE_BGL
 
993
        if((ionode_cnt = bluegene_nodecard_ionode_cnt * 2))
 
994
                ionode_cnt--;
 
995
        for(i=0; i<blockreq->small64; i++) {
 
996
                bit_nset(ionodes, start, start+ionode_cnt);
 
997
                found_record = create_small_record(bg_record, ionodes, 64);
 
998
                /* this needs to be an append so we
 
999
                   keep things in the order we got
 
1000
                   them, they will be sorted later */
 
1001
                list_append(records, found_record);
 
1002
                bit_nclear(ionodes, start, start+ionode_cnt);
 
1003
                start+=ionode_cnt+1;
 
1004
        }
 
1005
#endif
 
1006
        if((ionode_cnt = bluegene_quarter_ionode_cnt))
 
1007
                ionode_cnt--;
 
1008
        for(i=0; i<blockreq->small128; i++) {
 
1009
                bit_nset(ionodes, start, start+ionode_cnt);
 
1010
                found_record = create_small_record(bg_record, ionodes, 128);
 
1011
                /* this needs to be an append so we
 
1012
                   keep things in the order we got
 
1013
                   them, they will be sorted later */
 
1014
                list_append(records, found_record);
 
1015
                bit_nclear(ionodes, start, start+ionode_cnt);
 
1016
                start+=ionode_cnt+1;
 
1017
        }
 
1018
 
 
1019
#ifndef HAVE_BGL
 
1020
        if((ionode_cnt = bluegene_quarter_ionode_cnt * 2))
 
1021
                ionode_cnt--;
 
1022
        for(i=0; i<blockreq->small256; i++) {
 
1023
                bit_nset(ionodes, start, start+ionode_cnt);
 
1024
                found_record = create_small_record(bg_record, ionodes, 256);
 
1025
                /* this needs to be an append so we
 
1026
                   keep things in the order we got
 
1027
                   them, they will be sorted later */
 
1028
                list_append(records, found_record);
 
1029
                bit_nclear(ionodes, start, start+ionode_cnt);
 
1030
                start+=ionode_cnt+1;
 
1031
        }
 
1032
#endif
 
1033
 
 
1034
 
 
1035
        FREE_NULL_BITMAP(ionodes);
 
1036
 
 
1037
        return SLURM_SUCCESS;
 
1038
}
 
1039
#endif
797
1040
 
798
1041
extern int format_node_name(bg_record_t *bg_record, char *buf, int buf_size)
799
1042
{
841
1084
        for (x = start[X]; x <= end[X]; x++) {
842
1085
                for (y = start[Y]; y <= end[Y]; y++) {
843
1086
                        for (z = start[Z]; z <= end[Z]; z++) {
844
 
                                slurm_conf_lock();
 
1087
                                
845
1088
                                snprintf(node_name_tmp, sizeof(node_name_tmp),
846
1089
                                         "%s%c%c%c", 
847
 
                                         slurmctld_conf.node_prefix,
 
1090
                                         bg_slurm_node_prefix,
848
1091
                                         alpha_num[x], alpha_num[y],
849
1092
                                         alpha_num[z]);         
850
 
                                slurm_conf_unlock();
 
1093
                                
851
1094
                                ba_node = ba_copy_node(
852
1095
                                        &ba_system_ptr->grid[x][y][z]);
853
1096
                                ba_node->used = 1;