need help on global mem sync A way to make all threads wait for a global value to be ready?

I have global function (F) in which there is a reduction function on an array(A), and after a global Reduction , I do some other operations which need the result of the reduction.
global void F(type A)

  type redresult;
  redresult = globalReduction (A); 

////here need all threads to wait the redresult being ready////////////////
type alpha;
alpha = redresult + …; //some operation needing result

My question is how can I make all threads wait for redresult to be ready? is threadfence() useful here?

Believe me when I say that you don’t want to do this. If you need a global sync, split your function into two kernels.

thank you for your reply.

SO here threadfence() is not gonna work? i thought it will make the redResult visible to all threads?

threadefence is not a global barrier, which is what you’re looking for.