scieee AI-readable full text Open interactive document viewer

Exploring coordinated software and hardware support for hardware resource allocation

Figueiredo Boneti, Carlos Santieri de

Abstract

Multithreaded processors are now common in the industry as they offer high performance at a low cost. Traditionally, in such processors, the assignation of hardware resources between the multiple threads is done implicitly, by the hardware policies. However, a new class of multithreaded hardware allows the explicit allocation of resources to be controlled or biased by the software. Currently, there is little or no coordination between the allocation of resources done by the hardware and the prioritization of tasks done by the software.<br/>This thesis targets to narrow the gap between the software and the hardware, with respect to the hardware resource allocation, by proposing a new explicit resource allocation hardware mechanism and novel schedulers that use the currently available hardware resource allocation mechanisms.<br/>It approaches the problem in two different types of computing systems: on the high performance computing domain, we characterize the first processor to present a mechanism that allows the software to bias the allocation hardware resources, the IBM POWER5. In addition, we propose the use of hardware resource allocation as a way to balance high performance computing applications. Finally, we propose two new scheduling mechanisms that are able to transparently and successfully balance applications in real systems using the hardware resource allocation. On the soft real-time domain, we propose a hardware extension to the existing explicit resource allocation hardware and, in addition, two software schedulers that use the explicit allocation hardware to improve the schedulability of tasks in a soft real-time system.<br/>In this thesis, we demonstrate that system performance improves by making the software aware of the mechanisms to control the amount of resources given to each running thread. In particular, for the high performance computing domain, we show that it is possible to decrease the execution time of MPI applications biasing the hardware resource assignation between threads. In addition, we show that it is possible to decrease the number of missed deadlines when scheduling tasks in a soft real-time SMT system.

Full text

ADVERTIMENT . La consulta d’aquesta tesi queda condicionada a l’acceptació de les següents condicions d'ús: La difusió d’aquesta tesi per mitjà del servei TDX (www.tesisenxarxa.net) ha estat autoritzada pels titulars dels drets de propietat intel·lectual únicament per a usos privats emmarcats en activitats d’investigació i docència. No s’autoritza la seva reproducció amb finalitats de lucre ni la seva difusió i posada a disposició des d’un lloc aliè al servei TDX. No s’autoritza la presentació del seu contingut en una finestra o marc aliè a TDX (framing). Aquesta reserva de drets afecta tant al resum de presentació de la tesi com als seus continguts. En la utilització o cita de parts de la tesi és obligat indicar el nom de la persona autora. ADVERTENCIA. La consulta de esta tesis queda condicionada a la aceptación de las siguientes condiciones de uso: La difusión de esta tesis por medio del servicio TDR (www.tesisenred.net) ha sido autorizada por los titulares de los derechos de propiedad intelectual únicamente para usos privados enmarcados en actividades de investigación y docencia. No se autoriza su reproducción con finalidades de lucro ni su difusión y puesta a disposición desde un sitio ajeno al servicio TDR. No se autoriza la presentación de su contenido en una ventana o marco ajeno a TDR (framing). Esta reserva de derechos afecta tanto al resumen de presentación de la tesis como a sus contenidos. En la utilización o cita de partes de la tesis es obligado indicar el nombre de la persona autora. WARNING. On having consulted this thesis you’re accepting the following use conditions: Spreading this thesis by the TDX (www.tesisenxarxa.net) service has been authorized by the titular of the intellectual property rights only for private uses placed in investigation and teaching activities. Reproduction with lucrative aims is not authorized neither its spreading and availability from a site foreign to the TDX service. Introducing its content in a window or frame foreign to the TDX service is not authorized (framing). This rights affect to the presentation summary of the thesis as well as to its contents. In the using or citation of parts of the thesis it’s obliged to indicate the name of the author UNIVERSITAT POLIT ` ECNICA DE CATALUNYA Exploring Coordinated Software and Hardware Support for Hardware Resource Allocation by Carlos Santieri de Figueiredo Boneti A thesis submitted in partial fulfillment of the requirements for the degree of DOCTOR OF PHILOSOPHY / DOCTOR PER LA UPC in the Department of Computer Architecture 2009 UNIVERSITAT POLIT ` ECNICA DE CATALUNYA Exploring Coordinated Software and Hardware Support for Hardware Resource Allocation by Carlos Santieri de Figueiredo Boneti Advisors: Francisco J. Cazorla BARCELONA SUPERCOMPUTING CENTER Roberto Gioiosa IBM TJ. WATSON RESEARCH CENTER Mateo Valero Cort´ es UNIVERSITAT POLIT ` ECNICA DE CATALUNYA A thesis submitted in partial fulfillment of the requirements for the degree of DOCTOR OF PHILOSOPHY / DOCTOR PER LA UPC in the Department of Computer Architecture 2009 “An intellectual is someone whose mind watches itself.” Albert Camus “The difference between the right word and the almost right word is the difference between lightning and the lightning bug.” Mark Twain Abstract Multithreaded processors are now common in the industry as they offer high performance at a low cost. Traditionally, in such processors, the assignation of hardware resources between the multiple threads is done implicitly, by the hardware policies. However, a new class of multithreaded hardware allows the explicit allocation of resources to be controlled or biased by the software. Currently, there is little or no coordination between the allocation of resources done by the hardware and the prioritization of tasks done by the software. This thesis targets to narrow the gap between the software and the hardware, with respect to the hardware resource allocation, by proposing a new explicit resource allocation hardware mechanism and novel schedulers that use the currently available hardware resource allocation mechanisms. It approaches the problem in two different types of computing systems: on the high performance computing domain, we characterize the first processor to present a mechanism that allows the software to bias the allocation hardware resources, the IBM POWER5TM. In addition, we propose the use of hardware resource allocation as a way to balance high performance computing applications. Finally, we propose two new scheduling mechanisms that are able to transparently and successfully balance applications in real systems using the hardware resource allocation. On the soft real-time domain, we propose a hardware extension to the existing explicit resource allocation hardware and, in addition, two software schedulers that use the explicit allocation hardware to improve the schedulability of tasks in a soft real-time system. In this thesis, we demonstrate that system performance improves by making the software aware of the mechanisms to control the amount of resources given to each running thread. In particular, for the high performance computing domain, we show that it is possible to decrease the execution time of MPI applications biasing the hardware resource assignation between threads. In addition, we show that it is possible to decrease the number of missed deadlines when scheduling tasks in a soft real-time SMT system. List of Figures 1.1 Execution time of bzip2 when coscheduled with other benchmarks. . . . 2 1.2 Difference between the perception of an MT processor and reality . . . 3 2.1 Example of application of the FAME methodology. In this example Micro-Benchmark 1 takes longer than Micro-Benchmark 2. . . . . . . . 15 2.2 Performance improvement of the PThread as its priority increases with respect to the SThread. Note the different scale for ldint l1. . . . . . 21 2.3 Performance degradation of the PThread as its priority decreases with respect to the SThread. . . . . . . . . . . . . . . . . . . . . . . . . . . 22 2.4 Throughput w.r.t. execution (4,4). The legend shows the single-thread IPC of benchmarks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 2.5 Total IPCs with increasing priorities . . . . . . . . . . . . . . . . . . . 25 2.6 Single-threaded and multithreaded (with a software pipeline) organizations of LU and FFT combination. . . . . . . . . . . . . . . . . . . . . 26 2.7 Primary thread Execution Time with respect to Single-Thread when SThread has priority 1 . . . . . . . . . . . . . . . . . . . . . . . . . . 28 3.1 Expected effect of the proposed solution (T′< T). . . . . . . . . . . . 38 3.2 Effect of the proposed solution on Metbench. Each trace represents only some iterations of the application. . . . . . . . . . . . . . . . . . . . . 41 3.3 Effect of the proposed solution on BT-MZ. Each trace represents only some iterations of the application. . . . . . . . . . . . . . . . . . . . . 43 3.4 Effect of the proposed solution on SIESTA. . . . . . . . . . . . . . . . 46 4.1 Scheduling classes for the standard and the modified Linux kernel . . . 52 4.2 HPC application iterative behavior . . . . . . . . . . . . . . . . . . . . 57 4.3 Effect of the proposed solution on Metbench. . . . . . . . . . . . . . . 61 4.4 Effect of the proposed solution on MetbenchVar. . . . . . . . . . . . . . 63 4.5 Effect of the proposed solution on BT-MZ. Each trace represents only some iterations of the application. . . . . . . . . . . . . . . . . . . . . 65 4.6 Effect of the proposed solution on SIESTA. . . . . . . . . . . . . . . . 66 5.1 DLRB scheduling domains for load-balancing. . . . . . . . . . . . . . 73 5.2 Effect of the proposed solution on Metbench. . . . . . . . . . . . . . . 75 5.3 Relative execution times for ten iterations of Metbench. . . . . . . . . . 76 5.4 Effect of the proposed solution on MetbenchVar. Observe that the static prioritization has a different time scale. . . . . . . . . . . . . . . . . . . 77 xiii List of Figures xiv 5.5 Relative execution times for 45 iterations of MetbenchVar (changing behavior every 15). . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 5.6 Effect of the proposed solution on BT-MZ. Each trace represents only some iterations of the application. . . . . . . . . . . . . . . . . . . . . 79 5.7 Relative execution times for BT-MZ class A. . . . . . . . . . . . . . . . 79 5.8 Relative execution times for SIESTA. . . . . . . . . . . . . . . . . . . 80 6.1 Collaboration between the OS job scheduler and the SMT hardware: steps required to schedule a task set in classical SMT processors. . . . . 84 6.2 Accounted performance for LPT based MCT RA. . . . . . . . . . . . . 94 6.3 States and sub-states in which our resource allocation divides the execution of a workload . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 6.4 Registers and variables needed by the hs-thread. . . . . . . . . . . . . . 99 6.5 Hs-thread pseudo-code. . . . . . . . . . . . . . . . . . . . . . . . . . . 100 6.6 Processor and memory configuration for the simulation infrastructure . 103 6.7 Schematic view of the simulation infra-structure . . . . . . . . . . . . . 103 6.8 Comparison between various EDF based algorithms (4-,8-,12-tasks). . . 105 6.9 Comparison between the LLF based algorithms (4-,8-,12-tasks). . . . . 107 6.10 Comparison between our proposed algorithms (4-,8-,12-tasks). . . . . . 108 6.11 Aggregated success rate for all serial utilizations normalized to EDF. . . 109 List of Tables 2.1 Decode cycles allocation in the IBM POWER5 with different priorities . 13 2.2 Software-controlled thread priorities in the IBM POWER5 processor. . 14 2.3 Resource allocation when the priority of any of the threads is 0 or 1 . . 14 2.4 Loop body of the different micro-benchmarks. . . . . . . . . . . . . . . 17 2.5 IPC of micro-benchmarks in ST mode and in SMT with priorities (4,4). pt stands for PThread and tt for total IPC. . . . . . . . . . . . . . . . . 19 2.6 Execution time, in seconds, of FFT and LU. . . . . . . . . . . . . . . . 27 3.1 Metbench balanced and imbalanced characterization . . . . . . . . . . 42 3.2 BT-MZ balanced and imbalanced characterization . . . . . . . . . . . . 44 3.3 SIESTA balanced and imbalanced characterization . . . . . . . . . . . 47 4.1 Metbench balanced and imbalanced characterization . . . . . . . . . . 62 4.2 Variable-Metbench balanced and imbalanced characterization . . . . . . 64 4.3 BT-MZ balanced and imbalanced characterization . . . . . . . . . . . . 64 4.4 SIESTA balanced and imbalanced characterization . . . . . . . . . . . 67 6.1 Hypothetical task set. . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 6.2 MediaBench benchmarks used in this work. . . . . . . . . . . . . . . . 101 6.3 Benchmark interactions without explicit resource allocation. . . . . . . 107 6.4 Benchmark interactions without explicit resource allocation. . . . . . . 107 xv Abbreviations CMP Chip Multi-Processor DLRB Dynamic Load and Resource Balancer DRA Dual-objective Resource Allocation EDF Earliest Deadline First ERA Explicit Resource Allocation HPC High Performance Computing HPCSched HPC Scheduler hs Hardware-Scheduler IPC Instructions Per Cycle LLF Least Laxity First LPT Low Priority Thread LVP Low-Variability Performance MCT Most Critical Thread MinRa Minimum Resource Allocation MT Multi-Threaded NCT Non Critical Thread OS Operating System RA Resource Allocation RC Remaining Computation SU Serial Utilization TTD Time ToDeadline SMT Simultaneous Multithreading SRA Single-objective Resource Allocation WCET Worst Case Execution Time xvii Dedicated to my parents: Rita Vieira and Lindomar Boneti. xix Chapter 1 Introduction As the process technology evolves and the number of available transistors in a chip increases, limitations in exploitation of the instruction level parallelism and power constraints created a trend where modern processors started to execute multiple simultaneous execution flows. Simply increasing the frequency of a superscalar processor tends to increase the power consumption beyond today’s acceptable limits and, therefore, thread-level parallelism has become a common strategy to improve performance. Multithreaded1(MT) processors have widespread use in almost every class of computer system. They offer high performance at a low cost by sharing processor’s internal hardware resources among multiple execution flows or threads. In one extreme of the spectrum, in SMT processors, the threads share most of the processor’s internal hardware resources, while in the other extreme, in a CMP processor, they typically share cache levels and memory bandwidth. Levels of resource-sharing are often combined, as for instance, the IBM POWER5TM processor is both SMT and CMP: a POWER5 chip has two cores, where each core has two SMT threads. In addition to the achievement of higher throughput, MT processors have good performance/cost ratio as they often present simpler cores replicated in the chip, which are easier to design than more complex bigger cores. Furthermore, they commonly have better watt per committed instruction ratio than large super-scalar processors. In this domain several researchers have proposed many hardware improvements to maximize a number of metrics [68][77][76][75][13][19][14][11]. Hardware is often tailored to share the processor’s internal resources in order to maximize throughput or fairness. 1In this thesis, we refer to multithreaded processors as being any kind of processor that executes multiple threads at the same time. Simultaneous Multithreading (SMT), fine-grain multithreaded, coarsegrain multithreaded or Chip Multi-Processor (CMP) are examples of MT processors. 1 Chapter 1. Introduction 2 1.1 Background on resource allocation One of the major drawbacks of MT processors is that, in most cases, the way the internal hardware resources are split between the different execution flows or threads is not specified by the software, but implicitly decided by the hardware. In other words, such systems have implicit resource allocation. For instance, the sharing in the caches may be decided by the cache replacement policy [22][66], while the fetch bandwidth may be split using a multithreading fetch policy like icount [76], FLUSH [75] or FLUSH++ [13]. To better illustrate the problem, take for instance the fetch policy, which decides how the instructions are fetched from the running threads in a SMT processor. The fetch policy determines implicitly how the internal resources, like the renaming registers or the instruction queue entries, are allocated. A common characteristic of many proposed fetch policies is that they try to increase the processor’s throughput and/or fairness [59] by stalling or flushing instructions from threads presenting L2 misses [75][55]. They target to increase the overall system performance by seamlessly controlling the flow of a thread. FIGURE 1.1: Execution time of bzip2 when coscheduled with other benchmarks. Chapter 2 Software-Controlled Priority Characterization of POWER5 Processor 2.1 Introduction In the first part of this thesis, we focus on the High Performance Computing (HPC) domain, in which some processors allow the control of the assignment of hardware resources. Having a commercially available processor with explicit resource allocation allows us to evaluate our proposals on a real hardware, with a real operating system. We start with a detailed analysis of the IBM POWER5TM processor, which will be used for our experiments in the remaining of the HPC sections. The IBM POWER5 is a dual-core processor, where each core runs two threads. Threads share many resources such as the Global Completion Table (GCT or reorder buffer), the Branch History Table (BHT) and the Translation Lookaside Buffer (TLB). It is well known that higher performance is realized when resources are appropriately balanced across threads [49][50][69]. An IBM POWER5 system appropriately balances the usage of resources across threads with mechanisms in hardware [35][49]. Moreover, POWER5 employs a mechanism, through software/hardware co-design, that controls the instruction decode rate with eight priority levels. Its main motivation is to address instances where unbalanced thread priority is desirable. Several examples can be enumerated such as idle thread, thread waiting on a spin-lock, software determined 9 Chapter 2. Software-Controlled Priority Characterization of POWER5 Processor 10 non-uniform balance and power management [50][69]. Software-controlled priority1 can significantly improve both throughput and execution time depending on the application type. In the literature, a wide range of mechanisms has been proposed on dynamically balancing of resources to improve SMT performance. Most of these proposals focus on the instruction fetch policy as the means to obtain such balancing [32][75]. In addition to the instruction fetch policy, other mechanisms explicitly prioritize shared resources among threads to improve throughput, fairness [19][23] and Quality of Service [17]. While these studies do not correspond to the software prioritization mechanism of POWER5, they could justify the use of the mechanism. Nevertheless, the prioritization mechanism provided by POWER5 is rarely used among the software community and, even in these rare cases, the prioritization mechanism is mainly used for lowering the priority of a thread. For instance, the Linux kernel version 2.6.23 exploits the software-controlled priorities in few cases to reduce the priority of a processor that is not performing any useful computation. Moreover, Linux makes the assumption that the software-controlled priority mechanism is not used by the programmer and resets the priority to the default value at every interrupt or exception handling point. Currently, the lack of quantitative studies on software-controlled priority limit their use in real world applications. In this chapter, we provide the first quantitative study of the POWER5 prioritization mechanism. We show that the effect of thread prioritization depends on the characteristics of a given thread and the other thread it is coscheduled with. Our results show that, if used properly, software-controlled priorities may increase overall system performance, depending on the metric of interest. Furthermore, this study helps Linux and other software communities to tune the performance of their software by exploiting the software-controlled priority mechanism of the POWER5 processor. The main contributions of this chapter are: 1. We provide a detailed analysis of the effect of the POWER5 prioritization mechanism on execution time of applications with a set of selected micro-benchmarks that stress specific workload characteristics. We show that: •Threads executing long-latency operations (i.e., threads with a lot of misses in the caches) are less effected by priorities than threads executing short-latency 1POWER5 software-controlled priorities are independent of the operating systems concept of process or task priorities. Chapter 2. Software-Controlled Priority Characterization of POWER5 Processor 11 operations (i.e. cpu-bound threads). For example, we observe that increasing the priority of a cpu-bound thread could reduce its execution time by 2.5x over the baseline. Increasing the priority of memory-bound threads causes an execution time reduction of 1.7x when they are run with other memory-bound threads. •By reducing the priority of a cpu-bound thread, its performance can decrease up to 42x when running with a memory-bound thread and up to 20x when running with another cpu-bound thread. In general, improving the performance of one thread involves a higher performance loss on the other thread, sometimes by an order of magnitude. However, decreasing the priority of a long-latency thread has less effect on its execution time compared to a cpu-bound thread. For example, decreasing the priority of a memory-bound thread increases its execution time by 22x when running with another memory-bound thread, while increases less than 2.5x when running with the other benchmarks. In Section 2.5.3 we show how to exploit this to improve the overall performance. •For the micro-benchmarks used in this chapter, the IPC throughput of the POWER5 improves up to 2x by using software-controlled priorities. •We also show that a thread can run transparently, with almost no impact on the performance of a higher-priority thread. In general, foreground threads with lower IPC are less sensitive to a transparent thread. 2. We present two application case studies that show how priorities in POWER5 can be used to improve two different metrics: aggregated IPC and execution time. •In the case of a batch application where the main metric is throughput, the performance improves up to 23.7%. •In the case of an unbalanced MPI parallel application, execution time reduces up to 9.3% by using priorities to re-balance its resources. To our knowledge, this is the first quantitative study showing how software-controlled prioritization of POWER5 effects performance on a real system. Since other processors like the IBM POWER6TM [53] present a similar prioritization mechanism, this study can be significantly useful for the software community. This chapter is organized as follows: Section 2.2 presents the related work. Section 2.3 describes the POWER5 resource balancing in hardware and the software-controlled priority mechanisms. Section 2.4 presents our evaluation environment, and Section 2.5 shows our results and their analysis. Finally, Section 2.6 concludes this work. Chapter 2. Software-Controlled Priority Characterization of POWER5 Processor 12 2.2 Related Work In the literature a wide range of mechanisms have been proposed to prioritize the execution of a thread in a SMT processor. Many of these proposals focus on the instructionfetch policy to improve performance and fairness in SMT processors, while other focus on explicitly assigning processor resources to threads. Instruction Fetch Policies: An instruction fetch (I-fetch) policy decides how instructions are fetched from the threads, thereby implicitly determining the way processor resources, like rename registers or issue queue entries, are allocated to the threads. Many existing fetch policies attempt to maximize throughput and fairness by reducing the priority, stalling, or flushing threads that experience long latency memory operations [19][75]. Some other fetch policies focus on reducing the effects of misspeculation by stalling on hard-to-predict branches [51][58]. Explicit Resource Allocation: Some of the mechanisms explicitly allocate shared processor resources targeting throughput improvements [19][23]. Other resource allocation mechanisms provide better QoS guarantees for the execution time by ensuring a minimum performance for the time critical threads [20][17]. 2.3 The POWER5 Processor IBM POWER5 [43] processor is a dual-core chip where each core runs two threads [50]. POWER5 employs two levels of control among threads, through resource balancing in hardware (Section 2.3.1), as well as software-controlled prioritization (Section 2.3.2). 2.3.1 Dynamic hardware resource balancing POWER5 provides a dynamic resource-balancing mechanism that monitors processor resources to determine whether one thread is potentially blocking the other thread execution. Under that condition, the progress of the offending thread is throttled back, allowing the sibling thread to progress. POWER5 considers that there is an unbalanced use of resources when a thread reaches a threshold of L2 cache or TLB misses, or when a thread uses too many GCT (reorder buffer) entries. POWER5 employs one of the following mechanisms to re-balance resources among threads: 1) It stops instruction decoding of the offending thread until the congestion Chapter 2. Software-Controlled Priority Characterization of POWER5 Processor 13 clears (Stall). 2) It flushes all of the instructions of the offending thread that are waiting for dispatch and stopping the thread from decoding additional instructions until the congestion clears (Flush). Moreover, the hardware may temporarily adjust the decode rate of a thread to throttle its execution. 2.3.2 Software-controlled priorities The number of decode cycles assigned to each thread depends on the software-controlled priority. The enforcement of these software-controlled priorities is carried by hardware in the decode stage. In general, the higher the priority, the higher the number of decode cycles assigned to the thread. Let us assume that two threads, a primary thread (PThread) and a secondary thread (SThread), are running on one of the two cores of the POWER5 with priorities PrioP and PrioS, respectively. Based on the priorities, the decode slots are allocated using the following formula: R= 2|P rioP −P rioS|+1 (2.1) Table 2.1 shows the possible values of Rand how many decode slots are assigned to the two threads as the difference between ThreadA’s and ThreadB’s priority moves from 0 to 4. Notice that Ris computed using the difference of priorities of PThread and SThread,PrioP-PrioS. At any given moment, the thread with higher priority receives R- 1 decode slots, while the lower priority thread receives the remaining slot. For instance, assuming that PThread has priority 6 and SThread has priority 2, Rwould be 32, so the core decodes 31 times from PThread and once from SThread (more details on the hardware implementation are provided in [35]). The performance of the process running as PThread increases to the detriment of the one running as SThread. On the case where both threads have the same priority, R= 2, and therefore, each thread receives one slot, alternately. TABLE 2.1: Decode cycles allocation in the IBM POWER5 with different priorities Priority difference R Decode cycles Decode cycles (PrioP-PrioS) for A for B 0 2 1 1 1 4 3 1 2 8 7 1 3 16 15 1 4 32 31 1 Chapter 2. Software-Controlled Priority Characterization of POWER5 Processor 14 In POWER5, the software-controlled priorities range from 0 to 7, where 0 means the thread is switched off and 7 means the thread is running in Single Thread (ST) mode (i.e., the other thread is off). The supervisor or operating system can set six of the eight priorities ranging from 1 to 6, while user software can only set priority 2, 3 and 4. The Hypervisor can always use the whole range of priorities. As described in [35] and [43], the priorities can be set by issuing an or instruction in the form of or X,X,X, where Xis a specific register number. This operation only changes the thread priority and performs no other operation. If it is not supported (when running on previous POWER processors) or not permitted due to insufficient privileges, the instruction is simply treated as a nop. Table 2.2 shows the priorities, the privilege level required to set each priority and how to change priority using this interface. TABLE 2.2: Software-controlled thread priorities in the IBM POWER5 processor. Priority Priority level Privilege level or-nop instruction 0 Thread shut off Hypervisor - 1 Very low Supervisor or 31,31,31 2 Low User/Supervisor or 1,1,1 3 Medium-Low User/Supervisor or 6,6,6 4 Medium User/Supervisor or 2,2,2 5 Medium-high Supervisor or 5,5,5 6 High Supervisor or 3,3,3 7 Very high Hypervisor or 7,7,7 The behavior of the software-controlled thread prioritization mechanism is different when one of the threads has priorities 0 or 1 as shown in Table 2.3 [35][43]. For instance, when both threads have priority one, instead of being considered as difference 0 and perform as having no prioritization, the processor runs in low-power mode, decoding only one instruction every 32 cycles. TABLE 2.3: Resource allocation when the priority of any of the threads is 0 or 1 PThread SThread Action >1>1Decode cycles are given to the two threads as explained above 1>1SThread gets all the execution resources; PThread takes what is left over 1 1 Power save mode; both PThread and SThread receive 1 of 32 decode cycles 0>1Processor in ST mode. SThread receives all the resources. 0 1 1 of 32 cycles are given to SThread 0 0 Processor is stopped Chapter 2. Software-Controlled Priority Characterization of POWER5 Processor 15 2.4 Evaluation Methodology Execution 1 0 MB1 Execution ends here 0 MB2 1 2 3 5 6 7 8 9 104 1 2 3 4 5 6 7 8 9 10 11 12 13 14 ` Execution 2 FIGURE 2.1: Example of application of the FAME methodology. In this example Micro-Benchmark 1 takes longer than Micro-Benchmark 2. In order to explore the capabilities of the software-controlled priority mechanism in the POWER5 processor, we performed a detailed set of experiments. Our approach consists of analyzing the processor as a black-box, observing how the performance of a workload changes as we increase or reduce the priority of threads. In a SMT processor the performance of one process not only depends on the processor architecture but also on the other processes running at the same time on the same core and their specific program phases. Under such conditions, evaluating all the possible programs and all their phase combinations is simply not feasible. Moreover, when it comes to a real system evaluation, with the several layers of the running software, the OS interferences and all the asynchronous I/O services, the problem becomes even worse. For this reason, we use a set of micro-benchmarks that stresses a particular processor characteristic. While this scenario is not typical with real applications, this is one of the best ways to understand the mechanism under evaluation. It provides a uniform characterization based on specific program characteristics that can be mapped into real applications. With real applications it would be impossible to attribute fine-grain performance gain/loss to the prioritization mechanism due to applications own variability. 2.4.1 Running the experiments This chapter uses the FAME (FAirly MEasuring Multithreaded Architectures) methodology [78][79]. In [78] the authors state that the average accumulated IPC of a program is representative if it is similar to the IPC of that program when the workload reaches a steady state. The problem is that, as shown in [78][79], the workload has to run for a long time to reach this steady state. FAME determines how many times each benchmark in a multi-threaded workload has to be executed so that the difference between Chapter 2. Software-Controlled Priority Characterization of POWER5 Processor 16 the obtained average IPC and the steady state IPC is below a particular threshold. This threshold is called MAIV (Maximum Allowable IPC Variation). The execution of the entire workload stops when all benchmarks have executed as many times as needed to accomplish a given MAIV value. For the experimental setup and micro-benchmarks used in this chapter, in order to accomplish a MAIV of 1%, each micro-benchmark must be repeated at least 10 times. In our experiments we run two workloads, hence each experiment ends when both threads re-execute at least 10 times. Note that, at this point the fastest thread might already execute more than 10 times. Figure 2.1 shows an example where the second benchmark is faster than the first. In this example, while the MB1(MicroBenchmark1) executes 10 times, MB2executes 14 times. It is important to note that the execution time difference is not constant. For instance, if we change the software-controlled priorities, MB2 may execute faster or slower, and therefore we must guarantee that both threads execute a minimum number of repetitions. In our experiments, the average execution time for a thread is estimated as the total accounted execution time divided by the number of complete repetitions. For example, in Figure 2.1, the total execution time of MB2is measured until it completes the 14th iteration and the time for the remaining incomplete iteration is discarded. Furthermore, as previously shown [34][36], normal software environment can insert significant noise into performance measurements. To minimize such noise, both singlethread and multithreaded experiments were performed on the second core of the POWER5. All user-land processes and interrupt requests (IRQ) were isolated on the first one, leaving the second core as free as possible from noise. 2.4.2 Micro-benchmark In a multi-threaded architecture, the performance of one process tightly depends on the other process that it is running with. Moreover, the effect of the software-controlled priorities depends on the characteristics of the benchmarks under study. In order to build a basic knowledge of these effects, we developed a set of 15 synthetic micro-benchmarks, each of them stressing a specific processor characteristic. This methodology allows us to isolate independent behaviors of the platform. Furthermore, micro-benchmarks provide higher flexibility due to their simplicity. We classify the micro-benchmarks in four groups: Integer, Floating Point, Memory and Branch, as shown in Table 2.4. In each group, there are benchmarks with different instruction latency. For example, in the Integer group there are short (cpu int) Chapter 2. Software-Controlled Priority Characterization of POWER5 Processor 17 and long (lng chain int) latency operation benchmarks. In the Memory group, ldint l2 is a benchmark with all loads always hitting in second level of data cache, while ldint mem has all loads hitting in memory and, hence, missing in all cache levels. As expected, ldint l2 has higher IPC than ldint mem. In the Branch group, there are two micro-benchmarks with high (br hit) and low (br miss) hit prediction rate. All the micro-benchmarks have the same structure. They iterate several times on their loop body and the loop body is what differentiates them. One execution of the loop body is called a micro-iteration. Table 2.4 shows the details of the loop body structures for the micro-benchmarks. The size of the loop body and the number of micro-iterations is specific for each benchmark. The benchmarks are compiled with the xlc compiler with -O2 option and their object code are verified in order to guarantee that the benchmarks retain the desired characteristics. TABLE 2.4: Loop body of the different micro-benchmarks. Name Loop Body cpu int a += (iter *(iter - 1)) - xi*iter :xi∈ {1,2, ..., 54} cpu int add a += (iter + (iterp)) - xi+ iter :xi∈ {1,2, ..., 54}; iterp = iter -1 + a cpu int mul a = (iter *iter) *xi*iter :xi∈ {1,2, ..., 54}; lng chain int a += (iter *(iter - 1)) - x0*iter :xi∈ {1,2, ..., 20} b += (iter *(iter - 1)) - x1*iter + a ... a += (iter + (iter - 1)) - x10 *j... The cycle of instructions is repeated multiple times, for a total of 50 lines in the loop body. br hit br miss if (a[s]=0) a=a+1; else a=a-1; s∈ {1,2, ..., 28} a is filled with all 0’s for br hit and randomly (modulo 2) for br miss ldint l1 ldint l2 ldint l3 ldint mem a[i+s] = a[i+s]+1; where s is set that we always hit in the desired cache level. ldfp l1 ldfp l2 ldfp l3 ldfp lmem In the case of fp benchmarks, a is an array of floats. cpu fp a += (tmp *(tmp - 1.0)) - xi*tmp —xi∈ {1.0,2.0, ..., 54.0}. (float tmp = iter *1.0) After the first complete set of experiments, where we ran all the possible combinations, we realized that some of the benchmarks behave equally and do not add any further insight to the analysis. Therefore, we present only the benchmarks that provide differentiation for this characterization work. For example, br hit,br miss,cpu int add, cpu int mul and cpu int behave in a very similar way. Analogously, the loadintegers and load-floating-points do not significantly differ. Therefore, we present only the results for cpu int,lng chain int,ldint l1,ldint l2,ldint mem and cpu fp. Chapter 2. Software-Controlled Priority Characterization of POWER5 Processor 18 2.4.3 The Linux kernel Some of the priority levels are not available in user mode (Section 2.3.2). In fact, only three levels out of eight can be used by user mode applications, the others are only available to the OS or the Hypervisor. Modern Linux kernels (2.6.23) running on IBM POWER5 processors exploit software-controlled priorities in few cases such as reducing the priority of a process when it is not performing useful computation. Basically, it makes use of the thread priorities in three cases: •The processor is spinning for a lock in kernel mode. In this case the priority of the spinning process is reduced. •The kernel is waiting for operations to complete. For example, when the kernel requests a specific CPU to perform an operation by means of a smp call function() and it can not proceed until the operation completes. Under this condition, the priority of the thread is reduced. •The kernel is running the idle process because there is no other process ready to run. In this case the kernel reduces the priority of the idle thread and eventually puts the core in Single Thread (ST) mode. In all these cases the kernel reduces the priority of a processor’s context and restores it to MEDIUM (4) as soon as there is some job to perform. Furthermore, since the kernel does not keep track of the current priority, and to ensure responsiveness, it also resets the thread priority to MEDIUM every time it enters a kernel service routine (for instance, an interrupt, an exception handler, or a system call). This is a conservative choice induced by the fact that it is not clear how and when to prioritize a processor context and what the effect of that prioritization is. In order to explore the entire priority range, we developed a non-intrusive kernel patch which provides an interface to the user to set all the possible priorities available in kernel mode: •We make priority 1 to 6 available to the user. As mentioned in Section 2.3.2, only three of the priorities (4, 3, 2) are directly available to the user. Without our kernel patch, any attempt to use other priorities result in a nop operation. Priority 0 and 7 (context off and single thread mode, respectively) are also available to the user through a Hypervisor call. Chapter 2. Software-Controlled Priority Characterization of POWER5 Processor 25 For the second pair, with the default priorities, applu has an IPC of 0.500 and completes in 240 seconds. equake takes 74 seconds and has an IPC of 0.140. Together, they reach a total IPC of 0.630 (Figure 2.5 (b)). In this case, the peak combined IPC is obtained when applu receives priority +5. It represents a 14% of improvement when compared to the default case. (a) h264ref and mcf (b) applu and equake FIGURE 2.5: Total IPCs with increasing priorities Chapter 2. Software-Controlled Priority Characterization of POWER5 Processor 26 2.5.4 Optimizing execution time The highest throughput does not always directly translate into the shortest execution time of a whole application [12]. Most of the parallel applications have synchronization points where all the tasks must complete some amount of work in order to continue. Load balancing in parallel application is a hard problem since it is rarely the case where the synchronized tasks finish perfectly at the same time. In other words, usually a task has to wait for other tasks to complete. This could clearly delay the progress of the whole program. 2.5.4.1 Case Study In this section we present an example where we are able to improve the overall application execution time by using the prioritization mechanism. In this example, we apply a LU matrix decomposition over a set of results produced by a Fast Fourier Transformation (FFT) for a given spectral analysis problem (Figure 2.6(a)). One possible organization of the problem would create a software pipeline where one thread runs the Fast Fourier Transformation, producing the results that will be consumed by the second thread on the next iteration, by applying LU over parts of this output (Figure 2.6(b)). (a) Single-threaded execution (b) Multithreaded execution FIGURE 2.6: Single-threaded and multithreaded (with a software pipeline) organizations of LU and FFT combination. Chapter 2. Software-Controlled Priority Characterization of POWER5 Processor 27 In our measurement, the FFT takes for 1.86 seconds in single-thread mode, and the LU takes 0.26 seconds to process its part of the problem. In single-thread mode, the processor would first execute the FFT and then the LU, thus, each iteration would require 2.12 seconds to complete. In the multi-threaded scenario, there is only FFT running in the first iteration to produce the first input of the LU. On the remaining iterations, both threads would be running in parallel and the execution time of an iteration would be the execution time of the longest thread. As we can see on the Table 2.6, when run together in SMT mode, the FFT takes 2.05 seconds and the LU decomposition takes 0.42 seconds. The LU thread would waste 1.63 seconds waiting for the other task to complete. Using the prioritization mechanism, we could increase the priority of FFT so it executes faster, reducing the unbalance. TABLE 2.6: Execution time, in seconds, of FFT and LU. Priority Priority FFT exec. LU exec. Iteration exec. Difference time time time single-thread 1.86 – mode - – 0.26 2.12 4,4 0 2.05 0.42 2.05 5,4 +1 2.02 0.48 2.02 6,4 +2 1.91 0.64 1.91 6,3 +3 1.87 2.33 2.33 Table 2.6 shows that the best case consists of running with a priority pair (6,4), which yields an iteration execution time of 1.91 seconds. Effectively this represents a 10% improvement when compared to the execution time in single thread mode (where it would be necessary to run the FFT followed by LU) and 9.3% of improvement over the default priorities. On the other hand, by applying too much prioritization, it’s possible to inverse the unbalance, which normally represents a performance loss (priority (6,3)). The idea of using POWER5 prioritization mechanisms to balance real HPC applications, reducing their execution time, will be further explored in the next chapters of this thesis. 2.5.5 Transparent execution Dorai and Yeung [28] propose transparent threads, which is a mechanism that allows background threads to use resources that a foreground thread does not require for running at almost full speed. In POWER5 this is implemented by setting the priority of the “background” thread to 1 [35]. Chapter 2. Software-Controlled Priority Characterization of POWER5 Processor 28                        ¡   ¢ £ ¤ ¥ ¦ § ¨ © £ ¤ ¥ ¦ ª ¤ « ¨ ¬ ¦ £  ® § ¨ ¬ « ¯ § ¨ © ¦ « ° « ¯ § ¨ © ¦ « ± « ¯ § ¨ © ¦ ² ³ ² ´ µ ¶·¸ ¶µ ¹º » ¼ ½ ¶·¾ » ¿ À Á  à Á À Ä Å Æ Ç È Á Â É Æ Ê Ë Â Ì Í Ç Î Ï Â Ð À Á Ï É Ñ Î Ò Â Æ Ó À Ê Ë Â Ì Ä Ó Î À Å Ô Õ Ö × Ø Ù Ú Û Ü Ý Þ ß à Þá Ü Ùâã Ý Þ Ü Ù Ú Û Ý Þ ß Ù Ú Û Üä Ú àå Ý Þ ß Ü à æ àå Ý Þ ß Ü à ç àå Ý Þ ß Ü è é è ê ëì íî ïðñò ó ô õ ïöë ó ÷ ø ùù ÷ ø ÷ù ÷ ø úù ÷ ø ûù ÷ ø üù ÷ ø ýù ÷ ø þù ÷ ø ÿù ÷ ø  ù                                                              !   " # $ % &  ' $ ( ) * + % , - .   - ' / , 0 $ 1  ( ) * " 1 ,  # 2 3 4 5 6 789 : ; < = > <? : 7@A ; < : 789 ; < = 789 :B 8 >C ; < = : > D >C ; < = : >E >C ; < = : F G F H A7 I?JK9< C = @JGA C (a) PrioP=6, PrioS=1 (b) PrioP=5, PrioS=1 L M NN L M NO L M LN L M LO L M PN L M PO L M QN L M QO R S T L U R O T L U R V T L U R Q T L U R P T L U RW X Y Z W T W X Y Z[ U \ ] ^ _ ` a b c d ` e f ] g h i j g k ` l h _ k a m g n ` b ] h c d ` e f ] g h i o p q r s tu v wx u y z{ w t|} Y z{ y~ Y z  w    y~ Y z  w   w P                                                                                 ¡    ¢  £ ¤     £ ¥¦ § ¨ © ¦ ª «¬ ¨ ¥ ®  « ¨ ¥ ¦§  « ¯ ª°  « ¯ ¨ ± ² ± (c) Worst-case effect of a background (d) Average IPC of the background thread thread over the foreground thread FIGURE 2.7: Primary thread Execution Time with respect to Single-Thread when SThread has priority 1 Figure 2.7 shows the effect of background threads over foreground threads when a foreground thread runs with priority 6 (Figure 2.7 (a)) and with priority 5 (Figure 2.7 (b)). We observe that the most effected threads are ldint l1,cpu int and ldint l2, when they are running with a memory-bound background thread. Figure 2.7(c) presents the maximum effect that a background thread causes on the other foreground threads (ldint l2,cpu fp, and lng chain int) as we reduce its priority from 6 to 2. In the figure, the different foreground threads run with ldint mem in background as it proved to be the worst case for all combinations. For cpu fp and lng chain int the effect of the background thread increases linearly as we reduce the priority from 6 to 2 until about 10% of their ST performance. This is not the case for ldint mem that suffers a sudden increment when its priority is 3 or 2. In the chart, the label ’ld int mem 2’ represents the performance of the ldint mem when it runs as a foreground thread and the ldint mem is not the background thread. The graph shows that the effect that any other micro-benchmark causes on ldint mem is about 7%. We can conclude that, unless running with another copy Chapter 2. Software-Controlled Priority Characterization of POWER5 Processor 29 of itself, ldint mem can always run as foreground thread without much performance degradation. Finally, Figure 2.7(d) shows the performance of the background threads. Each point represents the average for all background threads: for example, the point ldint mem (6,1) represents the average performance of the background thread in the experiments (ldint mem,cpu int), (ldint mem,cpu fp), (ldint mem,lng chain int), (ldint mem,ldint l1), and (ldint mem,ldint mem) using priorities (6,1). We can observe that in the worst performance degradation case (under 10%) for cpu fp, the background threads obtain an IPC of 0.23. For the lng chain int benchmark this IPC is 0.15. In general, we can establish that the high-latency threads are the best candidates for foreground thread and the worst background thread. They suffer little impact from a background thread, but heavily effect the performance when running in background. Furthermore, threads with very high performance easily get effected by other threads (see ldint l1 on Figure 2.7 (a)). They may not be suitable to run with a background thread. 2.6 Conclusions The IBM POWER5 processor presents two levels of thread prioritization: the first level provides dynamic prioritization through hardware, while the second level is a softwarecontrolled priority mechanism that allows a thread to specify a priority value from 0 to 7. Currently, this mechanism is only used in few cases in the software platforms even if it can provide significant improvements on several metrics. We argue that it is mainly due to the fact that there are no previous works aimed at the characterization of the effects of this mechanism. In this chapter we perform an in-depth evaluation of the effects of the software-controlled prioritization mechanism over a set of synthetic micro-benchmarks, specially designed to stress specific processor characteristics. We present the following conclusions from our micro-benchmarks. First, workloads presenting a large amount of long-latency operations are less influenced by priorities then the ones executing low-latency operations (i.e., integer arithmetic). Second, it is possible, by using the prioritization mechanism, to improve the overall throughput up to two times, in very special cases. However, those extreme improvements often imply drastic reduction of the low IPC thread’s performance. On less extreme cases, it is possible to improve the throughput by 40%. Chapter 2. Software-Controlled Priority Characterization of POWER5 Processor 30 And third, we show that, instead of using the full spectrum of priorities, only priorities up to +/-2 should be used, while “extreme” priorities should be used only when the performance of one of the two threads is not important. In addition, we present three case studies where priorities can be used to improve the total throughput by 23.7%, the total execution time by 9.3% or to have a background thread. Finally, we conclude that the prioritization mechanism in POWER5 is a powerful tool that can be used to improve different metrics. This work opens a path into broader utilization of a software/hardware co-design that allows better balancing of the underlying hardware resources among the threads. In the following chapters, we explore the use of software controlled hardware resource allocation as a way to balance high performance computing applications. Chapter 3 presents a proof of concept of this technique with a deeper study than the one presented in Section 2.5.4.1. Chapter 3 Balancing HPC Applications Through Smart Allocation of Resources in MT Processors 3.1 Introduction High Performance Computing (HPC) applications are usually Single Process-Multiple Data (SPMD) and are implemented using an MPI or an OpenMP library. In MPI applications, all the processes execute the same code on different data sets and use synchronization primitives (such as barriers or collective operations) to coordinate their work. Since the processes execute the same code, they are supposed to reach their synchronization points roughly at the same time. However, this is not always the case. Some applications among those running on MareNostrum, the supercomputer installed at the Barcelona Supercomputing Center (BSC), suffer from imbalance, i.e. the execution time of the processes in the parallel application is not the same (in Section 3.2 we will see some causes of applications’ imbalance). Therefore, if a process runs for longer than the others belonging to the same application, all the other processes have to wait for that process to complete its execution. During this time the CPUs of the waiting processes are idle, thus, not performing any useful job. As an example, let us assume that one process has to complete its execution while all the other processes are waiting for it to reach the synchronization point; then, in MareNostrum, up to 10239 processor may be idle, resulting in a significant loss of performance and waste of resources. 31 Chapter 3. Balancing HPC Applications Through Smart Allocation of Resources in MT Processors 32 Resource sharing makes multi-threaded processors have good performance/cost and performance/power consumption ratios [5], two desirable characteristics for a Supercomputer. As a consequence, most of the current Supercomputers already use processors with some multi-threaded features [4]. Usually, software has no control over how processor resources are distributed among running threads in multi-threaded processors. For example, in an SMT processor the instruction fetch policy, decides how instructions are fetched from the threads, thereby implicitly determining the way internal processor resources are allocated to the threads. This is an undesirable characteristic that makes the execution time of programs unpredictable [17]. In order to alleviate this problem, recently, some processor vendors have equipped their MT processors with mechanisms that allow the software to control processor’s internals resource allocation, and thus, control application’s speed. Our view is that these mechanisms open new opportunities to improve applications performance as they offer fine-grain ways to control the progress of applications by allocating or deallocating processor resources to them. This chapter is a first step towards that direction. We show how re-assigning hardware resources in a multi-threaded processor can reduce the imbalance in parallel applications, and hence improving performance. In particular we propose a way to regain balance assigning more hardware resources to processes that computes for more time, reducing their execution time and, thus, the waiting time of all the other processes belonging to the same HPC application. This solution is transparent to the users: since the solution is at Operating System (OS)/hardware level, users do not need to know the processor’s implementation details at compile time nor to adapt their programming model in order to use our proposed solution. To the best of our knowledge, this is the first time that such a solution is implemented in a real machine. We explored this idea experimentally on a real system with a MT processor, the IBM POWER5TM [69]. The POWER5 is a dual-core, 2-way SMT processor that allows us to change the way hardware resources are assigned to the core’s contexts by means of a thread context priority (or hardware thread priority1) that controls the number of resources each context receives. This machine runs a Linux kernel that we had to modify in order to allow the HPC application to exploit the advantage of re-assigning the processor’s resources. We performed several experiments with MPI applications: 1. We started from a micro-benchmark (Metbench), developed at BSC, where we introduce some artificial imbalance. 1The hardware thread priorities mentioned here are independent of the operating systems concept of thread priority. Chapter 3. Balancing HPC Applications Through Smart Allocation of Resources in MT Processors 33 2. In the second experiment, we ran the widely used the BT-MZ NAS [64] benchmark; this version suffers of imbalance. 3. Finally, we used a real application running on MareNostrum, SIESTA [2]. Our results show an improvement of 18% for the NAS benchmark and 8.1% for SIESTA. In addition, our results also show that this mechanism of controlling hardware resources is a powerful tool that, if used incorrectly, may lead to significant performance loss. Moreover, non-HPC applications may benefit differently from re-assigning hardware resources or not at all. The rest of this chapter is organized as follows: Section 3.2 shows the imbalance problem in HPC applications; Section 3.3 presents similar works in the same area; Section 3.4 introduces our solution based on smart allocation of hardware resources; Section 3.5 shows our set of experiments on the IBM POWER5 system for our microbenchmark, a standard benchmark and a real application; finally Section 3.6 provides our conclusion and future work. 3.2 Imbalance in HPC applications HPC applications are usually SPMD, which means that every process executes the same code on different data. For example, let us assume that an HPC application is performing a matrix-vector multiplication and that each process receives a sub-matrix and the part of the vector required to compute the sub-matrix by vector multiplication. If the matrix can be divided into homogeneous parts (i.e., they require the same amount of time to be processed), all the processes in the parallel application would finish, ideally, at the same time. However, the data set could be very different: let us say that, in the previous example, the matrix is sparse or triagonal, hence, the time required to process the data sub-set could vary as well. In this scenario the amount of time required to complete the submatrix by vector multiplication depends on the number of non-zero values present in the sub-matrix. In the extreme case, one process could receive a full sub-matrix while another an empty one. It is clear that the former process requires much more time to reach the synchronization point than the latter. We classify the sources of imbalance in two main classes: intrinsic and extrinsic factors of imbalance. Chapter 3. Balancing HPC Applications Through Smart Allocation of Resources in MT Processors 34 3.2.1 Intrinsic imbalance We refer to intrinsic imbalance as the imbalance an application experiences because of data (for example a sparse matrix) or algorithm (master-slave architecture) imbalance. The causes for the imbalance are internal to the application’s code, input set or both. The intrinsic imbalance could be caused by several factors, here we point some of them out: Input set: As we already said, this scenario happens when a process has a small input set to work on while another has a large amount of data to process. Domain: Iterative methods approximate the solution of a problem (for example, Partial Differential Equations, PDE) with a function in some domain starting from an initial condition. The domain is divided in several sub-domains and each process computes its part of the solution. At the end of every iteration, the error made in the approximation is computed and, eventually, another iteration is to be started. If the function in some part of the domain is smooth, only few iterations are required to converge to a good approximation. Conversely, if the function has several picks in the sub-domain, more iterations are necessary to find a good solution and/or more points in the domain have to be considered during the computing phase. Data exchanging: During their execution, processes may require to exchange data among themselves. If the two peers are on the same node, the latency of the communication is small; if a process needs to exchange data with a neighbor on another node the latency is large, even larger if the destination process is far away in the network. In all the previous cases,the application might result to be imbalanced. 3.2.2 Extrinsic imbalance Even if both the application’s algorithm and the input set are balanced, the execution of the parallel application could still be imbalanced. This is caused by external factors that slow some processes down (but not others). For example, the Operating System (OS) might decide to run another process (say a kernel daemon) in place of the MPI process running on one CPU. Since that MPI process is not able to run all the time while the others are running, it takes more time to complete, making all the other processes wait for it. Chapter 3. Balancing HPC Applications Through Smart Allocation of Resources in MT Processors 41 (a) Metbench Case A (b) Metbench Case B (c) Metbench Case C (d) Metbench Case D FIGURE 3.2: Effect of the proposed solution on Metbench. Each trace represents only some iterations of the application. much faster than P1and P3that they spend most of their time waiting. As a result the execution time (95.71 sec) increases. Case D shows an interesting property of the IBM POWER5 hardware priority mechanism: the hardware thread priority implementation is a powerful tool but the performance of the penalized process can be reduced much more than linearly (in fact, exponentially), thus, it could become the new bottleneck. Chapter 3. Balancing HPC Applications Through Smart Allocation of Resources in MT Processors 42 TABLE 3.1: Metbench balanced and imbalanced characterization Test Proc Core % Comp Priority Exec. Time A P1 1 24.32 4 81.64s P2 1 98.99 4 P3 2 24.31 4 P4 2 99.99 4 B P1 1 51.16 5 76.98s P2 1 99.82 6 P3 2 51.18 5 P4 2 99.98 6 C P1 1 98.96 4 74.90s P2 1 98.56 6 P3 2 97.01 4 P4 2 98.37 6 D P1 1 99.87 3 95.71s P2 1 73.25 6 P3 2 99.72 3 P4 2 73.25 6 3.5.2 BT-MZ Block Tri-diagonal (BT) is one of the NAS Parallel Benchmarks (NPB) suite. BT solves discretized versions of the unsteady, compressible Navier-Stokes equations in three spatial dimensions, operating on a structured discretization mesh. BT Multi-Zone (BTMZ) [48] is a variation of the BT benchmark which uses several mesh (named zone) for, in realistic applications, a single mesh is not enough to describe a complex domain. Besides the complexity of the algorithm, BT-MZ shows a behavior very similar to our Metbench benchmark: every process in the MPI application performs some computation on its part of the data set and then exchanges data with its neighbors asynchronously (using mpi isend() and mpi irecv()); after this communication phase (which lasts for a very short time, around 0.10% of the total execution time) each process waits (with a mpi waitall() function) for its neighbors to complete their communication phases. In this way, each process gets synchronized with its neighbors (note that this does not mean that each process gets synchronized with all the other processes). Once a process has exchanged all the data it had to exchange, a new iteration can start and the previous behavior repeats again till the end of the application (in our experiments we used BT-MZ with default values: class A with 200 iterations). Case A: Figure 3.3(a) shows the BT behavior in the reference case, i.e. when process Piis assigned to CPUiand the priority of all the processes is 4. After an initialization phase (white bars at the beginning of the execution of each thread), all the processes Chapter 3. Balancing HPC Applications Through Smart Allocation of Resources in MT Processors 43 (a) BT-MZ Case A (b) BT-MZ Case B (c) BT-MZ Case C (d) BT-MZ Case D FIGURE 3.3: Effect of the proposed solution on BT-MZ. Each trace represents only some iterations of the application. reach a barrier (synchronization point). From this point on, the real algorithm starts: during every iteration, each process alternate computing phases (dark) with synchronization phases (grey) at the end of communication phases (black). It is easy to see from figure 3.3(a) that BT-MZ shows a great imbalance3. The imbalance is caused by the fact that some processes (for example process P1) have a small part of the data to work on, while other processes (for example, processes P4) have a large amount of data to take care of. It is also clear that process P4is the bottleneck of the application and that speeding up this process will improve overall performance. In order to solve the imbalance introduced by data repartition in BT-MZ, we ran process P1and P4on the same core and assigned more hardware resources to the latter, improving its performance while decreasing P1’s performance. This mapping should 3Even if the goal of this chapter is not to show whether SMT processors are useful in HPC or not, the table also shows the ST mode performance (only one process per core) of the application. Chapter 3. Balancing HPC Applications Through Smart Allocation of Resources in MT Processors 44 TABLE 3.2: BT-MZ balanced and imbalanced characterization Test Proc Core % Comp Priority Exec. Time ST P1 1 49.33 7 108.32s P2 2 99.46 7 A P1 1 17.63 4 81.64s P2 1 28.91 4 P3 2 66.47 4 P4 2 99.72 4 B P1 1 52.33 3 127.91s P2 2 99.64 3 P3 2 28.87 6 P4 1 46.26 6 C P1 1 65.32 4 75.62s P2 2 99.68 4 P3 2 53.78 6 P4 1 85.88 6 D P1 1 82.73 4 66.88s P2 2 73.68 4 P3 2 66.40 5 P4 1 99.72 6 allow us to give a large amount of resources to process P4without reversing the imbalance, i.e., without making process P1slower than P4like it was the case for Metbench (Case D). In fact, this mapping seems reasonable, for our goal is to increase the performance of P4(the most computing intensive process) and we know that, with this operation, we will reduce the performance of the process running on the same core with P4. We chose P1because it is the process with the shortest computation phase. Case B: In our first attempt to reduce the imbalance we assigned priority 3 to processes P1and P2and priority 6 to processes P3and P4. Figure 3.3(b) shows how 1) the imbalance has been inverted (process P1now takes longer than P4and 2) the new bottleneck is now process P2, which is also running with priority 3. As a consequence, the total execution time now takes longer (127.91 sec instead of 81.62 sec), which means the new bottleneck runs for much longer than the previous one. Case C: In order to restore the original relative behavior between process P1and P4 we incremented the resources assigned to process P1. Figure 3.3(c) shows that P1now runs for less time than P4, as in Case A. As we can see, giving more resource to P2 (which is again the bottleneck) reduced the total execution time to 75.62 sec, with a 7.37% of improvement with respect to Case A. Chapter 3. Balancing HPC Applications Through Smart Allocation of Resources in MT Processors 45 Case D: Finally, we can argue that P2and P3execute their operation on a similar amount of data, therefore the amount of resources given to each process should not be as different as for P1and P4. In our last test, we still assigned priority 4 to P1 and 6 to P4, as in the previous case, but we assigned priority 5 to P2and 6 to P3, sharing resources between these two processes running on the same core more equally. Figure 3.3(d) shows that the imbalance has been reduced again with respect to Case C, in fact, now P2and P3compute more or less for the same amount of time. Also the new bottleneck is P4, which takes much shorter than P2in Case C. Table 3.2 shows how the total execution time has also been reduced to 66.88 sec, with a 18.08% of improvement over the reference Case A. 3.5.3 Siesta Our last experiment consists of running SIESTA as an example of real application. SIESTA [72] is a method for ab initio order-N materials simulation, specifically it is a self-consistent density functional method that uses standard norm-conserving pseudopotentials and a flexible, numerical linear combination of atomic orbitals basis set, which includes multiple-zeta and polarization orbitals. The application presents an imbalance caused by both the algorithm and the input set. SIESTA behavior, however, is not constant during each iteration, as can be seen in Figure 3.4(a); this makes our static balancing solution not as good as for the BT-MZ case. Yet, we achieved a improvement of 8.1% of execution time reduction with respect to the reference case (Case A). Case A: Like for BT-MZ, Case A is the reference case, i.e., where process Piis assigned to CPUiand the priority of all the processes is set to 4. Figure 3.4(a) shows the trace for this reference case. The program starts with an initialization phase (11.99% of the total time) at the end of which each process in the application must reach a barrier. The initialization phase already presents some little imbalance, which evidences how the input set makes SIESTA not balanced. In the internal parts, each process exchanges data only with a subset of the other processes in the application, and then reaches a synchronization point (WaitAll()), waiting for all the others to complete their jobs. In the last part, the processes finalize their work (13.41% of the total time): after the last barrier, each process computes its function on its sub-set of data and then ends. A complete execution of the program in this configuration takes 858.57 secs. Case B: As we can see from the trace in Figure 3.4(a) is not easy to understand how to balance the application and whether our balancing approach is worth. However, Chapter 3. Balancing HPC Applications Through Smart Allocation of Resources in MT Processors 46 (a) SIESTA Case A (b) SIESTA Case B (c) SIESTA Case C (d) SIESTA Case D FIGURE 3.4: Effect of the proposed solution on SIESTA. Table 3.3 shows some more information about SIESTA (hard to retrieve from the trace): processes P1and P2spend a considerable amount of time waiting for P3and P4to reach the barrier. Thus, the first hint would be to put P1and P3on one core and P2 and P4on the other and then play with priority. We tried this case but then we realized that P2and P3have almost the same amount of data to work on. Thus, in Case B we put P2and P3on the first core and P1and P4on the second one and increased the priority of P3and P4to 5. In this case we achieved a little improvement of 1.24% (the total execution time is 847.91 sec). Figure 3.4(b) shows that, in this new configuration, P2is the new bottleneck of the finalization part. Case C: In the previous case we obtained a little improvement, still the application results quite imbalanced. We realized that, since P2and P3work, more or less, on the same amount of data, using a different priority for these two processes may introduce even more imbalance. Figure 3.4(b) shows that, indeed, this is the case. In Case C we restored the original relative behavior between process P2and P3setting both their priority to 4 (i.e., the difference is 0). Figure 3.4(c) shows how the application is now more Chapter 3. Balancing HPC Applications Through Smart Allocation of Resources in MT Processors 47 TABLE 3.3: SIESTA balanced and imbalanced characterization Test Proc Core % Comp Priority Exec. Time ST P1 1 81.79 7 1236.05s P2 2 93.72 7 A P1 1 75.94 4 858.57s P2 1 75.24 4 P3 2 82.08 4 P4 2 93.47 4 B P1 2 79.57 4 847.91s P2 1 87.06 4 P3 1 72.04 5 P4 2 77.73 5 C P1 2 83.04 4 789.20s P2 1 79.66 4 P3 1 80.78 4 P4 2 78.74 5 D P1 2 90.76 4 976.35s P2 1 65.74 4 P3 1 68.08 4 P4 2 63.95 6 balanced. For example, looking at the initialization and the finalization part, it is possible to see that the processes are much more balanced than in Case A and Case B. In fact, re-balancing SIESTA reduces the total execution time to 798.20 sec, an improvement of 8.1% with respect to the reference case. Case D: Following the same idea of the previous case (i.e., leave P2and P3with the same priority and play with P1and P4), we increased the amount of resources assigned to P4, penalizing P1. Figure 3.4(d) shows how we reverse the imbalance: SIESTA is again imbalanced, though in a different way than in the reference case. In Case D, P1(the process with less hardware resources) is the bottleneck (in the initialization, finalization and most of the internal phases) and the total execution time increases to 976.35 sec, with a loss of 13.72%. BT-MZ and SIESTA are two cases of non-balanced HPC applications, though their imbalance is quite different. BT-MZ executes several iterations, all of them similar from the execution time, CPU utilization and imbalance point of view. SIESTA also executes several iterations but each iteration is not necessarily similar to the previous or the next one. In particular, the process that computes the most is not the same across all the iterations. For example, in the i-th iteration P1could be the bottleneck while in the (i+1)-th the most computing process could be P4. This behavior suggests that a good balancing mechanism would prioritize P1in the i-th and P4in the i+1-th iteration. Chapter 3. Balancing HPC Applications Through Smart Allocation of Resources in MT Processors 48 Our static approach does not allow us to play in this way as we assign the priority at the beginning of the execution and never change them during the execution. We argue that a dynamic mechanism is required to correctly set priorities for applications that change their behavior throughout their execution. Since real applications are likely to behave like SIESTA rather than like BT-MZ, we intend to extend our balancing mechanism as part of the Operating System, so that the OS can dynamically set the priority of each process according to actual application behavior. 3.6 Conclusions In this chapter we showed how allowing software to control the amount of shared resources assigned to each thread in a MT processor may improve the performance of HPC applications. In fact, some applications show an imbalanced behavior, i.e., some processes require more time to complete their computing phase while all the other processes are waiting at some synchronization point and cannot move forward. While the imbalance can be caused by either external or internal factors (most likely both), it is clear that it may reduce the performance of an HPC application, resulting in a significant waste of resources in Supercomputers. Our results show how using our modified Linux kernel to control a processor capable to dynamically assign processor resources to running threads (the IBM POWER5 in our case), reduces the application imbalance and, therefore, improves overall performance. The experiments we performed show an improvement up to 18% for a widely used BT-MZ benchmark and up to 8.1% for a real application. We achieved these results without putting the burden of balancing the application on the programmer and regardless of the used programming model. Our results suggest that an automatic mechanism could even increase the actual improvement, thus, motivating the use of MT processors with the capability to re-assign hardware resources between threads in future Supercomputers. In the next chapter, we extend our OS by introducing an algorithm able to automatically detect if a process deserves a higher amount of resources and which process should be deprived of those resources so that imbalance can be reduced. In addition, a user-level mechanism is proposed in Chapter 5. Chapter 4 A Dynamic Scheduler for Balancing HPC Applications 4.1 Introduction Modern Supercomputers are often designed with commodity hardware components (for example, Intel or IBM POWER processors) and software. Generally, this kind of Supercomputers are distributed memory machines with a limited number of cores per-node (2-8 cores); the Message Passing Interface (MPI) [3] standard is the most common programming model used in those systems. In Chapter 2 we performed a deep analysis of how the hardware prioritization mechanism of POWER5TM processors affects the performance of applications. Two of the main conclusions, also used in this chapter, are the following: 1) In general, improving the performance of one task involves a higher performance loss on the task running on the other context, sometimes by an order of magnitude. In some cases, in order to reduce the execution time of a task by X% (with respect to the case when both tasks run with the same priority) by increasing its priority, the execution time of the other task in the same core may reduce by more 10X%. 2) Instead of using the full spectrum of priorities (from 0 to 7), we only explore priority differences up to ±2. Larger priority differences should be used mainly when the performance of one of the two tasks is not important (e.g., background task). In the previous chapter we showed how the hardware prioritization mechanism of POWER5 processors can be used to balance HPC applications. As a proof-of-concept, we ran a 49 Chapter 4. A Dynamic Scheduler for Balancing HPC Applications 50 4-tasks MPI application on a POWER5: in a first test, where we applied the same priority to the two tasks running in a core (default case), we detected which processes, on average, computed the longer and which tasks spent most of their time waiting for incoming messages or on a barrier. In the following experiments we manually increased the priority of the most computing intensive tasks, increasing their speed and reducing the load imbalance. In that chapter, the prioritization is applied to processes manually and statically at the beginning of the execution and each process runs with the same priority throughout its execution. With this solution we obtained an improvement of 8% on real HPC applications like SIESTA [2]. In the current chapter, we propose a dynamic solution implemented as a new task scheduler for Linux 2.6 kernels. The advantages of this new proposal over the static solution are obvious, the most important being that the OS automatically establishes the hardware priority to be assigned to each HPC process with no effort from the user. The second advantage is that the solution is transparent to the user: the only modification in the application source code concerns the scheduling policy (as shown in Section 4.3). The third advantage is that our scheduler is able to detect the correct hardware priority quickly (in one or two iterations) improving overall performance. Finally, the scheduler is able to catch up with the application in case the application’s behavior is dynamic, i.e., not constant throughout the iterations. All these advantages reduce the load imbalance of a HPC application, directly increasing the overall performance. In order to test our dynamic scheduler, we compared the results we obtained running HPC benchmarks and applications to the results we obtained in the last chapter. Most interesting is the case of the real application (SIESTA): with our previous static approach we were able to improve the total execution time by 8%; with the solution proposed in this chapter, we are able to improve the execution time by almost 6%, combining the effects of the load balancing and the high-responsive task scheduler without any effort from the programmer. The capability of the IBM POWER5 to allow the software to change processor’s internal resource allocation is not something isolated in the design of processors. Several factors support the idea that future supercomputers will use this type of processors. First, nowadays, Multi-Threaded processors are widely used in HPC systems (in addition to many other computing systems like desktops, real-time, etc.) for their good performance/energy consumption and performance/cost ratios. Second, other recent processors like the IBM POWER6TM [53], provide a similar prioritization mechanism. Third, many computer-architecture researchers advocate that allowing the software to control not only the decode stage of the processor, as it is the case in POWER5 and Chapter 4. A Dynamic Scheduler for Balancing HPC Applications 57 Hence, we decided to implement a simpler solution that only computes the new priority of a HPC task according to its statistics (thus, not considering the task running on the other context). FIGURE 4.2: HPC application iterative behavior While a task is running, the scheduler collects several metrics, such as the tasks’ execution and waiting time. Figure 4.2 shows a typical task trace: the process computes for tRseconds and then goes to sleep, waiting for messages coming from the other processes in the MPI application (tW). If ti=tR+tWis the total execution time in the iteration i, then the task utilization in the same iteration is Ui=tR/ti. The global task utilization is the ratio of the accumulated running and iteration times: U=PtR/Pti. These metrics are quite easy to compute, since the kernel already provides some of the required values. We only had to add the values necessary to introduce the concept of iteration that is not present in the standard Linux kernel. From our study in [8], we learned that priority differences greater than 2 drastically reduce the performance of the low priority task. Therefore, we limited the range of priorities that the HPC scheduler explores to [4,6] (where 4 is the normal priority assigned to each task at the beginning), so that the maximum allowed priority difference is ±2. In this way, the performance of the highest priority task might increase up to 95% of the maximum performance improvement but the lower priority task’s performance does not decrease too much. Once the information about the tasks’ progress have been stored, the HPC scheduler has to decide whether to increase, decrease or keep the same priority for the current process in the next iteration. Since HPC applications can be very different, it is hard to find an heuristic that works well in all the cases. In this chapter, we implemented and tested two heuristics: the first heuristic (Uniform heuristic) targets constant applications, i.e., applications that do not change drastically their behavior from one iteration to another. The second heuristic (Adaptive heuristic) is more aggressive and tries do adapt to different program phases. Which heuristic is better for a specific application depends on the characteristics of the applications itself. Section 4.4 shows how an application takes Chapter 4. A Dynamic Scheduler for Balancing HPC Applications 58 more advantages from one heuristic than from the other. We decided to allow the user to select which heuristic to use when compiling the kernel. Once the heuristic has been chosen, the user can set some parameters at run time to tune the heuristic and make it more suitable for the application. Uniform prioritization: This heuristic uses the global utilization ratio of a task. Every scheduling tick, the OS accumulates the running time for the active task and updates its utilization; the sleeping time is accounted when a task wakes up at the beginning of the new iteration. Just before starting the new iteration, the Load Balancer Detector checks the application’s imbalance and the heuristic eventually applies the new task priority according to the global utilization, We introduced two configurable limits, LOW UTIL and HIGH UTIL that define the boundaries when a task is considered to be a low, medium or high utilization task. Those boundaries are required to avoid that the scheduler changes too quickly the priority of a task, oscillating between two possible solutions. For the experiments presented in Section 4.4, we set HIGH UTIL to 85 and LOW UTIL to 65. The heuristic can be tuned by the user through specific entries in the sysfs filesystem. The Uniform heuristic is very simple and adds negligible overhead to the task scheduler. The heuristic properly balance applications with constant behavior although it could be slow to adapt to different behaviors of the program. If the heuristic is able to balance the application, i.e., to find a stable state, the Load Imbalance Detector only checks whether the application maintain the same behavior or not, without changing the priority of each task. If the application’s behavior changes, the Load Imbalance Detector tracks this and the heuristic selects the right priority for the next iterations. Adaptive prioritization: The Uniform heuristic may be too slow to adapt to new scenario if the application changes its behavior quickly, especially if the application runs for a long time (in which case it is hard to impact the global utilization, as Section 4.4.2 shows. We implemented another heuristic, that we called Uniform, which gives more weight to the recent history of the application. With this heuristic, the task utilization in the i−th iteration is computed as Ui=G∗Ug(i−1) + L∗Ul(i), where Ug(i−1) is the global utilization until the iteration i−1and Ul(i)is the CPU utilization of the last iteration i.Gand L(with G+L= 1) weight, respectively, the global and the last utilization. These parameters can be used to make the heuristic more or less aggressive: in fact, an aggressive heuristic (for example, L= 0.90 and G= 0.10) quickly adapts to the application’s behavior but may over-react, meaning that even small changes caused Chapter 4. A Dynamic Scheduler for Balancing HPC Applications 59 by external factors, like the OS noise, may cause the heuristic to change the task priority. On the other hand, if the value of Gis close to 1, the Adaptive heuristic behaves like the Uniform heuristic. As for the Uniform heuristic, the Adaptive heuristic can also be tuned at run time using different values for HIGH UTIL,MAX PRIO (the maximum allowed priority) and MIN PRIO. Moreover, if the Load Balancer stops to change the tasks’ priority if it detects that the application is well balanced. 4.3.3 Mechanism This is the only architecture-depended part of our solution. In fact, while the HPC scheduler can be used on any architecture and may, eventually, provide some performance improvement (because the HPC class has higher priority than the CFS class), balancing an MPI application assigning more or less hardware resources to a process can only be done if the underneath processor supports this feature. 4.4 Experiments In this section we evaluate the performance of our HPC scheduler and compare it to the standard CFS scheduler and the static solution proposed the previous chapter.As we said in Section 4.3, the goodness of the HPC scheduler strongly depends on the heuristics we apply. For this reason, some application may benefit more than other from an heuristic while other may experiment some performance degradation. Like in the previous chapter, we present our results for three different cases: Metbench, our micro-benchmark suite (Section 4.4.1), BT-MZ from the NAS benchmark suite (Section 4.4.3) and SIESTA, a real application (Section 4.4.4). In order to evaluate how our HPC scheduler handles dynamic applications, in this chapter we also present results for MetbenchVar (Section 4.4.2), a version of Metbench that changes its behavior after kiterations, reversing the load imbalance. We performed the experiments on an IBM OpenPower 710 server, equipped with one POWER5 processor. We ran our experiments on a standard Linux 2.6.24 (the last available Linux kernel at the moment of writing this paper) and our modified Linux kernel, also based on the same Linux kernel version. All the benchmarks are MPI applications (in the experiments we used the MPI-CH 1.0.4p1 implementation of MPI protocol). Chapter 4. A Dynamic Scheduler for Balancing HPC Applications 60 In order to graphically show how HPCSched balances an MPI application, we used PARAVER [52], a visualization and performance analysis tool developed at CEPBA to collect data and statistics and to show the trace of each process during the tests. As a performance metric we use CPU utilization of each task, and the total execution time of the application. Reducing the load imbalance lead to higher CPU utilization but does not necessarily improve performance: other factors, like the communication pattern of the application, may play an important role and reduce the performance of the application. On the other hand, HPCSched is also able to improve the performance of an application reducing the overhead an application running with the standard CFS scheduler may suffer. 4.4.1 Metbench Metbench (Minimum Execution Time Benchmark) is a suite of MPI micro-benchmarks developed at BSC which structure is representative of the real applications running on MareNostrum. It is described in Chapter 3, Section 3.5.1. Figure 4.3(a) shows part of the execution trace of our reference case where Metbench runs with the default CFS (Completely Fair Scheduler). In this figure, dark areas represent the computing time, while the gray show the waiting or communication time. Table 4.1 shows that two of the Metbench workers are idle for about 75% of the time. Figure 4.3(b) shows the solution proposed in [9], where we were able to statically balance the application: the execution time decrease from 74.64sec to 70.90sec, with an improvement of about 13%. The static approach we used in [9] require previous knowledge of the application and effort from the programmer to detect the load imbalance and to properly assign hardware resources to each task. Figures 4.3(c) and 4.3(d) show how HPCSched is able to properly balance Metbench after the first iteration. In fact, the behavior of Metbench is constant, thus, each iteration is representative of the following ones. In Figure 4.3(c), the Load Imbalance Detector detects the imbalance in the first iteration 2and the Uniform heuristic computes and apply the correct priority for each task before the beginning of the second iteration. At the end of the second iteration, the Load Imbalance Detector detects no imbalance, thus there is no need of trying to balance again the application. The execution time with the Uniform heuristic is 71.74sec (about 12% of improvement), comparable with the static solution shown in Figure 4.3(b) but without any effort from the programmer. 2Notice that the first iteration already uses non standard priority: this is the result of the initialization phase, not visible in the trace Chapter 4. A Dynamic Scheduler for Balancing HPC Applications 61 (a) Standard execution (b) Static prioritization (c) Uniform prioritization (d) Adaptive prioritization FIGURE 4.3: Effect of the proposed solution on Metbench. The Adaptive heuristic also provides good performance: the total execution time is 71.65sec (about 12% of improvement). In this experiment the Adaptive heuristic uses a very aggressive approach (10% global history, 90% last iteration), thus, even a small variation (caused, for example, by OS noise) may stimulate the heuristic to change the priority of some task. If this happens, like in Figures 4.3(d), the heuristic may respond too quickly and take the wrong decision. However, Figures 4.3(d) also shows how the Adaptive heuristic is able to recover after the error. 4.4.2 MetbenchVar MetbenchVar is a slightly modified version of Metbench where the workers change their behavior after kiteration. Figure 4.4(a) shows the standard execution of MetbenchVar Chapter 4. A Dynamic Scheduler for Balancing HPC Applications 62 TABLE 4.1: Metbench balanced and imbalanced characterization Test Proc % Comp Priority Exec. Time Baseline P1 25.34 4 81.78s 2.6.24 P2 99.98 4 P3 25.32 4 P4 99.97 4 Static P1 99.97 4 70.90s P2 99.64 6 P3 99.95 4 P4 99.64 6 Uniform P1 96.17 - 71.74s P2 98.57 - P3 90.94 - P4 99.57 - Adaptive P1 80.64 - 71.65s P2 99.52 - P3 87.52 - P4 99.20 - with k= 15: at the beginning P1and P3execute a small load while P2and P4a large load. At the 15th iteration, P1and P3start to execute the large load while P2and P4perform their task on the small load. In this way, we reverse the load imbalance at run time making the application’s behavior dynamic. At the 30th iteration, we switch again the behavior of the tasks. Figure 4.4(b) shows how a static works in this case: the application is perfectly balanced in the first (iterations 1-15) and third period (iteration 31-45) but the prioritization is reversed in the second period (iterations 16-30), as a result, in the second period the application performs worst than in the standard case. Our dynamic solution, instead, is able to detect that the application’s behavior has changed and dynamically adjust the priority of each task in order to re-balance the application. Figure 4.4(c) shows how HPCSched performs in this experiment when applying the Uniform heuristic: after the switching in the 15th iteration, the scheduler needs two more iterations to detect and correct the new load imbalance. However, after the second switch, the scheduler needs three more iterations to detect and correct the load imbalance and the trend continue if the application runs for longer time. Since the Uniform heuristic uses the global history to detect the imbalance, it is expected that the longer the application runs, the less responsive is the scheduler. Thus, increasing the value of kor the number of periods makes the scheduler slower to adapt to the new scenario. As Table 4.2, the execution time reduces from 368.17sec to 327.17sec, with an improvement of about 11%). Chapter 4. A Dynamic Scheduler for Balancing HPC Applications 63 (a) Standard execution (b) Static prioritization (c) Uniform prioritization (d) Adaptive prioritization FIGURE 4.4: Effect of the proposed solution on MetbenchVar. Figure 4.4(d) shows how the Adaptive heuristic preforms in this experiment: with k= 15, the scheduler always needs only two iterations to detect and correct the load imbalance but, as for the previous case, some times the heuristic is too aggressive and respond too quickly. Again, the Adaptive heuristic is able to correct its over-reaction in the following iteration and to reduce the execution time to 326.41sec (about 11% of improvement). Chapter 4. A Dynamic Scheduler for Balancing HPC Applications 64 TABLE 4.2: Variable-Metbench balanced and imbalanced characterization Test Proc % Comp Priority Exec. Time Baseline P1 50.24 4 368.17s 2.6.24 P2 75.09 4 P3 50.22 4 P4 75.08 4 Static P1 99.97 4 338.40s P2 68.06 6 P3 99.94 4 P4 68.04 6 Uniform P1 91.47 - 327.17s P2 95.55 - P3 91.44 - P4 95.33 - Adaptive P1 89.61 - 326.41s P2 93.08 - P3 89.99 - P4 95.15 - 4.4.3 BT-MZ Block Tri-diagonal Multi-Zone (BT-MZ) is one of the NAS Parallel Benchmarks (NPB) suite. It is better described in Chapter 3, Section 3.5.2. In our experiments we used BTMZ with default values: class A with 200 iterations. TABLE 4.3: BT-MZ balanced and imbalanced characterization Test Proc % Comp Priority Exec. Time Baseline P1 17.63 4 94.97s 2.6.24 P2 29.85 4 P3 66.09 4 P4 99.85 4 Static P1 70.64 4 79.63s P2 42.22 4 P3 60.96 5 P4 99.85 6 Uniform P1 70.31 - 79.81s P2 37.18 - P3 65.29 - P4 99.85 - Adaptive P1 70.31 - 79.92 P2 37.30 - P3 65.30 - P4 99.83 - Chapter 4. A Dynamic Scheduler for Balancing HPC Applications 65 (a) Baseline execution (b) Static prioritization (c) Uniform prioritization (d) Adaptive prioritization FIGURE 4.5: Effect of the proposed solution on BT-MZ. Each trace represents only some iterations of the application. Figure 4.5 shows how HPCSched is able to balance BT-MZ achieving results similar to the static prioritization (Figure 4.5(b)). Both the Uniform (Figure 4.5(c)) and the Adaptive (Figure 4.5(d)) heuristics are able to balance the application and remain in the stable state. Table 4.3 shows that the performance improvement is about 16% for both heuristics over the standard case shown in Figure 4.5(a) 4.4.4 SIESTA SIESTA [72] is a method for ab initio order-N materials simulation, specifically it is a self-consistent density functional method that uses standard norm-conserving pseudopotentials and a flexible, numerical linear combination of atomic orbitals basis set, which includes multiple-zeta and polarization orbitals. It is also described in Chapter 3, Section 3.5.3. Chapter 4. A Dynamic Scheduler for Balancing HPC Applications 66 (a) Standard execution (b) Uniform prioritization (c) Adaptive prioritization FIGURE 4.6: Effect of the proposed solution on SIESTA. In this experiment we used thebenzene particle as input set and we noticed that the application presents an imbalance caused by both the algorithm and the input set (see Figure 4.6(a) and Table 4.4). SIESTA behavior, however, is not constant during each iteration, as can be seen in Figure 4.6(a) and an iteration is not necessarily representative of the next one; this variability decreased the effectiveness of our static balancing. As can been seen in Table 4.4, both the Uniform and the Adaptive heuristics are only able to reduce the load imbalance marginally (the CPU utilization of each task slightly increases). However, the HPCSched is able to improve the application’s performance, reducing the total execution time from 81.49sec to 76.82sec for the Uniform heuristic and 76.91sec for the Adaptive heuristic. In both cases the improvement is about 6%. Clearly this improvement does not come from load imbalance reduction but from the other components of our solution, in this case, from the scheduler policy. Figure 4.6(a) shows that the execution phases are very small and that the tasks need to exchange several messages. While waiting for an incoming message, tasks sleep and need to be waken up as soon as the message arrives. The time between the arrival of the message and the moment the task resumes its execution is called scheduler latency: SIESTA is very sensible to this kind of OS noise. With the CFS scheduler, whenever a task becomes runnable, it has to compete with all the other processes in the system for the CPU. An SCHED HPC task that wakes up, instead, has to compete only with the other tasks in its class: considering our initial assumption (i.e., usually only one HPC task Chapter 5. A User-Level Load and Resource-Balancer for HPC Applications 73 FIGURE 5.1: DLRB scheduling domains for load-balancing. into the domains of the same level. As for instance, a typical system will execute one MPI task per CPU or hardware thread. After this step, every hardware thread will be running exactly one MPI task. Before the second iteration, once the utilization of every task is known, the load balancer will migrate the tasks in order to balance the loads in a way that every domain has roughly the same total utilization (summing up all the sub-domains utilizations). This will lead, whenever possible, to a situation where cores will have a high-utilization task in one hardware thread and a low-utilization task in the other hardware thread. For instance, in a system with one dual-core, dual-thread chip, suppose a program has four tasks (t1, t2, t3, t4) and they exhibit respectively the percent utilizations (15,23,50,99). At the first iteration, the tasks’ utilizations are still unknown. They will be scheduled as follows: t1will run on the first thread of the first core, t2will run on the first thread of the second core, t3, on the second thread of the first core and, finally, t4will run on the second thread of the second core. Once the utilizations are known, DLRB will realize that this distribution is not optimal, as the first core has lower utilization than the second core, and that this difference could be alleviated by migrating tasks. Tasks t1and t4will be coscheduled on the first core, and t2and t3in the second core. This distribution will persist for the entire program execution, unless a significant behavior change is detected. Although there is an important architectural overhead from moving one task from one core to another, or even between chips, we understand that usually HPC applications present many iterations and, furthermore, may use a large memory footprint. Therefore, having the risk of migration during the first iteration of a program iterative phase is not a prohibitive impact and the benefits of having a good architectural placement are, by Chapter 5. A User-Level Load and Resource-Balancer for HPC Applications 74 far, higher. In our experiments, the appropriate placement of the tasks represented a huge impact on the application execution time. In Chapter 4, we determined that one of the key factors to perform load or resource balance of an application is to determine which are the tasks limiting the performance. For this reason, in that work, the HPCSched only prioritized the tasks with utilization higher than 90%. In DLRB, at every iteration, when the loads of the tasks are evaluated, a bitmap of the tasks with utilization higher than 95% is quickly generated. When an iteration finishes, the bitmap from this iteration is compared with the previous utilization bitmap, if the pattern of the high-utilization tasks is changed, DLRB checks for a behavior change and re-evaluates the load-balancing. As the utilizations of a task is affected by the resource-balancing, the application is run without applying prioritization (resource-balance) during one iteration after a phase change is detected. While the load-balancer only runs when the program changes its utilization behavior, the resource-balancer is run every time there is unbalance between threads of a core. Its logic is explained in the next section. 5.2.3 Resource-Balancer Every time an unbalance is detected between the two hardware threads of a core, the resource-balancer tries to use the underlying thread prioritization mechanism to assign more hardware resources to the thread running longer. If there is more than an MPI task running on a hardware thread, the sum of their utilization will be accounted as the hardware thread’s utilization. This mechanism is fairly simple. While the difference of the two thread’s utilization is higher than a threshold, the priority of the thread with higher utilization will be increased. If the thread with higher utilization is already at the highest priority, because it already reached the priority configured as maximum, then the priority of the thread with lower utilization will be decreased (unless it reaches the priority defined as minimum). In order to converge faster to the right priority difference, an unbalance compensation is used: if the unbalance is higher than two times the threshold, the higher utilization thread will be prioritized by two priority steps, increasing its priority two times, or decreasing the other thread’s priority if needed. In this work, we used priorities ranging from four to six, inclusively, and an unbalance threshold of 20%2. 2In Chapter 2 we show that priority differences higher than two may incur in significant performance degradation for the low priority thread. Chapter 5. A User-Level Load and Resource-Balancer for HPC Applications 75 5.3 Experiments In this section we evaluate the performance of DLRB, our user-level load and resource balancer, and compare it to the standard environment, where no prioritization is used, the static solution proposed in Chapter 3 and the best result obtained, in each situation, from the two heuristics of HPCSched proposed in Chapter 4 We present results for Metbench, our micro-benchmark suite (Section 5.3.1), Metbench- Var (Section 5.3.2), BT-MZ (Classes A, B, C) from the NAS benchmark suite (Section 5.3.3) and SIESTA (Section 5.3.4). The experimental infrastructure used is similar to the previous two chapters. The key difference is that we used updated versions of MPI (MPI-CH 1.0.8) and Metbench/MetbenchVar (1.1a). As a performance metric, we evaluate the total execution time. 5.3.1 Metbench (a) Standard execution (b) Static prioritization (c) DLRB FIGURE 5.2: Effect of the proposed solution on Metbench. In this section we present the results, when running Metbench as previously described in Chapter 3, Section 3.5.1. Chapter 5. A User-Level Load and Resource-Balancer for HPC Applications 76 Figure 5.2(a) shows part of the execution trace of our reference case, where Metbench runs with the standard Linux scheduler. Recall that, in this figure dark areas represent the computing time, while gray areas represent the waiting or communication time. In fact, two of the Metbench workers are idle for about 75% of the time. Figure 5.2(b) shows the solution proposed in Chapter 3, where we were able to statically balance the application: the execution time is improvement by about 15%. The static approach we used in [9] require previous knowledge of the application and effort from the programmer to detect the load imbalance and to properly assign hardware resources to each task. FIGURE 5.3: Relative execution times for ten iterations of Metbench. Figure 5.2(c) shows the execution of DLRB. It is able to converge to the appropriate prioritization in two iterations, detecting the stable state of the application and maintaining the best allocation until the end of the the program execution. Figure 5.3 shows the relative performance of the standard execution (100%), the static prioritization (85%), HPCSched (88%) and DLRB (89%). Two issues are very important here: 1. the DLRB converges slightly slower than HPCSched, as it needs to wait until the end of every iteration to detect the unbalance. Furthermore, it runs the first iteration of a phase without applying any prioritization to test the load distribution. This extra iteration represents a penalty to the achieved improvement of the solutions based on DLRB. In fact, this effect is severely alleviated if Metbench is ran for a larger number of iterations, as for instance, with a hundred iterations, the static prioritization achieves 85% of improvement and DLRB achieves 85.5%. 2. For a relatively small number of iterations, the initial placement of the tasks matters and the speed of the first iteration is influenced by how the tasks are coscheduled. The example shown is the worst case, where the two high utilization tasks are scheduled in the same core until DLRB obtains their relative utilization and redistributes the loads. Chapter 5. A User-Level Load and Resource-Balancer for HPC Applications 77 Observe that the first iterations on Figure 5.2(c) are slightly longer than the first iteration on Figure 5.2(a). Metbench has five tasks (t1to t5), the first one, the master, has utilization close to zero and waits for the workers are performing their duty. The following four tasks are the workers, which, in this case have utilizations (25,99,25,99). At the load-distribution step the utilizations are unknown and t1and t5are placed on hardware thread one, t3is placed on thread two, t2on thread 3 and t4on thread four. Unfortunately, tasks two and four reveal to be the tasks with higher utilizations. Before the second iteration the utilizations are known and the tasks are redistributed, t4runs on the first thread, t3and t0on the second, and t2on the third and t1on the last thread. 5.3.2 MetbenchVar (a) Standard execution (b) Static prioritization (c) DLRB FIGURE 5.4: Effect of the proposed solution on MetbenchVar. Observe that the static prioritization has a different time scale. MetbenchVar is described in Chapter 4, Section 4.4.2. As we mentioned before, it is a modified version of Metbench (in this case, Metbench 1.1) that allows the workers to change their behavior after a configurable number of iterations. Figure 5.4(a) shows the default execution of this benchmark, when no prioritization is applied. Chapter 5. A User-Level Load and Resource-Balancer for HPC Applications 78 FIGURE 5.5: Relative execution times for 45 iterations of MetbenchVar (changing behavior every 15). Figure 5.4(b) shows that, for this workload, the negative impact of applying the wrong prioritization is extremely high and, although for 2 3of the cases the benchmark runs with the right priorities (4,6), the performance degradation of running with the wrong priorities is by far more important. Figure 5.5 shows that overall, the static prioritization presents a 50% performance degradation when compared to the standard case of this benchmark. HPCSched obtains 11% of improvement. Having an application that responds very negatively to wrong prioritization is the worst case scenario, when a task has drastic changes in the utilization phases. Because DLRB needs to wait until the end of a iteration to calculate the unbalances, it executes an entire iteration before detecting that the application behavior changed (see Figure 5.4(c)). Once it detects a change, it redistributes the tasks across the processors, then the application runs for another iteration without applying the priorities (see Section 5.2.2) and finally assumes the correct priorities for the next iteration (this is a two iteration convergence time). Because of this overhead, DLRB only obtains 5% of improvement for the benchmark. When MetbenchVar runs with phases of 45 iterations, for 180 iterations in total, DLRB obtains a performance improvement of 12%, comparing to the standard execution time. In both cases, DLRB converges to the right priority in two iterations and is able to maintain a stable state during the rest of the application phase. 5.3.3 BT-MZ Block Tri-diagonal Multi-Zone (BT-MZ) is one of the NAS Parallel Benchmarks (NPB) suite. It is better described in Chapter 3, Section 3.5.2. Figure 5.6 shows the execution of the standard execution, the static prioritization, DLRB. Because of the granularity of the prioritization mechanism, DLRB is not able to fully balance the application. Giving priorities four and six is not enough to fully balance the Chapter 5. A User-Level Load and Resource-Balancer for HPC Applications 79 (a) Baseline execution (b) Static prioritization (c) DLRB FIGURE 5.6: Effect of the proposed solution on BT-MZ. Each trace represents only some iterations of the application. FIGURE 5.7: Relative execution times for BT-MZ class A. loads, whereas priorities six and three would over-prioritize the task with high utilization and represent a significant performance loss (see Chapter 3). As we can see in Figure 5.7, the static prioritization yields 17% of performance improvement, while HPCSched and DLRB both yield 16%. For classes B and C, the static prioritization shows respectively 16% and 17% of improvement, while the rest of the solutions show 16% of improvement. Chapter 5. A User-Level Load and Resource-Balancer for HPC Applications 80 5.3.4 SIESTA SIESTA [72] is described in Chapter 3, Section 3.5.3. It is a real application ran at the BSC. Its behavior depends on the analyzed material and there is a plethora of available inputs. For our experiments, we analyze the benzene particle (the same presented in the previous chapter). With this material, the application presents a significant unbalance but only a small region of the application presents iterative behavior. For most of SIESTA’s execution, there is not an iteration that is representative of the behavior of the next one. The solution presented in the previous chapter was not effective to balance this application, but represented a performance improvement of 6% (See Figure 5.8). This improvement came from the fact that the HPCSched increased the responsiveness of the application and decreased the OS noise. As shown in the Figure 5.8, DLRB obtains 5% of improvement. A result similar to the one obtained by HPCSched. FIGURE 5.8: Relative execution times for SIESTA. 5.4 Conclusions and future work In the previous chapters, we presented the use of resource balancing, through hardwareprioritization, as a way to decrease the unbalance presented by HPC applications (Chapter 3) and developed a task scheduler for the Linux 2.6 kernels that, using one of the two proposed heuristics was able to reduce the load imbalance and improve applications’ performance (Chapter 4). We concluded that the ideal heuristic depends on the application. Chapter 5. A User-Level Load and Resource-Balancer for HPC Applications 81 Although it is possible to add new heuristics in the kernel, it is hard to allow the users to deploy new kernel-level heuristics on large clusters. Furthermore, debugging and development at the kernel level is harder than at user-level. In this chapter, we provided a user-level load and resource balancer, DLRB. It only requires a slim infrastructure at the kernel level, to allow the hardware priorities to be accessible from the user-level and provides an infrastructure that makes possible to the user to implement new heuristics or scheduling policies that best fit their specific needs. The mechanism proposed reaches similar results than the best heuristic of HPCSched in most cases and does not present performance degradation.We conclude that the current proposal is able to schedule both constant and dynamic applications with similar results as our kernel scheduler, while presenting a higher level of flexibility. As a future work, we would like to improve other metrics, like energy or temperature reduction and using other hardware mechanisms to perform the resource balance. Until this point of this thesis, we approached the problem of coordinating the hardware resource allocation with the software targets for the high performance computing domain. In the next chapter, we analyze the problem of scheduling tasks in a soft real-time SMT system. As there are no commercially available hardware with explicit resource allocation for soft real-time, we developed and used a simulator that allowed to perform the system’s task scheduling, taking into account the resource sharing in the underlying simulated architecture. Chapter 6. Scheduling for Soft Real-Time SMT Systems 89 show that making this bridge is not only possible, but also profitable and desirable. We developed a simulation environment that allows us to use a larger number of software threads than available hardware contexts, we evaluated costs of context switches and implemented different system schedulers, binding the task priorities to the hardware allocation. Such scheduler can be implemented in any explicit resource aware processor, or even on SMT processors featuring priority control, like, for instance, IBM POWER5TM [49]. However, for this research we chose to use a simulated environment as, to our knowledge, there is currently no commercially available processor with explicit prioritization for real-time systems. 6.3 Our Proposals In this chapter we propose two scheduling policies that take profit of SMT in-processor resource-allocation mechanisms to guarantee better schedulability. As a baseline, our new scheduling algorithms, SRA-EDF and SRA-LLF, use the hardware support proposed in [16], called LVP or Low-Variability Performance. In addition, we propose a new hardware support that allows the optimization of two targets: a minimum resource allocation and the maximization of a second function, as for instance, throughput. SRA-EDF and SRA-LLF allow a closer collaboration between the software level and the SMT hardware. This tight collaboration shows many advantages: First, it achieves better success rate than all the proposals previously explained in the Section 6.2. Second, no additional profiling, other than the WCET estimation, is required from applications to carry out the scheduling task, assuming that there is an estimate of the Worst Case Execution Time (WCET) of the tasks. Furthermore, when shared resources cannot be controlled by software, it is often the case that the internal hardware prioritization mechanism goes on the opposite direction of the OS priorities, for instance, giving fetch priority of the task with lesser OS priority. Our mechanism fully avoids this situation, as it binds the OS priorities to the hardware mechanism. We start by explaining in detail the underlying hardware support used as a baseline, the LVP mechanism. The basis of the hardware mechanism proposed in [16] is to partition the hardware resources between the threads running on a SMT and reserve a minimum fraction of the resources for a designated Most Critical Thread (MCT), enabling it to meet its deadline. In that work, the authors proposed two hardware resource allocators denominated static and dynamic LVP (Low Variation Performance). These allocators differ on what Chapter 6. Scheduling for Soft Real-Time SMT Systems 90 information the hardware mechanism expects to receive from the OS 1. In the static approach, it is assumed that the OS task scheduler provides a resource allocation that is fixed for an entire period. While in the dynamic approach, it provides the target IPC for the MCT. In the latter approach the resource allocator can dynamically vary the amount of resources dedicated to the critical thread. The Predictable Performance (PP) hardware, proposed in [17] differs from the dynamic LVP version as it receives the percentage of the performance the thread must be run. That is, it takes into account different program phases, being able to dynamically scale both resource allocation and the thread IPC. We chose to implement our algorithms with the static LVP version of the hardware. We do not implement the dynamic LVP or the PP hardware approach because, although they provide better results, they are more complex and have lower applicability than the static LVP. 6.3.1 Overall functioning When the WCET of a task is determined, it is assumed that this task has full access to all the underlying platform resources. However, when this task runs with other tasks in a multithreaded environment, it only uses a certain fraction of the resources. When the amount of resources given to a thread is reduced, its performance may decrease as well. The relation between the amount of resources allocated to a program and the performance is different for each program and may vary for different inputs of the same program. In [16] it was observed that in a SMT system the relation between the amount of resources given to a thread and its relative performance 2follows a “superlinear” relation. That is, if we reserve X% of resources to a given thread its relative performance is greater than or equal to X% of its performance when having all the resources. It was also observed that the main shared resources to take into account are the physical registers, the fetch bandwidth, and the instruction window. The proposed hardware splits the shared hardware resources among running threads as indicated by the OS task scheduler. That is, it allows the OS to specify the amount of resources to use by each thread. Our scheduling algorithms, SRA-EDF and SRA-LLF, use the hardware support proposed in [16] to take profit of this relation. When the OS level task scheduler wants 1Recall that [20],[16] and [17] only focus on the hardware part and do not deal with the workload composition problem. 2The relative performance is the IPC that a thread has when it is given X% of SMT resources, with respect to its performance when it is run with all the resources. It ranges between 0 and 1. Chapter 6. Scheduling for Soft Real-Time SMT Systems 91 to execute a critical task τi, given its WCETsti(Worst Case Execution Time in Single Thread mode) and a deadline di, it simply computes the allowable performance slowdown that, initially, is represented by, Si(0) = W CET sti di, and instructs the hardware to reserve, for that hardware context, a percentage of the resources equivalent to Si(0)3. For such a value of Si(0), each instance of this task should finish before its deadline, supposing that the real execution time of this instance is its WCETsti. Hence, Ti Si(0) =di W CET sti·WCETsti=di. Refer to Section 6.3.2 to further analysis on the allowable slowdown calculation. The proposed methods use global scheduling: tasks are not bound to contexts of a SMT and can be executed in any of the available contexts. For each workload we found the MCT, the thread with the highest priority according to the scheduling algorithm under study. The MCT is evaluated every time the running workload changes (whenever there is a context-switch on a context). Therefore, at any given moment, there will be exactly one thread running as MCT (also said that this thread has the MCT status) and as we use a 2-context SMT, there will be another thread as LPT. DRA-EDF and DRA-LLF operate in a very similar manner. They still specify the allowable slowdown Sifor the MCT, but due to the additional hardware support, the processor is free to give it more resources, tuning the resource allocation to yield the highest performance at a secondary metric. In this work we chose the processors aggregated throughput as a secondary metric. 6.3.2 The SRA-EDF scheduler This algorithm improves the normal EDF scheduler [56] in order to make it resource aware. It adds the concept of a most critical thread (MCT) and a lower priority thread (LPT) running together in the SMT and it is aware of the sharing of hardware resources across the processor contexts. SRA-EDF starts filling contexts, putting first the task with the closest deadline and, therefore, the highest priority. This task is considered to be running as the most critical thread (MCT). Then, the second closest deadline will occupy the second hardware context, being the second highest priority task or, to keep the notation of [16], the LPT. The MCT will receive an amount of resources large enough to guarantee its deadline, 3Si(t)stands for the allowed slowdown that a thread can have to still fulfill its deadline at a given instant t Chapter 6. Scheduling for Soft Real-Time SMT Systems 92 while the LPT will receive the rest of the available resources. This logic can be easily expanded to a n-way multithreaded processor as long as the first thread receives an amount larger or equal to the resources needed to reach its deadline, while the other threads can be considered as LPT and share the remaining resources. After some time, one of the following things may occur: •The task with nearest deadline finishes its execution. In this case, the second closest deadline becomes the next deadline and, therefore, the previous LPT becomes now the MCT. The resource allocation to the MCT context is re-evaluated and the highest priority task receives the amount of resources necessary to fulfill its deadline. The next task with the closest deadline is put in the newly free context. •The LPT finishes before the MCT. The next task with the closest deadline is put in the newly free context. As we can see, during its execution time, a task can run as MCT, LPT or, more likely, both (note that the status are mutually exclusive at a given instant). The resource allocation that the MCT receives at a given period of time (RA(t)) is calculated on the allowed slowdown (Si(t)) that a task τican take at an instant t, in order to fulfill its deadline, while the LPT runs with the remaining processor resources: RA(0) = Si(0). The allowed slowdown is evaluated every time the running workload changes or when the scheduler runs (typically at time slices boundaries). In other words, whenever tasks are changed on any of the hardware context, the Si(t)for the thread with the nearest deadline (MCT) is evaluated or adjusted. Conceptually the Si(t)calculation is very simple as it consists on the ratio between the Remaining Computation time for a task τi(RCi) and the remaining time to its deadline (TTDi), i.e: Si(t) = RCi TTDi (6.2) However, there are some considerations to be made on each of its factors, as we will see below. The Time to Deadline (TTD)is always evaluated as the difference between the deadline diof a task τiand the current time t(TTDi=di−t). However, we must take into account its range. When a task crosses its deadline boundary, the TTDibecomes negative, invalidating the resource allocation calculation. The appropriated action to be taken in this case may vary according to the system. If it makes no sense to continue, one may want to kill tasks that missed their deadlines, this is the case when processing Chapter 6. Scheduling for Soft Real-Time SMT Systems 93 video frames. On the other hand, for other applications, it may be interesting to give them full priority, when the deadline is somehow malleable. Finally, it may also be desirable to give them the minimum priority, understanding that the task is probably close to finish or the last evaluated priority (probably very high). The Remaining Computation time (RCi)evaluation is related to the difference between the the total amount of work to be done and the one that was already done. The simplest way to represent it, given our available data would be: RCi=WCETsti− running time, where WCETstirepresents the Worst Case Execution time, in singlethread, for a given task. The running time can be evaluated in different ways, according to how we take into consideration the impact of the resource sharing on the performance of the MCT and the LPT. The first option, is to consider them equally and simply use the number of cycles a task has been scheduled in a hardware thread. In this case, the Sicalculation would be expressed as follows: Si=WCETi−Pl γ=1(ωγ) di−t(6.3) Where Pl γ=1(ωγ)represents the sum of all intervals of size ωγthat a task τiran in a hardware thread. We found that better results could be achieved improving this calculation as we must consider that the processor was not entirely dedicated to only one task, and therefore the processing already done for a task should consider the resources allocated to the task. One step further is to consider the resource allocation a task received while running. Assuming the relation between the resource allocation and the performance of a task is linear, we simply calculated the processing done as the product of the time the task was running and the resource allocation given to it. Using this concept, we obtain the following formula: Si(t) = WCETi−Pm γ=1(ωγ∗RAγ) + Pl γ=1(ωγ∗(1 −RAγ)) di−t(6.4) Here, Pm γ=1(ωγ∗RAγ)represents all the resources that a given task τireceived as a MCT, that is, the sum of all the intervals of size ωγran with resource allocation RAγ when τiwas the top priority task of the system. In addition, we have Pl γ=1(ωγ∗(1 − RAγ)as the total amount of processing done when running as LPT. Chapter 6. Scheduling for Soft Real-Time SMT Systems 94 In [16], it was shown that the performance for the MCT is super-linear4. As a consequence, the relation among resources given to the LPT and its performance may, sometimes, be sub-linear. Based on this conclusion, we chose to evaluate the remaining computational time for a given task τiwith different functions whether the task is running as a MCT or LPT. When running as LPT, the worst case is assumed and the performance is considered sub-linear. This correction basically makes the time a thread runs as low priority accounts for less processing time than while it is running as a MCT. We believe that this is the most accurate evaluation. To summarize, the allowed slowdown for a task τi, is given by the following formula: Si(t) = WCETi−Pm γ=1(ωγ∗RAγ) + Pl γ=1(ωγ∗(1 −RAf γ)) di−t(6.5) Formula 6.5 differs from Formula 6.4 on the calculation of the devoted resources for the LPT as they are now evaluated as Pl γ=1(ωγ∗(1 −RAf γ).fis an empirical constant aimed to reduce the total accounted resources for the LPT. 0 10 20 30 40 50 60 70 80 90 100 0 10 20 30 40 50 60 70 80 90 10 0 Resource Allocation (%) relative IPC (%) f =1 f = 0.7 0 FIGURE 6.2: Accounted performance for LPT based MCT RA. 4Recall that the MCT receives priority over the LPT when fetching instructions from the instruction cache. Chapter 6. Scheduling for Soft Real-Time SMT Systems 95 We found, based on the results of [16] and on empirical data, that 0.7is the most appropriated value for the constant f. In Figure 6.2 we can see the accounted IPC for LPT when the relation between the LPT performance and resources allocated to the MCT is linear (f= 1) or sub-linear (f= 0.7). As we can see, the same amount of resources for both f= 1 and f= 0.7translates into a lower performance accounted for the period a task was executed in LPT mode.. The results, when using Formulas 6.3 and 6.4, show much less flexibility and the success rates were significantly smaller. In all cases, the formula 6.5 yielded better results. For simplicity, we only present experimental results for this evaluation method. Furthermore, we observed that, for task sets with many tasks of relatively distant deadlines, the allowed slowdown can be very significant, allocating less than half of the resources to the MCT. In such cases, we understand that there is no sense on giving less than 50% of the resources to the thread that is, by definition, the highest priority of the workload. We artificially constrain the Minimal Resource Allocation (MinRA) as 0.5. Hence, 0.5≤RA(t)≤1.0for the RA version of our proposed algorithm. The MCT resource allocation at a given moment is expressed as follows: RA(t) = max(MinRa, Si(t)) (6.6) It is also very important to observe that, even if the Si(t)calculation may seem complex, it is done in software, by the OS task scheduler and the above described sums are simply implemented as accumulators that are only updated when the resource allocation for the MCT changes (because of a context-switch, for instance) and the entire value of Si(t) is only evaluated for the MCT. 6.3.2.1 Example Consider a set of 4 tasks with the deadlines, WCETs, and utilization as shown in the Table 6.1. In a first step, the scheduler chooses the task τ1, the task with closest deadline. It becomes the MCT. The operating system (OS) also chooses to run, at lower priority, τ3, which is the task with second closest deadline. The OS finally assigns a RA to the MCT. It is set to the MAX(S1,0.5) and S1is calculated as S1=1−0 5−0= 0.2. Therefore, the MCT receives RA = 0.5. Assume that, at a given instant, say Υ=1.25,τ1finishes. τ3becomes the task with the closest deadline and the MCT. The context where τ1was running, receives now τ2. Chapter 6. Scheduling for Soft Real-Time SMT Systems 96 TABLE 6.1: Hypothetical task set. Task WCET Deadline Utilization τ11.0 5 0.20 τ34.0 6 0.67 τ20.5 7 0.07 τ42.0 8 0.25 S3is calculated as 4−(0+(1.25∗(1−0.50.7)) 6−1.25 = 0.74,RA =MAX(0.74,0.5) = 0.74. This workload executes until the instant Υ = 3.8, when τ2finishes. τ4starts to run on the free context and the new RA for τ3is calculated as follows: RA =MAX(S3,0.5) where S3=4−((2.55∗0.76)+(1−0.50.7)) 6−3.8= 0.76. This behavior repeats during the entire execution time. 6.3.3 The SRA-LLF scheduler Our SRA-LLF (Least laxity first) algorithm follows the same logic as the SRA-EDF. For each given workload, the Siis calculated in the same way and follows the same constraints. However, recall that LLF periodically calculates the laxity of each task, being the laxity: li= (TTDi)−(RCi). Recall that TTDiis the time to the deadline (deadlinei−actual time) of task τiand RCiis the remaining computation time necessary to complete this task. As discussed in the previous section, the RCican be computed in several ways. We chose the RCicalculation method used to determine the Si, explained in Formula6.5 (Section 6.3.2) and applied it to the laxity evaluation. Therefore, following the terminology of the section 6.3.2 the final laxity formula was: li=TTDi− WCETi− m X γ=1 (ωγ∗RAγ) + l X γ=1 (ωγ∗(1 −RAf γ))!! Again, the sums are the same accumulators that already existed for the Sicalculation and represent no additional complexity for the algorithm. Concerning task preemption, taking executing tasks out of the run queue while running a EDF based scheduler did not make sense, as our deadlines are fixed at the beginning of the execution, and, therefore, the priorities on the EDF would never change. For the LLF, however, it is possible that a running task looses priority while running, if its laxity becomes larger than another task that was previously evaluated as having more slack Chapter 6. Scheduling for Soft Real-Time SMT Systems 97 time. Similar to the EDF based versions, for which there is no task preemption (tasks execute until they finish as they priority cannot change), we found that our best SRA-LLF implementation did not interrupt running tasks when they do not have the least laxity any more. Although the switch time (including scheduling) is often neglected [37], our results shown that schedulers with higher switch rates yielded to worse overall results. A small correction was, however, found to be very useful to avoid the need to preempt a running task. At any workload change (when one of the tasks finished), a new task was inserted (being the task with the highest priority among the ready tasks) and the two running tasks had their laxities compared between them to determine which of the two would assume the role of MCT. In this way, the highest priority task in the processor is set to the task-set highest priority task. 6.3.4 A hardware support for improved scheduling In LVPs static approach, the MCT is allowed to use a given amount of resources established by the OS, which is called Minimum Resource Allocation or MRA. The other thread was allowed to use the remaining (1−MRA)% of resources. If any thread use more resources than given to it, that thread was stalled until it frees resources. A characteristic of this hardware mechanism is that it was single-objective in the sense that the hardware could only satisfy a single target function given by the OS. In this case the objective was to ensure a minimum resource allocation to the MCT. Our novel resource allocation, works with the assumption that the slowdown factor Si is the minimal bound for the slowdown that the MCT can suffer. Therefore, we can provide the MCT with any amount of resources xso that x≥Si. This is acceptable to guarantee the deadline of the task τi. Enabling the resource allocator to use any value x≥Siprovides a new degree of freedom to the hardware, allowing it to maximize a second objective function given by the OS. For this reason, we call our resource allocator DRA that stands for Double- Objective Resource Allocator. In our approach, the OS provides the workload, a minimum resource allocation to achieve for the MCT and a second objective function. In this work we use as a second objective function the IPC throughput or sum of IPC of co-scheduled workloads. Once the time-slice starts, our mechanism splits the execution of the given workload into two intervals or states that are executed in alternate fashion as shown in Figure 6.3. Chapter 6. Scheduling for Soft Real-Time SMT Systems 98 FIGURE 6.3: States and sub-states in which our resource allocation divides the execution of a workload During the first state, the Learning State the resource allocator tries different resource allocations greater than or equal to the minimum resource allocation provided by the OS for the MCT. The resource allocation leading to the highest value of the second target function is chosen and used during the application state and maintained until the next learning state. In Figure 6.3, we see an example where RAiis set to MRA and the increment per step in the resource allocation (RAinc) is set to 10%, which is the value used in our experiments. The learning state is split in sub-states. In the first learning sub-state the MCT is given RAi+ (0 ×RAinc)resources. In the second sub-state the MCT is given RAi+ (1 ×RAinc), and so on while RAi+ (k×RAinc)≤100%. The number of learning sub-phases or steps until 100% of the resources are allocated to the MCT depends on the minimum resource allocation (RAi) set by the OS and the size of the increment for each step (RAinc). The duration of an application period is set 30 times larger than a learning sub-state and the learning period is set to a maximum of 6 sub-states, as for the DRA versions the lower bound for the resource allocation on the most critical thread is 0.4 (0.4 + (6 ∗ 0.1) == 1). We coupled RA-EDF and RA-LLF to this new hardware support. The resulting combination of scheduling algorithms and hardware support were respectively called DRAEDF and DRA-LLF. Between a SRA and a DRA version of a resource-aware algorithm, the only difference lays in the underlying hardware mechanisms and implementation. 6.3.4.1 Hardware Implementation The DRA based schedulers require additional hardware support to track the phase and sub-phase in which the mechanism is in. This hardware is similar to the mechanism Chapter 6. Scheduling for Soft Real-Time SMT Systems 105 FIGURE 6.8: Comparison between various EDF based algorithms (4-,8-,12-tasks). the simulated scenario. First, as described in Section 6.4.1, we have different task sets distribution and generation mechanisms. Second, we considered a task set not schedulable when at least one task miss its deadlines, while in [47] the authors considered a task set not schedulable when more than 5% of the tasks have missed deadlines. Figure 6.8 shows a comparison between the various algorithms based on EDF. The first thing to note is the unexpected behavior of GLOB SYM US and GLOB NOSYM US. For the latter, recall that its behavior only differs from the EDF for tasks presenting utilization superior to N 2N−1. As the percentage of these tasks in our task sets is only of 11.3%, the results of this algorithm are very similar to those of the EDF. In fact, for our infrastructure, it obtains the same results as EDF. GLOB SYM US starts by co-scheduling the task with the earliest deadline (τedf ) and the task that provides the highest symbiosis with this task (τsymb). In [47], authors do not explain how the algorithm performs the rearrangement of the running workload once the τedf finishes. It is not clear how the algorithm performed the reconfiguration of the running workload once the task with the closest deadline finishes. In other words, given that the task with the earliest deadline is running on one of the hardware contexts, and the others occupied with the tasks that maximize the symbiosis, many decisions can be taken once the task Chapter 6. Scheduling for Soft Real-Time SMT Systems 106 with highest priority finishes. We tuned the following factors in order to have the best performance: •As the task left running is the τsymb, should the algorithm choose the next job in order to maximize the running workload symbiosis or should it pick the task with the nearest deadline? •Given that, during the previous step, the job with the closest deadline was inserted. If the context running the other (less priority) task did not offer the best symbiosis, should it be preempted in order to have always the best running symbiosis? We implemented and benchmarked every combination of the previous decisions and concluded that the best option presented the following behavior: Once the task with the closest deadline finishes (τedf ), the one with the next closest deadline is chosen. If this job is the one already running (previously chosen to improve symbiosis), we insert the task that maximizes the symbiosis of the running task set. If this is not the case (the thread with the earliest deadline is not in the SMT processor), then we insert the job with the closest deadline and, if and only if necessary, preempt the other running job in order to run the one with higher symbiosis on the task set. Although this option yields a larger number of context-switches, it proved to be the most efficient version of this algorithm. Still, in the overall, it schedules 32.7% less task sets than EDF. For EDF, one may observe that some task sets miss even when SU = 1.0. This occurs because of a hardware-software priority inversion problem, where the hardware is prioritizing threads in the opposite direction of the software-priorities. The first two cases occurred when adpcm cwas running with epic d. As we can see in Table 6.3 (task set 1), the default icount policy prioritizes epic d, in order to increase the overall processor throughput, disregarding the fact that adpcm chad a closer deadline (due to the lack of collaboration between the OS and the processor schedulers). For the third case, shown in the Table 6.4 (task set 2) the same problem occurs: epic dwas the task with the closest deadline and was scheduled with epic c, of lesser priority. Internally, icount policy prioritized the latter in order to increase the overall throughput. Observe that the symbiosis factor for these cases are larger than one, meaning that scheduling those tasks together gives a higher throughput than in single thread. GLOB SYM US tends to privilege cases with higher symbiosis, but is not able to tune the internal processor’s resource allocation to prioritize the task with closest deadline. It misses three more task sets than EDF and GLOB NOSYM US when running with serial utilization 1.0. Chapter 6. Scheduling for Soft Real-Time SMT Systems 107 TABLE 6.3: Benchmark interactions without explicit resource allocation. Task set 1: Benchmark IPC Alone IPC Together Relative IPC adpcm c 4.181 1.281 0.306 epic d 1.642 1.333 0.812 Symbiosis factor: 1.118 TABLE 6.4: Benchmark interactions without explicit resource allocation. Task set 2: Benchmark IPC Alone IPC Together Relative IPC epic d 1.642 0.787 0.479 epic c 3.175 1.912 0.602 Symbiosis factor: 1.081 Another interesting fact is that, even if the 4-, 8- and 12-task simulations follow the same trend of behavior, the 12-task sets yield better success rates. This can be explained by the fact that the as the number of tasks per task set increases, the individual pertask utilization utilization tends to decrease, becoming easier to accommodate a larger individual slowdown (traded for a global throughput increase). FIGURE 6.9: Comparison between the LLF based algorithms (4-,8-,12-tasks). As we can see in the Figure 6.8, our RA-EDF algorithm outperforms EDF in all cases. Comparing to the original EDF algorithm, the RA-EDF has, in average, 11.8% higher Chapter 6. Scheduling for Soft Real-Time SMT Systems 108 success rate5. In addition, our SRA-EDF and DRA-EDF successfully schedule task sets when others fail because of hardware-software priority inversion, as they are able to explicitly control the hardware resource allocation to the task with the highest priority. Compared to EDF, DRA-EDF schedules 13.9% more tasks. It achieves similar or higher results than SRA-EDF in all cases except for serial utilizations 1.6 and 2.6, where it schedules respectively one less and three less task sets. Figure 6.9 shows the LLF based algorithms. When compared to LLF, SRA-LLF schedules 10.5% more task sets, while DRA-LLF schedules 11.2% more task sets. For serial utilizations inferior to 1.8, DRA-LLF seems to be slightly worse than, or equal to, SRALLF. From 1.8 to 2.4, it is better than SRA-LLF. LLF schedules about 1.6% more task sets than EDF (Figure 6.11). FIGURE 6.10: Comparison between our proposed algorithms (4-,8-,12-tasks). Putting all together, Figure 6.10 shows all our proposed algorithms. They schedule very similar number of tasks, which highlights the fact that the biggest improvement comes from coupling the internal processor’s resource allocation to the software targets. The DRA versions tend to outperform by a small margin the SRA versions, among them, SRA-EDF is the scheduler that presents the smallest performance improvement (11.8% when compare do EDF). Nevertheless, we expect the choice between our proposals 5Recall that we consider a task set successfully scheduled when there is no missed deadline. Chapter 6. Scheduling for Soft Real-Time SMT Systems 109 to depend on more than their comparative performance. For instance, LLF based algorithms increase the scheduling complexity due to the fact that frequent laxity calculation must be performed for all tasks. On the other hand, DRA based algorithms require a more complex hardware support that may not be available. FIGURE 6.11: Aggregated success rate for all serial utilizations normalized to EDF. Figure 6.11 shows the number of scheduled task sets, normalized to EDF, for all serial utilizations and all schedulers. As we can see, the benchmark that performs the worse in our environment is the GLOB SYM US, scheduling 32.7% less task sets than EDF. The best aggregated result is the one obtained by DRA-EDF, which is very similar to the one obtained by DRA-LLF (0.9% difference). We should observe that, except for one task set, with serial utilization of 1.6, where DRA-EDF and DRA-LLF miss, there is no case in which our proposed algorithm has lower success rate than any of the others. Furthermore, using this resource aware scheduling algorithms eliminates the hardware-software priority inversion problems. That is, in contrast to normal SMT processors, where the hardware scheduler (fetch priority mechanism) and the OS scheduler are not aware of each other, there is no case where a lesser priority thread consumes more resources than the higher priority one. In addition, our solutions do not require profiling of the tasks to schedule. Chapter 6. Scheduling for Soft Real-Time SMT Systems 110 Another key observation is the fact that we used a very aggressive WCET estimate. The closer is the WCET to the average execution time, the harder will it be to schedule the task set, as there will be close to zero extra time on normal execution. On real systems, WCET are normally an upper bound on the execution time, and, therefore, even more task sets would be scheduled on the common case. Considering a soft realtime scenario, using this slack between the WCET and the “expected execution time” would be, on some cases, an acceptable situation. From our proposals, whenever the necessary hardware support can be implemented, we estimate that DRA-EDF should be chosen. Otherwise, SRA-EDF should be preferred. It presents very similar results to SRA-LLF and much lower complexity. 6.6 Conclusions Embedded systems require increasingly high throughput rates. To reach those rates, current embedded processors use features that resemble to the ones used in the highperformance processors. The use of these features impacts the performance predictability and creates new problems for real-time system. SMT processors are a clear example of this new trend. SMTs provide higher throughput with reduced costs but make harder the problem of computing the worst case execution time, generating task interference or even giving most of the shared hardware resources to a task with lower priority when multiple tasks are running on different hardware threads. In this chapter, we address the problem of scheduling a task set in a soft real-time SMT system from the software and hardware layers in a collaborative way. Our proposal allows better control of the underlying hardware resources by the scheduling algorithm, increasing the task scheduling success rate. Assuming that the Worst Case Execution Time (WCET) is given, for every task, our mechanisms do not require any additional profiling. The original Earliest Deadline First (EDF) algorithm, used in most RT systems, only aims to determine the order in which tasks should be executed. This is not enough if the task set is scheduled on an SMT processor due to the execution time variability of threads. We developed and evaluated, in a simulated environment, a new scheduling algorithm, called RA-EDF (Resource-Aware EDF), that uses a hardware support proposed in [16]. RA-EDF, in addition to determine the execution order of threads, controls the amount of resources to give to co-scheduled threads. We provide EDF with knowledge of the processor resources and instruct it in how to split resources among threads Chapter 6. Scheduling for Soft Real-Time SMT Systems 111 in order to meet their deadlines. This increases the success rate when scheduling tasks, outperforming state-of-the-art scheduling algorithms. The proposed scheduler algorithm obtains better results than EDF on every case when compared to the previous proposed task schedulers: 11.8% average improvement. In addition, we developed RA-LLF, a resource-aware LLF variant that, in addition to control the resource allocation, improves the laxity accounting. RA-LLF achieves better results than RA-EDF when there is skewed distribution of utilization between the tasks. Furthermore, we propose a new hardware support that allows hardware-level fine-grain dynamic prioritization. The RA-EDF and RA-LLF versions adapted to the dynamic prioritization hardware were called DRA-EDF and DRA-LLF respectively. DRA-EDF and DRA-LLF achieve better results than RA-EDF and RA-LLF. As a future work, we plan to expand the proposed mechanisms to an N-way SMT machine: keeping one MCT and many LPT would make it feasible. Furthermore, we would like to evaluate other secondary metrics for the double-objective hardware. Chapter 7 Conclusions Multithreaded processors became widely used in academia and industry as a way to increase the aggregated performance (throughput). They offer additional performance at a low cost and low complexity. Furthermore, they allow to increase the processor’s throughput with relatively small power increase. Due to their resource sharing, these processors present specific problems and characteristics. Hardware-software priority inversion (by the hardware resource allocation) and performance variability are two examples of such problems. These problems are caused or worsened by the fact that several separated hardware policies rule the allocation of the many levels of resource sharing: the cache replacement policy is not coordinated with the internal resource sharing policy or the fetch policy and so on. And even worse, the operating system or the software layer has no way to enforce the software targets. In this thesis, we use a comprehensive approach, coordinating targets of software and hardware. We employ hardware with explicit resource allocation and propose new hardware support when such hardware is not commercially available. For both the new simulated hardware and ones commercially available, we propose new software-controlled mechanisms to narrow the gap between software and hardware policies. The main contributions of this thesis are: 1. On the real time domain, we addressed the problem of scheduling a task set in a SMT system from the software and hardware layers in a collaborative way. We made two sets of contributions: scheduling mechanisms that improve the schedulability of the previous proposed soft real-time task schedulers, and an improved hardware support for explicit resource allocation that allows targeting a given metric while still guaranteeing a minimum performance for the high priority task. 113 Conclusions 114 The scheduling algorithms, RA-EDF and RA-LLF, when compared to EDF and LLF, improved success ratio scheduling soft real-time tasks by 11.8% and 10.5%, respectively. When running with the new hardware support, another 2.1% are harvested for DRA-EDF, improving EDF by 13.9%. DRA-LLF improves LLF by 11.2%. 2. On the HPC domain, we made the following contributions: •We characterized a real processor, the IBM POWER5, and perform an in-depth evaluation of the effects of this processor’s software-controlled prioritization mechanism over several different loads. We present the following conclusions: first, workloads presenting a large amount of long-latency operations are less influenced by priorities then the ones executing low-latency operations (i.e., integer arithmetic). Second, it is possible, by using the prioritization mechanism, to improve the overall throughput up to two times, in very special cases. However, those extreme improvements often imply drastic reduction of the low IPC thread’s performance. On less extreme cases, it is possible to improve the throughput by 40%. And third, we show that, instead of using the full spectrum of priorities, only priorities up to +/-2 should be used, while “extreme” priorities should be used only when the performance of one of the two threads is not important. •We propose the use of the thread prioritization mechanism as a way to perform load-balance in HPC applications and significantly reduce their execution time. •We propose HPCSched, a scheduler for the Linux kernel that is able to perform load-balancing transparently and dynamically, adapting to application’s behavior changes and requiring no changes in the program code. •We propose DLRB, a transparent dynamic user-level load and resource balancer in the form of a linked library. Our experiments show that HPCSched and DLRB achieve results close to the one obtained by static hand-tuning of the priorities for applications with constant behavior. In addition, for the cases where the static hand tuning cannot perform well due to the fact that the applications exhibit dramatic changes in behavior, both HPCSched and DLRB are able to adapt and re-balance the resources appropriately. Summing up our findings, we conclude that, by a coordinated hardware/software approach in which the system software and the hardware tightly collaborate, it is possible to develop improved heuristics to target different metrics. In this thesis, we control, from the software, the hardware resource allocation to improve two of the possible Bibliography 121 [17] Francisco J. Cazorla, Peter M. W. Knijnenburg, Rizos Sakellariou, Enrique Fernandez, Alex Ramirez, and Mateo Valero. Predictable performance in SMT processors: Synergy between the OS and SMTs. IEEE Transactions on Computers, 55(7):785–799, 2006. [18] Francisco J. Cazorla, Peter M.W. Knijnenburg, Rizos Sakellariou, Enrique Fernandez, Alex Ramirez, and Mateo Valero. Predictable performance in SMT processors. In Proceedings of the First Conference on Computing Frontiers (CF’04), pages 433–443, New York, NY, USA, 2004. ACM Press. [19] Francisco J. Cazorla, Alex Ramirez, Mateo Valero, and Enrique Fernandez. Dynamically controlled resource allocation in SMT processors. In Proceedings of the 37th International Symposium on Microarchitecture (MICRO’04), pages 171–182, Washington, DC, USA, 2004. IEEE Computer Society. [20] Francisco J. Cazorla, Alex Ramirez, Mateo Valero, Peter M. W. Knijnenburg, Rizos Sakellariou, and Enrique Fernandez. QoS for high-performance SMT processors in embedded systems. IEEE Micro, 24(4):24–31, July/August 2004. [21] Onur Celebioglu, Amina Saify, Tau Leng, Jenwei Hsieh, Victor Mashayekhi, and Reza Rooholamini. The performance impact of computational efficiency on HPC clusters with hyper-threading technology. In Proceedings of the 3rd International Workshop on Performance Modeling, Evaluation, and Optimization of Parallel and Distributed Systems (PMEO-PDS’04), Santa Fe, New Mexico, USA, April 2004. IEEE Computer Society (Los Alamitos, CA). [22] Derek Chiou, Larry Rudolph, Srinivas Devadas, and Boon S. Ang. Dynamic cache partitioning via columnization. In Proceedings of Design Automation Conference (DAC’00), June 2000. [23] Seungryul Choi and Donald Yeung. Learning-based SMT processor resource distribution via hill-climbing. In Proceedings 33th International Symposium on Computer Architecture (ISCA’06), volume 34, pages 239–251, Boston, MA, USA, June 2006. ACM SIGARCH / IEEE Computer Society. [24] Matthew Curtis-Maury and Tanping Wang. Integrating multiple forms of multithreaded execution on multi-SMT systems: A study with scientific applications. In Proceedings of the 2nd International Conference on the Quantitative Evaluation of Systems (QEST’05), pages 199–209, Torino, Italy, 2005. IEEE Computer Society. Bibliography 122 [25] Ronaldo de Lara Goncalves and Philippe Olivier Alexandre Navaux. Improving SMT performance scheduling processes. In Proceedings of the 10th Euromicro Conference on Parallel, Distributed and Network-based Processing (PDP’02), volume 0, pages 327–334, Los Alamitos, CA, USA, 2002. IEEE Computer Society. [26] Michael L. Dertouzos and Aloysius K. Mok. Multiprocessor on-line scheduling of hard-real-time tasks. IEEE Transactions on Software Engineering, 15(12):1497– 1506, December 1989. [27] Sudarshan K. Dhall and C. L. Liu. On a real-time scheduling problem. Operations Research, 26(1):127–140, January 1978. [28] Gautham K. Dorai and Donald Yeung. Transparent threads: Resource sharing in SMT processors for high single-thread performance. Proceedings of the 11th International Conference on Parallel Architectures and Compilation Techniques (PACT’02), pages 30–41, Sep 2002. [29] Alejandro Duran, Marc Gonzalez, Julita Corbalan, Xavier Martorell, Eduard Ayguade, Jesus Labarta, and Raul Silvera. Automatic thread distribution for nested parallelism in OpenMP. In Proceedings of the 19th ACM International Conference on Supercomputing (ICS’05), pages 121–130, Cambridge, Massachusetts, USA, June 2005. [30] Ali El-Haj-Mahmoud, Ahmed S. Al-Zawawi, Aravindh Anantaraman, and Eric Rotenberg. Virtual multiprocessor: an analyzable, high-performance architecture for real-time computing. In Proceedings of the International Conference on Compilers, Architecture, and Synthesis for Embedded Systems (CASES’05), pages 213–224. ACM Press, 2005. [31] Ali El-Haj-Mahmoud and Eric Rotenberg. Safely exploiting multithreaded processors to tolerate memory latency in real-time systems. In Proceedings of the International Conference on Compilers, Architecture, and Synthesis for Embedded Systems (CASES’04), pages 2–13. ACM Press, 2004. [32] Ali El-Moursy and David H. Albonesi. Front-end policies for improved issue efficiency in SMT processors. In Proceedings of the 9th International Conference on High Performance Computer Architecture (HPCA’03), pages 31–40, Anaheim, California, USA, February 2003. IEEE Computer Society. Bibliography 123 [33] Felix Freitag, Julita Corbalan, and Jesus Labarta. A dynamic periodicity detector: Application to speedup computation. In Proceedings of the 15th the International Parallel and Distributed Processing Symposium (IPDPS’01), pages 2–2, Los Alamitos, CA, 2001. IEEE Computer Society. [34] Isaac Gelado, Javier Cabezas, Lluis Vilanova, and Nacho Navarro. The cost of IPC: an architectural analysis. In Proceedings of the International Workshop on the Interaction between Operating Systems and Computer Architecture (WIOSCA’07). ACM Press, 2007. [35] Ben Gibbs, Balaji Atyam, Frank Berres, Bruno Blanchard, Lancelot Castillo, Pedro Coelho, Nicolas Guerin, Lei Liu, Cesar Diniz Maciel, Carlos Sosa, and Ravikiran Thirumalai. Advanced POWER Virtualization on IBM eServer p5 Servers: Architecture and Performance Considerations. Redbook. IBM, International Technical Support Organization, Austin, TX, USA, 2005. [36] Roberto Gioiosa, Fabrizio Petrini, Kei Davis, and Fabien Lebaillif-Delamare. Analysis of system overhead on parallel computers. In Proceedings of the 4th IEEE International Symposium on Signal Processing and Information Technology (ISSPIT’04), pages 387–390, Rome, Italy, 2004. [37] Joel Goossens and Christophe Macq. Limitation of the hyper-period in realtime periodic task set generation. In Proceedings of the RTS Embedded Systems (RTS’01), pages 133–148, Paris, France, 2001. [38] Joel Goossens and Pascal Richard. Overview of real-time scheduling problem. In Proceedings of the 9th International Conference on Project Management and Scheduling, pages 13–22, Nancy France, April. [39] Ronald L. Graham. Bounds on multiprocessing timing anomalies. SIAM Journal on Applied Mathematics, 17(2):416–429, 1969. [40] Fei Guo, Yan Solihin, Li Zhao, and Ravishankar Iyer. A framework for providing quality of service in chip multi-processors. In Proceedings of the 40th International Symposium on Microarchitecture (MICRO’07), pages 343–355, Washington, DC, USA, 2007. IEEE Computer Society. [41] John L. Henning. SPEC CPU2006 benchmark descriptions. SIGARCH Computer Architecture News, 34(4), 2006. [42] Weicheng Huang and Danesh Tafti. A parallel computing framework for dynamic power balancing in adaptive mesh refinement applications. In Proceedings of the Parallel Computational Fluid Dynamics (PCFD’99), 1999. Bibliography 124 [43] IBM. PowerPC Operating Environment Architecture version 2.02. Number 3 in PowerPC Architecture books. 2005. [44] IBM. Cell broadband engine programming handbook v1.11, 2008. [45] IBM, Sony, and Toshiba. Cell broadband engine architecture v1.01, 2006. [46] Ravi Iyer, Li Zhao, Fei Guo, Ramesh Illikkal, Srihari Makineni, Don Newell, Yan Solihin, Lisa R. Hsu, and Steve K. Reinhardt. QoS policies and architecture for cache/memory in CMP platforms. In Proceedings of the International Conference on Measurement and Modeling of Computer Systems (SIGMETRICS’07), pages 25–36, New York, NY, USA, 2007. ACM Press. [47] Rohit Jain, Christopher J. Hughes, and Sarita V. Adve. Soft real-time scheduling on simultaneous multithreaded processors. In Proceedings of the 23rd IEEE Real- Time Systems Symposium (RTSS’02), page 134, Washington, DC, USA, December 2002. IEEE Computer Society. [48] Haoqiang Jin and Rob F. Van der Wijngaart. Performance characteristics of the multi-zone NAS parallel benchmarks. Journal of Parallel and Distributed Computing, 66(5):674–685, 2006. [49] Ronald N. Kalla, Balaram Sinharoy, and Joel M. Tendler. SMT implementation in POWER5. In Hot Chips, volume 15, Aug 2003. [50] Ronald N. Kalla, Balaram Sinharoy, and Joel M. Tendler. IBM POWER5 Chip: a dual-core multithreaded processor. IEEE Micro, 24(2):40–47, 2004. [51] Peter M. W. Knijnenburg, Alex Ramirez, Josep L. Larriba-Pey, and Mateo Valero. Branch classification for SMT fetch gating. In Proceedings of the 6th Workshop on Multithreaded Execution, Architecture, and Compilation (MTEAC’02), pages 49–56, November 13 2002. [52] Jesus Labarta, Sergi Girona, Vincent Pillet, Toni Cortes, and Luis Gregoris. DiP: A parallel program development environment. In Proceedings of the 2nd International Conference on Parallel Processing (Euro-Par’96), volume II of Lecture Notes in Computer Science, pages 665–674, Lyon, France, 1996. Springer. [53] Hung Q. Le, William J. Starke, J. Stephen Fields, Francis P. O’Connell, Dung Q. Nguyen, Bruce J. Ronchetti, Wolfram Sauer, Eric M. Schwarz, and Michael T. Vaden. IBM POWER6 microarchitecture. IBM Journal of Research and Development, 51(6):639–662, 2007. Bibliography 125 [54] Chunho Lee, Miodrag Potkonjak, and William H. Mangione-Smith. MediaBench: A tool for evaluating and synthesizing multimedia and communications systems. In Proceedings of the 30th Annual International Symposium on Microarchitecture (MICRO’97), pages 330–335, Research Triangle Park, North Carolina, December 1–3, 1997. IEEE Computer Society. [55] C. Limousin, J. Sebot, A. Vartanian, and N. Drach-Temam. Improving 3D geometry transformations on a simultaneous multithreaded SIMD processor. In Proceedings of the 15th International Conference on Supercomputing (ICS’01), pages 236–245, Sorrento, Napoli, Italy, May 2001. ACM. [56] Chung Laung Liu and James W. Layland. Scheduling algorithms for multiprogramming in a hard-real-time environment. J. ACM, 20(1):46–61, January 1973. [57] Shi-Wu Lo, Kam-Yiu Lam, and Tei-Wei Kuo. Real-time task scheduling for SMT systems. In Proceedings of the International Workshop on Real-Time Computing Systems and Applications (RTCSA’05), pages 5–10, Los Alamitos, CA, USA, 2005. IEEE Computer Society. [58] Kun Luo, Manoj Franklin, Shubhendu S. Mukherjee, and Andre Seznec. Boosting smt performance by speculation control. In Proceedings of the 15th the International Parallel and Distributed Processing Symposium (IPDPS’01), page 2, Los Alamitos, CA, 2001. IEEE Computer Society. [59] Kun Luo, Jayanth Gummaraju, and Manoj Franklin. Balancing throughput and fairness in SMT processors. In Proceedings of the International Symposium on Performance Analysis of Systems and Software (ISPASS’01), pages 164–171. IEEE, November 2001. [60] Paul Mackerras, Thomas S. Mathews, and Randal C. Swanberg. Operating system exploitation of the POWER5 system. IBM Journal of Research and Development, 49(4/5):533–539, July 2005. [61] Deborah T. Marr, Frank Binns, David L. Hill, Glenn Hinton, David A. Koufaty, James Alan Miller, and Michael Upton. Hyper-threading technology architecture and microarchitecture. Intel Technology Journal, 6(1):4–15, February 2002. [62] Miquel Moreto, Francisco J. Cazorla, Alex Ramirez, and Mateo Valero. MLP- aware dynamic cache partitioning. In Proceedins of the 3rd International Conference on High Performance Embedded Architectures and Compilers (HiPEAC’08), volume 4917 of Lecture Notes in Computer Science, pages 337–352, Goteborg, Sweden, January 2008. Springer. Bibliography 126 [63] Onur Mutlu and Thomas Moscibroda. Stall-time fair memory access scheduling for chip multiprocessors. In Proceedings of the 40th International Symposium on Microarchitecture (MICRO’07), pages 146–160, Washington, DC, USA, 2007. IEEE Computer Society. [64] NASA. NAS parallel benchmarks. http://www.nas.nasa.gov/Resources/Software/npb.html. [65] Fabrizio Petrini, Darren J. Kerbyson, and Scott Pakin. The case of the missing supercomputer performance: Achieving optimal performance on the 8, 192 processors of ASCI Q. In International Conference for High Perfromance Computing, Networking, Storage and Analysis (SC’03), page 55. IEEE/ACM SIGARCH, 2003. [66] Moinuddin K. Qureshi and Yale N. Patt. Utility-based cache partitioning: A low-overhead, high-performance, runtime mechanism to partition shared caches. In Proceedings of the 39th International Symposium on Microarchitecture (MICRO’06), pages 423–432. IEEE Computer Society, 2006. [67] Kirk Schloegel, George Karypis, and Vipin Kumar. Parallel multilevel algorithms for multi-constraint graph partitioning. In Proceedings of the 6th International Conference on Parallel Processing (Euro-Par’00), volume 1900 of LNCS, pages 296–310. Springer-Verlag, Berlin, 2000. [68] Mauricio J. Serrano, Roger C. Wood, and Mario Nemirovsky. A study on multistreamed superscalar processors. In Technical Report 93-05, University of California Santa Barbara, 1993. [69] Balaram Sinharoy, Ronald N. Kalla, Joel M. Tendler, Richard J. Eickemeyer, and Jody B. Joyner. POWER5 system microarchitecture. IBM Journal of Research and Development, 49(4/5):505–521, 2005. [70] Allan Snavely and Dean M. Tullsen. Symbiotic jobscheduling for a simultaneous mutlithreading processor. ACM SIGPLAN Notices, 35(11):234–244, November 2000. [71] Allan Snavely, Dean M. Tullsen, and Geoff Voelker. Symbiotic jobscheduling with priorities for a simultaneous multithreading processor. In Proceedings of the International Conference on Measurement and Modeling of Computer Systems (SIGMETRICS’02), volume 30 of SIGMETRICS Performance Evaluation Review, pages 66–76, New York, June 15–19 2002. ACM Press. Bibliography 127 [72] Jose M. Soler, Emilio Artacho, Julian D. Gale, Alberto Garcia, Javier Junquera, Pablo Ordejon, and Daniel Sanchez-Portal. The SIESTA method for ab initio order-n materials simulation. Journal of Physics: Condensed Matter, 14(11), 2002. [73] Anand Srinivasan and Sanjoy Baruah. Deadline-based scheduling of periodic task systems on multiprocessors. Information Processing Letters, 84(2):93–98, 2002. [74] Dan Tsafrir, Yoav Etsion, Dror G. Feitelson, and Scott Kirkpatrick. System noise, os clock ticks, and fine-grained parallel applications. In Proceedings of the 19th International Conference on Supercomputing (ICS ’05), pages 303–312, New York, NY, USA, 2005. ACM Press. [75] Dean M. Tullsen and Jeffery A. Brown. Handling long-latency loads in a simultaneous multithreading processor. In Proceedings of the 34th International Symposium on Microarchitecture (MICRO’01), pages 318–327, Austin, Texas, December 1–5, 2001. IEEE Computer Society. [76] Dean M. Tullsen, Susan J. Eggers, Joel S. Emer, Henry M. Levy, Jack. L. Lo, and Rebecca L. Stamm. Exploiting choice: instruction fetch and issue on an implementable simultaneous multithreading processor. In Proceedings of the 23rd International Symposium on Computer Architecture (ISCA’96), pages 191–202, New York, NY, USA, 1996. ACM Press. [77] Dean M. Tullsen, Susan J. Eggers, and Henry M. Levy. Simultaneous multithreading: Maximizing on-chip parallelism. Proceedings of the 22nd Annual International Symposium on Computer Architecture (ISCA’95), pages 392–403, June 22– 24 1995. [78] Javier Vera, Francisco J. Cazorla, Alex Pajuelo, Oliverio J. Santana, Enrique Fernandez, and Mateo Valero. FAME: Fairly measuring multithreaded architectures. In Proceedings of the 16th International Conference on Parallel Architectures and Compilation Techniques (PACT’07), pages 305–316. IEEE Computer Society, 2007. [79] Javier Vera, Francisco J. Cazorla, Alex Pajuelo, Oliverio J. Santana, Enrique Fernandez, and Mateo Valero. Measuring the performance of multithreaded processors. In SPEC Benchmark Workshop, 2007. Bibliography 128 [80] Chris H. Walshaw and Mark Cross. Dynamic mesh partitioning and loadbalancing for parallel computational mechanics codes. In Computational Mechanics Using High Performance Computing, pages 79–94. Saxe-Coburg Publications, Stirling, 2002.