在ubuntu上编译opencl需要什么? (和扩展,opencl期间) [英] what is needed to compile opencl on ubuntu? (and by extension, opencl period)

查看:2210
本文介绍了在ubuntu上编译opencl需要什么? (和扩展,opencl期间)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:需要标题和驱动程序是否需要,我在哪里可以使用gcc / g ++编译在Ubuntu上打开的CL?

Question: What is needed headers and drivers are needed and where would I get them for compiling open CL on ubuntu using gcc/g++?

信息:一段时间以来,我一直在试图找出如何在我的桌面上安装打开CL,如果可能我的上网本。有几个教程,我试过,但没有一个似乎工作。此外,他们只是一步一步与真正解释为什么为什么,或更糟的是他们是特定的IDE,所以你必须学习IDE,以能够做任何事情。

Info: for a while now I've been stumbling around trying to figure out how to install open CL on my desktop and if possible my netbook. There are a couple tutorials out there that I've tried but none seem to work. Also, they all just give a step by step with out really explaining why for the what, or even worse they are specific to a particular IDE so you have to learn the IDE to be able to do anything.

所以我有一个NVIDA GX465在我的桌面和集成的图形在我的上网本。我的优先级当然是我的桌面,上网本只是一个方便的开发目的(两个运行ubuntu 11.04,一旦它出来将运行11.10)。可以有人告诉我什么是需要得到它,所以我可以实际编译代码,并让它运行。

So I have an NVIDA GX465 in my desktop and integrated graphics in my netbook. my priority is of course my desktop, the netbook is just a convenience for development purposes(both run ubuntu 11.04 and will be running 11.10 as soon as it comes out). Can some one spell out for me what exactly is needed to get it so I can actually compile code and have it run. and if you could also explain what each piece does so that I can understand it's importance.

推荐答案

要编译并运行OpenCL代码, Linux,你需要四件事:

To compile and run OpenCL code under Linux, you'll need four things:

1)支持OpenCL的NVIDIA驱动程序。与Ubuntu一起打包的驱动程序有点
old,但它们仍然可以正常工作。除非你明确需要当前
驱动程序,你应该坚持用Ubuntu打包的那些。要清楚,这些是
通过受限驱动​​程序管理器安装的相同驱动程序。 OpenCL库是随驱动程序一起提供的,所以只是运行OpenCL程序驱动程序就够了。

1) An NVIDIA Driver which supports OpenCL. The drivers packaged with Ubuntu are somewhat old, but they should still work just fine. Unless you have explicit need for current drivers, you should stick with the ones packaged with Ubuntu. To be clear, these are the same drivers installed through the restricted drivers manager. OpenCL libaries are shipped with driver, so to just run OpenCL programs driver should be enough.

2)CUDA工具包。这包括编译OpenCL代码所需的头文件。将此安装到默认位置。

2) The CUDA toolkit. This includes the headers necessary to compile OpenCL code. Install this to the default location.

3)GPU计算SDK(可选)。这包括各种NVIDIA特定的支持工具以及OpenCL代码示例。

3) The GPU Computing SDK (optional). This includes various NVIDIA specific support tools, as well as OpenCL code samples.

这三个项目都可以在http://developer.nvidia.com/cuda-toolkit-40

All three of these items may be found at http://developer.nvidia.com/cuda-toolkit-40.

4)OpenCL C ++绑定(可选)。奇怪的是,它们不包括在CUDA工具包中,但是如果你使用C ++,他们可以使你的代码更可重复。您可以从 http://www.khronos.org/registry/cl/api/1.1下载/cl.hpp ,并将它放在/ usr / local / cuda / include / CL桌面。

4) OpenCL C++ bindings (optional). Strangely, they are not included with CUDA Toolkit, but in case you use C++, they could make your code much more redable. You can download them from http://www.khronos.org/registry/cl/api/1.1/cl.hpp, and just put it in /usr/local/cuda/include/CL an you desktop.

安装完成后,需要执行几个步骤才能在NVIDIA SDK之外编译和运行OpenCL。

Once these are installed, you'll need to perform a few more steps to be able to compile and run OpenCL outside of the NVIDIA SDK.

1)CUDA工具包将包含OpenCL标题在 http://www.khronos.org/registry/cl/ ),可能它们在目录/ usr / local / cuda / include / CL。为了使这些头文件系统范围广泛,你应该将这个目录链接到/ usr / include /,这样它们可以作为/ usr / include / CL / [headerfilename]被访问。不要创建符号链接,您可以将/ usr / local / cuda / include添加到您的 C_INCLUDE_PATH CPLUS_INCLUDE_PATH 环境变量,但这只能用于currest会话。

1) The CUDA toolkit will have included the OpenCL headers (Listed at http://www.khronos.org/registry/cl/), likely they are in the directory /usr/local/cuda/include/CL. To make these headers available system wide, you should link this directory into /usr/include/, such that they may be accessed as /usr/include/CL/[headerfilename]. Instead of creating a symlink, you could add /usr/local/cuda/include to your C_INCLUDE_PATH and CPLUS_INCLUDE_PATH environment variables, but this would last for only currest session.

2)确保OpenCL库(libOpenCL.so)存在于/ usr / lib中。这应该已经由驱动程序,所以你不应该做任何事情。

2) Make sure that the OpenCL library (libOpenCL.so) is present in /usr/lib. This should have been put in place by the driver, so you shouldn't have to do anything.

您已准备好编写代码。如果要使用C ++,请确保包含 CL / cl.h (或 CL / cl.hpp 版本的API)在任何C(++)程序,使得OpenCL API调用。编译时,确保链接到OpenCL库(传递gcc -lOpenCL 标志)。

You're ready to write code. Make sure to include CL/cl.h (or CL/cl.hpp if you'd like to use C++ version of API) in any C(++) program which makes OpenCL API calls. When you compile, make sure to link against the OpenCL library (pass gcc the -lOpenCL flag).

就像你的上网本,集成图形一般不支持OpenCL。理论上, AMD的APP加速支持在CPU上运行OpenCL,但是它不清楚它实际上是工作。

As far as your netbook, integrated graphics don't generally support OpenCL. In theory, AMD's APP Acceleration supports running OpenCL on the CPU, but it's not clear that it actually works.

这篇关于在ubuntu上编译opencl需要什么? (和扩展,opencl期间)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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