Variables seen by all threads

Hi boys, i’m new of Cuda’s programming and I have a simple trouble:
I want to know if is possible to show to all thread a global variable. In my case, I want to can increase the value of two variables, X and Y, and, each thread must to see the changes made from previous thread (and I want to ensure orderly sequencing of threads, before the first, then the second etc.). My code is:

global void sumVect(QVECT *Vett, QVECT *VettRis, int N){
int tid; //Thread ID

//Calcolo del thread ID
tid=threadIdx.x + threadIdx.y * blockDim.x + threadIdx.z * blockDim.y * blockDim.x;

if(Y<N){
	VettRis[tid].x=/*Vett[X].x+Vett[Y].x*/X;
	VettRis[tid].y=/*Vett[X].y+Vett[Y].y*/Y;
	VettRis[tid].z=Vett[X].z+Vett[Y].z;
	VettRis[tid].Ene=Vett[X].Ene+Vett[Y].Ene;
	Y++;
}
else{
	X++;
	Y=X+1;
	VettRis[tid].x=Vett[X].x+Vett[Y].x;
	VettRis[tid].y=Vett[X].y+Vett[Y].y;
	VettRis[tid].z=Vett[X].z+Vett[Y].z;
	VettRis[tid].Ene=Vett[X].Ene+Vett[Y].Ene;
	Y++;
}

}

the variables involved are X and Y.

Thanks a lot and sorry for my english, I’m not a mother tongue.

If you just want to add the values from all threads with lower thread index, the operation is called prefix sum.

A general dependency would force the program to execute serially and thus defy the whole purpose of GPU computing.

I must do the calculation of pairs without repetition, that is N!/(M!*(N-M)!) and each thread must do a sum