【发布时间】:2017-08-17 03:27:04
【问题描述】:
我需要运行一个需要从标准 io 读取的并行程序。如何在 slurm sbatch 中将文件传递给它?我尝试了 -input 命令但没有用。这是我的批处理脚本
#!/bin/sh
#SBATCH -p main
#SBATCH --nodes=1
#SBATCH --ntasks=1
#SBATCH --time 0-23:59:59
#SBATCH --reservation=VR0188
#SBATCH --input /vlsci/VR****/phillis/input.txt
# Run info and srun job launch
echo 'start work--------------------'
srun helloworld
这是我的测试代码:
#include <stdio.h>
#include <omp.h>
main(int argc, char *argv[]) {
int nthreads, tid;
#pragma omp parallel private(tid)
{
/* Obtain and print thread id */
tid = omp_get_thread_num();
printf("Hello World from thread = %d\n", tid);
} /* All threads join master thread and terminate */
int a;
scanf("%d", &a);
printf("file input read as %d\n",a);
}
这个程序可以成功提交运行,但是scanf结果总是:
file input read as 0
【问题讨论】:
-
你试过
srun helloworld < input.txt还是cat input.txt | srun helloworld?
标签: c parallel-processing openmp slurm