官术网_书友最值得收藏!

Accessing GPU device properties from CUDA programs

CUDA provides a simple interface to find the information such as determining which CUDA-enabled GPU devices (if any) are present and what capabilities each device supports. First, it is important to get a count of how many CUDA-enabled devices are present on the system, as a system may contain more than one GPU-enabled device. This count can be determined by the CUDA API cudaGetDeviceCount(). The program for getting a number of CUDA enabled devices on the system is shown here:

#include <memory>
#include <iostream>
#include <cuda_runtime.h>
// Main Program
int main(void)
{
int device_Count = 0;
cudaGetDeviceCount(&device_Count);
// This function returns count of number of CUDA enable devices and 0 if there are no CUDA capable devices.
if (device_Count == 0)
{
printf("There are no available device(s) that support CUDA\n");
}
else
{
printf("Detected %d CUDA Capable device(s)\n", device_Count);
}
}

The relevant information about each device can be found by querying the cudaDeviceProp structure, which returns all the device properties. If you have more than one CUDA-capable device, then you can start a for loop to iterate over all device properties. The following section contains the list of device properties divided into different sets and small code snippets used to access them from CUDA programs. These properties are provided by the cudaDeviceProp structure in CUDA 9 runtime. 

For more details about properties in the different versions of CUDA, you can check the programming guide for a particular version.
主站蜘蛛池模板: 蓝田县| 蚌埠市| 金阳县| 宁远县| 海门市| 平塘县| 土默特右旗| 山阳县| 新民市| 横峰县| 壤塘县| 峨山| 土默特右旗| 虞城县| 惠水县| 阿克陶县| 微山县| 马尔康县| 西畴县| 留坝县| 柞水县| 区。| 新晃| 正蓝旗| 庄河市| 司法| 开远市| 九龙坡区| 五指山市| 宝鸡市| 重庆市| 长子县| 中阳县| 卓资县| 乐亭县| 泽普县| 揭阳市| 化隆| 桐庐县| 溧水县| 武穴市|