1

我在 ThinkPad T420(Core i5 2450M,升级到 8GB RAM)中有 Manjaro Linux 17.1.10(内核 4.17.0-2),我正在尝试使用 OpenMPI(版本 3.1.0)运行一些 C 程序,但我' m 在运行程序时遇到问题。

我能够从终端使用mpicc和 Ecplipse 的“构建”选项编译它们而不会出现问题,但是当我尝试从终端或在 Eclipse 中运行它们时(在启动选项中配置为并行应用程序)我遇到错误,无论我运行的代码。

我正在尝试运行 Ecipse Parallel 附带的 MPI hello world C 项目:

/*
 ============================================================================
 Name        : test.c
 Author      : MGMX
 Version     : 1
 Copyright   : GNU 3.0
 Description : Hello MPI World in C 
 ============================================================================
 */
#include <stdio.h>
#include <string.h>
#include "mpi.h"

int main(int argc, char* argv[]){
    int  my_rank; /* rank of process */
    int  p;       /* number of processes */
    int source;   /* rank of sender */
    int dest;     /* rank of receiver */
    int tag=0;    /* tag for messages */
    char message[100];        /* storage for message */
    MPI_Status status ;   /* return status for receive */

    /* start up MPI */

    MPI_Init(&argc, &argv);

    /* find out process rank */
    MPI_Comm_rank(MPI_COMM_WORLD, &my_rank); 

    /* find out number of processes */
    MPI_Comm_size(MPI_COMM_WORLD, &p); 


    if (my_rank !=0){
        /* create message */
        sprintf(message, "Hello MPI World from process %d!", my_rank);
        dest = 0;
        /* use strlen+1 so that '\0' get transmitted */
        MPI_Send(message, strlen(message)+1, MPI_CHAR,
           dest, tag, MPI_COMM_WORLD);
    }
    else{
        printf("Hello MPI World From process 0: Num processes: %d\n",p);
        for (source = 1; source < p; source++) {
            MPI_Recv(message, 100, MPI_CHAR, source, tag,
                  MPI_COMM_WORLD, &status);
            printf("%s\n",message);
        }
    }
    /* shut down MPI */
    MPI_Finalize(); 


    return 0;
}

如果我使用./test没有参数的简单程序运行程序,我有一个输出:

[mgmx@ThinkPad Debug]$ ./test
Hello MPI World From process 0: Num processes: 1

但是如果我使用mpirun我会得到不同的结果,具体取决于我选择的 pof process ( -np #) 数量;但他们都抛出错误:

[mgmx@ThinkPad Debug]$ mpirun -np 0 test
-------------------------------------------------------
Primary job  terminated normally, but 1 process returned
a non-zero exit code. Per user-direction, the job has been aborted.
-------------------------------------------------------
[mgmx@ThinkPad Debug]$ mpirun -np 1 test
-------------------------------------------------------
Primary job  terminated normally, but 1 process returned
a non-zero exit code. Per user-direction, the job has been aborted.
-------------------------------------------------------
--------------------------------------------------------------------------
mpirun detected that one or more processes exited with non-zero status, thus causing
the job to be terminated. The first process to do so was:

  Process name: [[49948,1],0]
  Exit code:    1
--------------------------------------------------------------------------
[mgmx@ThinkPad Debug]$ mpirun -np 2 test
-------------------------------------------------------
Primary job  terminated normally, but 1 process returned
a non-zero exit code. Per user-direction, the job has been aborted.
-------------------------------------------------------
[mgmx@ThinkPad Debug]$ mpirun -np 3 test
--------------------------------------------------------------------------
There are not enough slots available in the system to satisfy the 3 slots
that were requested by the application:
  test

Either request fewer slots for your application, or make more slots available
for use.
--------------------------------------------------------------------------
[mgmx@ThinkPad Debug]$ mpirun -np 4 test
--------------------------------------------------------------------------
There are not enough slots available in the system to satisfy the 4 slots
that were requested by the application:
  test

Either request fewer slots for your application, or make more slots available
for use.
--------------------------------------------------------------------------

我在本地运行一切。

这是--versionmpicc 和 mpirun 中的输出:

[mgmx@ThinkPad Debug]$ mpicc --version
gcc (GCC) 8.1.1 20180531
Copyright (C) 2018 Free Software Foundation, Inc.
Esto es software libre; vea el código para las condiciones de copia.  NO hay
garantía; ni siquiera para MERCANTIBILIDAD o IDONEIDAD PARA UN PROPÓSITO EN
PARTICULAR

[mgmx@ThinkPad Debug]$ mpirun --version
mpirun (Open MPI) 3.1.0

Report bugs to http://www.open-mpi.org/community/help/

还有 Eclipse 的“关于”窗口

我还以各种方式安装了 OpenMPI:使用 pacman 从 Manjaro 存储库,使用 pamac(pacman/yaourt GUI)和使用 yaourt 和 pamac 的 AUR 的 git 版本。

4

0 回答 0