OpenCL教程 第一章 环境搭建-AMD显卡篇(中)

第一章 环境搭建(AMD显卡)

准备工具

AMD WX3100显卡驱动:https://support.amd.com/zh-cn/download/
AMD-APP-SDK-v2.9http://www.pan66.com/show/2169430.html

显卡环境搭建

第一步:显卡驱动安装

显卡型号:WX3100
从官网下载AMD显卡驱动并正确安装

第二步:AMD-APP-SDK安装

安装AMD-APP-SDK-v2.9
双击运行
这里写图片描述
默认安装即可

第三步:配置VS

(1)首先新建一个空的工程并取名为Template

(2)选择 项目->属性
这里写图片描述

(3)选择 C/C++->常规->附加包含目录
这里写图片描述
添加$(AMDAPPSDKROOT)\include
这里写图片描述

(4)选择 链接器->常规->附加库目录
这里写图片描述
添加$(AMDAPPSDKROOT)\lib\x86
这里写图片描述

(5)选择 链接器->输入->附加依赖项
这里写图片描述
添加OpenCL.lib
这里写图片描述

第四步:验证工程

(1)添加main.cpp源文件,并将文件内容修改为如下

#include <iostream>
#include <string>
#include "CL\opencl.h"using namespace std;
​
string getPlatformName(const cl_platform_id pid){
    size_t param_value_size;
    clGetPlatformInfo(pid, CL_PLATFORM_NAME, 0, NULL, &param_value_size);
    char *param_value = new char[param_value_size];
    clGetPlatformInfo(pid, CL_PLATFORM_NAME, param_value_size, param_value, NULL);
    return param_value;
}
int main(){
    cl_uint num_platforms;
    clGetPlatformIDs(0, NULL, &num_platforms);
    cl_platform_id *platforms = new cl_platform_id[num_platforms];
    clGetPlatformIDs(num_platforms, platforms, NULL);
    for (cl_uint i = 0; i < num_platforms; i++){
        string platname = getPlatformName(platforms[i]);
        cout << "<" << i << "> " << "Platform name is :" << platname << endl;
    }
    return 0;
}

执行工程
这里写图片描述
如果环境配置正常将会出现上面的结果,到这里AMD显卡配置OpenCL开发环境就完成了

猜你喜欢

转载自blog.csdn.net/dh653667765/article/details/80930278