この質問は、次の質問に関連しています: MPI and D: Linker Options
私は D から MPI を動作させようとしています。ネットにはいくつかの投稿がありますが、実際に機能したものはありませんでした.
ここ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;
}
私はコンパイルします
dmd test_mpi.d -L-L/usr/lib/openmpi -L-lmpi -L-ldl -L-lhwloc
また
gdc test_mpi.d -pthread -L/usr/lib/openmpi -lmpi -ldl -lhwloc -o test_mpi
そして一緒に走る
mpirun -n 2 ./test_mpi
これは私が得るエラーです:
[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 を呼び出します。それで、私は何が欠けていますか?