<HPC>Torque 基本框架

背景

 

TORQUE provides administrators the ability to run scripts before and/or after each job executes. With such a
script, a site can prepare systems, perform node health checks, prepend and append text to output and error
log files, cleanup systems, and so forth.
The following table shows which mom runs which script. All scripts must be in the $PBS_HOME/mom_priv/
directory and be available on every compute node. $PBS_HOME by default is /usr/spool/PBS/. Mother
Superior is the pbs_mom on the first node allocated. Sisters refer to all other pbs_moms, although note that
a Mother Superior is also a sister node.

 

rpp.c 中主要是网络的收包,解包

 

可以看到torque 是通过udp来流通信的。

 

 

 

首先通过add_con 注册回调函数rpp_request()

 

接下来在

 

do_rqq()

 

通过 proto = disrsi(stream,&ret); 来获得消息的协议类型,然后去调用相应的协议处理方法

 

case rm_protocol:  资源监控的请求;

 

case im_rpotocol : 任务管理的请求

 

case is_protocol:   内部服务器的请求

 

 

 

im_request(); 对来自于另一个mom rpp 消息 进行处理

 

还是通过disrsi(stream,&ret); 按字节读取,包体组成为request(jobid,cookie,command,event,fromtast)

 

然后根据command的值分为

 

case im_join_job : 主要是来自mother superiorde 的工作消息。

 继续解析得到包体内容: auxiliary info (nodeid,nodenum,)

 这里会调用find_job 看看请求的jobid 是否已经存在 如果存在一般是错误的情况,需要清理告警

 

接下来会job_alloc 继续对任务的解析

 

job_nodes 会去解析工作的node

 

同时任务的状态为: JOB_STATE_TRANSIT;  表示正在接受新任务

 

在这个时候所有的sister会去执行 mom_priv/prologue.parallel"

 

接下来 mom_do_poll()会去看看该job是否被限制某些资源使用。

 

 

然后第一个switch做完, 系统也做好了一些关于job的准备工作。

 

如果没有匹配上第一个SWITH reply = 0. 说明下面的消息是需要反馈的。

 

下一个switch开始

 

case IM_KILL_JOB: 一般是qdel  来删除这个jobid 消息同样来自mom superior

 

case IM_SPAWN_TASK: 这里说明某个 mom job需要开始, 这样大家MOM都要开始干活

 

做了一些合法行检查之后 就要pbs_task_create()

接下来 就到了:  start_process() 这就是真正干活的地方

 

这里面会产生一个pipe,用于fork之后父进程收集子进程的信息

 

子进程 InitUserEnv() 初始化所有环境变量

然后重定向fd ,设置euid 工作目录,等工作

 

最后当然就是  execvp(argv[0],argv);

 

 

 

 

 

mother  主要的工作就是

 

         process_request()

                   dispatch_request()

 

                            case PBS_BATCH_Commit:  req_commit();

                              pj->ji_qs.ji_state = JOB_STATE_RUNNING;

                  

                            主要的执行job就是start_exec()

 

                            TMomFinalizeJob1();*

 Used by MOM superior to start the shell process.

                          perform all server level pre-job tasks, collect information

create parent-child pipes

 

                            TMomFinalizeJob2()

                                      子进程执行TMomFinalizeChild(){

                                               经过多次forksisiter类似的准备工作

                                               execve(shell,arg,vtable.v_envp);

}

 

                            TMomCheckJobChild();

 

TMomFinalizeJob3(){ 这里把JOB的做内部和外部JOB_STATE_RUNNING状态改为RUNNING

         如果失败会

         exec_bail(){

                     send_sisters(pjob,IM_ABORT_JOB); 通知所有sisters

}

 

}

 

 

 

 

 

 Torque的代码 简单而丑陋。。。HPC领域可能本来就是注重并行算法,不在意调度这些辅助库。。

 

 

 

 

猜你喜欢

转载自sunzixun.iteye.com/blog/1166013
今日推荐