scieee AI-readable full text Open interactive document viewer

The Advanced Computing Hub at BSC: Improving fusion codes following modern software engineering standards

Saez Pous, Xavier,Soba, Alejandro,Vinyals Ylla Català, Joan,Saxena, Gaurav,Garcia Gasulla, Marta,Morales, Cristian,Vicente Dorca, David,Mantsinen, Mervi

Abstract

Several dedicated High-Performance Computing (HPC) centers provide essential expertise and support in developing a suitable portfolio of EUROfusion standard codes. Barcelona Supercomputing Center (BSC) is one of these HPC hubs involved in this complex task. Several fusion codes were selected, installed and analyzed to meet the developers' requirements, ranging from portability to GPU, improving the performance, getting better data management, extending the capacity of coupling with other codes, etc. In this paper, we will describe the work developed by BSC and some of the tasks carried out in this project. We will explain briefly how the project is faced and the work required to create good quality codes, i.e. robust and trustable software capable of running efficiently in modern HPC systems.

Full text

Plasma Physics and Controlled Fusion ACCEPTED MANUSCRIPT • OPEN ACCESS The Advanced Computing Hub at BSC: Improving fusion codes following modern software engineering standards To cite this article before publication: Xavier Sáez et al 2024 Plasma Phys. Control. Fusion in press https://doi.org/10.1088/1361-6587/ad4589 Manuscript version: Accepted Manuscript Accepted Manuscript is “the version of the article accepted for publication including all changes made as a result of the peer review process, and which may also include the addition to the article by IOP Publishing of a header, an article ID, a cover sheet and/or an ‘Accepted Manuscript’ watermark, but excluding any other editing, typesetting or other changes made by IOP Publishing and/or its licensors” This Accepted Manuscript is © 2024 The Author(s). Published by IOP Publishing Ltd. As the Version of Record of this article is going to be / has been published on a gold open access basis under a CC BY 4.0 licence, this Accepted Manuscript is available for reuse under a CC BY 4.0 licence immediately. Everyone is permitted to use all or part of the original content in this article, provided that they adhere to all the terms of the licence https://creativecommons.org/licences/by/4.0 Although reasonable endeavours have been taken to obtain all necessary permissions from third parties to include their copyrighted content within this article, their full citation and copyright line may not be present in this Accepted Manuscript version. Before using any content from this article, please refer to the Version of Record on IOPscience once published for full citation and copyright details, as permissions may be required. All third party content is fully copyright protected and is not published on a gold open access basis under a CC BY licence, unless that is specifically stated in the figure caption in the Version of Record. View the article online for updates and enhancements. This content was downloaded from IP address 84.88.53.170 on 16/05/2024 at 15:17 Submitted to: Plasma Phys. Control. Fusion The Advanced Computing Hub at BSC: Improving fusion codes following modern software engineering standards X. S´aez1∗, A. Soba1,2, J.V. Ylla Catal`a1, G. Saxena1, M. Garcia-Gasulla1, C. Morales1, D.V. Dorca1, M. Komm3, A. Podolnik3, J.Romazanov4, E. S´anchez5, J.L. Velasco5and M.J. Mantsinen1,6 1BSC - Barcelona Supercomputing Center, Barcelona, Spain 2CONICET - Consejo Nacional de Investigaciones Cient´ıficas y T´ecnicas, Argentina 3Institute of Plasma Physics of the Czech Academy of Sciences, Prague, Czech Republic 4IEK-4 - Institute of Energy and Climate Research, Forschungszentrum J¨ulich, Germany 5Laboratorio Nacional de Fusi´on - CIEMAT, Madrid, Spain 6ICREA - Instituci´o Catalana de Recerca i Estudis Avan¸cats, Barcelona, Spain E-mail: [email protected],[email protected], [email protected], [email protected], [email protected],[email protected],[email protected],[email protected], [email protected],[email protected],[email protected], [email protected],[email protected] Abstract. Several dedicated High-Performance Computing (HPC) centers provide essential expertise and support in developing a suitable portfolio of EUROfusion standard codes. Barcelona Supercomputing Center (BSC) is one of these HPC hubs involved in this complex task. Several fusion codes were selected, installed and analyzed to meet the developers’ requirements, ranging from portability to GPU, improving the performance, getting better data management, extending the capacity of coupling with other codes, etc. In this paper, we will describe the work developed by BSC and some of the tasks carried out in this project. We will explain briefly how the project is faced and the work required to create good quality codes, i.e. robust and trustable software capable of running efficiently in modern HPC systems. Keywords: Advanced Computing Hub, Fusion codes, HPC, GPU, Optimization, Performance analysis, ERO2, SPICE, KNOSOS. 1. Introduction In the European Research Roadmap to the Realisation of Fusion Energy [1], there is a need to accelerate the understanding and predictive capabilities of simulation models to guide ITER [2] operation and DEMO [3] design. A key factor to achieve this milestone is the production of a high-quality suite of research codes called EUROfusion-standard software to model data from existing EUROfusion facilities and to reliably extrapolate to these future devices. EUROfusion-standard software [4] is basically a common development platform following modern software engineering standards that will benefit EUROfusion users with free availability of up-to-date release versions of the research source codes to be used for production runs. To enable large-scale numerical simulations, several dedicated High-Performance Computing (HPC) centers provide essential expertise and support in developing a suitable portfolio of EUROfusion standard software codes. These centers are called Advanced Computing Hubs (ACHs) and will provide expert help to users under three categories: 1) High-Performance Computing working in scalable algorithms, code parallelization, performance optimization, code refactoring, and GPU-enabling, among others; 2) Integrated Modelling and Control working in code adaptation to IMAS framework; and finally, 3) Data management developing open access to data and data analysis tools. Barcelona Supercomputing Center (BSC) is one of the HPC hubs involved in this complex task. Several fusion codes were selected, installed and analyzed in order to meet the developers’ requirements, ranging from portability to GPU, improving the performance, getting better data management or extending the capacity of coupling with other codes. Three different group from BSC are involved in this project: Operations, BePPP and Fusion. The operations group is in charge of maintenance, deployment and performance knowledge of the clusters available at BSC. This group is fundamental in the installation, performance testing and acceleration of software using vectorization and hybridization techniques on Page 1 of 14 AUTHOR SUBMITTED MANUSCRIPT - PPCF-104318.R2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 Accepted Manuscript The Advanced Computing Hub at BSC: Improving fusion codes 2 heterogeneous HPC architectures. The Best Practices for Performance and Programmability group (BePPP) is expert in activities such as developing programming models, dynamic load balancing of HPC code or scalability on many architectures. The researchers at BePPP have a long track record in performance assessment as well as in software engineering, development of tools, methodologies and techniques for the analysis and performance enhancement of the performance of HPC codes. Finally, the fusion group, has experts in the optimization of codes, GPU porting and expertise in the simulated physics in which each code is involved. This paper describes the work developed by BSC in this project, and it is structured as follows. Section 2introduces the role of the ACHs and their objectives within the EUROfusion framework. In Section 3, the methodology and tools used to develop the work are presented. Section 4explains the work required to improve an example set of codes to be capable of running efficiently in modern HPC systems. We included in this paper the work on three codes: SPICE2, ERO2.0 and KNOSOS. Finally, some concluding remarks are highlighted. 2. EUROfusion Advanced Computing Hubs The European Research Roadmap provides a clear and structured way forward to commercial energy from fusion, and it can be considered the basis for the programs of EUROfusion and Fusion for Energy (F4E). The roadmap outlines steps to push fusion from being laboratory-based and science-driven towards an industry- and technology-driven venture. The most remarkable milestones in this roadmap are the building of two machines: DEMO and ITER. DEMOnstration fusion power plant project is being conducted in Europe as part of the European Research Roadmap. DEMO follows ITER project and its goal is to design a commercial fusion power plant. This is a crucial step since ITER is an experimental machine not connected to the grid to deliver electrical energy. Conversely, DEMO should deliver 300-500 MW of electrical energy to the grid (MWe). The design, construction and operation of DEMO require the full involvement of industry and this will ensure that after a successful DEMO operation industry can take on the responsibility for commercial fusion power. However, the step from ITER to DEMO is challenging. DEMO design is complex regarding the number of systems necessary to produce and control the plasma. Experimental data from ITER and IFMIF-DONES [5] are essential but insufficient to design DEMO with confidence inside an unexplored environment to predict plasma and materials performance. Consequently, there is a need to create a highquality suite of research codes (EUROfusion-standard software) to model data from existing EUROfusion facilities and extrapolate to future devices reliably. Therefore, the goal is to bring together fusion physicists, materials scientists and engineers with a new generation of mathematicians and computer scientists within the same organizational framework to use high-performance computers (HPC) and accelerate the development of fusion energy. As part of this approach, EUROfusion has initiated coordination among theory and advanced simulation by creating the Theory, Simulation, Validation and Verification tasks (TSVV) and the Advanced Computing Hubs (ACHs). The TSVVs will perform fundamental research and channel science, and the ACHs will be computing centers of excellence in specific fields of scientific modeling and simulation that will provide their expertise and knowledge to TSVVs. 2.1. BSC-ACH In 2021, EUROfusion, through the Center for Energy, Environmental and Technological Research (CIEMAT) [6], entrusted BSC to create one of these ACHs that offers advanced simulation to TSVVs. This hub is named BSC-ACH and provides expert support to users regarding High-Performance Computing: scalable algorithms, code parallelization, performance optimization, code refactoring, and GPU-enabling, among others. BSC-ACH is organized as Figure 1shows. Three research groups at BSC work collaboratively in each project: Fusion, Operations and Best Practices for Performance and Programmability (BePPP). The Fusion group provides the knowledge required by the fusion scientific codes. The Operations team contributes the knowledge and tools to cover the different computer architectures. Finally, the BePPP team brings the experience to modify and update the codes following the best practices to get high-quality codes. Page 2 of 14AUTHOR SUBMITTED MANUSCRIPT - PPCF-104318.R2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 Accepted Manuscript The Advanced Computing Hub at BSC: Improving fusion codes 3 Figure 1: BSC-ACH organization. Following Figure 1, TSVVs are responsible for making the necessary requests to ACHs to improve the performance and efficiency of the codes they need for their research. These requests may include optimizing existing codes, implementing new functionalities, porting the code to new architectures or adopting new tools and technologies that can help them achieve their goals by reducing the computing time spent in the simulations or improving the quality of the results achieved. In other words, the ACHs’ goal is to ensure that the codes are as efficient and effective as possible, allowing TSVVs to advance their research more quickly and efficiently. In particular, as an example, Table 1depicts the work requests done by TSVVs to BSC-ACH on different fusion codes. Code Work required ACH groups in charge SOLPS 1. Check the correctness of the OpenMP multi-threading 2. Improve compiler options and/or job submission script 3. Consider vectorization of the code profitable for use on Cray platform Operations, BePP KNOSOS Optimization Operations XTOR-K GPU porting Fusion, Operations BIT1 GPU porting Fusion, Operations SPICE2 Implementing parallel Poisson Solver and parallel electric field calculations Fusion, Operations GENE-X 1. Implementing the ability to access the unstructured computational grid in arbitrary order 2. Testing the performance of different reordering strategies Fusion, Operations ERO 2.0 GPU porting Fusion, BePPP STELLA Optimization BePPP JOREK Reduce memory consumption and improve performance Fusion, Operations Table 1: Codes assigned to BSC-ACH. The codes with a gray background have been selected for this paper. 3. Methodology 3.1. Working procedure The working diagram starts with a kick-off meeting (KoM) between the developers and the ACH staff. This meeting is the first contact between both teams to answer basic questions to start working: description of the code, libraries used, parallelization applied, performance, requests from developers to perform in the code, etc. Regarding these requests, there is a discussion to establish the priority among them depending on their feasibility and required resources, since the available time and resources to achieve the results are limited. Page 3 of 14 AUTHOR SUBMITTED MANUSCRIPT - PPCF-104318.R2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 Accepted Manuscript The Advanced Computing Hub at BSC: Improving fusion codes 4 The next step is installing the code in one of the BSC clusters. Any issue that appears in this process is discussed with the developers. Once the code is installed, the Operations and BePPP teams do a performance analysis to evaluate if there is room for improvement, e.g. detecting bottlenecks among memory accesses, unbalance among processes, or a low number of arithmetic instructions executed. This analysis serves as a basis for deciding on the next steps. The priority is to solve any performance issue detected. If this is not possible because there is not enough time and resources to carry out such a task, a new following meeting is scheduled to discuss with the developers how to continue. For example, improving efficiency could require the change of specific data structures that would involve modifying much of the source code. Finally, for each code is written a report of the work developed every year. 3.2. Tools This section introduces some of the tools used for the analysis in the example codes described later. 3.2.1. Profiling •Extrae [7] is a tool to trace the performance of a code by collecting hardware performance indicators and software events to generate trace files. Extrae is compatible with several programming models, such as OpenMP [8], MPI [9], OpenCL [10], CUDA [11], and their combined usage with MPI. To analyze a code with Extrae, it is necessary to instrument that code by the submission of a script defining certain environmental variables. The user can customize the instrumentation in an XML file, which specifies hardware counters to record, detail level of the tracing, and more. Once the execution is completed, each process generates a file encapsulating the collected performance data. These files are unified in a coherent way to one final file using another tool. The fundamental strategy used by Extrae for tracing is based on the early loading of a cloned MPI library with the same routines, using LD PRELOAD environment variable in Linux systems. This cloned library contains extra code for tracing the execution and then calling the true routines in the original library. Extrae also offers the option of a more detailed instrumentation by allowing the user to add manually specific events inside the code. •POP Standard Metrics [12] is a methodology for analyzing parallel codes to provide a quantitative way of measuring the relative impact of the different factors inherent in parallelization. This methodology was defined by the Performance Optimisation and Productivity Center of Excellence in HPC (POP CoE) [13]. From the trace data of an execution provided by Extrae, the tool calculates a set of metrics, organized in a hierarchy, so that each metric reflects a common cause of inefficiency in parallel programs (such as for example Figure 5, which is presented later in this paper). These metrics are then calculated as efficiencies between 0% and 100% and, in general, efficiencies above 80% are considered acceptable, whereas lower values indicate performance issues that need to be explored in detail. 3.2.2. Tracing •Paraver [14], also known as Parallel Visualization and Events Representation, is a utility designed at BSC to visualize and examine trace files. From trace files produced by Extrae of an execution, Paraver can present a timeline (such as Figure 4, which is discussed further on) from a great number of available metrics (e.g. Floating-Point Operations Per Second (flop/s), Instructions Per Second (IPS), Instructions Per Cycle (IPC), MPI calls, user functions, bandwidths and more). Analyzing these timelines, we can identify patterns or regions with performance issues as bottlenecks. •NVIDIA Nsight Systems [15] is a system-wide performance analysis tool designed at NVIDIA Corporation to help identify regions that present bottlenecks across the CPU and GPU. The tool supports various programming languages, APIs, and standards, including CUDA, OpenACC [16], OpenMP, and more. Nsight Systems provides a unified timeline (such as Figure 7, which can be found later in the next section) that presents how an application utilizes the system’s hardware and software resources. As Paraver, this timeline allows us to identify opportunities for optimization and avoid potential performance pitfalls, such as inefficient resource usage or load unbalancing among threads. Page 4 of 14AUTHOR SUBMITTED MANUSCRIPT - PPCF-104318.R2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 Accepted Manuscript The Advanced Computing Hub at BSC: Improving fusion codes 5 3.3. Machines This section gives an overview of the different machines used for this paper. •MareNostrum 4 (MN4) [17] is a general-purpose system located at BSC. It is composed of 3,456 nodes and each node has two Intel Xeon Platinum 8160 chips, each with 24 processors, amounting to a total of 165,888 processors and a main memory of 390 Terabytes. Its peak power is 11.15 Petaflop/s. •CTE-POWER [17] is a cluster based on IBM Power9 processors hosted at BSC, with a Linux Operating System and an Infiniband interconnection network. Its main characteristic is the availability of 4 NVIDIA Volta GPUs per node, making it an ideal cluster for GPU-accelerated applications. It has a computing power of over 1.5 Petaflop/s. •Marconi [18] is a supercomputer located at CINECA with 3,188 computing nodes. Each node contains 2 Intel Xeon 8160 (24-processors) with 192 GBytes of RAM. The nodes are connected using an Intel Omnipath network. The peak performance is 10 Petaflop/s. •Marconi100 (M100) [18] is an accelerated cluster based on Power9 chips and Volta NVIDIA GPUs acquired by CINECA. It has 980 nodes and each node contains 2 IBM POWER9 AC922 with 16 processors and 256 GBytes. The nodes are connected using an InfiniBand network. The peak performance is about 32 Petaflop/s. 4. Example codes This section addresses our work on a selection of codes (SPICE, ERO2 and KNOSOS) applying the methodology and the tools detailed in the above section. For each code, there is a brief description of that code, the task requested by the developers, the work and tools employed, and the results obtained in relation to the goals established initially. The aim of this section is to share this knowledge, since it is difficult to find this kind of real experience of porting or improving the performance of production fusion codes in HPC architectures due to its complexity. 4.1. SPICE2 The Sheath Particle In CEll (SPICE) package [19–21] includes two codes: SPICE2 (2D3V) and SPICE3 (3D3V). These codes are dedicated to performing simulations of particles in a fixed magnetic and selfconsistent electric field and have been successfully used for the study of plasma deposition near castellated plasma facing components (PFCs). SPICE2 is written in Fortran 90 and parallelized following the domain decomposition principle and message-passing interface (MPI). All internal routines are parallel, except for the Poisson solver. The Poisson solver is sequential and takes 3% of the overall calculation time. It operates with global matrices of potential and charge density. The solvers available in SPICE2 before this ACH work were a direct solver built on UMFPACK libraries [22], using a sparse matrix strategy to manage the matrix information, and one parallel solver that present limitations in scalability. The better solver, the serial one, is very fast, although it suffers from the limitations of any direct solver when it reaches the memory limit of the system. After the KoM, the SPICE2 developers required the following main goals. Firstly, implementing a 2D parallel Poisson solver to run simulations by increasing grid size to allow the code to treat bigger domains than the UMFPACK library allows using (≈4000 cells in each dimension). And secondly, the implementation of a parallel routine for E-field calculation. To achieve these goals, the first task was to include a solver from PETSc library [23] in the code. The solver selected was the KSP linear solver context, and several options were explored for solving the Poisson equation. Thirteen KSP solvers were tested, and the fastest ones were KSPBCGS (preconditioned biconjugate stabilized method), KSPFBCGSR (a mathematically equivalent variant of flexible bi-CG-stab), KSPPIPEBCGS (pipelined BiCGStab method) and KSPCG (preconditioned conjugate method). Among them, the best result in terms of CPU time consumption was the KSPCG solver. The preconditioner of KSP solver can be chosen from a big list of option in the PETSc library. We use the Jacobi’s preconditioner to the Conjugated gradient method. In general, the PETSC library allows the use of different preconditioners for each solver and it was not possible to assess the performance of the solver and the preconditioner separately [24]. But as we deal with a very simple Poisson equation, the Page 5 of 14 AUTHOR SUBMITTED MANUSCRIPT - PPCF-104318.R2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 Accepted Manuscript The Advanced Computing Hub at BSC: Improving fusion codes 6 usual solvers reach convergence easily, and better results have always been observed using preconditioners, regardless of the number of nodes used (see Figure 2) [25,26]. 4.1.1. PETSc inclusion The new solvers were analyzed separately. Figure 2shows the scalability (left) and the wall-time consumed (right) of the new solvers. The figure indicates the best performance in the PETSc case: super-scalability for GMRES and lowest wall-time for KPSPCG. These tests were done using a medium matrix size, generated with a square of 1612x1612 domain. Figure 2: Scalability of selected KSP solvers for SPICE2 (left) and the wall-time consumed per each solver (right). Despite the good scalability of the solver based on the PETSc library, the computation times, even for 128 processors, do not exceed the computation speed of the solver based on the UMFPACK library, which is a direct, sparse and serial solver. The new solver, based on the PETSc library, is able to run without present limitations regarding the domain size. We obtain a good performance up to 128 processors. Figure 3(left) shows the results for the whole code using PETSc solver on Marconi. In Figure 3(right), PETSc solver standalone and SPICE2 code are shown running up to 128 processors on MareNostrum 4. Figure 3: Scalability of SPICE2 on Marconi (left) and MN4 (right) We can remark that in both supercomputers (Marconi and MareNostrum4), a loss of scalability for 256 and 512 processors is observed. Given the local domain is so small, the number of communications makes the problem inefficient. If the domain is increased, our expectation is that the efficiency will improve. Page 6 of 14AUTHOR SUBMITTED MANUSCRIPT - PPCF-104318.R2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 Accepted Manuscript The Advanced Computing Hub at BSC: Improving fusion codes 7 A comparison of the use of the serial UMFPACK solver vs. the PETSc solver is presented in Table 2 for a 1600x1600 domain in SPICE2. The computing time of the code (excluding IO functions to avoid overhead) shows that while the computing time using the serial solver increases slightly deb to the relative weight of the time used to make initial matrix inversion, the computing time using the PETSc solver reaches better values for 256 processors. processors UMFPACK (s) PETSc (s) 16 108.716 976.339 32 105.991 441.469 64 117.479 247.903 128 124.301 175.839 256 160.317 153.775 Table 2: Comparison of the SPICE2 time using the serial UMFPACK solver vs. the PETSc solver. To summarize the results of the scalability analysis, the code has been tested and can run up to 512 processors with acceptable scalability. The accuracy of the results with both parallel solvers is acceptable, and the results were compared with those from the direct solver when was possible, concretely in small and medium domains. Using bigger domains (more than 4000 cells per side), the comparison is not possible as we explained earlier, and only the new PETSc solver can be used. 4.2. ERO2 ERO2.0 [27] is a parallel Monte-Carlo simulation code for particle transport in fusion plasma devices (e.g., tokamaks) written in C++ and parallelized using MPI and OpenMP. Following the initial work plan established with the ERO2.0 team, we worked on two lines of improvements: firstly, the performance analysis and, secondly, the introduction of GPU support. 4.2.1. Performance assessment of ERO2.0 and proposal for optimizations Figure 4b plots the communications matrix. Given a row i and column j, there is a communication between process i and process j when there is a colour point in the intersection (i,j). The colour gradient between green and blue indicates the number of messages, where blue is the maximum value. Therefore, the figure shows there are only communications between the MPI rank 0 and any other rank because row 0 and column 0 have colour points, which means the parallel scheme of ERO2.0 is Master/Slave. Looking at a different aspect, Figure 4a plots a colour gradient timeline (horizontal axis) for all the processes (in the vertical axis). In this figure, green means a short burst of computation, whereas blue means more significant useful computation times. Hence from the random distribution of colours in the timeline, we deduce a variability in the duration of chunk computations, which we could later map to a variability in particle computation time. We can also observe that due to this difference in duration in particle simulation, a load imbalance is induced at the end of the simulation. This load imbalance scales to become the main bottleneck in the execution. For instance, the run shown in Figure 4c (in the same time scale as Figure 4a) finishes much faster and, consequently, the load imbalanced part of the whole elapsed time is roughly half of the total execution time. For each process, the execution consists of fetching a chunk of particles, opening an OpenMP parallel region to compute the particles using all of its threads, and finally, when all particles have been computed, closing the parallel region to start the following communication. We have observed that due to particle execution time variability, load imbalance occurs each time the parallel region is closed. The main reason for using OpenMP, as expressed by the developers, is to reduce memory usage. However, when we increase the threads per process ratio to improve memory usage, the application suffers more from this load imbalance. The next step was to characterize the performance of ERO2.0 code by measuring the efficiency of the code by computing the POP metrics for executions with different amounts of nodes. Figure 5depicts the loss of Parallel Efficiency is correlated with both the Load Balance Efficiency and the Serialization Efficiency. This means that the load imbalance is a problem at both levels, MPI and OpenMP. Moreover, the figure also shows a serialization problem which we have found is caused by a lack of parallelization at the data-gathering phase. Page 7 of 14 AUTHOR SUBMITTED MANUSCRIPT - PPCF-104318.R2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 Accepted Manuscript The Advanced Computing Hub at BSC: Improving fusion codes 8 (a) ERO2.0 Execution with 4 nodes - Useful duration Paraver timeline (b) ERO2.0 Execution with 4 nodes - MPI Connectivity Paraver 2D histogram. (c) ERO2.0 Execution with 32 nodes - Useful duration Paraver timeline Figure 4: ERO2.0 Extrae trace view in Paraver. Figure 5: ERO2.0 POP metrics table for 4, 8, 16, and 32 nodes As a result, the work was focused on solving the Load Balance issues following three proposals: two to solve the MPI load imbalance and one for the OpenMP load imbalance. The first proposal is to start with larger chunks of particles and gradually reduce their size. This proposal aims to increase the probability that a particle that will take long falls within a chunk of the beginning of the execution. The second idea tries to solve the load imbalance caused by particles that take much more time to compute and are distributed with one of the last chunks. The proposed solution is to dynamically compute the average computation time of particles and then use this information, the number of remaining particles, and the number of resources to predict when most particles will have finished. Finally, this prediction is used to terminate the execution of particles past that point. The last suggestion to solve the OpenMP load imbalance involves including the MPI communication (needed to fetch chunks) inside the OpenMP parallelization. More specifically, each thread would perform its communication and manages its particles. This parallelization scheme allows to have more threads sharing some memory, reducing the overall memory usage per node without the need for synchronization with each other. We have implemented proofs of concept for the three suggestions and measured their performance in the MN4 machine, obtaining some preliminary results. For the first case, we observed up to 34% speedups in most cases. On the contrary, a slight improvement was observed from the second suggestion. Finally, the measures realized using all the suggestions applied reached a 50% improvement in the bestcase scenario. This answer allows us to continue to the next level of work, which includes adding all these improvements to the production version of the ERO2.0 code. 4.2.2. Introduction of GPU support The starting point for porting to GPU was the introduction of OpenACC standardization in the most time-consuming part, which was identified using NVIDIA Nsight tool (Figure 6). The routine getDistance Page 8 of 14AUTHOR SUBMITTED MANUSCRIPT - PPCF-104318.R2 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 Accepted Manuscript