1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
/*
* Copyright 1998-1999, University of Notre Dame.
* Authors: Brian W. Barrett, Arun F. Rodrigues, Jeffrey M. Squyres,
* and Andrew Lumsdaine
*
* This file is part of XMPI
*
* You should have received a copy of the License Agreement for XMPI
* along with the software; see the file LICENSE. If not, contact
* Office of Research, University of Notre Dame, Notre Dame, IN 46556.
*
* Permission to modify the code and to distribute modified code is
* granted, provided the text of this NOTICE is retained, a notice that
* the code was modified is included with the above COPYRIGHT NOTICE and
* with the COPYRIGHT NOTICE in the LICENSE file, and that the LICENSE
* file is distributed with the modified code.
*
* LICENSOR MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED.
* By way of example, but not limitation, Licensor MAKES NO
* REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY
* PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE COMPONENTS
* OR DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS
* OR OTHER RIGHTS.
*
* Additional copyrights may follow.
*
* $Id: asc_schedule.c,v 1.3 1999/11/08 06:20:37 bbarrett Exp $
*
* Function: - schedules an application schema
* - LAM specific
* - generates a new application list with one
* process, one node entries
* - four scheduling cases:
* 1) "foo -c # <nodes>" # procs on this list of nodes
* 2) "foo -c #" # procs using all nodes
* 3) "foo <nodes>" 1 proc on each of these nodes
* 4) "foo" 1 proc on every node
*
* Accepts: - parsed application schema
* Returns: - expanded, precise application schema or NULL
*/
#include <all_list.h>
#include <app_schema.h>
#include <ndi.h>
LIST *
asc_schedule(applist)
LIST * applist;
{
LIST * newapplist; /* scheduled app schema */
LIST * newnodelist; /* explicit node ids */
LIST * parsenodelist; /* parsed nodes or default */
struct aschema newproc; /* precise app process */
struct aschema *p; /* current app process */
struct ndi * node; /* current node ID */
char * nodev[3]; /* default node spec */
int n;
/*
* Expand each entry in the parsed schema.
*/
p = (struct aschema *) al_top(applist);
newapplist = al_init(sizeof(struct aschema), 0);
while (p) {
/*
* Absent node information is replaced by all nodes.
*/
if (al_count(p->asc_nodelist) == 0) {
nodev[0] = "cmd";
nodev[1] = "N";
nodev[2] = 0;
parsenodelist = ndi_parse(2, nodev, 0);
if (parsenodelist == 0) {
al_free(newapplist);
return(0);
}
} else {
parsenodelist = p->asc_nodelist;
}
/*
* Expand the node list into plain node identifiers.
*/
newnodelist = ndi_resolve(parsenodelist);
if (al_count(p->asc_nodelist) == 0) {
al_free(parsenodelist);
}
if (newnodelist == 0) {
al_free(newapplist);
return(0);
}
/*
* An absent process count means one process on each node.
*/
n = (p->asc_proc_cnt < 1) ? al_count(newnodelist) :
p->asc_proc_cnt;
/*
* Generate a one process, one node application schema.
*/
node = (struct ndi *) al_top(newnodelist);
newproc.asc_errno = 0;
newproc.asc_proc_cnt = 1;
newproc.asc_args = p->asc_args;
newproc.asc_env = p->asc_env;
newproc.asc_nodelist = 0;
while (n > 0) {
newproc.asc_node = node->ndi_node;
newproc.asc_srcnode = (p->asc_srcnode == -1) ?
node->ndi_node : p->asc_srcnode;
newproc.asc_args->apa_refcount += 1;
newproc.asc_env->ape_refcount += 1;
if (al_append(newapplist, &newproc) == 0) {
al_free(newapplist);
al_free(newnodelist);
return(0);
}
node = (struct ndi *) al_next(newnodelist, node);
if (node == 0) {
node = (struct ndi *) al_top(newnodelist);
}
n--;
}
al_free(newnodelist);
p = al_next(applist, p);
}
return(newapplist);
}
|