Accelerating Barnes-Hut t-SNE Algorithm by Efficient Parallelization on Multi-Core CPUs

Narendra Chaudhary, Alexander Pivovar, Pavel Yakovlev, Andrey Gorshkov, Sanchit MisraarXiv 2022 · DOI

Abstract

Researchers at Intel have developed Acc-t-SNE, a highly optimized version of the Barnes-Hut t-SNE algorithm designed specifically for multi-core CPUs. By leveraging Morton codes for parallel tree building, SIMD vectorization, and aggressive cache optimizations, they achieved speeds up to 261x faster than scikit-learn and 4x faster than the previous state-of-the-art CPU implementation (daal4py), making massive dataset visualization feasible on standard workstation hardware.

Introduction

t-Distributed Stochastic Neighbor Embedding (t-SNE) is the "gold standard" for visualizing high-dimensional data, such as single-cell RNA sequencing or image features, in 2D or 3D. However, the exact algorithm's $O(N^2)$ complexity is computationally prohibitive for large datasets. While the Barnes-Hut (BH) approximation reduces this to $O(N \log N)$, existing CPU implementations—including the widely used scikit-learn library—often fail to scale effectively with modern multi-core processors.

GPU-accelerated versions exist but are frequently constrained by limited GPU memory capacity. This research addresses the "CPU efficiency gap," optimizing the BH t-SNE pipeline to handle million-point datasets efficiently on standard CPU-based cloud instances and workstations.

Methodology

The authors identified that previous high-performance implementations still suffered from sequential bottlenecks and poor memory locality. To overcome these, they introduced a series of architectural optimizations across the entire t-SNE pipeline.

The Barnes-Hut t-SNE algorithm pipeline, divided into input similarity computation and iterative gradient descent.

Parallel Tree Construction and Summarization

Traditional spatial tree building is recursive and difficult to parallelize. Acc-t-SNE utilizes Morton-Code Based Quadtree Building, which maps 2D points into a 1D space using Z-order curves. This bit-manipulation approach transforms a complex structural problem into a sorting task that is highly "parallel-friendly" and amenable to SIMD (Single Instruction, Multiple Data) instructions. Additionally, the authors parallelized the bottom-up tree traversal used for summarization (calculating cell centers-of-mass), which was previously a major sequential bottleneck.

Force Calculation Optimizations

  • SIMD & Software Prefetching: Calculating "attractive forces" involves irregular memory access. The team utilized AVX512 instructions to process eight points simultaneously and implemented software prefetching to hide memory latency.
  • Cache-Aware Data Layout: By storing tree nodes contiguously in memory based on their level, the implementation significantly improved cache hit rates during the "repulsive force" calculation—the most computationally expensive phase of the algorithm.

Experimental Results

The implementation was evaluated on six standard datasets, including a 1.3 million-cell Mouse Brain dataset and MNIST. Benchmarks were conducted on a 32-core Intel Icelake instance.

Performance comparison of Acc-t-SNE against other popular implementations, showing significant speedup in execution time.

Key Findings

  • Massive Speedups: On the 1.3M point dataset, Acc-t-SNE achieved a 261.2x speedup over scikit-learn and outperformed the previous CPU leader, daal4py, by 4.4x.
  • Efficient Scaling: Unlike previous implementations that struggled to utilize more than 8-16 cores, Acc-t-SNE demonstrated excellent multi-core scaling up to 32 cores.
  • Preserved Accuracy: These performance gains did not sacrifice quality; the KL-divergence remained nearly identical to standard implementations, ensuring the resulting visualizations are accurate representations of the high-dimensional data.

Conclusion

Acc-t-SNE demonstrates that through holistic optimization—addressing tree building, data layout, and memory latency—CPU-based t-SNE can achieve performance levels previously thought to require specialized GPU hardware. The authors suggest that these Morton-code and SIMD techniques could be extended to other visualization algorithms like UMAP, further broadening the impact of this high-performance framework.

Summary updated

BibTeX
@misc{chaudhary2022accelerating,
  author = {Narendra Chaudhary and Alexander Pivovar and Pavel Yakovlev and Andrey Gorshkov and Sanchit Misra},
  title = {{Accelerating Barnes-Hut t-SNE Algorithm by Efficient Parallelization on Multi-Core CPUs}},
  year = {2022},
  eprint = {2212.11506},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2212.11506},
}
Figure