windows下如何安裝OpenCL
由于我的電腦是windows10,顯卡是集顯Intel® UHD Graphics 630。
下載Intel的SDK for OpenCL,下載地址https://software.intel.com/en-us/opencl-sdk/choose-download
,也可以在我的資源里面直接下載
http://xiazai.jb51.net/202305/yuanma/intel_sdk_for_opencl_applications_283428.rar
運(yùn)行install.exe,安裝
運(yùn)行后,如果vs打開了需要關(guān)閉。
默認(rèn)安裝路徑在C:\Program Files (x86)\IntelSWTools,找到OpenCL安裝位置在C:\Program Files (x86)\IntelSWTools\system_studio_2020\OpenCL
配置環(huán)境變量,發(fā)現(xiàn)以及自動(dòng)配置到里面了
下載intel提供測(cè)試工具,下載地址:https://download.csdn.net/download/qq_36314864/87756581
然后下載了直接運(yùn)行,打印如下表示安裝成功。
自己搭建一個(gè)OpenCL工程,創(chuàng)建一個(gè)C++控制臺(tái)工程
打開配置屬性,包含OpenCL的頭文件,即將C:\Program Files (x86)\IntelSWTools\system_studio_2020\OpenCL\sdk\include
添加依賴項(xiàng),如果工程是x64,就在C:\Program Files (x86)\IntelSWTools\system_studio_2020\OpenCL\sdk\lib\x64下面,如果x86就依賴x86下面的
拷貝下面測(cè)試代碼替換helloword
#include <cstdlib> #include <iostream> #include <iomanip> #include <cstring> #include <cassert> #include <CL/cl.h> /* * 修改自官方示例intel_ocl_caps_basic_win,用于測(cè)試手工配置項(xiàng)目 */ int main() { using namespace std; const char* required_platform_subname = "Intel"; //函數(shù)返回值,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); \ } // 遍歷系統(tǒng)中所有OpenCL平臺(tái) cl_uint num_of_platforms = 0; // 得到平臺(tái)數(shù)目 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]; // 得到所有平臺(tái)的ID err = clGetPlatformIDs(num_of_platforms, platforms, 0); CAPSBASIC_CHECK_ERRORS(err); //列出所有平臺(tái) 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); // 調(diào)用兩次,第一次是得到名稱的長度 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; }
到此這篇關(guān)于windows下如何安裝OpenCL的文章就介紹到這了,更多相關(guān)windows安裝OpenCL內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
C++使用郵件槽實(shí)現(xiàn)ShellCode跨進(jìn)程傳輸
在計(jì)算機(jī)安全領(lǐng)域,進(jìn)程間通信(IPC)一直是一個(gè)備受關(guān)注的話題,在本文中,我們將探討如何使用Windows郵件槽(Mailslot)實(shí)現(xiàn)ShellCode的跨進(jìn)程傳輸,需要的可以參考下2023-12-12VSCode Linux的C++代碼格式化配置的實(shí)現(xiàn)
動(dòng)格式化代碼容易出現(xiàn)錯(cuò)誤,特別是當(dāng)代碼量較大時(shí),使用自動(dòng)格式化可以減少這種錯(cuò)誤的風(fēng)險(xiǎn),本文主要介紹了VSCode Linux的C++代碼格式化配置的實(shí)現(xiàn),感興趣的可以了解一下2023-10-10C語言使用DP動(dòng)態(tài)規(guī)劃思想解最大K乘積與乘積最大問題
Dynamic Programming動(dòng)態(tài)規(guī)劃方法采用最優(yōu)原則來建立用于計(jì)算最優(yōu)解的遞歸式,并且考察每個(gè)最優(yōu)決策序列中是否包含一個(gè)最優(yōu)子序列,這里我們就來展示C語言使用DP動(dòng)態(tài)規(guī)劃思想解最大K乘積與乘積最大問題2016-06-06詳解C++中vector的理解以及模擬實(shí)現(xiàn)
vector是表示可變大小數(shù)組的序列容器。這篇文章主要為大家詳細(xì)介紹了vector的理解以及模擬實(shí)現(xiàn),文中的示例代碼講解詳細(xì),感興趣的可以了解一下2023-03-03Matlab實(shí)現(xiàn)四種HSV色輪圖繪制的示例代碼
色輪圖就是色彩相位圖,它完整表現(xiàn)了色相環(huán)360度的全部顏色。本文將利用Matlab語言繪制四種不同的HSV色輪圖,感興趣的可以動(dòng)手嘗試一下2022-07-07