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

« back to all changes in this revision

Viewing changes to src/plugins/sched/wiki/get_jobs.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
 *  get_jobs.c - Process Wiki get job info request
3
3
 *****************************************************************************
4
 
 *  Copyright (C) 2006 The Regents of the University of California.
 
4
 *  Copyright (C) 2006-2007 The Regents of the University of California.
 
5
 *  Copyright (C) 2008 Lawrence Livermore National Security.
5
6
 *  Produced at Lawrence Livermore National Laboratory (cf, DISCLAIMER).
6
7
 *  Written by Morris Jette <jette1@llnl.gov>
7
 
 *  LLNL-CODE-402394.
 
8
 *  CODE-OCEC-09-009. All rights reserved.
8
9
 *  
9
10
 *  This file is part of SLURM, a resource management program.
10
 
 *  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.
11
13
 *  
12
14
 *  SLURM is free software; you can redistribute it and/or modify it under
13
15
 *  the terms of the GNU General Public License as published by the Free
15
17
 *  any later version.
16
18
 *
17
19
 *  In addition, as a special exception, the copyright holders give permission 
18
 
 *  to link the code of portions of this program with the OpenSSL library under 
 
20
 *  to link the code of portions of this program with the OpenSSL library under
19
21
 *  certain conditions as described in each individual source file, and 
20
22
 *  distribute linked combinations including the two. You must obey the GNU 
21
23
 *  General Public License in all respects for all of the code used other than 
49
51
static char *   _dump_all_jobs(int *job_cnt, time_t update_time);
50
52
static char *   _dump_job(struct job_record *job_ptr, time_t update_time);
51
53
static uint16_t _get_job_cpus_per_task(struct job_record *job_ptr);
 
54
static uint16_t _get_job_tasks_per_node(struct job_record *job_ptr);
52
55
static uint32_t _get_job_end_time(struct job_record *job_ptr);
53
56
static char *   _get_job_features(struct job_record *job_ptr);
54
57
static uint32_t _get_job_min_disk(struct job_record *job_ptr);
81
84
 *      WCLIMIT=<secs>;                 wall clock time limit, seconds
82
85
 *      TASKS=<cpus>;                   CPUs required
83
86
 *      [NODES=<nodes>;]                count of nodes required
 
87
 *      [TASKSPERNODE=<cnt>;]           tasks required per node
84
88
 *      DPROCS=<cpus_per_task>;         count of CPUs required per task
85
89
 *      QUEUETIME=<uts>;                submission time
86
90
 *      STARTTIME=<uts>;                time execution started
87
91
 *      PARTITIONMASK=<partition>;      partition name
 
92
 *      [DMEM=<mbytes>;]                MB of memory required per cpu
88
93
 *      RMEM=<MB>;                      MB of memory required
89
94
 *      RDISK=<MB>;                     MB of disk space required
90
95
 *      [COMPLETETIME=<uts>;]           termination time
91
96
 *      [SUSPENDTIME=<secs>;]           seconds that job has been suspended
92
 
 *      [QOS=<quality_of_service>];     quality of service
93
 
 *      [ACCOUNT=<bank_account>];       bank account name
 
97
 *      [ACCOUNT=<bank_account>;]       bank account name
 
98
 *      [QOS=<quality_of_service>;]     quality of service
 
99
 *      [RCLASS=<resource_class>;]      resource class
94
100
 *      [COMMENT=<whatever>;]           job dependency or account number
95
101
 *      UNAME=<user_name>;              user name
96
102
 *      GNAME=<group_name>;             group name
203
209
{
204
210
        char tmp[16384], *buf = NULL;
205
211
        char *uname, *gname;
206
 
        uint32_t end_time, suspend_time;
 
212
        uint32_t end_time, suspend_time, min_mem;
207
213
 
208
214
        if (!job_ptr)
209
215
                return NULL;
265
271
        xstrcat(buf, tmp);
266
272
 
267
273
        if (!IS_JOB_FINISHED(job_ptr)) {
 
274
                uint16_t tpn;
268
275
                snprintf(tmp, sizeof(tmp),
269
276
                        "NODES=%u;",
270
277
                        _get_job_min_nodes(job_ptr));
271
278
                xstrcat(buf, tmp);
 
279
                tpn = _get_job_tasks_per_node(job_ptr);
 
280
                if (tpn > 0) {
 
281
                        snprintf(tmp, sizeof(tmp),
 
282
                                 "TASKPERNODE=%u;",
 
283
                                 tpn);
 
284
                        xstrcat(buf, tmp);
 
285
                }
272
286
        }
273
287
 
274
288
        snprintf(tmp, sizeof(tmp),
283
297
                job_ptr->partition);
284
298
        xstrcat(buf, tmp);
285
299
 
 
300
        min_mem = _get_job_min_mem(job_ptr);
 
301
        if (min_mem & MEM_PER_CPU) {
 
302
                snprintf(tmp, sizeof(tmp),
 
303
                        "DMEM=%u;", min_mem & (~MEM_PER_CPU));
 
304
                xstrcat(buf, tmp);
 
305
        }
 
306
 
286
307
        snprintf(tmp, sizeof(tmp),
287
308
                "RMEM=%u;RDISK=%u;",
288
309
                _get_job_min_mem(job_ptr),
305
326
 
306
327
        if (job_ptr->account) {
307
328
                /* allow QOS spec in form "qos-name" */
308
 
                if (!strncmp(job_ptr->account,"qos-",4)) {
 
329
                if (!strncmp(job_ptr->account, "qos-", 4)) {
309
330
                        snprintf(tmp, sizeof(tmp),
310
331
                                 "QOS=%s;", job_ptr->account + 4);
311
332
                } else {
316
337
        }
317
338
 
318
339
        if (job_ptr->comment && job_ptr->comment[0]) {
319
 
                snprintf(tmp,sizeof(tmp),
320
 
                        "COMMENT=%s;", job_ptr->comment);
321
 
                xstrcat(buf,tmp);
 
340
                /* Parse comment for class/qos spec */
 
341
                char *copy;
 
342
                char *cred, *value;
 
343
                copy = xstrdup(job_ptr->comment);
 
344
                cred = strtok(copy, ",");
 
345
                while (cred != NULL) {
 
346
                        if (!strncmp(cred, "qos:", 4)) {
 
347
                                value = &cred[4];
 
348
                                if (value[0] != '\0') {
 
349
                                        snprintf(tmp, sizeof(tmp),
 
350
                                                 "QOS=%s;", value);
 
351
                                        xstrcat(buf, tmp);
 
352
                                }
 
353
                        } else if (!strncmp(cred, "class:", 6)) {
 
354
                                value = &cred[6];
 
355
                                if (value[0] != '\0') {
 
356
                                        snprintf(tmp, sizeof(tmp),
 
357
                                                "RCLASS=%s;", value);
 
358
                                        xstrcat(buf, tmp);
 
359
                                }
 
360
                        }
 
361
                        cred = strtok(NULL, ",");
 
362
                }
 
363
                xfree(copy);
 
364
                snprintf(tmp, sizeof(tmp),
 
365
                         "COMMENT=%s;", job_ptr->comment);
 
366
                xstrcat(buf, tmp);
322
367
        }
323
368
 
324
369
        if (job_ptr->details &&
345
390
        return cpus_per_task;
346
391
}
347
392
 
 
393
 
 
394
static uint16_t _get_job_tasks_per_node(struct job_record *job_ptr)
 
395
{
 
396
        uint16_t tasks_per_node = 0;
 
397
 
 
398
        if (job_ptr->details && job_ptr->details->ntasks_per_node)
 
399
                tasks_per_node = job_ptr->details->ntasks_per_node;
 
400
        return tasks_per_node;
 
401
}
 
402
 
348
403
static uint32_t _get_job_min_mem(struct job_record *job_ptr)
349
404
{
350
405
        if (job_ptr->details)
526
581
        int i, j, task_cnt;
527
582
        char *buf = NULL, *host;
528
583
        hostlist_t hl = hostlist_create(job_ptr->nodes);
 
584
        select_job_res_t select_ptr = job_ptr->select_job;
529
585
 
 
586
        xassert(select_ptr && select_ptr->cpus);
530
587
        buf = xstrdup("");
531
588
        if (hl == NULL)
532
589
                return buf;
533
590
 
534
 
        for (i=0; i<job_ptr->alloc_lps_cnt; i++) {
 
591
        for (i=0; i<select_ptr->nhosts; i++) {
535
592
                host = hostlist_shift(hl);
536
593
                if (host == NULL) {
537
 
                        error("bad alloc_lps_cnt for job %u (%s, %d)", 
 
594
                        error("bad node_cnt for job %u (%s, %d)", 
538
595
                                job_ptr->job_id, job_ptr->nodes,
539
 
                                job_ptr->alloc_lps_cnt);
 
596
                                job_ptr->node_cnt);
540
597
                        break;
541
598
                }
542
 
                task_cnt = job_ptr->alloc_lps[i];
 
599
                task_cnt = select_ptr->cpus[i];
543
600
                if (job_ptr->details && job_ptr->details->cpus_per_task)
544
601
                        task_cnt /= job_ptr->details->cpus_per_task;
545
602
                for (j=0; j<task_cnt; j++) {