[torqueusers] How to get number of allocated CPUs within
jobscript?
Martin Siegert
siegert at sfu.ca
Fri Apr 7 15:05:59 MDT 2006
On Fri, Apr 07, 2006 at 04:31:02PM -0400, Andrew J Caird wrote:
> On Thu, 6 Apr 2006, Norbert Paschedag wrote:
>
> >There was a patch for torque floating around on this list (I think) that
> >would add additional environment variables $NCPUS (similar to what
> >PBSpro is doing on SMPs) and $PBS_NCPUS. Worked fine on our cluster.
> >
> >If you're interested I can send you my version of the patch.
>
> Norbert,
>
> I'd like a copy of that patch.
>
> Garrick, will this be rolled into the main Torque stream at some point?
Here is the latest version of the patch created for torque-2.0.0p7
that works for torque-2.0.0p8 as well.
Martin
--
Martin Siegert
Head, HPC at SFU
WestGrid Site Manager
Academic Computing Services phone: (604) 291-4691
Simon Fraser University fax: (604) 291-4242
Burnaby, British Columbia email: siegert at sfu.ca
Canada V5A 1S6
-------------- next part --------------
--- torque-2.0.0p7/src/resmom/start_exec.c.ncpus Fri Jan 27 10:42:05 2006
+++ torque-2.0.0p7/src/resmom/start_exec.c Fri Jan 27 18:39:19 2006
@@ -184,7 +184,8 @@
"PBS_TASKNUM",
"PBS_MOMPORT",
"PBS_NODEFILE",
- "TMPDIR" };
+ "TMPDIR",
+ "PBS_NCPUS" };
static int num_var_else = sizeof(variables_else) / sizeof(char *);
@@ -1769,6 +1770,8 @@
job *pjob;
task *ptask;
+ resource *resc;
+ long ncpus = 1;
struct passwd *pwdp;
@@ -1865,6 +1868,22 @@
bld_env_variables(&vtable,"PBS_VNODENUM",buf);
+ /* PBS_NCPUS
+ first check "ncpus" resource, then vnodes */
+
+ resc = find_resc_entry(
+ &pjob->ji_wattr[(int)JOB_ATR_resource],
+ find_resc_def(svr_resc_def,"ncpus",svr_resc_size));
+ if (resc != NULL) {
+ ncpus = resc->rs_value.at_val.at_long;
+ }
+ if (pjob->ji_numvnod > ncpus) {
+ ncpus = pjob->ji_numvnod;
+ }
+ sprintf(buf,"%d",
+ ncpus);
+ bld_env_variables(&vtable,variables_else[13],buf);
+
#if defined(PENABLE_CPUSETS) || defined(PENABLE_DYNAMIC_CPUSETS)
#ifdef PENABLE_DYNAMIC_CPUSETS
More information about the torqueusers
mailing list