我通过Perl API向SLURM提交工作时需要的`job_desc_msg_t`格式是什么?

问题描述 投票:1回答:1

`job_desc_msg_t`是什么格式?SLURM的Perl API 表示,要用API提交一个工作,需要我们给它一个 "工作描述"($job_desc$job_desc_msg),其结构为 job_desc_msg_t 但它并没有告诉你什么 job_desc_msg_t 是。

更新:我发现它在 slurm.h,从第1162行开始。所以我猜测我需要传入一个类似结构的哈希。

perl slurm
1个回答
4
投票

根据手册页面,这正是你必须做的。

典型的情况是,C结构被转换为(也许是祝福)Perl的哈希引用,以字段名作为哈希键。C中的数组在Perl中被转换为数组。例如,有一个结构 "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;

这个结构将被转换为一个哈希引用,结构如下:

{
    last_update => 1285847672,
    job_array => [ {account => 'test', alloc_node => 'ln0', alloc_sid => 1234, ...},
                   {account => 'debug', alloc_node => 'ln2', alloc_sid => 5678, ...},
                   ...
                 ]
}

注意哈希中缺少 "record_count "字段。它可以从数组 "job_array "中的元素数量中得到。

要向API函数传递参数,请使用相应的哈希引用,例如。

$rc = $slurm->update_node({node_names => 'node[0-7]', node_state => NODE_STATE_DRAIN});

请参阅"<slurmslurm.h> "中关于结构的定义。

© www.soinside.com 2019 - 2024. All rights reserved.