1. 程式人生 > >編寫cuda程式碼檢視自己機器的顯示卡資訊

編寫cuda程式碼檢視自己機器的顯示卡資訊

程式碼如下:

cudaDeviceProp 是一個結構體,一些引數就是cudaDeviceProp 結構體中的引數。cudaGetDeviceProperties(&cudade,0);這個函式就是例項化,第一個引數就是例項化,第二個引數是哪一個顯示卡,預設0是第一塊顯示卡,1為第二塊顯示卡,以此類推。

#include <cuda_runtime.h>
#include <stdio.h>
#include <iostream>

int main()
{
    cudaDeviceProp cudade;
    cudaGetDeviceProperties(&cudade,0);
    std::cout << "GPU型號: " << cudade.name << std::endl;
    std::cout << "每塊全域性記憶體儲存容量(B): " << cudade.totalGlobalMem << std::endl;
    std::cout << "每塊共享記憶體儲存容量(B): "<< cudade.sharedMemPerBlock << std::endl;
    std::cout << "每塊註冊器數量: " << cudade.regsPerBlock << std::endl;
    std::cout << "WarpSize:  " << cudade.warpSize << std::endl;
    std::cout << "最大記憶體複製步長:  " << cudade.memPitch << std::endl;
    std::cout << "每塊最大執行緒數量:  " << cudade.maxThreadsPerBlock << std::endl;
    std::cout << "執行緒塊三維: " << cudade.maxThreadsDim << std::endl;
    std::cout << "執行緒格三維: " << cudade.maxGridSize << std::endl;
    std::cout << "計算核心時鐘頻率(kHz):  " << cudade.clockRate << std::endl;
    std::cout << "常量儲存容量:  " << cudade.totalConstMem << std::endl;
    std::cout << "次計算能力(小數點後的值): " << cudade.minor << std::endl;
    std::cout << "紋理對齊要求: " << cudade.textureAlignment << std::endl;
    std::cout << "繫結到等步長記憶體的紋理滿足的要求: " << cudade.texturePitchAlignment << std::endl;
    std::cout << "GPU是否支援併發記憶體複製和kernel執行: " << cudade.deviceOverlap << std::endl;
    std::cout << "SMX數量:  " << cudade.multiProcessorCount << std::endl;
    std::cout << "是否有執行時限制:  " << cudade.kernelExecTimeoutEnabled << std::endl;
    std::cout << "裝置是否整合(否則獨立):  " << cudade.integrated << std::endl;
    std::cout << "可否對主機記憶體進行對映: " << cudade.canMapHostMemory << std::endl;
    std::cout << "計算模式: " << cudade.computeMode << std::endl;
    std::cout << "最大1D紋理尺寸:  " << cudade.maxTexture1D << std::endl;
    std::cout << "線性記憶體相關的最大1D紋理尺寸:  " << cudade.maxTexture1DLinear << std::endl;
    std::cout << "最大2D紋理維度:  " << cudade.maxTexture2D << std::endl;
    std::cout << "最大2D紋理維度(width,height,pitch): " << cudade.maxTexture2DLinear << std::endl;
    std::cout << "紋理聚集時的最大紋理維度: " << cudade.maxTexture2DGather << std::endl;
    std::cout << "最大3D紋理維度: " << cudade.maxTexture3D << std::endl;
    std::cout << "最大立方圖紋理維度: " << cudade.maxTextureCubemap << std::endl;
    std::cout << "最大1D分層紋理維度:  " << cudade.maxTexture1DLayered << std::endl;
    std::cout << "最大2D分層紋理維度:  " << cudade.maxTexture2DLayered << std::endl;
    std::cout << "最大立方圖分層紋理維度:  " << cudade.maxTextureCubemapLayered << std::endl;
    std::cout << "最大1D表面尺寸: " << cudade.maxSurface1D << std::endl;
    std::cout << "主計算能力(小數點前的值):  " << cudade.major << std::endl;
    std::cout << "最大2D表面維度: " << cudade.maxSurface2D << std::endl;
    std::cout << "最大3D表面維度:  " << cudade.maxSurface3D << std::endl;
    std::cout << "最大1D分層表面維度:  " << cudade.maxSurface1DLayered << std::endl;
    std::cout << "最大2D分層表面維度:  " << cudade.maxSurface2DLayered << std::endl;
    std::cout << "最大立方圖表面維度: " << cudade.maxSurfaceCubemap << std::endl;
    std::cout << "表面對齊要求: " << cudade.surfaceAlignment << std::endl;
    std::cout << "裝置能併發的kernel數量: " << cudade.concurrentKernels << std::endl;
    std::cout << "是否開啟ECC校驗: " << cudade.ECCEnabled << std::endl;
    std::cout << "PCI匯流排ID:  " << cudade.pciBusID << std::endl;
    std::cout << "PCI裝置ID:  " << cudade.pciDeviceID << std::endl;
    std::cout << "PCI域ID:  " << cudade.pciDomainID << std::endl;
    std::cout << "是否支援TCC(Tesla叢集): " << cudade.tccDriver << std::endl;
    std::cout << "非同步引擎數量: " << cudade.asyncEngineCount << std::endl;
    std::cout << "主機和裝置共享同一地址空間:  " << cudade.unifiedAddressing << std::endl;
    std::cout << "儲存時鐘頻率:  " << cudade.memoryClockRate << std::endl;
    std::cout << "Global memory 匯流排頻寬:  " << cudade.memoryBusWidth << std::endl;
    std::cout << "L2 Cache尺寸(B):  " << cudade.l2CacheSize << std::endl;
    std::cout << "每個SMX駐留的最大執行緒數量:  " << cudade.maxThreadsDim << std::endl;
}