diff -uNr torque-2.5.5.orig/src/resmom/start_exec.c torque-2.5.5/src/resmom/start_exec.c --- torque-2.5.5.orig/src/resmom/start_exec.c 2011-02-15 11:06:18.000000000 -0800 +++ torque-2.5.5/src/resmom/start_exec.c 2011-03-07 18:59:33.000000000 -0800 @@ -246,6 +246,7 @@ tveNumNodesStr, tveNumPpn, tveGpuFile, + tveNprocs, tveLAST }; @@ -269,6 +270,7 @@ "PBS_NUM_NODES", /* number of nodes specified by nodes string */ "PBS_NUM_PPN", /* ppn value specified by nodes string */ "PBS_GPUFILE", /* file containing which GPUs to access */ + "PBS_NP", /* number of processors requested */ NULL }; @@ -2403,6 +2405,10 @@ bld_env_variables(&vtable, "PBS_VNODENUM", buf); + /* PBS_NP */ + sprintf(buf, "%d", vnodenum); + bld_env_variables(&vtable, variables_else[tveNprocs], buf); + #ifdef PENABLE_LINUX26_CPUSETS if (use_cpusets(pjob) == TRUE) diff -uNr torque-2.5.5.orig/src/server/resc_def_all.c torque-2.5.5/src/server/resc_def_all.c --- torque-2.5.5.orig/src/server/resc_def_all.c 2010-07-20 10:57:35.000000000 -0700 +++ torque-2.5.5/src/server/resc_def_all.c 2011-03-07 18:59:33.000000000 -0800 @@ -115,6 +115,7 @@ static int decode_nodes(struct attribute *, char *, char *, char *); static int set_node_ct(resource *, attribute *, int actmode); +static int set_proc_ct(resource *, attribute *, int actmode); static int set_tokens(struct attribute *attr, struct attribute *new, enum batch_op actmode); static int set_mppnodect(resource *, attribute *, int actmode); @@ -293,6 +294,16 @@ READ_ONLY | ATR_DFLAG_MGWR | ATR_DFLAG_RASSN | ATR_DFLAG_RMOMIG, ATR_TYPE_LONG }, + { "procct", /* count of number of processors requested */ + decode_l, /* read-only, set by server whenever */ + encode_l, /* "nodes" and/or "procs" is set */ + set_l, + comp_l, + free_null, + NULL_FUNC, + READ_ONLY | ATR_DFLAG_MGWR | ATR_DFLAG_RMOMIG, + ATR_TYPE_LONG + }, { "mpplabel", /* PE label required for execution */ decode_str, @@ -464,7 +475,7 @@ set_l, comp_l, free_null, - NULL_FUNC, + set_proc_ct, READ_WRITE | ATR_DFLAG_MOM | ATR_DFLAG_RMOMIG, ATR_TYPE_LONG }, @@ -951,11 +962,56 @@ /* + * count_proc = count the number of processors in a node spec + */ + +long count_proc( + + char *spec) + + { + long num_nodes = 0, num_procs = 0, total_procs = 0; + char *substr, *ppnloc; + + spec = strdup(spec); + if (spec == NULL) + return(-1); + + /* split on + */ + substr = strtok(spec, "+"); + do + { + num_nodes = atoi(substr); + if (num_nodes == 0) + /* no number */ + num_nodes = 1; + + ppnloc = strstr(substr, ":ppn="); + if (ppnloc == NULL) + num_procs = 1; + else + num_procs = atoi(ppnloc + 5); + + total_procs += num_procs * num_nodes; + substr = strtok(NULL, "+"); + } while(substr != NULL); + + free(spec); + return(total_procs); + + } /* END count_proc */ + + + + + + +/* * set_node_ct = set node count * * This is the "at_action" routine for the resource "nodes". - * When the resource_list attribute changes, then set/update - * the value of the resource "nodect" for use by the scheduler. + * When the resource_list attribute changes, then set/update the + * value of the resources "nodect" and "procct" for use by the scheduler. */ static int set_node_ct( @@ -967,6 +1023,10 @@ { resource *pnct; resource_def *pndef; + resource *ppct; + resource_def *ppdef; + resource *pprocsp; + resource_def *pprocsdef; if (actmode == ATR_ACTION_RECOV) { @@ -1023,7 +1083,46 @@ pnct->rs_value.at_flags |= ATR_VFLAG_SET; - /* SUCCESS */ + /* SUCCESS nodect */ + + /* set "procct" to count of processors in "nodes" plus "procs" */ + + ppdef = find_resc_def(svr_resc_def, "procct", svr_resc_size); + + if (ppdef == NULL) + { + return(PBSE_SYSTEM); + } + + if ((ppct = find_resc_entry(pattr, ppdef)) == NULL) + { + if ((ppct = add_resource_entry(pattr, ppdef)) == 0) + { + return(PBSE_SYSTEM); + } + } + + pprocsdef = find_resc_def(svr_resc_def, "procs", svr_resc_size); + if (pprocsdef == NULL) + { + return(PBSE_SYSTEM); + } + + if ((pprocsp = find_resc_entry(pattr, pprocsdef)) == NULL) + { + ppct->rs_value.at_val.at_long = + count_proc(pnodesp->rs_value.at_val.at_str); + } + else + { + ppct->rs_value.at_val.at_long = + count_proc(pnodesp->rs_value.at_val.at_str) + + pprocsp->rs_value.at_val.at_long; + } + + ppct->rs_value.at_flags |= ATR_VFLAG_SET; + + /* SUCCESS procct */ return(0); } /* END set_node_ct() */ @@ -1033,6 +1132,77 @@ /* + * set_proc_ct = set processor count + * + * This is the "at_action" routine for the resource "procs". + * When the resource_list attribute changes, then set/update + * the value of the resource "procct" + */ + +static int set_proc_ct( + + resource *pprocsp, /* I */ + attribute *pattr, /* I */ + int actmode) /* I */ + + { + resource *pnodesp; + resource_def *pndef; + resource *ppct; + resource_def *ppdef; + + if (actmode == ATR_ACTION_RECOV) + { + /* SUCCESS */ + + return(0); + } + + /* set "procct" to count of processors in "nodes" plus "procs" */ + + ppdef = find_resc_def(svr_resc_def, "procct", svr_resc_size); + + if (ppdef == NULL) + { + return(PBSE_SYSTEM); + } + + if ((ppct = find_resc_entry(pattr, ppdef)) == NULL) + { + if ((ppct = add_resource_entry(pattr, ppdef)) == 0) + { + return(PBSE_SYSTEM); + } + } + + pndef = find_resc_def(svr_resc_def, "nodes", svr_resc_size); + if (pndef == NULL) + { + return(PBSE_SYSTEM); + } + + if ((pnodesp = find_resc_entry(pattr, pndef)) == NULL) + { + ppct->rs_value.at_val.at_long = + pprocsp->rs_value.at_val.at_long; + } + else + { + ppct->rs_value.at_val.at_long = + pprocsp->rs_value.at_val.at_long + + count_proc(pnodesp->rs_value.at_val.at_str); + } + + ppct->rs_value.at_flags |= ATR_VFLAG_SET; + + return(0); + } /* END set_proc_ct() */ + + + + + +/* * set_tokens = set node count * */ diff -uNr torque-2.5.5.orig/src/server/svr_jobfunc.c torque-2.5.5/src/server/svr_jobfunc.c --- torque-2.5.5.orig/src/server/svr_jobfunc.c 2011-01-13 12:22:14.000000000 -0800 +++ torque-2.5.5/src/server/svr_jobfunc.c 2011-03-07 18:59:33.000000000 -0800 @@ -1960,6 +1960,19 @@ return(i); } + else + { + if (strcmp(pque->qu_attr->at_val.at_str, "Execution") == 0) + { + /* job routed to Execution queue successfully */ + /* unset job's procct resource */ + resource_def *pctdef; + resource *pctresc; + pctdef = find_resc_def(svr_resc_def, "procct", svr_resc_size); + if ((pctresc = find_resc_entry(&pjob->ji_wattr[JOB_ATR_resource], pctdef)) != NULL) + pctdef->rs_free(&pctresc->rs_value); + } + } } /* END if (mtype != MOVE_TYPE_MgrMv) */ /* SUCCESS - job can enter queue */