运行 在 32 位和 64 位处理器上混合 mpi 可执行文件
Running mixed mpi executables on 32 bit and 64 bit processors
我正在尝试使用以下 tutorial 使用 ubuntu 14.04 和 beagleboard xm 板创建一个 mpi 集群。问题是我的客户端是 beagleboard-xm,它有一个 32 位 armv7 处理器。我使用 mpic++ -o hello_world.c 创建了一个可执行文件,其内容是:
#include <mpi.h>
#include <stdio.h>
int main(int argc, char** argv) {
// Initialize the MPI environment
MPI_Init(NULL, NULL);
// Get the number of processes
int world_size;
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
// Get the rank of the process
int world_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
// Get the name of the processor
char processor_name[MPI_MAX_PROCESSOR_NAME];
int name_len;
MPI_Get_processor_name(processor_name, &name_len);
// Print off a hello world message
printf("Hello world from processor %s, rank %d"
" out of %d processors\n",
processor_name, world_rank, world_size);
// Finalize the MPI environment.
MPI_Finalize();
}
我可以在 ubuntu 14.04 (intel x86_64) 和 beagleboard-xm 上编译它。但是,当我尝试并行使用 运行 时,例如使用“mpirun -host Server,board1 ./mpi_hello_world
”,我得到
bash: orted: command not found
--------------------------------------------------------------------------
A daemon (pid 8349) died unexpectedly with status 127 while attempting
to launch so we are aborting.
我认为这是因为无法从我的服务器启动 32 位可执行文件。如果我 运行 "./mpi_hello_world 在开发板上,我会得到 "-su: ./mpi_hello_world: cannot execute binary file: Exec format error
" 。如果我在开发板上编译并尝试在服务器上 运行 它,则会发生相反的情况. 所以我的问题是我怎样才能拥有一个可以同时在我的服务器和主板上 运行 的可执行文件?
Open MPI 抱怨无法在远程主机的路径中找到 orted
。您应该修改 Beagle board 上 shell 配置文件脚本中的 PATH
变量以包含 bin
目录的路径,并修改 LD_LIBRARY_PATH
变量以包含 lib
Open MPI 安装目录。或者使用 --prefix
选项给出远程安装的路径:
mpiexec --prefix /path/to/openmpi/on/beagle ...
前缀在远程系统上设置 PATH
和 LD_LIBRARY_PATH
。请注意,库路径的最后一个组件是从本地安装复制的,例如如果 Open MPI 在 /path/to/openmpi/lib64
中有它的库(因为你的主机是 64 位的),那么它会将远程主机上的 LD_LIBRARY_PATH
设置为 /path/to/openmpi/on/beagle/lib64
,这可能是不正确的。这通常仅在 Open MPI 安装在默认系统库位置时才会引起关注,例如当从一个包安装时,并且只在某些 Linux 发行版上,特别是那些基于 RedHat 的发行版。 Ubuntu 遵循 Debian 约定,将 64 位库放在 /usr/lib
中,因此您应该仍然可以安全地使用 --prefix
机制。
由于您希望运行 程序在具有不同CPU 类型的主机上,您必须在具有--enable-heterogeneous
的两个系统上重建Open MPI 以启用对异构计算的支持。确保您没有使用 --enable-orterun-prefix-by-default
进行构建,因为它需要将 Open MPI 安装在主机和 Beagle board 上完全相同的位置。
如果两个平台上的可执行文件不共享一个公共文件系统,则无需为它们指定不同的名称,但这样做有助于防止混淆。
总结一下:
mpiexec --prefix /path/to/openmpi/on/beagle \
-H localhost -n 1 ./binary_x64 : \
-H bealgexm -n 1 ./binary_arm
这仍然假定主机上的当前目录,例如/home/user/mpitest
也存在于 Beagle 板上。如果不是,请在第二个应用程序上下文中提供 ARM 可执行文件的完整路径。
注意: Open MPI 中的异构支持是 generally broken。只有非常简单的代码才可能起作用。
我正在尝试使用以下 tutorial 使用 ubuntu 14.04 和 beagleboard xm 板创建一个 mpi 集群。问题是我的客户端是 beagleboard-xm,它有一个 32 位 armv7 处理器。我使用 mpic++ -o hello_world.c 创建了一个可执行文件,其内容是:
#include <mpi.h>
#include <stdio.h>
int main(int argc, char** argv) {
// Initialize the MPI environment
MPI_Init(NULL, NULL);
// Get the number of processes
int world_size;
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
// Get the rank of the process
int world_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
// Get the name of the processor
char processor_name[MPI_MAX_PROCESSOR_NAME];
int name_len;
MPI_Get_processor_name(processor_name, &name_len);
// Print off a hello world message
printf("Hello world from processor %s, rank %d"
" out of %d processors\n",
processor_name, world_rank, world_size);
// Finalize the MPI environment.
MPI_Finalize();
}
我可以在 ubuntu 14.04 (intel x86_64) 和 beagleboard-xm 上编译它。但是,当我尝试并行使用 运行 时,例如使用“mpirun -host Server,board1 ./mpi_hello_world
”,我得到
bash: orted: command not found
--------------------------------------------------------------------------
A daemon (pid 8349) died unexpectedly with status 127 while attempting
to launch so we are aborting.
我认为这是因为无法从我的服务器启动 32 位可执行文件。如果我 运行 "./mpi_hello_world 在开发板上,我会得到 "-su: ./mpi_hello_world: cannot execute binary file: Exec format error
" 。如果我在开发板上编译并尝试在服务器上 运行 它,则会发生相反的情况. 所以我的问题是我怎样才能拥有一个可以同时在我的服务器和主板上 运行 的可执行文件?
Open MPI 抱怨无法在远程主机的路径中找到 orted
。您应该修改 Beagle board 上 shell 配置文件脚本中的 PATH
变量以包含 bin
目录的路径,并修改 LD_LIBRARY_PATH
变量以包含 lib
Open MPI 安装目录。或者使用 --prefix
选项给出远程安装的路径:
mpiexec --prefix /path/to/openmpi/on/beagle ...
前缀在远程系统上设置 PATH
和 LD_LIBRARY_PATH
。请注意,库路径的最后一个组件是从本地安装复制的,例如如果 Open MPI 在 /path/to/openmpi/lib64
中有它的库(因为你的主机是 64 位的),那么它会将远程主机上的 LD_LIBRARY_PATH
设置为 /path/to/openmpi/on/beagle/lib64
,这可能是不正确的。这通常仅在 Open MPI 安装在默认系统库位置时才会引起关注,例如当从一个包安装时,并且只在某些 Linux 发行版上,特别是那些基于 RedHat 的发行版。 Ubuntu 遵循 Debian 约定,将 64 位库放在 /usr/lib
中,因此您应该仍然可以安全地使用 --prefix
机制。
由于您希望运行 程序在具有不同CPU 类型的主机上,您必须在具有--enable-heterogeneous
的两个系统上重建Open MPI 以启用对异构计算的支持。确保您没有使用 --enable-orterun-prefix-by-default
进行构建,因为它需要将 Open MPI 安装在主机和 Beagle board 上完全相同的位置。
如果两个平台上的可执行文件不共享一个公共文件系统,则无需为它们指定不同的名称,但这样做有助于防止混淆。
总结一下:
mpiexec --prefix /path/to/openmpi/on/beagle \
-H localhost -n 1 ./binary_x64 : \
-H bealgexm -n 1 ./binary_arm
这仍然假定主机上的当前目录,例如/home/user/mpitest
也存在于 Beagle 板上。如果不是,请在第二个应用程序上下文中提供 ARM 可执行文件的完整路径。
注意: Open MPI 中的异构支持是 generally broken。只有非常简单的代码才可能起作用。