1 package net.bmahe.genetics4j.gpu.spec.fitness.kernelcontext;
2
3 public class KernelExecutionContextComputers {
4
5 private KernelExecutionContextComputers() {
6 }
7
8 public static KernelExecutionContextComputer ofGenotypeSize() {
9 return (openCLExecutionContext, kernelName, generation,
10 genotypes) -> KernelExecutionContext.builder().globalWorkSize(new long[] { genotypes.size() }).build();
11 }
12
13 public static KernelExecutionContextComputer ofGlobalWorkSize(final long[] globalWorkSize) {
14 return (openCLExecutionContext, kernelName, generation,
15 genotypes) -> KernelExecutionContext.builder().globalWorkSize(globalWorkSize).build();
16 }
17
18 public static KernelExecutionContextComputer ofGlobalWorkSize1D(final long globalWorkSize) {
19 return (openCLExecutionContext, kernelName, generation,
20 genotypes) -> KernelExecutionContext.builder().globalWorkSize(globalWorkSize).build();
21 }
22
23 public static KernelExecutionContextComputer ofGenotypeSizeAndWorkGroup(final long[] workGroupSize) {
24 return (openCLExecutionContext, kernelName, generation, genotypes) -> KernelExecutionContext.builder()
25 .globalWorkSize(new long[] { genotypes.size() })
26 .workGroupSize(workGroupSize)
27 .build();
28 }
29
30 public static KernelExecutionContextComputer of(final long[] globalWorkSize, final long[] workGroupSize) {
31 return (openCLExecutionContext, kernelName, generation, genotypes) -> KernelExecutionContext.builder()
32 .globalWorkSize(globalWorkSize)
33 .workGroupSize(workGroupSize)
34 .build();
35 }
36 }