slurm sbatch 标准 IO 重定向
slurm sbatch standard IO redirection
我需要 运行 一个需要从标准 io 读取的并行程序。我如何在 slurm sbatch 中将文件传递给它?我尝试了 -input 命令但没有用。这是我的 sbatch 脚本
#!/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
sbatch 中的--input
选项会将文件传输到提交脚本的标准输入,而不是您程序的标准输入。您有三个行动方案:
将 --input
参数移动到 srun
调用:srun --input /vlsci/VR****/phillis/input.txt helloworld
将提交脚本的标准输入传输到srun
,后者又将其传输到helloworld
:cat | srun helloworld
忽略 --input
参数并明确使用重定向:srun helloworld < /vlsci/VR****/phillis/input.txt
我需要 运行 一个需要从标准 io 读取的并行程序。我如何在 slurm sbatch 中将文件传递给它?我尝试了 -input 命令但没有用。这是我的 sbatch 脚本
#!/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
sbatch 中的--input
选项会将文件传输到提交脚本的标准输入,而不是您程序的标准输入。您有三个行动方案:
将
--input
参数移动到srun
调用:srun --input /vlsci/VR****/phillis/input.txt helloworld
将提交脚本的标准输入传输到
srun
,后者又将其传输到helloworld
:cat | srun helloworld
忽略
--input
参数并明确使用重定向:srun helloworld < /vlsci/VR****/phillis/input.txt