开发者

MPI and D: Linker Options

开发者 https://www.devze.com 2023-03-26 10:40 出处:网络
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 translate

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 transl开发者_如何学编程ation wrong. Next question: How do to it right.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号