## 3 Parallel Computing Based on a Hybrid OpenMP-MPI Approach
### Parallelization Strategy Based on Hybrid OpenMP-MPI Approach
The degradation comes from two major critical issues, as follows: (i) a larger thread memory is needed for evaluating integral (8), that is characterized by element-element interactions; (ii) the output of this calculation has to be stored at the node level in a matrix that is shared among all the threads. To guarantee consistency, the update of such a matrix is performed by a sequential access of the threads. The advantage of using the proposed hybrid OpenMP-MPI approach is the possibility to optimize the memory and to obtain the same speed-up for both the assembly tasks. \begin{table}
\begin{tabular}{c c c} \hline \hline  & **SUNCUDA Cluster** & **MARCONI Cluster** \\ \hline Number of nodes & 2 & 3216 \\ Number of processors per node & 2 & 2 \\ Processor type & Intel Xeon [EMAIL_ADDRESS] GHz & Intel Xeon [EMAIL_ADDRESS] GHz \\ Number of cores per processor & 8 & 48 \\ RAM at each node & 128 GB & 192 GB \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Features of the adopted parallel systems. ### Case Study 1: A Plasma Ring

Case study 1 refers to the study of the interaction of a plasma ring subjected to an asymmetric kink instability in the presence of a conducting vacuum vessel and a set of toroidal field coils, as shown in Figure 4. The kink is described by assuming the plasma as a single tilted and shifted filament, with respect to its axisymmetric equilibrium position. In Figure 4a, we show a sector of 90\({}^{\circ}\) of the total mesh, together with the surface enclosing the plasma rings necessary for integrating the Maxwell stress tensor. In Figure 4b, we show the time history of the x component of the resultant force due to the interaction between the plasma ring and the toroidal field, computed by means of the \(j\times B\) expression and by using the Maxwell stress tensor. We notice that this method is very efficient in presence of a 3D plasma current distribution with time-varying shape and position. For this case, we adopted a mesh with 44,200 elements, 88,400 nodes, 12,600 points, and \(N_{dof}\) = 44,202. For eddy current problems in nuclear fusion machines, such as in this case study and in case study 2, discussed later on, a satisfactory estimation of the current density, \(j\), in the conductors, comes from the choice of linear basis functions and a number of Gauss points equal to 2, in the numerical computation of the integrals--see [21]. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**MPI** & \multirow{2}{*}{**OpenMP Threads**} & \multicolumn{2}{c}{**Speed-Up Values**} \\ \cline{3-4}
**Tasks** & & **Assembly of V\({}_{0}\)** & **Assembly of L** \\ \hline \(1\) (reference) & 1 (reference) & 1 & 1 \\ \(1\) & 4 & 4.0 & 3.4 \\ \(1\) & 8 & 7.4 & 6.7 \\ \(4\) & 1 & 3.7 & 3.8 \\ \(4\) & 4 & 14 & 15 \\ \(4\) & 8 & 26 & 27 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Benchmark case: speed-up values for tasks (a) and (b) with OpenMP–MPI on SUNCUDA Cluster. Figure 3: The benchmark case study: a pancake coil over a conducting plate. For this case study, the computational effort for task (c) has been evaluated--evaluation of the flux density matrix \(Q\). Here, the reference time is given by the solution evaluated with 10 nodes, 2 MPI tasks per node, and 1 OpenMP thread: such a time is 1932 s on the Marconi cluster. Table 3 shows the speed-up values as functions of the total nodes, of the OpenMP threads and of the MPI tasks. The speed-up value depends almost linearly by the number of MPI tasks and OpenMP threads. It is noteworthy that this performance is obtained with a proper handling of the memory burden, since the memory is equally partitioned between the nodes involved in the computation. From Table 3, we can see that using 40 nodes and 1 MPI task per node provides a lower speed-up with respect to using 20 nodes and 2 MPI tasks per node. This is due to the reduction in the amount of communication needed in the second case, as this amount depends on the granularity of the test case.