opencl - Or-equals on constant as reduction operation (ex. value |= 1 ) thread-safe? -


let's have variable x.

x = 0 

i spawn number of threads, , each of them may or may not run following expression without use of atomics.

x |= 1 

after threads have joined main thread, main thread branches on value.

if(x) { ... } else { ... } 

is possible there race condition in situation? thoughts no, because doesn't seem matter whether or not thread interrupted thread between reading , writing 'x' (in both cases, either 'x == 1', or 'x == 1'). said, want make sure i'm not missing stupid obvious or ridiculously subtle.

also, if happen provide answer contrary, please provide instruction-by-instruction example!

context: i'm trying to, in opencl, have threads indicate presence or absence of feature among any of work-items. if of threads indicate presence of feature, host ought able branch on result. i'm thinking of using above method. if guys have better suggestion, works too!

detail: i'm trying add early-exit opencl radix-sort implementation, skip radix passes if data banded (i.e. 'x' above x[radix] , i'd have work groups, right after partial reduction of data, indicate presence or absence of elements in radix bins via 'x').

it may work within work-group. need insert barrier before testing x. i'm not sure faster using atomic increments.

it not work across several work-groups. imagine have 1000 work-groups run on 20 cores. typically, small number of work-groups can resident on single core, example 4, meaning 80 work-groups can in flight inside gpu @ given time. once work-group done executing, retired, , 1 started. halting kernel in middle of execution wait 1000 work-groups reach same point impossible.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -