2012-04-09 55 views
1

帮助!如何在运行MPI程序时知道错误进程号?

我正在运行我的MPI代码,并返回运行时错误“一个进程终止恶劣: 正在清理......进程管理器错误等待完成”,我想弄清错误进程的数量如何?如果使用4X4(每台4台机器使用4台机器),但如果使用4X6或更多(4X8),则会出现错误。

我减少代码如下:

#include <stdio.h> 
int main(void) 
{ 
    int num,rank; 
    scanf("%d %d",&num, &rank); 
    int depth = 1; 
    int flag = 0; 
    while(num > 1) { 
     if(rank < num){ 
      flag = num % 2; 
      if(rank % 2 != 0){ 
       //MPI_Send(to (rank-1)*depth); 
       printf("Send to %d\n", (rank - 1) * depth); 
       rank *= num; 
       break; 
      } 
      else{ 
       if(!(flag && (rank == (num - 1)))) { 
        //MPI_Recv(from (rank+1)*depth); 
        printf("Recv from %d\n", (rank+1)*depth); 
       } 
       rank /= 2; 
      } 
      depth *= 2; 
     } 
     num = num/2 + flag; 
    } 
    return 0; 
} 

谢谢!

+0

你可以发布简化代码示例吗? – chrisaycock 2012-04-09 03:29:04

+0

你可以使用调试器this.check这一点:http://stackoverflow.com/questions/329259/how-do-i-debug-an-mpi-program – chemeng 2012-04-09 06:49:18

+2

'减少的代码示例'是,唉,不,一个MPI程序。你可以发布一个简化的代码示例,展示你试图消除的异常行为吗? – 2012-04-09 07:57:21

回答

0

如果问题与某些MPI错误有关,例如您尝试将消息发送给不存在的排名,则应使用MPI_Comm_create_errhandler创建自己的MPI错误处理程序。在这里您可以打印产生错误的排名的编号。不过,您必须在调试器中运行代码才能解决问题。