Is it the same? Use the same number of registers?

To assume that A and B are both in global memory. In kernel if i write

  1. int foo = A[i] * B[i];

  2. int a = A[i];
    int b = B[i];
    int foo = a * b;

Do the both cases use the same number of on-board registers of a multiprocessor?
Do the SPs of a multiprocessor have their extra own registers?

As long as a and b are not used afterwards, I would assume that both compile to the same code.
Each thread has its own set of registers, yes.

As long as a and b are not used afterwards, I would assume that both compile to the same code.
Each thread has its own set of registers, yes.

SPs don’t have registers. You should think of an SP as a fancy ALU, not a self-contained execution core since it lacks an instruction decoder and register file. (Tera is right, though. Registers are assigned statically to each thread for the duration of the execution of a block.)

SPs don’t have registers. You should think of an SP as a fancy ALU, not a self-contained execution core since it lacks an instruction decoder and register file. (Tera is right, though. Registers are assigned statically to each thread for the duration of the execution of a block.)

Otherwise the registers holding the values of A[i] and B[i] in case 1) can be reused afterwards, but registers

referenced by a and b in case 2) are occupied until the end of the life of a and b. Right?

Otherwise the registers holding the values of A[i] and B[i] in case 1) can be reused afterwards, but registers

referenced by a and b in case 2) are occupied until the end of the life of a and b. Right?

Ah, Thanks of a lot :rolleyes:

Ah, Thanks of a lot :rolleyes:

No, the compiler performs its own lifetime analysis and allows the registers to be reused immediately after the addition in both cases. In fact, the compiler will not even assign registers to both values but use one directly from memory in both cases.

No, the compiler performs its own lifetime analysis and allows the registers to be reused immediately after the addition in both cases. In fact, the compiler will not even assign registers to both values but use one directly from memory in both cases.