CUDA入門2 獲取顯示卡引數

2021-08-13 09:12:08 字數 1480 閱讀 4510

#ifndef _cudainput_h_

#define _cudainput_h_

#include "cuda_runtime.h"

#include "device_launch_parameters.h"

#include

typedef enum ci_result;

class

input_engine ;

#endif // !_cuda_h_

這是為了防止該標頭檔案被重複引用,具體內容可見《#ifndef/#define/#endif使用詳解》。

typedef enum ci_result;
這是和公司影象大神學的程式設計規範,用來簡化**的return,個人感覺很有效果。

ci_result initcuda();
其具體實現接下來說明。另外這裡有char*型別,是為具體實現中的printf()使用。stdio.h標頭檔案與printf()有關。

#include "cuda.cuh"

ci_result input_engine::initcuda()

cudadeviceprop prop; //獲得顯示卡狀態

for (int i = 0; i < count; i++)

if (prop.major < 3)

if (cudasetdevice(0) != cudasuccess)

return ci_ok;}}

#include "cuda.cuh"
這裡需要注意的是預設使用第乙個顯示卡,如果是多顯示卡的話需要做額外的處理。

#include "cuda.cuh"

#include

void printf_usage()

int main()

return

0;}

#include "cuda.cuh"

#include

conio.h與下文_getch()方法有關。

int main()
這時候如果直接執行程式會出現視窗一閃而過的情況。就需要一種方法讓視窗一直顯示,直到觸發某件事再退出。

start:

if ('q' != _getch())

這裡意思是如果鍵盤按下去的不是q,就去執行start,結果就是這個方法被迴圈執行,實現顯示視窗的功能。而printf_usage()方法是為了給使用者提示。

至此,執行就可以獲取顯示卡詳細資訊。

05 struts2中獲取請求引數

v jsp m action c action strutsprepareandexecutefilter jsp表單 loginaction中 private string username private string password public string getusername pub...

Struts2 獲取客戶端請求引數

struts2是乙個優秀的mvc model view controller 框架,其中客戶端請求引數在mvc架構中作為model的屬性存在。struts2框架有兩種方式獲取客戶端請求的引數。1 通過屬性驅動的方式獲取客戶端請求的引數 將action類作為model的方式 1 將pojo類作為act...

Python 爬蟲入門2 獲取搜狗的搜尋結果

usr bin env python coding utf 8 需求 爬取搜狗首頁的頁面資料 noinspection pyunresolvedreferences import requests if name main ua偽裝 將訪問物件偽裝為瀏覽器 headers 爬蟲主體 url 1.處理...