Leveraging the potential of task-based programming with OpenMP task graphs
Authors:   , Yu Chenle 
Published: December 2024

(English) The task execution model is widely used in computer engineering, it helps developers to design, develop and understand software systems. OpenMP is the de-facto programming model to parallelize sequential algorithms on shared-memory machines. Coupled with the task parallelization, OpenMP is able to conveniently parallelize structured and non-structured applications, it also allows users to offload work onto accelerators as target tasks. However, the runtime overhead incurred by the OpenMP tasking model is an important concern for users to develop OpenMP task programs. This work focuses on improving OpenMP tasking model.
Firstly, we carried out an analysis of the performance overhead and bottleneck of mainstream task implementations and proposed a solution in the OpenMP specification to tackle it. To elaborate, we observe that a significant portion of the overhead in the tasking model stems from thread contention, where multiple threads compete to access shared resources simultaneously, such as task queues, causing these threads to stall. As the number of cores in modern architectures increases, this further hampers the scalability of OpenMP tasking. We propose a mechanism that creates graphs representing sets of OpenMP tasks. Once built, executing such graphs incurs less runtime overhead by drastically reducing the access to shared resources. This mechanism is exposed to the users as a new OpenMP directive, namely Taskgraph.
Secondly, we implemented the proposed solution, the taskgraph directive, in both GCC (prototype implementation) and LLVM compilers (complete implementation). Initially, our focus was on the GCC compiler, particularly its runtime system: libgomp. Our prototype implementation in this compiler demonstrated promising performance improvement using taskgraph. However, it also revealed a performance bottleneck in libgomp: all tasks are scheduled into a common queue, leading to significant contention and resulting in poor performance and scalability compared to LLVM.
The complete implementation of the taskgraph framework is in the LLVM compiler. Our modifications in the compiler range from the front-end to the middle-end of the compiler, in addition to its runtime library: libomp. This framework allows users to declare taskgraph directives in OpenMP C/C++ code to create graphs conveniently, at either compile time or run-time. The experiments show that the taskgraph framework outperforms the original task implementations from GCC and LLVM. We carried out the experiments on nodes of the Marenostrum4 supercomputer.
Finally, we enhance the OpenMP offloading mechanism by leveraging taskgraph. Particularly, we implemented the transformation of taskgraph to CUDA graphs. Consequently, our framework enhances the interoperability of OpenMP with other programming models (in this case, CUDA) and improves the performance of OpenMP accelerator model by alleviating the synchronization overhead.
With these contributions, this thesis ameliorates both the OpenMP tasking and accelerator models. The framework has been used by other Ph.D. students to develop their research, for example, Cyril Cetre from Thales Research and Technology successfully improved the performance of a cyber-physical application by utilizing static generation of CUDA graphs, as presented in this manuscript. Furthermore, the OpenMP Language Committee accepted our proposition to include the taskgraph directive into the OpenMP Specification v6.0. This thesis also contributed to the upstream LLVM repository. These commits are mainly focused on the record-and-replay mechanism of taskgraph, serving also as a basis for the official taskgraph implementation in the LLVM. We hope with these endeavors, this work will promote the use of OpenMP task in general.

(Català) El model d’execució de tasques és àmpliament utilitzat en l’enginyeria informàtica, ajudant els programadors a dissenyar, desenvolupar i comprendre sistemes de programari. OpenMP és el model de programació estàndard per paral·lelitzar algoritmes seqüencials en màquines de memòria compartida. Juntament amb la paral·lelització de tasques, OpenMP és capaç de paral·lelitzar convenientment aplicacions no estructurades i carregar les tasques en acceleradors com a target task. Tanmateix, la sobrecàrrega (i.e., overhead) de temps d’execució que implica el model de tasques d’OpenMP és una preocupació important per als usuaris que desenvolupen programes de tasques amb OpenMP.
Aquest manuscrit se centra en la millora del model de tasques d’OpenMP. Més concretament, la primera contribució d’aquesta tesi consisteix a analitzar la sobrecàrrega de rendiment i els “bottlenecks” de les implementacions de tasques principals i proposar una solució en l’especificació d’OpenMP per abordar-la. Com a segona contribució, vam implementar la solució proposada, la directiva taskgraph, en el compilador LLVM. Juntament amb la implementació, vam avaluar el rendiment de la nostra solució per garantir que resol els problemes de rendiment. Finalment, vam explorar la possibilitat de millorar el mecanisme de offloading d’OpenMP aprofitant CUDA Graph i taskgraph. En fer-ho, també vam millorar la interoperabilitat d’OpenMP.
Amb aquestes contribucions, millorem el model de tasques tant en l’especificació actual d’OpenMP com en la implementació. Esperem que aquest treball promogui l’ús de tasques d’OpenMP en general.

(Español) El modelo de ejecución de tareas es ampliamente utilizado en la ingeniería informática, ayudando a los programadores a diseñar, desarrollar y comprender sistemas de software. OpenMP es el modelo de programación estándar para paralelizar algoritmos secuenciales en máquinas de memoria compartida. Junto con la paralelización de tareas, OpenMP es capaz de paralelizar convenientemente aplicaciones no estructuradas y cargar las tareas en aceleradores como un target task. Sin embargo, la sobrecarga (i.e., overhead) de tiempo de ejecución que incurre el modelo de tareas de OpenMP es una preocupación importante para los usuarios que desarrollan programas de tareas en OpenMP.
Este manuscrito se centra en la mejora del modelo de tareas de OpenMP. Más concretamente, la primera contribución de esta tesis consiste en analizar la sobrecarga de rendimiento y los “bottlenecks” de las implementaciones de tareas principales y proponer una solución en la especificación de OpenMP para abordarla. Como segunda contribución, implementamos la solución propuesta, la directiva taskgraph, en el compilador LLVM. Junto con la implementación, evaluamos el rendimiento de nuestra solución para garantizar que resuelve los problemas de rendimiento. Finalmente, exploramos la posibilidad de mejorar el mecanismo de offloading de OpenMP aprovechando CUDA Graph y taskgraph. Al hacerlo, también mejoramos la interoperabilidad de OpenMP.
Con estas contribuciones, mejoramos el modelo de tareas tanto en la especificación actual de OpenMP como en la implementación. Esperamos que este trabajo Promueva el uso de tareas de OpenMP en general.