How does gpu solve data dependency

Hi,

I am new to GPGPU. May I ask a very simple question?

How does gpu solve data dependency? Just like the following code:

When the warp is issued, will it have to first issue the warp used for calculation the first line?

[i]global
void saxpy(int n, float a, float x, float y)
{
int i = blockIdx.x
blockDim.x + threadIdx.x;
if (i < n)
{
y[i] = a
x[i] + y[i]; //first line
x[i] = y; //second line
}
}

Thanks in advance

When it comes to high-level languages like this, compilers can re-order instructions and processors can also best decide how to execute a pipeline of instructions as well.

One thing that’s always guaranteed is logical equivalency. No matter how the code is compiled or executed, you can safely assume that something logically equivalent to what you typed will be executed.

So yes, you can safely assume that y[i] will be assigned to before x[i] is assigned to.

I’m not sure if that helps or not :P

Thank you for your help. I understand it now~