cpu serial version of downsampling