CUDA 检查硬件配置

2019-03-12  本文已影响0人  _酒酿芋圆
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include "cuda_runtime.h"
#include "device_launch_parameters.h"

using namespace std;

cudaError_t cudaStatus;

int main() {
    int dev = 0;
    cudaDeviceProp devProp;
    
    cudaStatus = cudaGetDeviceCount(&dev);
    for (int i = 0; i < dev; i++) {
        cudaGetDeviceProperties(&devProp, i);
        cout << "使用GPU device " << dev << ": " << devProp.name << endl; 
        cout << "SM的数量:" << devProp.multiProcessorCount << endl; 
        cout << "每个线程块的共享内存大小:" << devProp.sharedMemPerBlock / 1024.0 << " KB" << endl; 
        cout << "每个线程块的最大线程数:" << devProp.maxThreadsPerBlock << endl; 
        cout << "每个EM的最大线程数:" << devProp.maxThreadsPerMultiProcessor << endl; 
        cout << "每个EM的最大线程束数:" << devProp.maxThreadsPerMultiProcessor / 32 << endl;
    }

    return 0;
}

参考链接:
https://blog.csdn.net/xiaohu2022/article/details/79599947

上一篇下一篇

猜你喜欢

热点阅读