001、
(base) [b20223040323@admin1 batch_test02]$ ls ## 测试模板、测试sam文件
template.slurm test.sam
(base) [b20223040323@admin1 batch_test02]$ cat template.slurm ## 程序模板
#!/bin/bash
#SBATCH -J xxxx
#SBATCH -p Cnode2
##SBATCH -o %j.xxxx.result
##SBATCH -e %j.xxxx.error
#SBATCH -N 1
#SBATCH -n xxxx
#SBATCH --cpus-per-task=1
STIME=`date +%s`
samtools view -@ xxxx -b -S test.sam > xxxx.bam
let ETIME=`date +%s`-$STIME
echo thread_xxxx Elapsed time: $ETIME s > xxxx.time ## 分别给与4、16、32和64线程,并记录程序运行的时间
(base) [b20223040323@admin1 batch_test02]$ for i in 4 16 32 64; do sed "s/xxxx/$i/g" template.slurm > $i.slurm; done
(base) [b20223040323@admin1 batch_test02]$ find *.slurm | grep -v "template.slurm" | xargs -n 1 sbatch ## 投递任务
Submitted batch job 396049
Submitted batch job 396050
Submitted batch job 396051
Submitted batch job 396052
002、运行结果:
(base) [b20223040323@admin1 batch_test02]$ cat *.time | sort -V ## 查看运行的时间
thread_4 Elapsed time: 159 s
thread_16 Elapsed time: 46 s
thread_32 Elapsed time: 24 s
thread_64 Elapsed time: 13 s
003、结论
在其他参数不变的情况下,转化的效率与线程数几乎是成正比,线程数越多,运行速度越快。