在32位和64位处理器上运行混合的mpi可执行文件

Running mixed mpi executables on 32 bit and 64 bit processors

本文关键字:混合 mpi 可执行文件 运行 32位 64位 处理器      更新时间:2023-10-16

我正在尝试使用下面的教程使用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 processorsn",
           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板上shell概要文件脚本中的PATH变量,使其包含Open MPI安装的bin目录的路径,并修改LD_LIBRARY_PATH变量,使之包含Open MPI的lib目录的路径。或者使用--prefix选项提供远程安装的路径:
mpiexec --prefix /path/to/openmpi/on/beagle ...

Prefix在远程系统上同时设置PATHLD_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板上完全相同的位置。

如果两个平台上的可执行文件不共享一个公共文件系统,则不需要为它们指定不同的名称,但这样做有助于防止混淆。

总结:

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中的异构支持通常已中断。只有非常简单的代码才可能工作。