zoukankan      html  css  js  c++  java
  • CUDA开发:了解设备属性

      原文链接

      今天介绍一下CUDA设备的相关属性,只有熟悉了硬件是相关属性,是怎么工作的,就能写出更适合硬件工作的代码。cudaDeviceProp这个结构体记录了设备的相关属性。

    1 struct cudaDeviceProp
     2 {
     3   char   name[256];                  /**< 设备的ASCII标识 */
     4   size_t totalGlobalMem;             /**< 可用的全局内存量,单位字节 */
     5   size_t sharedMemPerBlock;          /**< 每个block可用的共享内存量,单位字节 */
     6   int    regsPerBlock;               /**< 每个block里可用32位寄存器数量 */
     7   int    warpSize;                   /**< 在线程warp块大小*/
     8   size_t memPitch;                   /**< 允许的内存复制最大修正,单位字节*/
     9   int    maxThreadsPerBlock;         /**< 每个block最大进程数量 */
    10   int    maxThreadsDim[3];           /**< 一block里每个维度最大线程量 */
    11   int    maxGridSize[3];             /**< 一格里每个维度最大数量 */
    12   int    clockRate;                  /**< 时钟频率,单位千赫khz */
    13   size_t totalConstMem;              /**< 设备上可用的常量内存,单位字节 */
    14   int    major;                      /**< 计算功能主版本号*/
    15   int    minor;                      /**< 计算功能次版本号*/
    16   size_t textureAlignment;           /**< 对齐要求的纹理 */
    17   int    deviceOverlap;              /**< 判断设备是否可以同时拷贝内存和执行内核。已过时。改用asyncEngineCount */
    18   int    multiProcessorCount;        /**< 设备上的处理器数量 */
    19   int    kernelExecTimeoutEnabled;   /**< 内核函数是否运行受时间限制*/
    20   int    integrated;                 /**< 设备是不是独立的 */
    21   int    canMapHostMemory;           /**< 设备能否映射主机cudaHostAlloc/cudaHostGetDevicePointer */
    22   int    computeMode;                /**< 计算模式,有默认,独占,禁止,独占进程(See ::cudaComputeMode) */
    23   int    maxTexture1D;               /**< 1D纹理最大值 */
    24   int    maxTexture2D[2];            /**< 2D纹理最大维数*/
    25   int    maxTexture3D[3];            /**< 3D纹理最大维数 */
    26   int    maxTexture1DLayered[2];     /**< 最大的1D分层纹理尺寸 */
    27   int    maxTexture2DLayered[3];     /**< 最大的2D分层纹理尺寸  */
    28   size_t surfaceAlignment;           /**< 表面的对齐要求*/
    29   int    concurrentKernels;          /**< 设备是否能同时执行多个内核*/
    30   int    ECCEnabled;                 /**< 设备是否支持ECC */
    31   int    pciBusID;                   /**< 设备的PCI总线ID */
    32   int    pciDeviceID;                /**< PCI设备的设备ID*/
    33   int    pciDomainID;                /**<PCI设备的域ID*/
    34   int    tccDriver;                  /**< 1如果设备是使用了TCC驱动的Tesla设备,否则就是0 */
    35   int    asyncEngineCount;           /**< 异步Engine数量 */
    36   int    unifiedAddressing;          /**< 设备是否共享统一的地址空间与主机*/
    37   int    memoryClockRate;            /**<峰值内存时钟频率,单位khz*/
    38   int    memoryBusWidth;             /**< 全局内存总线宽度,单位bit*/
    39   int    l2CacheSize;                /**< L2 cache大小,单位字节 */
    40   int    maxThreadsPerMultiProcessor;/**< 每个多处理器的最大的常驻线程 */
    41 };

      通过cudaGetDeviceProperties()得到设备属性,cudaGetDeviceCount()来获取设备的个数,通过cudaChooseDevice()选择符合条件的设备,通过cudaGetDevice()可以得到当前的设备,通过cudaSetDevice()设置选择设备,SLI技术支持多个GPU。

      更多内容请点击:

      CUDA专区:http://cuda.it168.com/

      CUDA论坛:http://cudabbs.it168.com/

  • 相关阅读:
    只用一个字节 计算象棋将帅之间可能的位置
    后缀数组学习
    java 构造不可变类集的使用方法
    topcoder SRM 639 div2
    navicat和pymysql
    表查询
    表的关系对应
    MySQl数据类型和条件限制
    复习之网络编程
    协程
  • 原文地址:https://www.cnblogs.com/liangliangdetianxia/p/3977796.html
Copyright © 2011-2022 走看看