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

« back to all changes in this revision

Viewing changes to src/common/slurm_step_layout.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:
6
6
 *  Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
7
7
 *  Written by Chris Holmes, <cholmes@hp.com>, who borrowed heavily
8
8
 *  from other parts of SLURM.
9
 
 *  LLNL-CODE-402394.
 
9
 *  CODE-OCEC-09-009. All rights reserved.
10
10
 *  
11
11
 *  This file is part of SLURM, a resource management program.
12
 
 *  For details, see <http://www.llnl.gov/linux/slurm/>.
 
12
 *  For details, see <https://computing.llnl.gov/linux/slurm/>.
 
13
 *  Please also read the included file: DISCLAIMER.
13
14
 *  
14
15
 *  SLURM is free software; you can redistribute it and/or modify it under
15
16
 *  the terms of the GNU General Public License as published by the Free
55
56
/* build maps for task layout on nodes */
56
57
static int _init_task_layout(slurm_step_layout_t *step_layout, 
57
58
                             const char *arbitrary_nodes, 
58
 
                             uint32_t *cpus_per_node, uint32_t *cpu_count_reps,
 
59
                             uint16_t *cpus_per_node, uint32_t *cpu_count_reps,
59
60
                             uint16_t cpus_per_task,
60
61
                             uint16_t task_dist, uint16_t plane_size);
61
62
 
62
63
static int _task_layout_block(slurm_step_layout_t *step_layout, 
63
 
                              uint32_t *cpus);
 
64
                              uint16_t *cpus);
64
65
static int _task_layout_cyclic(slurm_step_layout_t *step_layout, 
65
 
                               uint32_t *cpus);
 
66
                               uint16_t *cpus);
66
67
static int _task_layout_plane(slurm_step_layout_t *step_layout,
67
 
                               uint32_t *cpus);
 
68
                               uint16_t *cpus);
68
69
#ifndef HAVE_FRONT_END
69
70
static int _task_layout_hostfile(slurm_step_layout_t *step_layout,
70
71
                                 const char *arbitrary_nodes);
89
90
 */
90
91
slurm_step_layout_t *slurm_step_layout_create(
91
92
        const char *tlist,
92
 
        uint32_t *cpus_per_node, uint32_t *cpu_count_reps, 
 
93
        uint16_t *cpus_per_node, uint32_t *cpu_count_reps, 
93
94
        uint32_t num_hosts, 
94
95
        uint32_t num_tasks,
95
96
        uint16_t cpus_per_task,
99
100
        char *arbitrary_nodes = NULL;
100
101
        slurm_step_layout_t *step_layout = 
101
102
                xmalloc(sizeof(slurm_step_layout_t));
102
 
                
 
103
 
 
104
        step_layout->task_dist = task_dist;
103
105
        if(task_dist == SLURM_DIST_ARBITRARY) {
104
106
                hostlist_t hl = NULL;
105
 
                char buf[8192];
 
107
                char buf[65536];
106
108
                /* set the node list for the task layout later if user
107
109
                   supplied could be different that the job allocation */
108
110
                arbitrary_nodes = xstrdup(tlist);
115
117
        } else {
116
118
                step_layout->node_list = xstrdup(tlist);
117
119
        }
118
 
                        
 
120
 
119
121
        step_layout->task_cnt  = num_tasks;
120
122
        
121
123
#ifdef HAVE_FRONT_END   /* Limited job step support */
156
158
 */
157
159
slurm_step_layout_t *fake_slurm_step_layout_create(
158
160
        const char *tlist,
159
 
        uint32_t *cpus_per_node, 
 
161
        uint16_t *cpus_per_node, 
160
162
        uint32_t *cpu_count_reps,
161
163
        uint32_t node_cnt, 
162
164
        uint32_t task_cnt) 
165
167
        int cpu_cnt = 0, cpu_inx = 0, i, j;
166
168
/*      char *name = NULL; */
167
169
        hostlist_t hl = NULL;
168
 
        slurm_step_layout_t *step_layout = 
169
 
                xmalloc(sizeof(slurm_step_layout_t));
 
170
        slurm_step_layout_t *step_layout = NULL;
170
171
 
171
 
        if(node_cnt <= 0 || (task_cnt <= 0 && !cpus_per_node) || !tlist) {
 
172
        if((node_cnt <= 0) || (task_cnt <= 0 && !cpus_per_node) || !tlist) {
172
173
                error("there is a problem with your fake_step_layout request\n"
173
174
                      "node_cnt = %u, task_cnt = %u, tlist = %s",
174
175
                      node_cnt, task_cnt, tlist);
175
 
                xfree(step_layout);
176
176
                return NULL;
177
177
        }
178
178
 
261
261
        layout->node_list = xstrdup(step_layout->node_list);
262
262
        layout->node_cnt = step_layout->node_cnt;
263
263
        layout->task_cnt = step_layout->task_cnt;
 
264
        layout->task_dist = step_layout->task_dist;
264
265
        
265
266
/*      layout->node_addr = xmalloc(sizeof(slurm_addr) * layout->node_cnt); */
266
267
/*      memcpy(layout->node_addr, step_layout->node_addr,  */
293
294
        packstr(step_layout->node_list, buffer);
294
295
        pack32(step_layout->node_cnt, buffer);
295
296
        pack32(step_layout->task_cnt, buffer);
 
297
        pack16(step_layout->task_dist, buffer);
296
298
/*      slurm_pack_slurm_addr_array(step_layout->node_addr,  */
297
299
/*                                  step_layout->node_cnt, buffer); */
298
300
 
323
325
        safe_unpackstr_xmalloc(&step_layout->node_list, &uint32_tmp, buffer);
324
326
        safe_unpack32(&step_layout->node_cnt, buffer);
325
327
        safe_unpack32(&step_layout->task_cnt, buffer);
 
328
        safe_unpack16(&step_layout->task_dist, buffer);
326
329
        
327
330
/*      if (slurm_unpack_slurm_addr_array(&(step_layout->node_addr),  */
328
331
/*                                        &uint32_tmp, buffer)) */
393
396
/* build maps for task layout on nodes */
394
397
static int _init_task_layout(slurm_step_layout_t *step_layout,
395
398
                             const char *arbitrary_nodes,
396
 
                             uint32_t *cpus_per_node, uint32_t *cpu_count_reps,
 
399
                             uint16_t *cpus_per_node, uint32_t *cpu_count_reps,
397
400
                             uint16_t cpus_per_task,
398
401
                             uint16_t task_dist, uint16_t plane_size)
399
402
{
400
403
        int cpu_cnt = 0, cpu_inx = 0, i;
401
404
        hostlist_t hl = NULL;
402
405
/*      char *name = NULL; */
403
 
        uint32_t cpus[step_layout->node_cnt];
 
406
        uint16_t cpus[step_layout->node_cnt];
404
407
 
405
408
        if (step_layout->node_cnt == 0)
406
409
                return SLURM_ERROR;
419
422
 
420
423
        hl = hostlist_create(step_layout->node_list);
421
424
        /* make sure the number of nodes we think we have 
422
 
           is the correct number */
 
425
         * is the correct number */
423
426
        i = hostlist_count(hl);
424
427
        if(step_layout->node_cnt > i)
425
428
                step_layout->node_cnt = i;
442
445
/*              debug2("host %d = %s", i, name); */
443
446
/*              free(name); */
444
447
                cpus[i] = (cpus_per_node[cpu_inx] / cpus_per_task);
 
448
                if (cpus[i] == 0) {
 
449
                        /* this can be a result of a heterogeneous allocation
 
450
                         * (e.g. 4 cpus on one node and 2 on the second with
 
451
                         *  cpus_per_task=3)  */
 
452
                        cpus[i] = 1;
 
453
                }
445
454
                //info("got %d cpus", cpus[i]);
446
455
                if ((++cpu_cnt) >= cpu_count_reps[cpu_inx]) {
447
456
                        /* move to next record */
490
499
        debug2("list is %s", arbitrary_nodes);
491
500
        step_alloc_hosts = hostlist_create(arbitrary_nodes);
492
501
        if(hostlist_count(step_alloc_hosts) != step_layout->task_cnt) {
493
 
                error("Asked for %u tasks have %d in the nodelist."
494
 
                      "Check your nodelist",
 
502
                error("Asked for %u tasks have %d in the nodelist.  "
 
503
                      "Check your nodelist, or set the -n option to be %d",
495
504
                      step_layout->task_cnt, 
 
505
                      hostlist_count(step_alloc_hosts), 
496
506
                      hostlist_count(step_alloc_hosts));
497
507
                return SLURM_ERROR;
498
508
        }
552
562
/* to effectively deal with heterogeneous nodes, we fake a cyclic
553
563
 * distribution to figure out how many tasks go on each node and
554
564
 * then make those assignments in a block fashion */
555
 
static int _task_layout_block(slurm_step_layout_t *step_layout, uint32_t *cpus)
 
565
static int _task_layout_block(slurm_step_layout_t *step_layout, uint16_t *cpus)
556
566
{
557
567
        int i, j, taskid = 0;
558
568
        bool over_subscribe = false;
600
610
 *                     12 13 14 15  etc.
601
611
 */
602
612
static int _task_layout_cyclic(slurm_step_layout_t *step_layout, 
603
 
                               uint32_t *cpus)
 
613
                               uint16_t *cpus)
604
614
{
605
615
        int i, j, taskid = 0;
606
616
        bool over_subscribe = false;
647
657
 *                     12 13 14 15  etc.
648
658
 */
649
659
static int _task_layout_plane(slurm_step_layout_t *step_layout,
650
 
                               uint32_t *cpus)
 
660
                               uint16_t *cpus)
651
661
{
652
662
        int i, j, k, taskid = 0;
653
663
 
704
714
        
705
715
        return SLURM_SUCCESS;
706
716
}
 
717
 
 
718
extern char *slurm_step_layout_type_name(task_dist_states_t task_dist)
 
719
{
 
720
        switch(task_dist) {
 
721
        case SLURM_DIST_CYCLIC:
 
722
                return "Cyclic";
 
723
                break;
 
724
        case SLURM_DIST_BLOCK:  /* distribute tasks filling node by node */
 
725
                return "Block";
 
726
                break;
 
727
        case SLURM_DIST_ARBITRARY:      /* arbitrary task distribution  */
 
728
                return "Arbitrary";
 
729
                break;
 
730
        case SLURM_DIST_PLANE:  /* distribute tasks by filling up
 
731
                                   planes of lllp first and then by
 
732
                                   going across the nodes See
 
733
                                   documentation for more
 
734
                                   information */
 
735
                return "Plane";
 
736
                break;
 
737
        case SLURM_DIST_CYCLIC_CYCLIC:/* distribute tasks 1 per node:
 
738
                                   round robin: same for lowest
 
739
                                   level of logical processor (lllp) */
 
740
                return "CCyclic";
 
741
                break;
 
742
        case SLURM_DIST_CYCLIC_BLOCK: /* cyclic for node and block for lllp  */
 
743
                return "CBlock";
 
744
                break;
 
745
        case SLURM_DIST_BLOCK_CYCLIC: /* block for node and cyclic for lllp  */
 
746
                return "BCyclic";
 
747
                break;
 
748
        case SLURM_DIST_BLOCK_BLOCK:    /* block for node and block for lllp  */
 
749
                return "BBlock";
 
750
                break;
 
751
        case SLURM_NO_LLLP_DIST:        /* No distribution specified for lllp */
 
752
        case SLURM_DIST_UNKNOWN:
 
753
        default:
 
754
                return "Unknown";
 
755
 
 
756
        }
 
757
}