## 5 Gaussian Mixture Model Modeling Using Data-Parallel Primitives
### Improvement of the Shared Memory Environment  
Algorithm 4 duplicates \(Sample\), \(Weight\), \(Mean\), and \(CovMatrix\) to enable parallelization using data-parallel primitives. The algorithm can be used on both distributed memory and shared memory environments because all the arrays processed by data-parallel primitives are equal in length, and can easily be distributed to computing nodes or threads. However, duplicating \(Sample\), \(Weight\), \(Mean\), and \(CovMatrix\) needs extra computational time. If we run the algorithm on a shared memory environment, the duplication is not necessary because we can randomly access arrays. We have to use the MAP primitive with a customizing operator which can access some input arrays randomly. The operator must have the same number of arguments as the MAP primitive, and their arguments have one-to-one correspondence. The arguments in brackets are the array that the operator can randomly access. All elements of the arguments without brackets are computed concurrently. Therefore, the lengths of all arguments without brackets and the output array must be the same. The code segment defines the computation of each element of the arguments without brackets. Line 18 and the operator defined at Line 43 in Algorithm 5 is an example of the MAP primitive with a customizing operator. Algorithm 5 is the most efficient algorithm for shared memory parallelization. It has the same aim as Algorithm 5; the difference is its use of the MAP primitives with a customizing operator to avoid the array duplication. We remove Line 10 in Algorithm 4. Furthermore, Line 19, Lines 23-24, Lines 32-35, and Lines 38-39 in Algorithm 4 are replaced by the MAP primitives at Line 18, Line 22, Line 30, and Line 34 in Algorithm 5, respectively. In addition, we remove most of the Gather primitives used to duplicate arrays in Algorithm 5. Figure 14: Illustration of the process of updating responsibilities by data-parallel primitives. ```
1:Input : Sample[\(N\)]
2:Input : SetID[\(N\)]
3:Input : Sample[\(N*K\)]
4:Input : Sample[\(N*K\)]
5:Input : Reg[\(N*K\)]
6:Output : Weight[\(K*K\)]
7:Output : Mean[\(s*K\)]
8:Output : CostArray[\(s*K\)]
9:\(\prime\)-Flatten Samples[\(N^{\prime}\)]
10:Flattenest[\(D\)] : Gather[\(StID\),Sample[\(Index\)]
11:Counter[\(N*K\)] := [\(1\),\(1\),\(1\),\(1\)



to the covariance matrix, to save the computational time and memory. In addition, from Equation (6), we know that the computation of each element in the covariance matrix is independent. We can compute each element in parallel to maximize the parallelization:

\[c_{ij}=c_{j,i}=\sum_{index\in I}R_{index,k}*(x_{i}^{index}-\mu_{i}^{index,k})*( x_{j}^{index}-\mu_{j}^{index,k}) \tag{6}\]

where \(I=\{index|SetID[index]=s\}\). Figure 15 is a schematic diagram of the process of computing the covariance matrix when there are three variables of the input samples. ## 6 Experiment

In this section, we evaluate the impact of parameters and the number of threads on the execution time of our proposed algorithms using three different scientific datasets. We conduct the experiments on a supercomputer, Taiwania 2. Each node of Taiwania 2 has two Intel Xeon Gold 6154 18-Cores 3.0 GHz and eight NVIDIA(r) Tesla(r) V100 SXM2. We implement our proposed algorithms using the VTK-m library [10], a platform that enables scientists to develop scientific data analysis and visualization algorithms using data-parallel primitives. VTK-m supports both CPU and GPU computing backends. When using CPU as the computing backend, VTK-m allows users to use either Intel Threading Building Block (TBB) or OpenMP libraries to run the program using multiple CPU cores. The programs for the performance evaluations of our proposed algorithms which are carried out on CPU are implemented by a VTK-m library that uses Intel TBB. The three datasets are listed as follows:

* Dataset 1 is hurricane pressure volume data. The resolution is 500 \(\times\) 500 \(\times\) 100 and each grid point is a scalar value. * Dataset 2 is dark matter momentum vector data.