MPI and D: Linker Options
Asked Answered
S

1

10

I'm trying to use MPI with the D programming language. D fully supports the C ABI and can link with and call any C code. I've done the obvious stuff and translated the MPI header to D. I then translated a test program from Wikipedia to D. I compiled it with the following command:

dmd test.d -L-lmpistubs

It works when I just run ./test, and prints:

0: We have 1 processors

However, when I run with mpiexec -n 8 test, it prints nothing. My understanding is that MPI executables require a bunch of weird linking options, which is why tools like mpicc exist to automate the process. However, this doesn't help me if I'm trying to use MPI in D. I assume it's because I'm not using the right linker options. Can someone please tell me what mpicc does and how I can make DMD do the same thing?

Edit: I've found the answer using mpicc -showme. This shows what commands mpicc forwards to gcc. However, I also realized I did the header file translation wrong. Next question: How do to it right.

Sites answered 4/8, 2011 at 16:1 Comment(2)
did you use extern(C) when you were translating?Peafowl
have you tried running strace -f mpicc test.c or something like that, to look for the linker options? I assume it's calling ld or something as a child process.Gull
G
2

mpicc is common name of different scripts and even programs. Some of them have option like -echo, -show, -compile-info, -link-info or -showme or environment option to show what is actually called.

Try to check what is it actually with

 file -k `which mpicc`

If it is script, it can be written in sh, bash, perl, python. You can easily view it and find correct option. If it is an program, try to run

 strings `which mpicc`

Sometimes strings can extract option names and/or environment variables which controls the work of script.

Also, most of mpicc check CC env variable to get name of compiler. You can write a script or a program which will just print its arguments and set CC env to this program.

Gunwale answered 4/8, 2011 at 18:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.