Fixes a bug involving multiple devices and MPI.
Only do calculations if it is not the last device.
Same bugfix as before but for left/upper matrices.