generate new column from another table column, treating nulls are unique
Adding the column:

alter table device_login
  add column person_id int ;


The query is a bit complicated, due to the nulls. First group the not null logins per login and keep each null seprately

with a as 
( select min(device_id) as device_id, login_id
  from device_login
  where login_id is not null
  group by login_id 
union all
  select device_id, login_id
  from device_login
  where login_id is null
)


then use dense_rank() to assign separate numbers to each group

, b as
( select dl.device_id, a.login_id, 
         dense_rank() over (order by a.device_id, a.login_id) as rnk
  from a join device_login as dl 
      on a.login_id = dl.login_id 
      or a.login_id is null and a.device_id = dl.device_id
)


and finally update the table:

update device_login as dl
set person_id = b.rnk
from b
where b.login_id = dl.login_id 
   or b.login_id is null and b.device_id = dl.device_id ;


Tested at SQLfiddle.