使用bash脚本运行MPI程序时出现分段错误

时间:2013-12-15 21:18:55

标签: bash mpi

我正在尝试编写一个简单的脚本,用不同的进程数来测试我的MPI应用程序。 run.sh脚本的内容:

#!/bin/bash
if [ $# -lt 3 ]; then
    echo "args required: <thread_count> <executable> <args>..."
    exit
fi

echo "
$@
$(date)">>result

TH_MAX=$1
THREAD=2
while [ $THREAD -le $TH_MAX ]; do
    echo $THREAD threads
    output=$(mpirun -np $THREAD ./$2 $THREAD ${@:3})
    echo $THREAD $output >> result
    let THREAD=THREAD+1
done

现在,当我使用它来运行正常的程序时,一切都很棒。但是,因为我打电话给mpirun我得到了分段错误。

呼叫:

./run.sh 2 main data_file 100

结果:

2 threads
[ubuntu:07144] *** Process received signal ***
[ubuntu:07144] Signal: Segmentation fault (11)
[ubuntu:07144] Signal code: Address not mapped (1)
[ubuntu:07144] Failing at address: (nil)
[ubuntu:07144] [ 0] /lib/x86_64-linux-gnu/libpthread.so.0(+0xfcb0) [0x7fc6359fccb0]
[ubuntu:07144] [ 1] /lib/x86_64-linux-gnu/libc.so.6(fgets+0x1e) [0x7fc63569bfee]
[ubuntu:07144] [ 2] main(main+0x1f7) [0x400f6b]
[ubuntu:07144] [ 3] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed) [0x7fc63564e76d]
[ubuntu:07144] [ 4] main() [0x400cb9]
[ubuntu:07144] *** End of error message ***

我应该提一下,当我在脚本之外调用mpirun时,一切都很完美。

0 个答案:

没有答案