linux opencl(AMD) Example
来源:互联网 发布:linux引导windows 编辑:程序博客网 时间:2024/05/21 06:42
当然,首先要安装AMD-APP-SDK和AMD的显卡驱动。我的是linux系统加AMD显卡。我下APP的地址:http://developer.amd.com/Downloads/AMD-APP-SDK-v2.7-lnx64.tgz。
搞定以后就可以开始写程序了。找到apple的一个例程:http://developer.apple.com/library/mac/#samplecode/OpenCL_Hello_World_Example/Listings/hello_c.html。
当然,我这非苹果的系统直接用这个是不行的。需要把#include <OpenCL/opencl.h>改为#include <CL/opencl.h>。apple的头文件目录和其他的平台有区别的。
好了,开始编译:
g++ -L/opt/AMDAPP/lib/x86_64 -lOpenCL -I/opt/AMDAPP/include /home/delat2/mac_square.cpp -o /home/delat2/mac_square.cpp.o
编译成功,运行看看。居然提示:Error: Failed to create a device group!看看代码,可以发现是clGetDeviceIDs这个函数返回了错误。google一下,得知
clGetDeviceIDs returns CL_SUCCESS if the function is executed successfully. Otherwise it returns the following:
CL_INVALID_PLATFORM if platform is not a valid platform.
CL_INVALID_DEVICE_TYPE if device_type is not a valid value.
CL_INVALID_VALUE if num_entries is equal to zero and device_type is not NULL or if both num_devices and device_type are NULL.
CL_DEVICE_NOT_FOUND if no OpenCL devices that matched device_type were found.
用switch case判断一下错误,说是CL_INVALID_PLATFORM。莫非我的APP-SDK还没装好?用/opt/AMDAPP/samples/opencl/bin/x86_64下的例程测试一下是可以的。google一下CL_INVALID_PLATFORM,找到了AMD的说明(http://developer.amd.com/support/KnowledgeBase/Lists/KnowledgeBase/DispForm.aspx?ID=71)。原来是新版本的SDK有几处修改。按照说明,clGetDeviceIDs的cl_platform_id参数不能为NULL。而获取platform_id的方法
cl_platform_id platform_id=NULL;
err=clGetPlatformIDs(1,&platform_id,NULL);
相应的clGetDeviceIDs改为
err = clGetDeviceIDs(platform_id, gpu ? CL_DEVICE_TYPE_GPU : CL_DEVICE_TYPE_CPU, 1, &device_id, NULL);
重新编译,运行就没出错了。
- linux opencl(AMD) Example
- Linux上使用AMD的OpenCL开发运行环境
- Linux+AMD+OpenCL配置&start-project&开启关闭X-server
- AMD OpenCL大学课程
- AMD OpenCL 大学课程
- AMD OpenCL 大学课程
- AMD OpenCL 大学课程
- 安装OpenCL和AMD驱动程序
- AMD OpenCL+VS2010+VAssistX配置
- 安装OpenCL和AMD驱动程序
- OpenCL 学习step by step (1) 安装AMD OpenCL APP
- OpenCL简测,AMD与NV平台对比
- AMD GPU+VS2010的OpenCL配置
- AMD GPU+VS2010的OpenCL配置
- AMD迎接变革:加速OpenCL的未来
- AMD迎接变革:加速OpenCL的未来
- ubuntu14.04 amd显卡 OpenCL caffe安装
- VS2010 + OpenCL 1.1 @ Windows 7 + AMD HD6870(转)
- 如何进行Sublime Text插件的升级和卸载?
- SQLite数据库存储数据
- 以太网基础
- C语言深度剖析
- 使用linux命令统计log4j业务日志信息
- linux opencl(AMD) Example
- numpy的基本操作(矩阵、文件)
- NYOJ 353 3D dungeon + zoj 1940 Dungeon Master
- OpenCL快速入门教程
- ConcurrentModificationException类详解
- hdu 1423 Greatest Common Increasing Subsequence(最长公共上升子序列、LCIS)
- GPU通用计算调研报告
- hdoj 3832 Earth Hour(最短路)
- JVM垃圾回收机制