OpenCL VS2008配置

转载自http://opencl.codeplex.com/wikipage?title=OpenCL%20Tutorials%20-%200&referringTitle=OpenCL%20Tutorials 

Hi,
I've decided to create this short tutorial to help programmers to setup Visual Studio 2008 as an OpenCL developement environment.
Notice that I'm using the NVIDIA version of OpenCL (CUDA SDK 3.0), installed in the default path (C:\Documents and Settings\All Users\Dados de aplicativos\NVIDIA Corporation\, which from now on will be referenced as ~\NVIDIA Corporation). If you are using ATI drivers, other NVIDIA driver or other Windows version (I'm using XP) you may have to update the paths.

1. Configuring Appearance:

1.1. OpenCL files as C++ files:
In VS2008,
- Go Tools->Options->Text Editor->File Extension, add a new extension "cl" and select Microsoft Visual C++ as Editor. This will enable C++ syntax highlighting on OpenCL files;
- If you wish, you can also add "cu" extensions for CUDA

1.2. Syntax highlighting (for OpenCL reserved words)
- This should be done using a file called "usertype.dat", located at ~\NVIDIA Corporation\NVIDIA GPU Computing SDK\OpenCL\doc, which contains all OpenCL reserved words
- Copy this file to ~\Program Files\Microsoft Visual Studio 9.0\Common7\IDE (again, it may change depending on your OS version)
- This can be done also for CUDA reserved words. CUDA configuration file is at ~\NVIDIA Corporation\NVIDIA GPU Computing SDK\C\doc\syntaxhighlighting\visualstudio_8 (its also called "usertype.dat"
- IMPORTANT NOTE: if there is already an "usertype.dat" on your VS folder (what should happen when adding CUDA and OpenCL files), you should merge both (copying the content of one and pasting at the end of the other)

2. Setting Up a Project

All you must do to use VS and OpenCL is configure correctly the dependencies. After creating a new VC project, right click on the project->properties (also available up in the menu or with the shortcut ALT+F7
1. At Configuration Properties->C++->General->Additional Include Directories add:
  • "~\NVIDIA Corporation\NVIDIA GPU Computing SDK\OpenCL\common\inc";
  • "~\NVIDIA Corporation\NVIDIA GPU Computing SDK\shared\inc";

2. At Linker->General->Additional Library Directories add:
  • "~\NVIDIA Corporation\NVIDIA GPU Computing SDK\OpenCL\common\lib";
  • "~\NVIDIA Corporation\NVIDIA GPU Computing SDK\OpenCL\common\lib\Win32"; (if you are using Windows)
  • "~\NVIDIA Corporation\NVIDIA GPU Computing SDK\shared\lib";

3. At Linker->Input->Additional Dependencies add
  • shrUtils32D.lib
  • oclUtils32D.lib
  • OpenCL.lib

3. Configuring Code Generation Properties

We're almost ready to use OpenCL now. The final step you need to do is clicking on Project->Properties, and then Configuration Properties->C/C++->Code Generation. You must assert the property "Runtime Library" is set to "Multi-threaded Debug (/MTd)". This property specifies wheter the Runtime Library will be statically or dynamically linked to your project. If your project and the libraries it uses are compiled and linked with different runtime libraries, some weird linker errors will happen. Since the '.libs' we just added uses the static runtime library, our project needs to use it as well. More information about this can be found in http://www.cs.unc.edu/~lhp/personal/how2CompileInVC.html .

It's ready. You may now be able to create and compile successfully an OpenCL project using VS2008

Feel free to contact us if you have any doubts.

Leonardo, Bruno
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值