CUDA测试设备属性的代码
2014-10-25 20:46
225 查看
#include <cuda_runtime.h>
#include <cuda.h>
#include <device_launch_parameters.h>
bool CUDA_initial(void)
{
int i;
int device_count;
if( cudaGetDeviceCount(&device_count) )
{
printf(" There is zero device beyond 1.0/n");
return false;
}
else
{
printf("There is %d device beyond 1.0/n",device_count);
}
for(i=0;i<device_count;i++)
{
struct cudaDeviceProp device_prop;
if(cudaGetDeviceProperties(&device_prop,i)==cudaSuccess)
{
printf("device properties is :\n"
" device name is %s\n"
"/t totalGlobalMem is %d\n"
"/t sharedMemPerBlock is %d\n"
"/t regsPerBlock is %d\n"
"/t warpSize is %d\n"
"/t memPitch is %d\n"
"/t maxThreadsPerBlock is %d\n"
"/t maxThreadsDim [3] is %d X %d X %d\n"
"/t maxGridSize [3] is %d X %d X %d\n"
"/t totalConstMem is %d\n"
"/t device version is major %d ,minor %d\n"
"/t clockRate is %d\n"
"/t textureAlignment is %d\n"
"/t deviceOverlap is %d\n"
"/t multiProcessorCount is %d\n",
device_prop.name,
device_prop.totalGlobalMem,
device_prop.sharedMemPerBlock,
device_prop.regsPerBlock,
device_prop.warpSize,
device_prop.memPitch,
device_prop.maxThreadsPerBlock,
device_prop.maxThreadsDim[0],device_prop.maxThreadsDim[1],device_prop.maxThreadsDim[2],
device_prop.maxGridSize[0],device_prop.maxGridSize[1],device_prop.maxGridSize[2],
device_prop.totalConstMem,
device_prop.major,device_prop.minor,
device_prop.clockRate,
device_prop.textureAlignment,
device_prop.deviceOverlap,
device_prop.multiProcessorCount);
break;
}
}
if(i==device_count)
{
printf("\nGet the propertites of device occurred error\n");
return false;
}
if(cudaSetDevice(i)==cudaErrorInvalidDevice)
{
printf("\nSet Device occurred error\n");
return false;
}
}
int main()
{
if (CUDA_initial() == true)
printf("CUDA initial successed!\n");
getchar();
return 0;
}
#include <cuda.h>
#include <device_launch_parameters.h>
bool CUDA_initial(void)
{
int i;
int device_count;
if( cudaGetDeviceCount(&device_count) )
{
printf(" There is zero device beyond 1.0/n");
return false;
}
else
{
printf("There is %d device beyond 1.0/n",device_count);
}
for(i=0;i<device_count;i++)
{
struct cudaDeviceProp device_prop;
if(cudaGetDeviceProperties(&device_prop,i)==cudaSuccess)
{
printf("device properties is :\n"
" device name is %s\n"
"/t totalGlobalMem is %d\n"
"/t sharedMemPerBlock is %d\n"
"/t regsPerBlock is %d\n"
"/t warpSize is %d\n"
"/t memPitch is %d\n"
"/t maxThreadsPerBlock is %d\n"
"/t maxThreadsDim [3] is %d X %d X %d\n"
"/t maxGridSize [3] is %d X %d X %d\n"
"/t totalConstMem is %d\n"
"/t device version is major %d ,minor %d\n"
"/t clockRate is %d\n"
"/t textureAlignment is %d\n"
"/t deviceOverlap is %d\n"
"/t multiProcessorCount is %d\n",
device_prop.name,
device_prop.totalGlobalMem,
device_prop.sharedMemPerBlock,
device_prop.regsPerBlock,
device_prop.warpSize,
device_prop.memPitch,
device_prop.maxThreadsPerBlock,
device_prop.maxThreadsDim[0],device_prop.maxThreadsDim[1],device_prop.maxThreadsDim[2],
device_prop.maxGridSize[0],device_prop.maxGridSize[1],device_prop.maxGridSize[2],
device_prop.totalConstMem,
device_prop.major,device_prop.minor,
device_prop.clockRate,
device_prop.textureAlignment,
device_prop.deviceOverlap,
device_prop.multiProcessorCount);
break;
}
}
if(i==device_count)
{
printf("\nGet the propertites of device occurred error\n");
return false;
}
if(cudaSetDevice(i)==cudaErrorInvalidDevice)
{
printf("\nSet Device occurred error\n");
return false;
}
}
int main()
{
if (CUDA_initial() == true)
printf("CUDA initial successed!\n");
getchar();
return 0;
}
相关文章推荐
- CUDA从入门到精通到精通_笔记4:GPU设备属性查询的代码
- cuda学习心得--3.了解设备属性
- 【代码片段】jQuery测试属性过滤选择器
- 字符设备驱动模块与测试代码编写。
- imx6q led灯驱动及测试代码ioctl(自动创建设备文件v2)
- 分析显示设备属性代码
- [有码有真相]python类私有属性等要点理解及测试示例代码
- android属性动画—自己的测试代码
- LDD3 Chapter3 分配主设备号测试代码
- 不会写代码和设备碎片化都不再是问题,Apptimize提供面向Android的A/B测试服务
- java代码---继承-子类使用继承父类的属性。理解测试
- Google Test(GTest)使用方法和源码解析——私有属性代码测试技术分析
- GPU && CUDA:主机和设备间数据传输测试
- LDD3源码分析之字符设备驱动程序(加上测试代码)
- ARM11 paltform驱动代码完成,最简单的测试直接在装载设备中运行,实现秒读
- HELLOWORLD级事件属性监听小技巧,随便写了点测试代码
- 国嵌内核驱动进阶班-7-1(Ioctl设备控制)--- 测试代码
- CUDA-CODE3-查询GPU设备属性
- 使用内核定时器的second字符设备驱动及测试代码
- CUDA开发:了解设备属性