Experiences with HPX on Embedded Real-Time Systems

Experiences with HPX on Embedded Real-Time Systems

CORE Metadata, citation and similar papers at core.ac.uk Provided by DSpace at University of West Bohemia Experiences with HPX on Embedded Real-Time Systems Remko van Wagensveld Ulrich Margull Technische Hochschule Ingolstadt Technische Hochschule Ingolstadt Esplanade 10, 85049 Ingolstadt Esplanade 10, 85049 Ingolstadt Germany Germany Email: [email protected] Email: [email protected] Abstract—Recently more and more embedded devices standard and are therefore programmed in C. The use multi-core processors. For example, the current standard’s upcoming extension Adaptive AUTOSAR generation of high-end engine-control units exhibit triple- [9], allows using C++ as a programming language for core processors. To reliably exploit the parallelism of these cores, an advanced programming environment is these kinds of systems. Therefore, it is necessary to needed, such as the current C++17 Standard, as well know if the use of C++ language features would be as the upcoming C++20 Standard. Using C++ to co- beneficial for the current generation of engine-control operatively parallelize software is comprehensively in- systems. vestigated, but not in the context of embedded multi- This paper is structured as follows. First, the cur- core devices with real-time requirements. For this paper we used two algorithms from Continental AG’s power- rent state of research is shown, and afterwards we train which are characteristic for real-time embedded summarize some new concepts in C++17 and C++20, devices and examined the effect of parallelizing them with as well as HPX. After that we present the algorithms C++17/20, represented by HPX as a C++17/20 runtime of our case studies and our parallelization approach implementation. Different data sizes were used to increase respectively. Subsequently, we present and discuss our the execution times of the parallel sections. According to Gustafson’s Law, with these increased data sizes, the measurement results. Finally, we will address our ex- benefit of parallelization increases and greater speed-ups amined overhead with HPX. are possible. When keeping Continental AG’s original data sizes, HPX is not able to reduce the execution time II. RELATED WORK of the algorithms. This chapter describes the current research in the I. INTRODUCTION field of parallel programming environments and the In 2022 “multi-core will be everywhere” [1, p. 45]. usage of C++ for embedded real-time systems. The automotive industry is already using multi-core There is a multitude of ways to exploit parallelism processors for the power-train control systems, which and concurrency in C++. OpenMP [10] is a library have real-time requirements. This evolution calls for for parallel shared-memory systems that lets the user programming environments which are optimized for expose parallelism via pragmas in the source code. exploiting multi-core processors for embedded devices OpenMP is widely used, but is not suitable for em- with real-time requirements. C++17 [2] has additions bedded systems and needs additional extensions to be to the parallel execution of algorithms in form of the usable as parallel programming model for such systems Parallelism Technical Specification (TS) [3]. Addition- [11]. ally, the Concurrency TS [4] adds ways to manage Intel developed the Threading Building Blocks the concurrent execution of tasks. However, is is not (TBB) [12], a C++ template library providing access to yet merged into the C++ Standard. Both changes are parallel algorithms, data containers, locks and atomic implemented by HPX [5], a general purpose C++ operations, a task scheduler, and a memory allocator runtime system based on ParalleX [6]. [13]. Microsoft developed the Parallel Patterns Library In this paper we will investigate if HPX is suitable (PPL) [14] which provides parallel algorithms. PPL is to be used in the automotive industry for embedded built on top of the Microsoft Concurrency Runtime systems. These real-time systems usually execute algo- which provides a Task Scheduler and a Resource rithms which are not arithmetical intense and use only Manager [15]. The PPL only works on Microsoft small data sets; also the hardware used has very little Windows as an Operating System (OS) and is thus resources. These circumstances make a parallelization not suitable for embedded systems where GNU/Linux more difficult [7]. This is a completely different set is common. Both Intel TBB and Microsoft PPL have of problems, compared to the common circumstances an Application Programming Interface (API) that is in High Performance Computing for which HPX is not standardized, which makes the code reliant on the optimized. library implementation. The use of C++17 does not Additionally, the current generation of power-train have such a constraint since every runtime implement- engine-control systems conform to the AUTOSAR [8] ing C++17 will be able to execute a C++17 conform ISBN 978-80-261-0642-5, © University of West Bohemia, 2017 program. Another research field that should be addressed is the operation has been finished. The operation can the use of C++ on embedded devices. Most of the return values which are then saved in the enclosing advanced C++ features introduce either no or a fixed future object. Through this concept it is possible to overhead [16, p. 78ff.]. This makes the execution time declare a value that is required in the “future” but not for these features predictable and therefore suitable for now. Therefore, when the value, represented by the use in real-time systems. However, dynamic memory future object, is needed, the future.get() method allocation, dynamic data-type casting, and exceptions is called, which blocks until the value is ready. This is introduce a low, but undetermined overhead. This pre- equivalent to a synchronization of the current calling vents a timing prediction [16], and thus they are not thread and the asynchronous operation. recommended for use in real-time systems [17, p. 6]. In the Concurrency TS the concept of contin- These concepts are not used in the automotive industry uations is added into C++. When using a future and therefore C++ does not have a disadvantage in to save the state of an asynchronous operation, comparison to C for real-time systems. it is now possible to continue the asynchronous When comparing C++ with the Real-Time Speci- operation with another operation by the use of fication for Java (RTSJ), it is shown that the “C++ future.then(chained_operation). programming model is simpler and safer” than RTSJ. Additional to the continuations, in C++20 it is [18, p. 1]. The reason for this is the missing Garbage possible to create a future that gets ready when Collection when using RTSJ with hard real-time, where all futures of a set are ready. To accomplish this, on the other hand, C++ implicitly deconstructs the future.when_all() is used. objects when leaving scope [18]. This helps to prevent In combination with the continuations there exists memory leaks and access of data after its release. C++ an elegant way to describe complex task graphs. also prevents illegal memory mutation by the usage of constant references [18] which increases the integrity IV. CASE STUDIES of the data. For our work we identified two key algorithms used Research has been done in the field of C++ on by the automotive industry with parallel executable embedded devices with real-time requirements. But, to sections. These algorithms also have been examined the best of our knowledge, there are no studies covering by Hartmann et al. [20] for the use in a GPGPU parallelism with C++ on embedded devices with real- environment. time requirements. The first algorithm is a curve-sketching algorithm III. HPX AND C++17/20 and the second is a finite element simulation. In se- quential form, the curve-sketching algorithm is already “HPX is a general purpose C++ runtime system for in production and the finite element simulation is parallel and distributed applications of any scale” [19]. currently in pre-production. In this section the two It implements the ParalleX execution model [6]. HPX examined algorithms are presented. uses lightweight userspace threads to minimize the overhead needed for thread creation and scheduling. At A. Curve-Sketching Algorithm startup HPX allocates a predefined number of system cores and executes the HPX task scheduler on each of The first examined algorithm is a curve-sketching those cores. The task schedulers are able to schedule problem where the challenge is to find a specific inflec- and execute HPX lightweight threads on the allocated tion point in a given characteristic. The characteristic core. is a voltage curve measured by an Analog-to-digital- When executing a parallel algorithm, the lightweight Converter (ADC). After the calculation of the second threads needed are created and put into the queues derivation, the second biggest negative area under the used by the task schedulers. The task schedulers then curve marks the bend. The biggest negative area under execute the next lightweight thread in their queue. the second derivation curve results from triggering the HPX implements C++17 and C++20 language fea- mechanical device which overshoots and can therefore tures, especially those introduced in the Parallelism TS be ignored. and the Concurrency TS. In Fig. 1 a typical characteristic is shown, as are the The Parallelism TS adds execution policies to the corresponding first and second derivation. The data for language and is merged into C++17 [2]. An execution the characteristic is given in discrete values. policy defines how an algorithm can be executed, for Only the second derivation is needed, therefore the 00 example, if it is able to be executed in parallel or has central difference approximation for f (x) is used, as to be executed sequentially. These policies are added shown in Equation (1).

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    6 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us