# Adaptation of Parallel SaaS to Heterogeneous Co-Located Cloud Resources
## 3 Cloud Infrastructure and Developed SaaS
### Parallel DEM SaaS  
The DEM model for granular flows of the non-cohesive frictional visco-elastic spherical particles is implemented in the parallel SaaS. The particle system consists of a finite number of deformable particles with the specified size distribution and material properties. An arbitrary particle undergoes translational and rotational motion, involving the forces and torques originated in the process of particles' interaction. In this study, the force of gravity is considered, but not the electrostatic force [53] or other external forces [54]. The normal contact force comprises elastic and viscous components. The normal elastic force is calculated using [PERSON]'s contact model in this research. The tangential contact force is divided into the parts of static friction and dynamic friction. The dynamic friction force is directly proportional to the normal component of the contact force. The static friction force is calculated by summing up the elastic counterpart and the viscous damping counterpart. A contact search was performed by using the infinite grid method [43]. Time integration with small time steps was performed by the explicit velocity Verlet method [55]. The details of the governing DEM relations for granular flows are provided in [25; 30]. Hybrid Parallelization and Runtime Load Adaptation to Heterogeneous Resources  
The simulations at the particle level of detail make the DEM computationally very expensive. The specific characteristics of the solved problem and employed numerical method \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Containers** & **Cores** & **Architecture** & **RAM, GB** & **HDD, TB** \\ \hline CN-6700-1 & 1 & i7-6700 & 8 & 0.5 \\ CN-6700-2 & 2 & i7-6700 & 16 & 0.5 \\ CN-6700-3 & 3 & i7-6700 & 24 & 0.5 \\ CN-6700-4 & 4 & i7-6700 & 32 & 0.5 \\ CN-4790-4 & 4 & i7-4790 & 32 & 0.5 \\ CN-GPU & 1792 (CUDA) & Tesla(tm) P100 & 12 & 0.5 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Characteristics of containers. highly influence the choice of a parallel solution algorithm [30; 38]. Hybrid parallelization of the DEM SaaS was developed to exploit the potential of different types of memory and to simplify mapping of partitions to heterogeneous multicore cloud resources. The dynamic partitioning of particles was performed, implementing the required internode communications by the MPI library for distributed-memory architectures. The RCB method from the Zoltan library [52] was utilized to partition particles into subsets, as it is particularly effective for particle simulations [6]. The main computational procedures of the DEM were implemented by using OpenCL [37] for shared-memory multicore machines or GPUs. Thus, each OpenCL device performs computations only on its subset of particles. However, it needs to share data of ghost particles with OpenCL devices, working on other nodes. Therefore, internode communication, required after partitioning, was implemented by using MPI. The algorithm of the developed hybrid MPI/OpenCL parallelization is outlined in the pseudocode (Algorithm 1). All computations are performed in the time loop. In line 5 of the pseudocode, the load \(\mathbf{L}\) is internally monitored for resource-aware partitioning. The computational load \(L_{i}\) of each parallel process \(i\) is measured by timers in computational procedures of the DEM software. Heterogeneous resources, such us containers of highly different computing performance, can cause substantial load imbalance of the parallel software. The percentage load imbalance measure \(\lambda\) quantifies the uneven distribution of computational load by using the following formula:  
\[\lambda=\left(\frac{L_{\text{max}}}{L_{\text{avg}}}-1\right)\cdot 100\%, \tag{1}\]  
where \(L_{\text{avg}}\) denotes the averaged load over all processes and \(L_{max}\) represents the largest load.