Unlisted Videos All Videos All Videos Submit Video



Combining Co-Routines and Functions into a Job System - Helmut Hlavacs - CppCon 2021








Uploaded to YouTube by: CppCon
Date submitted to Unlisted Videos: 20 February 2024
Date uploaded/published to YouTube: 26 December 2021

Tags:




Description:

https://cppcon.org/
https://github.com/CppCon/CppCon2020
---
Every game engine today should have a job system that harvests the power of the available CPU cores. Additionally, C++20 has introduced co-routines, which can schedule other tasks and suspend until these tasks have finished. Due to this suspension, the thread the co-routine is running on is free to serve other jobs.

Using co-routines in a job system results in easy to read code, local variables do not go out of scope until the co-routine returns.

However, there is a price to pay. Co-routines demand to use their own machinery for suspension and synchronizing them with other co-routines. Mixing in functions, lambdas or functors that do not have access to this machinery proves to be a demanding task, especially if they should interact and synchronize with co-routines.

This talk presents the Vienna Game Job System (VGJS), a C++20 based job system that seamlessly combines co-routines with functions, lamdas and functors. Co-routines can synchronize with functions, and vice-versa. This way, programmers can always choose which form of job is appropriate - either create a co-routine (which incurs some overhead due to allocations from the heap and the co-routine machinery), or run a function, a functor, etc., with generally better performance.

Additionally, VGJS allows to create tagged jobs to be run later, e.g., if a game in the game loop goes sequentially through phases, and specific jobs should be run in them. VGJS also allows for collecting performance trace files to be visualized in Chrome, and supports memory resources to be used for its allocations.

The talk will also show performance differences between co-routines, functions, and fibers (co-routines that do not return).

---
Helmut Hlavacs

Dr. Helmut Hlavacs is Full Professor for Computer Science at the University of Vienna, Austria (ORCID: orcid.org/0000-0001-6837-674X). Dr. Hlavacs has a PhD in Mathematics (2001), and an MSc in Mathematics (1993). He also was awarded a Habilitation in the area of Applied Computer Science (2004). He currently heads a research group on Entertainment Computing, focusing here on technical aspects of computer games, game engines and C++, rendering with the Vulkan API, as well as application of computer games and virtual reality for well being, health, and anxiety therapy.

---
Videos Streamed & Edited by Digital Medium: http://online.digital-medium.co.uk

*--*