Abstract
Set intersection is a fundamental operation in data processing, yet it presents significant challenges for high-performance computing on Graphics Processing Units (GPUs). Traditional representations like bitmaps and sorted lists force a trade-off between memory efficiency and computational regularity. This paper introduces BATMAP, a novel data layout that achieves both. By employing a 2-of-3 redundant hashing scheme and bit-level compression, BATMAP enables branchless, massively parallel set intersection. Experimental results demonstrate that BATMAP achieves throughputs up to 36.2 Gbyte/s on a GeForce GTX 285, significantly outperforming traditional CPU-based algorithms.
Introduction
Set intersection—the process of identifying common elements between two or more sets—is a cornerstone of modern data science, powering applications from database joins to frequent itemset mining. While Graphics Processing Units (GPUs) offer the massive parallelism required for these tasks, they demand highly regular data access patterns and minimal branching to achieve peak performance.
Historically, developers have faced a binary choice: use bitmaps for speed at the cost of memory (especially for sparse data), or use sorted lists for space efficiency at the cost of the unpredictable branching inherent in merge-based intersections. BATMAP (Bit-level Adaptive Table for Massive Parallelism) bridges this gap by providing a layout that is both compact and perfectly suited for the GPU's SIMD (Single Instruction, Multiple Data) architecture.
The BATMAP Layout
The core innovation of BATMAP is its use of redundant hashing to ensure that intersections can be performed without complex searching or merging logic.
2-of-3 Redundant Hashing
Instead of storing an element in a single location, BATMAP stores each element in two out of three possible hash table locations. This redundancy ensures that if an element exists in two different sets, there is a mathematical guarantee that they will share at least one hash bucket. This allows the GPU to perform intersections by simply comparing corresponding buckets in parallel.
Layout Structure
The layout maps elements to buckets using three distinct hash functions ($h_1, h_2, h_3$). The physical memory layout interleaves these buckets to optimize for coalesced memory access on the GPU, ensuring that threads can read data in neat, predictable blocks.
Implementation and Optimization
BATMAP achieves its high performance through several key optimizations:
- Branchless Intersection: By fixing the comparison locations, the algorithm avoids
ifstatements. It uses bitwise XOR, OR, and shift operations to count matches, keeping the GPU execution pipeline full. - Implicit Compression: To minimize memory footprint, BATMAP does not store full 32-bit or 64-bit values. Since the bucket index itself encodes some bits of the element, only the "remainder" bits are stored. This allows the system to pack four elements into a single 32-bit integer.
- Deterministic Control Flow: The problem is transformed from a data-dependent search into a data-independent array comparison, which is the ideal scenario for GPU hardware.
Performance Evaluation
The authors evaluated BATMAP against industry-standard CPU algorithms like Apriori and FP-growth using both synthetic and real-world datasets (WebDocs).
- Throughput: On a GeForce GTX 285, BATMAP reached an intersection throughput of 36.2 Gbyte/s.
- Speedup: The GPU implementation was approximately 5 times faster than an optimized version running on an 8-core CPU.
- Scalability: Unlike Apriori, which often fails due to memory exhaustion on large, sparse datasets like WebDocs, BATMAP scales linearly and handles high-cardinality sets with ease.
Conclusion
BATMAP demonstrates that deliberate redundancy can be a powerful tool for GPU optimization. By trading a small amount of storage for extreme computational regularity, it enables set intersection at speeds previously unattainable for sparse data. Future work includes moving the preprocessing steps to the GPU and generalizing the "d out of d+1" hashing scheme for more complex query types.
Summary updated