## 3 Parallel Computing Based on a Hybrid OpenMP-MPI Approach  
### Parallelization Strategy Based on MPI Approach: Description and Limits  
The numerical model of the MQS problem, described in the previous section, has been implemented in a parallel-computing scheme, based on a pure MPI approach, which is here briefly summarized (further details are given in [26]). As for task (a), when assembling the known-terms vector, \(\mathbf{V}_{0}\), the sources are the impressed currents, given in an external mesh (the sources mesh). The computation of the entries of \(\mathbf{V}_{0}\) requires a double loop: the first on the mesh elements, the second one on the external mesh (as shown in Algorithm 1). Actually, \(\mathbf{V}_{0}\) is a small size vector, and hence, although each MPI process allocates the whole vector in V0_loc, only a part of its memory is used. Then, a reduction operation is required in order to gather the final vector. ```
// Initialization Split Source Points between MPI processes // Parallel pure MPI computation for each MPI process do for each iell mesh element point do for each iell0 source mesh element do  compute V0 contribution, between iel and iell0 endfor endfor // All reduce of the local contribute on the global V0 mpi_allreduce(V0_loc,V0_global)
```  
**Algorithm 1** Evaluation of \(\mathbf{V}\)0, pure MPI approach  
The assembly cost for task (b) is mainly related to the inductance matrix \(\mathbf{L}\), being \(\mathbf{R}\) a sparse matrix [26]. The choice of the most suitable parallelization approach for computing the \(\mathbf{L}\) matrix comes from a trade-off between the needs of optimizing the costs of computa  
Figure 1: Benchmark case study: times required for the inversion of (6) and for the assembly of \(\mathbf{L}\) versus the number of degrees of freedom, \(N_{dd}\). The assembly times are parametrized to the number of Gauss points, \(n\). tion, memory writing, and communications. For this purpose, two main strategies have been in the past investigated by the authors [26]: in the first one, the element by elements interactions needed to compute the integrals in (8) are distributed all over available MPI processes; in the second one, each process takes care of building a sub-block of the \(\mathbf{L}\) matrix. Overall, numerical experiments in [26] show that the first approach proved to be the most effective one, given the characteristics of the transient electromagnetic problems of interest in the study of nuclear fusion machines. For this reason, we have adopted such an approach, that is here implemented by means of a hybrid OpenMP-MPI paradigm. Looking at its definition in (8), the assembly of \(\mathbf{L}\) requires two nested loops on the mesh elements, to compute the element-element interactions, as shown in Algorithm 2. To this end, a critical point is the need to accumulate and store these interactions in a correct way. Three dummies' memories are defined:  
* \(M_{DMESH}\), used to store the geometrical mesh information. These data have a dimension of the order of magnitude of the number of the mesh elements;
* \(M_{DL}\), used to temporarily store the entries \(L_{ij}\) produced during the main loop of element-element interactions. This memory has the same dimension of \(M_{LOC}\), that is the chunk memory required for matrix storage at each node;
* \(M_{DEF}\), used to carry on the main loop of element-element interactions: such a memory is of the order of \(N_{dof,el}^{2}\), being \(N_{dof,el}\) the number of degrees of freedom per element.