PTX ISAの原子操作atomの小結


原子操作atomの小結について
atom
Atomic reduction operations for thread-to-thread communication.
構文
atom{.space}{.scope}.op.type d, [a], b; 

atom{.space}{.scope}.op.type d, [a], b, c; 

.space = { .global, .shared }; 

.scope = { .cta, .gpu, .sys }; 

.op = { .and, .or, .xor, // .b32, .b64
        .cas, .exch, // .b32, .b64
        .add, // .u32, .s32, .f32, .u64, .f64 
        .inc, .dec, // .u32 only 
        .min, .max }; // .u32, .s32, .u64, .s64 

.type = { .b32, .b64, .u32, .u64, .s32, .s64, .f32, .f64 };


説明
実際、atom操作、すなわちread-motified-writeの3ステップ操作
eg
 atom.global.inc.s32  d,[a],n;

​ 1.aのアドレスからdを読み、read/load
​ 2.incの定義に基づいて
計算((d>=n)?0 : (d+1)); motified
​ 3.そして算出した値をaの住所に書き戻す.write/store
incは、aがnに成長すると、a=0になることを意味する.
ptx isa - atom http://docs.nvidia.com/cuda/parallel-thread-execution/#parallel-synchronization-and-communication-instructions-atom
atomicInc()詳細分析
http://stackoverflow.com/questions/18008975/atomicinc-is-not-working
*nvidia公式ドキュメントlink*https://docs.nvidia.com/cuda/cuda-c-programming-guide/#arithmetic-functions