Please use this identifier to cite or link to this item: https://hdl.handle.net/10216/167735
Author(s): Alexandre Guimarães Gomes Correia
Title: Leveraging Low-Level Code Optimization on Mobile and Wearable Devices
Issue Date: 2025-07-08
Abstract: Mobile and wearable devices are capable of executing increasingly complex and privacy-sensitive tasks, all while remaining bound by strict energy and latency constraints. This dissertation investi- gates how utilizing low-level code can improve performance and efficiency on Android devices in contrast to the standard Kotlin/Java toolchain. After reviewing the state of the art, four studies were conducted using both Kotlin and C/C++ with the Android Native Development Kit (NDK). These studies focused on prime number generation, using the Sieve of Eratosthenes, the Fast Fourier Transform (FFT), and square matrix multiplication. Additionally, we developed an Android ap- plication that performs wake word or hotword detection using TensorFlow Lite C API, followed by voice command recognition for a limited set of commands after detecting a wake word. The exploration of the algorithms revealed that native code offers limited benefits for the Sieve algorithm, achieving only a 1.4x speed-up in the best-case scenario, with performance degrading as the input size increases. However, native code provides better control over memory usage, enabling the processing of larger input sizes than the Kotlin approach. The iterative FFT imple- mented in native code achieves a speed-up of 5.82x for an input size of 220, with performance improving as input size increases. While the matrix multiplication algorithm achieved a speed- up of 6x in a matrix size of 2048, utilizing the compiler's -O3 optimization flag, which enabled instruction vectorization. Moreover, the development of the wake word detector and voice command recognition appli- cation using the TensorFlow Lite C API allowed on-device real-time processing while also incor- porating noise and voice activity filtering. One of our goals was to compare a native implementa- tion in C with one in Kotlin to explore potential optimizations. Empirical evaluation confirmed a functional audio pipeline that consumed approximately 200MB of memory and could sustain up to 41 hours of continuous listening in an environment composed of equal portions (33,3...% each) of silence, random noise, and human voice.
Description: Os dispositivos móveis e vestíveis são capazes de executar tarefas cada vez mais complexas e sensíveis à privacidade, ao mesmo tempo que estão sujeitos a restrições rigorosas de energia e latência. Esta dissertação investiga como a utilização de código de baixo nível pode melhorar o desempenho e a eficiência em dispositivos Android, em contraste com a standard toolchain Kotlin/Java. Depois de analisar o estado da arte, foram realizados quatro estudos utilizando Kotlin e C/C++ com o Android Native Development Kit (NDK). Estes estudos centraram-se na geração de números primos, utilizando o Crivo de Eratóstenes, a Fast Fourier Transform (FFT) e a multi- plicação de matrizes quadradas. Ainda desenvolvemos uma aplicação para Android que realiza a deteção da wake word ou hotword utilizando a API em C do TensorFlow Lite, seguido do recon- hecimento de comandos de voz para um conjunto limitado de commands, após a wake word ser detetada. A exploração dos algoritmos revelou que o código nativo oferece benefícios limitados para o algoritmo Sieve, alcançando apenas um speed-up de 1,4x no melhor cenário, com o desempenho a degradar-se à medida que o tamanho do input aumenta. No entanto, o código nativo pode propor- cionar um melhor controlo sobre a utilização da memória, permitindo o processamento de inputs de maiores dimensões do que a abordagem em Kotlin. A FFT iterativa implementada em código nativo alcançou um speed-up de 5,82x para um tamanho de input de 220, com o desempenho a melhorar à medida que o tamanho do input aumenta. Ao passo que o algoritmo de multiplicação de matrizes alcançou um speed-up de 6x com um tamanho de matriz de 2048, utilizando a flag -O3 do compilador que permitiu ativar a vetorização de instruções. Além disso, desenvolvemos uma aplicação composta por um wake word detector e um sistema reconhecimento de comandos de voz utilizando a API em C do TensorFlow Lite, que permitiu a execução em tempo real e on-device, ao mesmo tempo que implementámos a filtragem de ruído e voz humana. O nosso objetivo era comparar uma implementação nativa em C com uma em Kotlin para explorar potenciais optimizações. A avaliação empírica confirmou que a pipeline de áudio ficou funcional, usando aproximadamente 200 MB de memória e pode durar até 41 horas de funcionamento contínuo num ambiente composto por porções iguais (33,3...% cada) de silêncio, ruído aleatório e voz humana.
Subject: Engenharia electrotécnica, electrónica e informática
Electrical engineering, Electronic engineering, Information engineering
Scientific areas: Ciências da engenharia e tecnologias::Engenharia electrotécnica, electrónica e informática
Engineering and technology::Electrical engineering, Electronic engineering, Information engineering
TID identifier: 204110025
URI: https://hdl.handle.net/10216/167735
Document Type: Dissertação
Rights: openAccess
Appears in Collections:FEUP - Dissertação

Files in This Item:
File Description SizeFormat 
732359.pdfLeveraging Low-Level Code Optimization on Mobile and Wearable Devices860.32 kBAdobe PDFThumbnail
View/Open


Items in DSpace are protected by copyright, with all rights reserved, unless otherwise indicated.