#include "device_launch_parameters.h"
#include <iostream>
int main(int argc, char*argv[])
{
int deviceCount; // 设备数目
cudaGetDeviceCount(&deviceCount);
for(int i = 0; i < deviceCount; i++)
{
cudaDeviceProp devProp; // 声明设备属性
cudaGetDeviceProperties(&devProp, i);
std::cout << "GPU 设备序号:" << i << devProp.name << std::endl;
std::cout << "设备全局内存总量:" << devProp.totalGlobalMem / 1024 /1024 << "MB" << std::endl;
std::cout << "SM数目:" << devProp.multiProcessorCount << std::endl;
std::cout << "每个线程块的共享内存大小:" << devProp.sharedMemPerBlock << std::endl;
std::cout << "设备上线程快Block可用的32位寄存器数目:" << devProp.regsPerBlock << std::endl;
std::cout << "每个SM的最大线程数:" << devProp.maxThreadsPerMultiProcessor << std::endl;
std::cout << "每个SM的最大线程束数:" << devProp.maxThreadsPerMultiProcessor / 32 << std::endl;
std::cout << "每个SM的最大共享内存:" << devProp.sharedMemPerMultiprocessor / 1024 << "KB" << std::endl;
std::cout << "每个Grid的最大尺寸:" << devProp.maxGridSize[0] << " " << devProp.maxGridSize[1] << " " << devProp.maxGridSize[2] << std::endl;
std::cout << "每个Block的最大尺寸:" << devProp.maxThreadsDim[0] << " " << devProp.maxThreadsDim[1] << " " << devProp.maxThreadsDim[2] << std::endl;
}
return 0;
}
GPU 设备序号:1NVIDIA GeForce RTX 4090
设备全局内存总量:24214MB
SM数目:128
每个线程块的共享内存大小:49152
设备上线程快Block可用的32位寄存器数目:65536
每个SM的最大线程数:1536
每个SM的最大线程束数:48
每个SM的最大共享内存:100KB
每个Grid的最大尺寸:2147483647 65535 65535
每个Block的最大尺寸:1024 1024 64
标签:int,deviceCount,线程,Cuda,SM,GPU,Hello,设备
From: https://www.cnblogs.com/XL2COWARD/p/MyCuda_1.html