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
運行install.exe,安裝
運行后,如果vs打開了需要關(guān)閉。
默認安裝路徑在C:\Program Files (x86)\IntelSWTools,找到OpenCL安裝位置在C:\Program Files (x86)\IntelSWTools\system_studio_2020\OpenCL
配置環(huán)境變量,發(fā)現(xiàn)以及自動配置到里面了
下載intel提供測試工具,下載地址:https://download.csdn.net/download/qq_36314864/87756581
然后下載了直接運行,打印如下表示安裝成功。
自己搭建一個OpenCL工程,創(chuàng)建一個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"; //函數(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平臺 cl_uint num_of_platforms = 0; // 得到平臺數(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]; // 得到所有平臺的ID err = 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); // 調(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)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
C++使用郵件槽實現(xiàn)ShellCode跨進程傳輸
在計算機安全領(lǐng)域,進程間通信(IPC)一直是一個備受關(guān)注的話題,在本文中,我們將探討如何使用Windows郵件槽(Mailslot)實現(xiàn)ShellCode的跨進程傳輸,需要的可以參考下2023-12-12VSCode Linux的C++代碼格式化配置的實現(xiàn)
動格式化代碼容易出現(xiàn)錯誤,特別是當代碼量較大時,使用自動格式化可以減少這種錯誤的風險,本文主要介紹了VSCode Linux的C++代碼格式化配置的實現(xiàn),感興趣的可以了解一下2023-10-10C語言使用DP動態(tài)規(guī)劃思想解最大K乘積與乘積最大問題
Dynamic Programming動態(tài)規(guī)劃方法采用最優(yōu)原則來建立用于計算最優(yōu)解的遞歸式,并且考察每個最優(yōu)決策序列中是否包含一個最優(yōu)子序列,這里我們就來展示C語言使用DP動態(tài)規(guī)劃思想解最大K乘積與乘積最大問題2016-06-06