问题
The Perl API for SLURM indicates that to submit a job with the API requires that we give it a "job description" ($job_desc
or $job_desc_msg
), which has the structure job_desc_msg_t
but it doesn't tell what job_desc_msg_t
is.
I found it in slurm.h starting at line 1160, so I'm guessing that I will need to pass in a hash with a similar structure. I plan to play with it and post an answer later today or tomorrow, once I've had a chance to try it out.
回答1:
That's exactly what you must do according to the man page.
Typicaly, C structures are converted to (maybe blessed) Perl hash references, with field names as hash keys. Arrays in C are converted to arrays in Perl. For example, there is a structure "job_info_msg_t":
typedef struct job_info_msg { time_t last_update; /* time of latest info */ uint32_t record_count; /* number of records */ job_info_t *job_array; /* the job records */ } job_info_msg_t;
This will be converted to a hash reference with the following structure:
{ last_update => 1285847672, job_array => [ {account => 'test', alloc_node => 'ln0', alloc_sid => 1234, ...}, {account => 'debug', alloc_node => 'ln2', alloc_sid => 5678, ...}, ... ] }
Note the missing of the "record_count" field in the hash. It can be derived from the number of elements in array "job_array".
To pass parameters to the API functions, use the corresponding hash references, for example:
$rc = $slurm->update_node({node_names => 'node[0-7]', node_state => NODE_STATE_DRAIN});
Please see "<slurm/slurm.h>" for the definition of the structures.
来源:https://stackoverflow.com/questions/30079725/what-is-this-job-desc-msg-t-format-that-i-need-to-submit-jobs-to-slurm-via-the