## 3 GPU Parallelization of Metaphorless Optimization Algorithms
### GPU-Based Acceleration of the Java Optimization Algorithm
They primarily adhere to identical execution procedures, diverging primarily due to the absence of nested loops iterating through the population elements (i.e., candidate solutions) and decision variables. This aspect is a fundamental component of the established parallelization methodology, aiming to maintain the philosophical underpinnings of the original algorithm throughout its adaptation to GPU processing. As a result, the GPU-based version of Jaya retains the ability to generate an optimization behavior identical to the original algorithm. The provided procedure relies on a heterogeneous computational approach, where the computational involvement of the host is notably limited. As delineated in Algorithm 10, the primary tasks of the host entail initializing algorithmic parameters, invoking various kernel functions, overseeing the algorithm's iterative steps (encapsulated in the main loop), and documenting the optimal solution identified. Consequently, the host manages the sequential aspects of the algorithm, whereas all optimization-related data reside and undergo processing exclusively within the device. This operational paradigm ensures that no data are transferred between the host and device throughout the main computational process. In the final step of the algorithm, the device identifies the best solution discovered, which is then transferred to the host for output. Given the aforementioned details, the generation of the initial population takes place directly within the device, following the procedure outlined in Algorithm 11. ```
1:/* Initialization*/
2:Initialize\(numVar\),\(popSize\) and\(maxIter\);\(\triangleright\)Host
3:\(X\leftarrow\textsc{Generate\_initial\_population\_kernel}()\);
4:Evaluate_fitness_values_kernel\((X)\);
5:\(i\gets 1\);
6:/* Main loop*/
7:while\(i\leq maxIter\)do\(\triangleright\)Host
8: Determine\(X_{best,i}\) and \(X_{worst,i}\);
9:\(X_{i}^{new}\leftarrow\textsc{Jaya\_driven\_population\_update\_kernel}(X_{i})\);
10:Evaluate_fitness_values_kernel\((X_{i}^{new})\);
11:Greedy_selection_kernel\((X_{i},X_{i}^{new})\);
12:\(i\gets i+1\);
13:endwhile
14:Output the best solution found and terminate.\(\triangleright\)Host and device
```  
**Algorithm 11** GPU-based parallel Jaya  
In the context of the GPU-based algorithm, the conventional nested loops utilized for iterating through population data during processing have become obsolete due to concurrent/parallel execution. Employing a two-dimensional thread block arrangement grid, the kernel specified in Algorithm 11 facilitates the parallel creation of the initial population. This methodology assigns an individual thread to generate each individual data element within the population (\(X\)), supported by a matrix data structure with dimensions \(popSize\times numVar\). The kernel leverages the \(x\) and \(y\) coordinates (indices) from the block dimension (\(blockDim\)), block index (\(blockIdx\)), and thread index (\(threadIdx\)) to determine the specific row and column in the data matrix allocated for computation for assigning each data element individually to a separated thread for processing. This allocation strategy maximizes the efficiency of parallel processing, allowing each thread to perform designated computations based on its unique position within the block and grid structure. ```
1:functionGenerate_initial_population_kernel()
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[row,col]\gets LB[col]+rand()\times(UB[col]-LB[col])\). 7:endif
8:endfunction
```  
**Algorithm 11** Kernel for generating the initial population  
The same parallelization technique is applied across various algorithm phases encompassed within the main loop. Consequently, each stage of the computational process now runs concurrently on all elements within a given iteration.