【CUDA编程4】获取device详细信息
CUDA编程,从某种意义而言,可以划分为异构系统编程,其实是一个CPU+GPU模式。其中,CPU被称为Host,而GPU被称为Device。
#include <cuda_runtime.h>
#include <stdio.h>int main(int argc,char** argv)
{int deviceCount = 0;cudaError_t error_id = cudaGetDeviceCount(&deviceCount);if(error_id!=cudaSuccess){printf("cudaGetDeviceCount returned %d\n ->%s\n",(int)error_id,cudaGetErrorString(error_id));printf("Result = FAIL\n");exit(EXIT_FAILURE);}if(deviceCount==0){printf("There are no available device(s) that support CUDA\n");}else{printf("Detected %d CUDA Capable device(s)\n",deviceCount);}int dev=0, driverVersion=0, runtimeVersion=0;cudaSetDevice(dev);cudaDeviceProp deviceProp;cudaGetDeviceProperties(&deviceProp,dev);printf("Device %d:\"%s\"\n",dev,deviceProp.name);cudaDriverGetVersion(&driverVersion);cudaRuntimeGetVersion(&runtimeVersion);printf(" CUDA Driver Version / Runtime Version %d.%d / %d.%d\n",driverVersion/1000,(driverVersion%100)/10,runtimeVersion/1000,(runtimeVersion%100)/10);printf(" CUDA Capability Major/Minor version number: %d.%d\n",deviceProp.major,deviceProp.minor);printf(" Total amount of global memory: %.2f GBytes (%llu bytes)\n",(float)deviceProp.totalGlobalMem/pow(1024.0,3),deviceProp.totalGlobalMem);printf(" GPU Clock rate: %.0f MHz (%0.2f GHz)\n",deviceProp.clockRate*1e-3f,deviceProp.clockRate*1e-6f);printf(" Memory Bus width: %d-bits\n",deviceProp.memoryBusWidth);if (deviceProp.l2CacheSize){printf(" L2 Cache Size: %d bytes\n",deviceProp.l2CacheSize);}printf(" Max Texture Dimension Size (x,y,z) 1D=(%d),2D=(%d,%d),3D=(%d,%d,%d)\n",deviceProp.maxTexture1D,deviceProp.maxTexture2D[0],deviceProp.maxTexture2D[1],deviceProp.maxTexture3D[0],deviceProp.maxTexture3D[1],deviceProp.maxTexture3D[2]);printf(" Max Layered Texture Size (dim) x layers 1D=(%d) x %d,2D=(%d,%d) x %d\n",deviceProp.maxTexture1DLayered[0],deviceProp.maxTexture1DLayered[1],deviceProp.maxTexture2DLayered[0],deviceProp.maxTexture2DLayered[1],deviceProp.maxTexture2DLayered[2]);printf(" Total amount of constant memory %lu bytes\n",deviceProp.totalConstMem);printf(" Total amount of shared memory per block: %lu bytes\n",deviceProp.sharedMemPerBlock);printf(" Total number of registers available per block:%d\n",deviceProp.regsPerBlock);printf(" Wrap size: %d\n",deviceProp.warpSize);printf(" Maximun number of thread per multiprocesser: %d\n",deviceProp.maxThreadsPerMultiProcessor);printf(" Maximun number of thread per block: %d\n",deviceProp.maxThreadsPerBlock);printf(" Maximun size of each dimension of a block: %d x %d x %d\n",deviceProp.maxThreadsDim[0],deviceProp.maxThreadsDim[1],deviceProp.maxThreadsDim[2]);printf(" Maximun size of each dimension of a grid: %d x %d x %d\n",deviceProp.maxGridSize[0],deviceProp.maxGridSize[1],deviceProp.maxGridSize[2]);printf(" Maximu memory pitch %lu bytes\n",deviceProp.memPitch);printf("----------------------------------------------------------\n");printf("Number of multiprocessors: %d\n", deviceProp.multiProcessorCount);printf("Total amount of constant memory: %4.2f KB\n",deviceProp.totalConstMem/1024.0);printf("Total amount of shared memory per block: %4.2f KB\n",deviceProp.sharedMemPerBlock/1024.0);printf("Total number of registers available per block: %d\n",deviceProp.regsPerBlock);printf("Warp size %d\n", deviceProp.warpSize);printf("Maximum number of threads per block: %d\n", deviceProp.maxThreadsPerBlock);printf("Maximum number of threads per multiprocessor: %d\n",deviceProp.maxThreadsPerMultiProcessor);printf("Maximum number of warps per multiprocessor: %d\n",deviceProp.maxThreadsPerMultiProcessor/32);return EXIT_SUCCESS;
}
将上述代码保存为device_info.cu,然后编译运行:
nvcc -o device_info device_info.cu
./device_info
输出为:
【CUDA编程4】获取device详细信息相关推荐
- java获取主机信息大全,网络编程:Java获取网络主机信息
java.net.InetAddress类表示互联网协议 (IP) 地址. 有两个子类:Inet4Address, Inet6Address 通过 InetAddress可以方便获取一个域名下的IP, ...
- PHP 获取服务器详细信息
PHP 获取系统信息,PHP 获取服务器详细信息 获取系统类型及版本号: php_uname() (例:Windows NT ...
- 淘宝/天猫API接口,item_sku - 淘宝商品SKU详细信息查询,淘宝/天猫获取sku详细信息 API 返回值说明
欢迎使用淘宝API接口(item_sku - 淘宝商品SKU详细信息查询 ) 你好! 这是你使用我们的淘宝API接口获取商品详细接口说明. 测试地址:获取Key和secret 测试结果: Reques ...
- 淘宝API接口:获取sku详细信息
今天分享的是淘宝平台API,item_sku - 获取sku详细信息 点击注册测试地址(获取Key和secret) { "item": { "num_iid": ...
- 微信小程序控制台 报错 对应的服务器证书无效 控制台输入 showRequestInfo() 可以获取更详细信息 原因是ssl证书过期 重新申请即可
微信小程序控制台 报错 对应的服务器证书无效.控制台输入 showRequestInfo() 可以获取更详细信息 报错原因:域名下的SSL证书过期 我这边报错的原因是ssl证书过期 重新申请后就好了, ...
- NX二次开发-UFUN获取工程图详细信息UF_DRAW_ask_drawing_info
NX二次开发-UFUN获取工程图详细信息UF_DRAW_ask_drawing_info NX9+VS2012#include <uf.h> #include <uf_draw.h& ...
- 淘宝/天猫如何获取sku API接口,item_sku - 获取sku详细信息
一.接口参数说明: 通过淘宝/天猫app中分享至PC端的短链接商品ID,通过调用item_sku - 获得sku接口,可以得到接口要的商品sku详情数据. 点击获取测试key和secret 请求地址: ...
- 淘宝API接口(item_sku - 获取sku详细信息)
今天分享淘宝API接口:获取sku详细信息,包括其他各大电商平台都在使用范围内 想了解的可以进去看看:点击测试 参数示例: { "item": { &quo ...
- Android获取歌曲详细信息
Android获取歌曲详细信息 一.目标 二.实现方案 三.HTML方案 四.JSON方案 五.接下来 六.Finally 在<Android实现歌词笔记构思>时,构思了如何在笔记中添加歌 ...
最新文章
- [JS]手写动画最小时间间隔设置
- jstl 获取 javascript 定义的变量_前端开发大牛完整总结出了JavaScript 难点 +最新web前端开发教程...
- hbase 页面访问_HBase
- Serverless 实战 —— 轻松搭建基于 SpringBoot + Vue 的 Web 商城应用
- web和python前景_我想了解一下pythonweb和javaweb比较详细的学习成本和应用前景,谢谢!?...
- 服务器2003系统安装时蓝屏,安装2003server操作系统蓝屏是怎么回事?
- 【NVIDIA Jetson TK1】一,开发板重装ubuntu系统,重新刷机,重新烧系统,恢复系统
- 基因加性方差、显性方差与上位性方差定义
- cvs数据格式 gps_运动手表GPS轨迹文件导出方法
- Vision Transformer(VIT)代码分析——保姆级教程
- 窗——开了又关,关了又开(改编)
- (4.2.40)阿里开源路由框架ARouter的源码分析
- command在计算机中的意义,MAC系统中Command键功能有哪些
- 使用 代码 读取 build.gradle 中的自定义配置信息
- 关于jsp中java代码的使用;
- 交换式多兆位数据服务(SMDS)--网络大典
- matlab sym转str,sym struct 转换
- 计算机研究生复试英语自我介绍,计算机研究生复试专业英语自我介绍.doc
- Addressable如何删除旧资源
- vt版本不见了_BIOS问题 我的版本BIOS 找不到 开启 intel vt-x功能