Abstract
Mobile and edge computing increasingly require local data processing to address privacy, connectivity, and energy concerns. However, leveraging the massive parallelism of integrated mobile GPUs for general-purpose computing (GPGPU) on Android remains challenging due to the lack of official OpenCL support and aggressive OS lifecycle management. This paper introduces a custom wrapper library that enables OpenCL-accelerated data mining on Android 7+ devices. Through implementations of DBSCAN and K-means, we demonstrate that while GPUs face a significant "setup tax," they offer superior scaling and energy efficiency for large-scale data processing compared to traditional Java and native C implementations.
Introduction
Modern Android devices contain powerful integrated GPUs, yet these resources are underutilized for general-purpose computing. Two primary hurdles exist: the absence of official OpenCL support from Google, which leads to fragmentation and compatibility issues, and the Android OS's aggressive background task termination to preserve battery life. This research addresses these challenges by developing a portable wrapper library and a robust execution framework capable of handling the unique constraints of the mobile ecosystem.
Methodology
The core of the solution is a custom wrapper library that dynamically loads native OpenCL shared libraries at runtime, bypassing the need for specialized root access or OS-specific modifications. To ensure stability under Android's lifecycle management, the system utilizes WorkManager and Foreground Services to prevent process suspension during "Doze" mode.
A critical component is the implementation of a reentrant Reader-Writer (RW) lock mechanism (see Figure 1). This "Safe Abort Mechanism" allows the system to interrupt GPU calculations safely if the application is closed, ensuring that driver resources are released without causing system instability.
Experimental Setup
The study evaluated five implementations of DBSCAN and K-means: single-threaded Java, multi-threaded Java, single-threaded C, multi-threaded C, and C + OpenCL (GPU). Testing was conducted on a Samsung Galaxy Tab A (Exynos 7885 SoC, Mali-G71 MP2 GPU) using synthetic datasets. The experiments covered 60 combinations of features, cluster counts, and cluster sizes, totaling 4,272 individual tests.
Results and Analysis
The experimental results highlight a significant trade-off between initial overhead and long-term scaling.
The GPU Setup Tax
A primary finding was the high cost of initializing the GPU environment. Setting up OpenCL buffers and compiling kernels introduced a latency of 115ms to 141ms. For small datasets, this overhead makes the GPU implementation slower than even basic Java code. DBSCAN, requiring two separate kernels, exhibited higher setup times than the single-kernel K-means.
Performance Scaling
Despite the setup penalty, the GPU implementation demonstrates superior scaling. As data complexity increases, the GPU's execution time grows much more slowly than CPU-based methods.
As shown in Figure 4, the GPU (C+GPU) eventually outperforms all other implementations once the workload reaches a critical mass. Notably, pure C implementations consistently outperformed Java across all non-GPU tests, highlighting the overhead of the Java Virtual Machine (JVM) on mobile hardware. Threading overhead was also measured, with C requiring only 3.2ms to initialize a multi-threaded environment compared to 10.5ms for Java.
Energy Efficiency
While the GPU draws more instantaneous power, its ability to complete large-scale tasks significantly faster than the CPU results in lower total energy consumption (electric charge). This makes GPGPU a viable strategy for extending battery life during heavy data processing tasks.
Conclusion
This work proves that "desktop-style" OpenCL code can be successfully ported to Android with minimal modification. While the current implementation faces memory constraints (e.g., limited constant memory on mobile GPUs) and is restricted to single-precision math, the performance gains for large-scale data mining are clear. Future optimizations, such as using SPIR-V to reduce kernel compilation time, could further mitigate the GPU setup overhead, making mobile GPGPU even more competitive for a wider range of applications.
Summary updated