Thursday, 14 May 2015

Cuda: Finding Compute Capability of a GPU

What is Compute Capability?
           Compute capability represents the micro architecture generation of a gpu. e.g. 1.x represents Tesla micro architecture generation. Similarly 2.x represents Fermi, 3.x represents Kepler, 5.x represents Maxwell. The number before decimal point is called as major. It represents significant change in the generation of micro architecture. The number after the decimal point is called minor. It represents smaller change in the micro architecture generation. It is just like Android versions. 4.x is called Kitkat while 5.x is called Lollypop version. 4.1 and 4.2 shows the smaller changes in the Kitkat version.



Program to find Compute Capability of a current GPU:
#include<stdio.h>
#include<cuda.h>

int main()
{
    cudaDeviceProp p;
    int device_id;
    int major;
    int minor;


    cudaGetDevice(&device_id);
    cudaGetDeviceProperties(&p,device_id);

    major=p.major;
    minor=p.minor;

    printf("Name of GPU on your system is %s\n",p.name);

    printf("\n Compute Capability of a current GPU on your system is %d.%d",major,minor);

    return 0;
}



Output:
Name of GPU on your system is GeForce 210

 Compute Capability of a current GPU on your system is 1.2



Explanation
            cudaDeviceProp is a predefined structure(i.e. structure in C language) which is defined in the cuda.h header file. It has variables, which represent the information of a gpu. For e.g. name, warpSize, major, minor etc. 
cudaGetDevice() returns the id of a current gpu in the system. Id of gpu starts from 0 to n-1 where n is the total number of gpus present in the system. The gpu id is get assigned to the variable whose address is passed to cudaGetDevice() function as an argument. cudaGetDeviceProperties(&p,device_id) returns the values of properties of a gpu having id device_id. These values are get assigned to the structure variable (in this case p). p.major and p.minor gives the major and minor values of micro architecture generation of a gpu whose properties values are saved into the structure variable p.

Next: CUDA Multi-GPU : To set a GPU of required Compute Capability as current GPU

Previous: Cuda program using constant memory of a GPU





No comments:

Post a comment