简体   繁体   English

如何在Mac OS X 10.5和Ubuntu 10.4上使用OpenMP?

[英]How best do I get to use OpenMP on Mac OS X 10.5 and Ubuntu 10.4?

I'm looking at an open-source library ( DDS , a double-dummy bridge solver) which in its latest release (2.1.1) adds some very useful multi-tasking functionality requiring either a Windows system or OpenMP (indeed, that latest version won't even compile at all on a non-Windows system without full OpenMP support!-). 我正在看一个开源库( DDS ,一个双虚拟桥解算器),它在最新版本(2.1.1)中添加了一些非常有用的多任务功能,需要Windows系统 OpenMP(实际上,最新版本)如果没有完整的OpenMP支持,版本甚至根本不会在非Windows系统上编译! - )。 Ubuntu 10.4 has a package available for an older version (1.1.9), which includes the Python interface to the library ( pydds ). Ubuntu 10.4有一个可用于旧版本(1.1.9)的软件包,其中包括库的Python接口( pydds )。 I contributed to upstream long ago, but I'd really like to use (and contribute a Python interface to;-) the new functionality... but, for that, I need a C compiler and supporting libraries that will give me OpenMP functionality...! 我很久以前就为上游做出了贡献,但我真的很想使用(并提供一个Python接口;-)新功能...但是,为此,我需要一个C编译器和支持库,它将为我提供OpenMP功能...!

Plus, I need them on both Ubuntu 10.4 and my good old Intel Macs which still run Mac OS X 10.5 (to avoid losing compatibility with my good old PowerPC Macs -- but I'm not holding out for a way to get OpenMP support on those PowerPC Macs too, though of course I'd just love to... the Intel-based ones would suffice!-). 另外,我需要在Ubuntu 10.4 我仍然运行Mac OS X 10.5的旧款Intel Mac上使用它们(以避免失去与我的旧版PowerPC Mac的兼容性 - 但我并不赞成如何获得OpenMP支持那些PowerPC Mac也是如此,当然我只是喜欢......基于英特尔的那些就足够了! - )。

I fully plan to hack as much as needed (and contribute patches upstream of course once I have them working, as I've long done on all open source code I've hacked on, including DDS itself in the past;-) on DDS itself, pydds, and any ancillary functionality for them, but ... exactly because of that, I'd just love to avoid having to do a lot more "preliminary" hacking to get OpenMP support (for C) in the first place on the platforms I need it on!-). 我完全打算根据需要进行攻击(并且当我让它们正常工作时,在上游提供补丁,因为我已经对我已经攻击的所有开源代码做了很长时间,包括过去的DDS本身;-)在DDS上本身,pydds,以及他们的任何辅助功能, ......正因为如此,我只是希望避免为了获得OpenMP支持(对于C)而不得不做更多的“初步”黑客攻击我需要它的平台! - )。

So, is there (ideally!-) anything I could just apt-get install for Ubuntu 10.4, and a disk image or Darwinport or whatever for Mac OS X 10.5 at least on Intel processors, that I could use to get started...? 那么,有没有(理想情况下! - )我可以为Ubuntu 10.4 apt-get install任何东西,以及至少在英特尔处理器上用于Mac OS X 10.5的磁盘映像或Darwinport等等,我可以用来开始...... ? I'm of course ready to build-from-sources, patch sources, etc., as needed, but I'd much rather not have to, if I can avoid it...;-). 我当然准备建设,从来源,补丁源等,如需要,但我宁愿没有 ,如果我能避免它... ;-)。

On Mac OSX 10.5, it looks like -fopenmp is not a valid option (gcc version 4.0.1). 在Mac OSX 10.5上,看起来-fopenmp不是有效选项(gcc版本4.0.1)。

$ gcc -fopenmp foo.c 
cc1plus: error: unrecognized command line option "-fopenmp"

However, I was able to compile and run on 10.6 (gcc version 4.2.1). 但是,我能够在10.6(gcc版本4.2.1)上编译和运行。 So, it looks like your only options are 1) upgrade to 10.6, or 2) custom compile a version of gcc. 所以,看起来你唯一的选择是1)升级到10.6,或2)自定义编译一个版本的gcc。

(Side Note: The man page for gcc on 10.5 does not mention -fopenmp , where 10.6 does.) 旁注: 10.5上gcc的手册页没有提到-fopenmp ,其中10.6就是这样。)

As suggested by Garrett Hyde, the version of gcc that ships with Mac OS 10.5 is too old to have OpenMP support. 正如Garrett Hyde所建议的那样,Mac OS 10.5附带的gcc版本太旧而无法获得OpenMP支持。 But no problem. 但没问题。

Install MacPorts (http://trac.macports.org/wiki/InstallingMacPorts) - you'll need to have Xcode installed, and then X11, both of which you should still be able to get from the apple site if you don't still have your install media. 安装MacPorts(http://trac.macports.org/wiki/InstallingMacPorts) - 你需要安装Xcode,然后安装X11,如果你不安装它们,你仍然可以从苹果网站获得还有你的安装媒体。 Then once macports is setup, "sudo port install gcc45" (or at least 44) and wait quite a while for it to build gcc and all of its dependencies. 然后一旦设置了macports,“sudo port install gcc45”(或至少44)并等待一段时间,以便构建gcc及其所有依赖项。 Anything gcc 4.4.x or later will have pretty solid OpenMP 3.0 support. 任何gcc 4.4.x或更高版本都将拥有非常可靠的OpenMP 3.0支持。 And then you should be good to go. 然后你应该好好去。

As has been pointed out in comments, the stock gcc that comes with Ubuntu 10.4 also will work out of the box. 正如评论中指出的那样,Ubuntu 10.4附带的股票gcc也可以开箱即用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM