大东 的博客专栏

时光啊时光

(2)查询CUDA设备

调用CUDA提供API查询当前计算机支持CUDA 的设备信息:

(打印出部分信息)

 

#include "stdafx.h"
#include "cuda_runtime_api.h"

int main(int argc, _TCHAR* argv[])
{

 //get Devices count 
 int nDevCount = -1;
 cudaError_t nErr;

 nErr = cudaGetDeviceCount(&nDevCount);

 if (cudaSuccess != nErr)
 {
  printf("Get devices count failed !\n");
  return -1;
 }
 if (nDevCount <= 0)
 {
  printf("You have no graphics card support CUDA !\n");
 }
 else
 {
  printf("You have %d graphics card support CUDA !\n", nDevCount);
 }

 //Get devices info
 cudaDeviceProp pProp;
 nErr = cudaGetDeviceProperties(&pProp, 0);
 if (cudaSuccess != nErr)
 {
  printf("Get devices info failed !\n");
  return -1;
 }
 printf("Name: %s\n", pProp.name);
 printf("totalGlobalMemory: %lld\n", pProp.totalGlobalMem);
 printf("totalConstMemory :%lld\n", pProp.totalConstMem);
 printf("clockRate: %d\n", pProp.clockRate);
 printf("multiProcessorCount :%d\n", pProp.multiProcessorCount);
 printf("major:%d\n", pProp.major);
 printf("minor :%d\n", pProp.minor);
 printf("maxThreadsPerBlock :%d\n", pProp.maxThreadsPerBlock);

 int i = 0;
 scanf("%d", &i);
 
 return 0;
}

运行结果:

阅读更多
版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/randong1988/article/details/17102099
个人分类: CUDA
上一篇(1)VS2010 + CUDA 5.0 如何在 VC++工程里面编译 CUDA 源文件
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭