2013-02-06 2 views
4

에 대한 MPI : MPI and D: Linker Options이 질문은이 질문에 관련되어있는 D 프로그래밍 언어

내가 MPI 그물에서 발견되는 여러 게시물이 있습니다 D.에서 작업을 진행하려고하지만, 내가 찾은 것도 실제로는 작동하지 않았다

내가 여기 https://github.com/1100110/OpenMPI/blob/master/mpi.d에서 mpi.d을 가져다가 최소한의 프로그램 설정 :

import mpi; 
import std.stdio; 

void* MPI_COMM_WORLD = cast(void*)0; 

int main(string[] args) 
{ 

    int rank, size; 
    int argc = cast(int)args.length; 
    char *** argv = cast(char***)&args; 


    MPI_Init (&argc, argv); /* starts MPI */ 
    MPI_Comm_rank (MPI_COMM_WORLD, &rank); /* get current process id */ 
    MPI_Comm_size (MPI_COMM_WORLD, &size); /* get number of processes */ 
    writefln("Hello world from process %d of %d", rank, size); 
    MPI_Finalize(); 

    return 0; 
} 

내가

01 컴파일을 ... 그래서 여기 내가 지금까지 한 일이다

[box:1871] *** An error occurred in MPI_Comm_rank 
[box:1871] *** on communicator MPI_COMM_WORLD 
[box:1871] *** MPI_ERR_COMM: invalid communicator 
[box:1871] *** MPI_ERRORS_ARE_FATAL: your MPI job will now abort 
-------------------------------------------------------------------------- 
mpirun has exited due to process rank 0 with PID 1870 on 
node bermuda-iii exiting improperly. There are two reasons this could occur: 

1. this process did not call "init" before exiting, but others in 
the job did. This can cause a job to hang indefinitely while it waits 
for all processes to call "init". By rule, if one process calls "init", 
then ALL processes must call "init" prior to termination. 

2. this process called "init", but exited without calling "finalize". 
By rule, all processes that call "init" MUST call "finalize" prior to 
exiting or it will be considered an "abnormal termination" 

This may have caused other processes in the application to be 
terminated by signals sent by mpirun (as reported here). 
-------------------------------------------------------------------------- 
[box:01869] 1 more process has sent help message help-mpi-errors.txt/mpi_errors_are_fatal 
[box:01869] Set MCA parameter "orte_base_help_aggregate" to 0 to see all help/error messages 

은 분명히 내가 MPI_Init 및 MPI_Finalize 전화 않습니다 23,534,968,193,

또는

gdc test_mpi.d -pthread -L/usr/lib/openmpi -lmpi -ldl -lhwloc -o test_mpi 

mpirun -n 2 ./test_mpi 

이 실행 내가 얻을 오류입니다. 그래서 나는 무엇을 놓치고 있습니까?

+0

Sooo ... 내가 그곳을 떠날 때부터 아직 작동합니까? 나는 풀 요구를 받아 들인다! – 0b1100110

+0

나는 여전히 테스트 중입니다 ... 지금까지이 간단한 예제는 눈물을 흘리지만, 더 복잡한 것들은 아닙니다. 이유를 알아 내려고 노력하고 있습니다 ... – steffen

+0

당신에게 쉽다면, 어쨌든 당겨보고 보도록하겠습니다. 어쩌면 나는 그것을 발견 할 수있을 것이다. (걱정하지 않는다면 언젠가는 업데이트 할 것입니다.) – 0b1100110

답변

6

오픈 MPI C 통신기 핸들은 실제 통신기 구조에 대한 포인터입니다. MPI_COMM_WORLD은 사전 작성된 세계 전달자 구조에 대한 포인터이며 사용자가 정의 할 때 NULL 포인터가 아닙니다. 열기 MPI는 MPI_COMM_RANK에 호출에 중단 이유입니다 - 당신이 mpi.dline 808을 살펴 경우는 C.

MPI_Comm_rank(NULL, &rank)를 호출하는 것과 같습니다

, 당신은 MPI_COMM_WORLD가 이미 정의되어 있음을 알 것 같은 :

MPI_COMM_WORLD  = cast(void*) &(ompi_mpi_comm_world), 

MPI_COMM_WORLD을 다시 정의한 행을 제거하면 코드가 작동합니다.

+0

Doh! 나는 그것을 다른 버전의 mpi.d로 컴파일하기 위해 놓았습니다. 그리고 그것을 삭제하는 것을 잊었습니다! 고마워요. – steffen

3

오른쪽으로 string[]에서 char***으로 전송하지 않았습니다. 대신이 작업을 수행해야합니다 : 그것은 작동하는 방법

import std.string, std.algorithm, std.array; 

char** argv = cast(char**)map!(toStringz)(args).array.ptr; 
MPI_Init (&argc, &argv); 

은 다음과 같습니다

  • 지도 toStringzargs 요소.

  • 지도가 범위를 반환하기 때문에 array을 사용하여 배열을 배열합니다.

  • 배열 포인터 가져 오기.

+0

괄호가 누락되었습니다. 지도 전에? – steffen

+0

고마워. – Robik

+0

확인해 주셔서 감사합니다. 그러나 불행히도 그것은 문제를 해결하지 않습니다 ... : ( – steffen