## 3 GPU Parallelization of Metaphorless Optimization Algorithms
### GPU-Based Acceleration of the Java Optimization Algorithm
This paradigm shift means that \(X^{new}\) now signifies all updated candidate solutions within a given algorithmic iteration rather than representing a singular updated candidate. Subsequently, all algorithmic steps have been adjusted accordingly, commencing with the population update kernel outlined in Algorithm 12. ```
1:functionJaya-driven_population_update_kernel(\(X\))
2:/*Device code*/
3: Determine row using \(x\) dimension of \(blockDim\), \(blockIdx\), and threadIdx;
4: Determine col using \(y\) dimension of \(blockDim\), \(blockIdx\), and threadIdx;
5:ifrow\(\leq popSize\)and\(col\leq numVar\)then
6:\(X^{new}[row,col]=X[row,col]+rand()\times(X_{best}[col]-|X[row,col]|)-rand() \times(X_{worst}[col]-|X[row,col]|)\); \(\triangleright\) Equation (1)
7: Check_boundary_integrity_Function(\(X^{new}\)). 8:endif
9:endfunction
```  
**Algorithm 12** Kernel for population update (Jaya)  
Similar to the original algorithm, the maintenance of newly generated candidate solutions within the search space boundary remains a necessity. Within the GPU-based algorithm, this task is managed by the function delineated in Algorithm 13. ```
1:functionCheck_boundary_integrity_function(\(X^{new}\))
2:if\(X^{new}[row,col]>UP[col]\)then
3:\(X^{new}[row,col]\gets UP[col]\);
4:endif
5:if\(X^{new}[row,col]<LB[col]\)then
6:\(X^{new}[row,col]\gets LB[col]\). 7:endif
8:endfunction
```  
**Algorithm 13** Function to ensure boundary integrity
The selection of the best candidate solution by a greedy selection algorithm is parallelized in Algorithm 14. ```
1:functionGreedy_selection_kernel(\(X\), \(X^{new}\))
2:/*Device code */
3: Determine \(index\) using \(x\) dimension of \(blockDim\), \(blockIdx\), and \(threadIdx\);
4:if\(index\leq popSize\)then
5:if\(f(X^{new}[index])\) is better than \(f(X[index])\)then
6:\(X[index]\gets X^{new}[index]\);
7:\(f(X[index])\gets f(X^{new}[index])\). 8:endif
9:endif
10:endfunction
```  
**Algorithm 14** Kernel for greedy selection  
Considering that the data structures supporting fitness values for both the newly generated candidate solutions and the current candidate solutions consist of single-dimensional arrays, each with a length of \(popSize\), the kernel implementation solely requires a one-dimensional grid arrangement to conduct parallel comparisons. Essentially, for concurrent determination of the optimal candidate solution, the greedy selection kernel operates using a total number of threads equivalent to \(popSize\). The indexing of data and threads is managed by the variable \(index\), which is determined using inherent variables with details about the hierarchical arrangement of blocks and threads. The present GPU-based parallelization of Java distinguishes itself from the previous approaches by its efficient utilization of both the host and device during computation. Specifically, the host exclusively oversees the main loop, and data transfers between the host and device are minimized, never occurring during the most computationally demanding phases of the algorithm. Furthermore, the device directly accesses data without necessitating additional mapping or conversion. Notably, the approach to GPU grid arrangement and kernel invocations deviates from prior implementations. The dimensional structure of the grid and the determination of the necessary threads and blocks for computation are primarily driven by the size and structure of the data undergoing processing.