At this time there is no way to retrieve via Perl API the list of allocated CPUs on a node for a particular job. To give you some background one of our developers, Dennis McRitchie, has been adapting pbstop to work with slurm - we are calling it slurmtop. One of its features is to show which CPUs on nodes are used by which jobs. I.e. if a job 1212 is using CPUs 8-15 we would like to be able to get that info. Currently the only place where one can get that information is in scontrol show job ... and we would really need to be able to get this directly via perl API rather then trying to parse out that kind of output.
The information required is in the C job data structure, in this field: job_resources_t *job_resrcs; /* opaque data type, job resources */ It is currently available using the scontrol -d show job command, but not in the Perl API: JobId=21470 Name=scontrol UserId=jette(1001) GroupId=jette(1001) .... Nodes=tux1 CPU_IDs=0-3 Mem=128 Nodes=tux[2-3] CPU_IDs=0-1 Mem=128
Hi, I wanted to touch base on this one - we knew about scontrol way of getting to it but that's a very inefficient way for us to do that (slurmtop is ran by multiple users and would do that multiple times per minute for 1000+ jobs we have in the queue). Any plans on exposing this info via perl API directly? Thanks!
(In reply to Josko Plazonic from comment #2) > Hi, > > I wanted to touch base on this one - we knew about scontrol way of getting > to it but that's a very inefficient way for us to do that (slurmtop is ran > by multiple users and would do that multiple times per minute for 1000+ jobs > we have in the queue). > > Any plans on exposing this info via perl API directly? > > Thanks! We'll try to get this into the v15.08 release.
This has been added to 15.08 and the commit 4e15ddc1b04 should work with previous versions of Slurm. A Simple script like #! /usr/bin/perl -w use strict; use Slurm ':all'; my $job_flags = SHOW_ALL | SHOW_DETAIL; my $resp = Slurm->load_jobs(0, $job_flags); foreach my $job (@{$resp->{job_array}}) { if ($job->{'node_rescrs'}) { foreach my $rescrs (@{$job->{'node_rescrs'}}) { printf("\tNodes = %s CPU_IDS = %s Mem = %s\n", $rescrs->{'nodes'}, $rescrs->{'cpu_ids'}, $rescrs->{'mem'}); } } } should get you what you want. SHOW_DETAIL is the key here in the flags.
Hi, one minor issue (pointed out by our Dennis who is starting to use this feature so he wants to make sure the correct name sticks) - shouldn't it be node_resrcs rather then node_rescrs? It's a trivial change/fix: --- ./contribs/perlapi/libslurm/perl/job.c.original 2015-07-21 15:51:01.882759414 -0400 +++ ./contribs/perlapi/libslurm/perl/job.c 2015-07-21 16:26:12.234828155 -0400 @@ -168,7 +168,7 @@ } slurm_hostlist_destroy(hl); slurm_hostlist_destroy(hl_last); - hv_store_sv(hv, "node_rescrs", newRV_noinc((SV*)av)); + hv_store_sv(hv, "node_resrcs", newRV_noinc((SV*)av)); return 0; } Thanks!
Corrected in: https://github.com/SchedMD/slurm/commit/dad397f926ade6d7322bfeff7eb119055b86a171 THanks!