如何在Ubuntu上编译OpenCL? [英] How to compile OpenCL on Ubuntu?

查看:94
本文介绍了如何在Ubuntu上编译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.

推荐答案

要在Linux上编译和运行OpenCL代码,您需要做四件事:

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

1)一个支持OpenCL的NVIDIA驱动程序. Ubuntu随附的驱动程序有点 旧的,但它们仍然可以正常工作.除非您有明确的需求 驱动程序,您应该坚持使用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 Toolkit中,但是如果您使用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_PATHCPLUS_INCLUDE_PATH 环境变量,但这仅适用于当前会话.

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)确保/usr/lib中存在OpenCL库(libOpenCL.so).这应该由驾驶员来完成,所以您不必做任何事情.

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.

您已经准备好编写代码.确保在进行OpenCL API调用的任何C(++)程序中都包含CL/cl.h(如果要使用API​​的C ++版本,则包含CL/cl.hpp).编译时,请确保链接到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加速支持运行OpenCL在CPU上运行,但尚不清楚它是否可以正常工作.

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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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