On variability and reliability of CMOS and spin-based devices