inverse_cpu - fixing bugs & calling swap as device function