MPI和D:链接器选项 [英] MPI and D: Linker Options

查看:123
本文介绍了MPI和D:链接器选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将MPI与D编程语言一起使用. D完全支持C ABI,并且可以链接和调用任何C代码.我已经完成了显而易见的工作,并将MPI标头转换为D.然后,我翻译了 Wikipedia 到D.我使用以下命令对其进行了编译:

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

它在我刚运行./test并打印时起作用:

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

0: We have 1 processors

但是,当我使用mpiexec -n 8 test运行时,它什么也不打印.我的理解是MPI可执行文件需要很多奇怪的链接选项,这就是为什么存在诸如mpicc之类的工具来自动执行该过程的原因.但是,如果我尝试在D中使用MPI,这对我没有帮助.我认为这是因为我没有使用正确的链接器选项.有人可以告诉我mpicc做什么以及如何使DMD做同样的事情吗?

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?

我已经使用mpicc -showme找到了答案.这显示了mpicc转发给gcc的命令.但是,我也意识到我的头文件翻译错误.下一个问题:如何正确处理.

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.

推荐答案

mpicc是不同脚本甚至程序的通用名称. 其中有些具有-echo-show-compile-info-link-info-showme之类的选项,或者具有显示实际调用内容的环境选项.

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.

尝试检查它到底是什么

 file -k `which mpicc`

如果是脚本,则可以用sh,bash,perl,python编写.您可以轻松查看它并找到正确的选项. 如果是程序,请尝试运行

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`

有时strings可以提取控制脚本工作的选项名称和/或环境变量.

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

此外,大多数mpicc都检查CC env变量以获取编译器的名称.您可以编写脚本或程序,仅打印其参数并将CC env设置为该程序.

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.

这篇关于MPI和D:链接器选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆