当前位置: 首页 > news >正文

windows下安装OpenCL

由于我的电脑是windows10,显卡是集显Intel® UHD Graphics 630。

下载Intel的SDK for OpenCL,下载地址https://software.intel.com/en-us/opencl-sdk/choose-download,也可以在我的资源里面直接下载https://download.csdn.net/download/qq_36314864/87756570
在这里插入图片描述
运行install.exe,安装
在这里插入图片描述
运行后,如果vs打开了需要关闭。
在这里插入图片描述
默认安装路径在C:\Program Files (x86)\IntelSWTools,找到OpenCL安装位置在C:\Program Files (x86)\IntelSWTools\system_studio_2020\OpenCL
在这里插入图片描述
配置环境变量,发现以及自动配置到里面了
在这里插入图片描述
下载intel提供测试工具,下载地址:https://download.csdn.net/download/qq_36314864/87756581然后下载了直接运行,打印如下表示安装成功。
在这里插入图片描述
自己搭建一个OpenCL工程,创建一个C++控制台工程
在这里插入图片描述
打开配置属性,包含OpenCL的头文件,即将C:\Program Files (x86)\IntelSWTools\system_studio_2020\OpenCL\sdk\include
在这里插入图片描述
添加依赖项,如果工程是x64,就在C:\Program Files (x86)\IntelSWTools\system_studio_2020\OpenCL\sdk\lib\x64下面,如果x86就依赖x86下面的
在这里插入图片描述
在这里插入图片描述
拷贝下面测试代码替换helloword

#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <cassert>#include <CL/cl.h>/** 修改自官方示例intel_ocl_caps_basic_win,用于测试手工配置项目
*/
int main()
{using namespace std;const char* required_platform_subname = "Intel";//函数返回值,CL_SUCCESS表示成功cl_int err = CL_SUCCESS;// 判断返回值是否正确的宏
#define CAPSBASIC_CHECK_ERRORS(ERR)        \if(ERR != CL_SUCCESS)                  \{                                      \cerr                                   \<< "OpenCL error with code " << ERR    \<< " happened in file " << __FILE__    \<< " at line " << __LINE__             \<< ". Exiting...\n";                   \exit(1);                               \}// 遍历系统中所有OpenCL平台cl_uint num_of_platforms = 0;// 得到平台数目err = clGetPlatformIDs(0, 0, &num_of_platforms);CAPSBASIC_CHECK_ERRORS(err);cout << "Number of available platforms: " << num_of_platforms << endl;cl_platform_id* platforms = new cl_platform_id[num_of_platforms];// 得到所有平台的IDerr = clGetPlatformIDs(num_of_platforms, platforms, 0);CAPSBASIC_CHECK_ERRORS(err);//列出所有平台cl_uint selected_platform_index = num_of_platforms;cout << "Platform names:\n";for (cl_uint i = 0; i < num_of_platforms; ++i){size_t platform_name_length = 0;err = clGetPlatformInfo(platforms[i],CL_PLATFORM_NAME,0,0,&platform_name_length);CAPSBASIC_CHECK_ERRORS(err);// 调用两次,第一次是得到名称的长度char* platform_name = new char[platform_name_length];err = clGetPlatformInfo(platforms[i],CL_PLATFORM_NAME,platform_name_length,platform_name,NULL);CAPSBASIC_CHECK_ERRORS(err);cout << "    [" << i << "] " << platform_name;if (strstr(platform_name, required_platform_subname) &&selected_platform_index == num_of_platforms // have not selected yet){cout << " [Selected]";selected_platform_index = i;}cout << endl;delete[] platform_name;}delete[] platforms;return 0;
}

在这里插入图片描述

http://www.lryc.cn/news/66049.html

相关文章:

  • 前端项目的通用优化策略
  • 关于 IO、存储、硬盘和文件系统
  • 计算机网络期中复习提纲-酷酷的聪整理版
  • clickhouse的嵌套数据结构Tuple、Array与Nested类型介绍和使用示例
  • 人脸修复增强调研
  • 【Java】继承和多态
  • ThingsBoard集群部署之k8s
  • 【Gorm】如何在 GORM 中实现模型之间的关联?
  • Linux危险命令
  • FPGA入门系列13--异步串口通信
  • k8s基础4——deployment控制器、应用部署、升级、回滚、水平扩容缩容
  • 动态规划算法——40道leetcode实例入门到熟练
  • Nmap入门到高级【第十一章】
  • 配置本地Angular环境并使用VsCode调试Angular前端项目
  • 100ASK_全志V853-PRO开发板支持人形检测和人脸识别
  • 简单实现基于UDP与TCP的回显服务器
  • 家用洗地机有什么推荐的吗?家用洗地机哪款好
  • 深度学习与文本聚类:一篇全面的介绍与实践指南
  • AP5153 线性降压恒流驱动芯片 2.5A
  • Unity物理系统脚本编程(下)
  • 容器技术的发展
  • Python Flask request中常见存储参数的介绍
  • php+vue网盘系统的设计与实现
  • [前端]深浅拷贝
  • 文章纠错免费软件-文字校对软件免费下载
  • 【Redis】Redis缓存雪崩、缓存穿透、缓存击穿(热key问题)
  • 为什么很多程序员喜欢linux系统?
  • Bean 作用域和生命周期
  • PMP考试常见13个固定套路
  • Leecode101 ——对称二叉树