Cluster computing 并行运行多个串行相关作业

Cluster computing 并行运行多个串行相关作业,cluster-computing,hpc,pbs,gnu-parallel,Cluster Computing,Hpc,Pbs,Gnu Parallel,我正在PBS集群上运行一些CFD模拟。我将运行大量案例,因此希望在集群节点上进行预处理。我需要做两个步骤,第一步是网格划分,当网格划分完成后,我想运行网格划分例程。 为了避免手工操作,我想在pbs作业脚本中对此进行编程 我可以通过运行以下命令并行运行所有情况的网格划分: #!/usr/bin/env bash #PBS -q regular #PBS -l nodes=1:ppn=8 #PBS -N prep_tst_2 #PBS -l walltime=6:00:00 cd $PBS_O_W

我正在PBS集群上运行一些CFD模拟。我将运行大量案例,因此希望在集群节点上进行预处理。我需要做两个步骤,第一步是网格划分,当网格划分完成后,我想运行网格划分例程。 为了避免手工操作,我想在pbs作业脚本中对此进行编程

我可以通过运行以下命令并行运行所有情况的网格划分:

#!/usr/bin/env bash
#PBS -q regular
#PBS -l nodes=1:ppn=8
#PBS -N prep_tst_2
#PBS -l walltime=6:00:00

cd $PBS_O_WORKDIR

hexp -batch -project tst_1.igg &
hexp -batch -project tst_2.igg &
hexp -batch -project tst_3.igg &
hexp -batch -project tst_4.igg &
hexp -batch -project tst_5.igg &
hexp -batch -project tst_6.igg &
hexp -batch -project tst_7.igg &
hexp -batch -project tst_8.igg &

#End of script
其中hexp是啮合程序

我还可以运行网格划分任务,然后通过运行以下命令进行分区:

hexp -batch -project tst_1.igg ; partit -batch -project tst_1.igg
但是我怎样才能把两者结合起来呢? 我想并行运行最后一个命令的8个实例,以便在完成tst_1.igg的网格划分后,无论其他实例的状态如何,它都会继续对tst_1.igg进行分区


向你问好,亚当,你要找的是工作依赖性。假设您的预处理命令被放置在一个名为preprocess.sh的脚本中,您想要运行8次的分区块被放置在一个名为partition.sh的脚本中

jobid=`qsub preprocess.sh`
for ((i=0; i < 8; i++)); do
  qsub partition.sh -W depend=afterok:$jobid
done
jobid=`qsub preprocess.sh`
对于((i=0;i<8;i++);做
qsub partition.sh-W depend=afterok:$jobid
完成
这将使preprocess.sh脚本成为一个作业,然后提交8个作业,除非第一个作业以零退出,否则这些作业不会执行。如果您让预处理脚本将结果输出到所有计算节点都可以读取的网络文件位置,并且您将partition.sh脚本设置为从同一位置读取,那么这将非常有效


您可以在

中阅读有关作业依赖关系的更多信息。看起来这个问题可以通过
GNU Parallel
很好地解决。如果我理解正确,您希望为给定文件依次运行
hexp
,然后是
partit
。您希望序列对多个文件并行运行。我想您应该使用
GNU Parallel
如下:

首先,创建一个简单的bash脚本,该脚本接受filename参数并启动两个命令:

#!/bin/bash
hexp -batch -project $1 ; partit -batch -project $1

#name this file hexpart.sh and make it executable
接下来,在PBS脚本中使用
GNU Parallel
在多个CPU上启动
hexpart.sh
。在这种情况下,一个节点上的8个CPU上有8个文件:

#!/bin/bash
#PBS -l nodes=1:ppn=8
#Other PBS directives

cd $PBS_O_WORKDIR
module load gnu-parallel   # this will depend on your cluster setup

parallel -j8 --sshloginfile $PBS_NODEFILE --workdir $PBS_O_WORKDIR \
  `pwd`/hexpart.sh tst_{}.igg' ::: 1 2 3 4 5 6 7 8

#name this file launch.pbs

然后运行
qsub launch.pbs
parallel
命令将在八个文件上运行hexpart.sh,每个文件都在一个单独的CPU上。文件名将通过将
{}
替换为
后面的参数来生成。这是一本书