Use Thrust's log2_ri