CUDA ---2 分支控制,变量

来源:互联网 发布:警车巡逻防控优化 编辑:程序博客网 时间:2024/06/04 19:14

Control Flow Opteration:

Instruction cycle for anthimetic aritinstruction:
Fetch | Decode | Execute | Memory

 

control Divergence Exampls

---Example with divergence:
IF (threadIdx.x >2) {}
1. This creates two different control paths for threads in a

block.
2.  Branch granularity(颗粒度) < wrap size; thread 0, 1 and 2

follow different path than the rest of the threads in the first

warp.
threadIdx.x >2 所以0, 1, 2都是失败的。

---Example without divergence:
IF (threadIdx.x /WARP_SIZE) {}
1. Also creates two different control paths for threads in a

block.
2. Branch granularity is a whole multiple of warp size, all

threads in any given warp follow the same path.


cuda variable Type Qualifiers

          Variable declaration                                 memory                    scope(范围)                 lifetime
             int LocalVar;                                             register                       thread                              thread
_device_  _shared_  int SharedVar;                  shared                       block                                block
_device_           int GlobalVar;                              global                           grid                                application
_device_ _constant_ int ConstantVar;             constant                        grid                                application

原创粉丝点击