第二个程序的目的是点看我电脑上的gpu的基本信息。查询设备。
文件存为cuda_1.1。
更改如下:
// Add vectors in parallel.
//cudaError_t 是cuda错误类型,取值为整数。
cudaError_t cudaStatus;
int num = 0;
cudaDeviceProp prop;
cudaStatus = cudaGetDeviceCount(&num);
for(int i = 0;i<num;i++)
{
cudaGetDeviceProperties(&prop,i);
printf( " --- General Information for device %d ---\n", i );
printf( "Name: %s\n", prop.name );//名称
printf( "Compute capability: %d.%d\n", prop.major, prop.minor );设备计算功能集的主版本号以及次版本号
printf( "Clock rate: %d\n", prop.clockRate );时钟频率
printf( "Device copy overlap: " );一个布尔类型值,表示设备是否能同时执行一个cudaMemory()调用和一个核函数调用。
if (prop.deviceOverlap)
printf( "Enabled\n" );
else
printf( "Disabled\n");
printf( "Kernel execution timeout : " );内核执行超时
if (prop.kernelExecTimeoutEnabled)
printf( "Enabled\n" );
else
printf( "Disabled\n" );
printf( " --- Memory Information for device %d ---\n", i );
printf( "Total global mem: %ld\n", prop.totalGlobalMem );设备上全局内存的总量,单位为字节。
printf( "Total constant Mem: %ld\n", prop.totalConstMem );总常量MEM
printf( "Max mem pitch: %ld\n", prop.memPitch );
printf( "Texture Alignment: %ld\n", prop.textureAlignment );
printf( " --- MP Information for device %d ---\n", i );
printf( "Multiprocessor count: %d\n",
prop.multiProcessorCount );
printf( "Shared mem per mp: %ld\n", prop.sharedMemPerBlock );
printf( "Registers per mp: %d\n", prop.regsPerBlock );
printf( "Threads in warp: %d\n", prop.warpSize );
printf( "Max threads per block: %d\n",
prop.maxThreadsPerBlock );
printf( "Max thread dimensions: (%d, %d, %d)\n",
prop.maxThreadsDim[0], prop.maxThreadsDim[1],
prop.maxThreadsDim[2] );
printf( "Max grid dimensions: (%d, %d, %d)\n",
prop.maxGridSize[0], prop.maxGridSize[1],
prop.maxGridSize[2] );
printf( "\n" );
}
multiProcessorCount:GPU大核数,一个大核(专业点称为流多处理器,SM,Stream-Multiprocessor)包含多个小核(流处理器,SP,Stream-Processor)
调用cudaGetDeviceCount(&num);可以对每个设备进行迭代 ,并查询各个设备的相关信息。cuda运行时候将会返回一个cudaDeviceProp结构的,其中包含啦设备的相关属性。