2014-01-24 2 views
0

나는 다음과 같은 코드가 있습니다 MPI_Waitall 오류가 : 매핑 된 주소는 아니다

#include <stdio.h> 
#include <stdlib.h> 
#include <string.h> 
#include <mpi.h> 

static int rank, size; 

char msg[] = "This is a test message"; 

int main(int argc, char **argv) { 
    MPI_Init(&argc, &argv); 

    MPI_Comm_rank(MPI_COMM_WORLD, &rank); 
    MPI_Comm_size(MPI_COMM_WORLD, &size); 

    if (size != 2) { 
     fprintf(stderr, "This test requires exactly 2 tasks (has: %d).\n", size); 
     MPI_Finalize(); 
     return -1; 
    } 

    int run = 1; 
    if (argc > 1) { 
     run = atoi(argv[1]); 
    } 

    int len = strlen(msg) + 1; 
    if (argc > 2) { 
     len = atoi(argv[2]); 
    } 

    char buf[len]; 

    strncpy(buf, msg, len); 

    MPI_Status statusArray[run]; 

    MPI_Request reqArray[run]; 


    double start = MPI_Wtime(); 

    for (int i = 0; i < run; i++) { 
     if (!rank) { 
      MPI_Isend(buf, len, MPI_CHAR, 1, 0, MPI_COMM_WORLD, &reqArray[i]); 
      printf("mpi_isend for run %d\n", i); 
     } else { 
      MPI_Irecv(buf, len, MPI_CHAR, 0, 0, MPI_COMM_WORLD, &reqArray[i]); 
      printf("mpi_irecv for run %d\n", i); 
     } 
    } 
    int buflen = 512; 
    char name[buflen]; 
    gethostname(name, buflen); 
    printf("host: %s has rank %d\n", name, rank); 
    printf("Reached here! for host %s before MPI_Waitall \n", name); 
    if(!rank) { 
     printf("calling mpi_waitall for sending side which is %s\n", name); 
     MPI_Waitall(run, &reqArray[0], &statusArray[0]); 
    } 
    else { 
     printf("calling mpi_waitall for receiving side which is %s\n", name); 
     MPI_Waitall(run, &reqArray[0], &statusArray[0]); 
    } 
    printf("finished waiting! for host %s\n", name); 
    double end = MPI_Wtime(); 
    if (!rank) { 
     printf("Throughput: %.4f Gbps\n", 1e-9 * len * 8 * run/(end - start)); 
    } 

    MPI_Finalize(); 
} 

내가 MPI_Waitall 전에 송신 측에 SEG-오류를 가지고 있습니다. 오류 메시지는 다음과 같습니다

[host1:27679] *** Process received signal *** 
[host1:27679] Signal: Segmentation fault (11) 
[host1:27679] Signal code: Address not mapped (1) 
[host1:27679] Failing at address: 0x8 
[host1:27679] [ 0] /lib64/libpthread.so.0() [0x3ce7e0f500] 
[host1:27679] [ 1] /usr/lib64/openmpi/mca_btl_openib.so(+0x21dc7) [0x7f46695c1dc7] 
[host1:27679] [ 2] /usr/lib64/openmpi/mca_btl_openib.so(+0x1cbe1) [0x7f46695bcbe1] 
[host1:27679] [ 3] /lib64/libpthread.so.0() [0x3ce7e07851] 
[host1:27679] [ 4] /lib64/libc.so.6(clone+0x6d) [0x3ce76e811d] 
[host1:27679] *** End of error message *** 

내가 MPI_Request의 배열에 문제가 있다고 생각합니다. 누군가 그것을 지적 할 수 있을까요? 감사합니다.

+0

실패한 경우'run'의 값은 무엇입니까? –

답변

2

문제없이 프로그램을 실행했습니다 (unistd.h을 포함하지 않는 경고 제외). 이 문제는 아마도 Open MPI 설정과 관련이 있습니다. InfiniBand 네트워크가있는 컴퓨터를 사용하고 있습니까? 그렇지 않다면 기본 tcp 구현을 사용하기 위해 변경하려고합니다. 귀하의 문제는 그와 관련이있을 수 있습니다. 당신은 TCP를 사용합니다 지정하려면

, 당신은 다음과 같이 실행해야합니다 : 그의 OpenIB을 보장

mpirun --mca btl tcp,self -n 2 <prog_name> <prog_args> 

실수로 감지가 안 될 때 사용되지 않습니다.

InfiniBand를 사용하려는 경우 Open MPI에서 문제가 발생했을 수 있습니다. 나는 당신이 아무것도 공상적으로하지 않고 있기 때문에 그것이 사실이라고 의심 스럽다.

+0

예, IB 네트워크가있는 컴퓨터에서 실행 중이며 해당 인터페이스를 사용하려고합니다. – Ra1nWarden

+0

그럴 경우 Open MPI와 관련이있을 것입니다. Open MPI 태그를 추가하기 위해이 질문에 태그를 다시 지정 했으므로 그 중 한 사람이 곧 와서 도움을 줄 수 있기를 바랍니다. –

+0

여기에 응답이 없으면 Open MPI 사용자 메일 링리스트 (http://www.open-mpi.org/community/lists/ompi.php)에 질문을 올릴 수도 있습니다. –