Lab 01 - Cihaz Sorgusu

Amaç

  • Sistemimizde bulunan CUDA uyumlu cihaz(lar) hakkında detaylı bilgi sahibi olmak.

  • Örnek CUDA kodunu derlemek.

Aşamalar

Sayfanın aşağısında görmekte olduğunuz kod, sisteminizde bulunan CUDA uyumlu cihaz hakkında şu bilgileri gösterir:

  • Grafik İşlem Biriminin adı

  • Grafik İşlem Biriminin hesaplama kapasitesi

  • Blokların maksimum boyutları

  • Örgünün maksimum boyutları

  • Grafik İşlem Biriminin bellek boyutu

  • Sabit ve paylaşımlı bellek boyutları

  • Warp boyutu

Bu noktada kodun içeriğindense üzerinde çalıştığınız sistemi tanımaya önem gösterin.

#include <iostream>
using namespace std;

//@@ The purpose of this code is to become familiar with the submission
//@@ process. Do not worry if you do not understand all the details of
//@@ the code.

int main(int argc, char **argv)
{
    int deviceCount;
    cudaGetDeviceCount(&deviceCount);

    for (int dev = 0; dev < deviceCount; dev++)
    {
        cudaDeviceProp deviceProp;
        cudaGetDeviceProperties(&deviceProp, dev);
        if (dev == 0)
        {
            if (deviceProp.major == 9999 && deviceProp.minor == 9999) {
                cout << "No CUDA GPU has been detected\n";
                return -1;
            } else if (deviceCount == 1) {
                cout << "There is 1 device supporting CUDA\n";
            } else {
                cout << "There are " << deviceCount << " devices supporting CUDA\n";
            }
        }

        cout << "Device " << dev << " name: " << deviceProp.name << "\n";
        cout << " Computational Capabilities: " << deviceProp.major << "."
            << deviceProp.minor << "\n";
        cout << " Maximum global memory size: " << deviceProp.totalGlobalMem << "\n";
        cout << " Maximum constant memory size: " << deviceProp.totalConstMem << "\n";
        cout << " Maximum shared memory size per block: "
            << deviceProp.sharedMemPerBlock << "\n";
        cout << " Maximum block dimensions: " << deviceProp.maxThreadsDim[0] << " x "
            << deviceProp.maxThreadsDim[1] << " x " << deviceProp.maxThreadsDim[2]
            << "\n";
        cout << " Maximum grid dimensions: " << deviceProp.maxGridSize[0]
            << " x " << deviceProp.maxGridSize[1] << " x "
            << deviceProp.maxGridSize[2] << "\n";
        cout << " Warp size: " << deviceProp.warpSize << "\n";
    }

    return 0;
}