optimized k-nn for 8 cores