CUDA 编程入门-GPU信息读取

#include "cuda_runtime.h"
#include "device_launch_parameters.h"

#include 

void myDeviceInfo();

int main()
{
    // mykernel <<<1, 10 >>> ();
    myDeviceInfo();
    cudaDeviceSynchronize();
    return 0;
}

void myDeviceInfo()
{
    int dev_count;
    cudaGetDeviceCount(&dev_count);
    cudaDeviceProp dev_prop;
    int i;
    for (i = 0; i < dev_count; i++) {
        cudaGetDeviceProperties(&dev_prop, i);
        printf("----------- Information of device %d -----------\n", i);
        printf("The streaming multiprocessor(SM) number is %d\n", dev_prop.multiProcessorCount);
        printf("The max thread block numberof per SM is %d\n", dev_prop.maxBlocksPerMultiProcessor);
        printf("The max threads number of per SM is %d\n", dev_prop.maxThreadsPerMultiProcessor);
        printf("The max threads number of per block is %d\n", dev_prop.maxThreadsPerBlock);
        printf("The max thread blocks number in (x, y, z) dim is (%d, %d, %d)\n", dev_prop.maxGridSize[0], dev_prop.maxGridSize[1], dev_prop.maxGridSize[2]);
        printf("The max threads number of (x, y, z) dim is (%d. %d, %d)\n", dev_prop.maxThreadsDim[0], dev_prop.maxThreadsDim[1], dev_prop.maxThreadsDim[2]);
        printf("----------- Information of device end -----------\n");
    }
}

 

你可能感兴趣的:(CUDA,C)