lib: add sdiff_nperp