1 | package net.bmahe.genetics4j.gpu.spec.fitness; | |
2 | ||
3 | import java.util.HashMap; | |
4 | import java.util.HashSet; | |
5 | import java.util.List; | |
6 | import java.util.Map; | |
7 | import java.util.Map.Entry; | |
8 | import java.util.Set; | |
9 | import java.util.concurrent.CompletableFuture; | |
10 | import java.util.concurrent.ConcurrentHashMap; | |
11 | import java.util.concurrent.ExecutorService; | |
12 | ||
13 | import org.apache.commons.collections4.MapUtils; | |
14 | import org.apache.commons.lang3.Validate; | |
15 | import org.apache.logging.log4j.LogManager; | |
16 | import org.apache.logging.log4j.Logger; | |
17 | import org.jocl.CL; | |
18 | import org.jocl.Pointer; | |
19 | import org.jocl.Sizeof; | |
20 | ||
21 | import net.bmahe.genetics4j.core.Genotype; | |
22 | import net.bmahe.genetics4j.gpu.opencl.OpenCLExecutionContext; | |
23 | import net.bmahe.genetics4j.gpu.opencl.model.Device; | |
24 | import net.bmahe.genetics4j.gpu.spec.fitness.cldata.CLData; | |
25 | import net.bmahe.genetics4j.gpu.spec.fitness.kernelcontext.KernelExecutionContext; | |
26 | import net.bmahe.genetics4j.gpu.spec.fitness.multistage.MultiStageDescriptor; | |
27 | import net.bmahe.genetics4j.gpu.spec.fitness.multistage.StageDescriptor; | |
28 | ||
29 | /** | |
30 | * GPU-accelerated fitness evaluator that executes multiple sequential OpenCL kernels for complex fitness computation. | |
31 | * | |
32 | * <p>MultiStageFitness provides a framework for implementing fitness evaluation that requires multiple sequential | |
33 | * GPU kernel executions, where each stage can use results from previous stages as input. This is ideal for complex | |
34 | * fitness functions that require multiple computational phases, such as neural network training, multi-objective | |
35 | * optimization, or hierarchical problem decomposition. | |
36 | * | |
37 | * <p>Key features: | |
38 | * <ul> | |
39 | * <li><strong>Sequential execution</strong>: Multiple OpenCL kernels executed in sequence</li> | |
40 | * <li><strong>Inter-stage data flow</strong>: Results from earlier stages used as inputs to later stages</li> | |
41 | * <li><strong>Memory optimization</strong>: Automatic cleanup and reuse of intermediate results</li> | |
42 | * <li><strong>Pipeline processing</strong>: Support for complex computational pipelines</li> | |
43 | * <li><strong>Stage configuration</strong>: Individual configuration for each computational stage</li> | |
44 | * </ul> | |
45 | * | |
46 | * <p>Multi-stage computation architecture: | |
47 | * <ul> | |
48 | * <li><strong>Stage descriptors</strong>: Each stage defines its kernel, data loaders, and result allocators</li> | |
49 | * <li><strong>Data reuse patterns</strong>: Previous stage results can be reused as arguments or size parameters</li> | |
50 | * <li><strong>Memory lifecycle</strong>: Automatic management of intermediate results between stages</li> | |
51 | * <li><strong>Static data sharing</strong>: Algorithm parameters shared across all stages</li> | |
52 | * </ul> | |
53 | * | |
54 | * <p>Typical usage pattern: | |
55 | * <pre>{@code | |
56 | * // Define multi-stage descriptor with sequential kernels | |
57 | * MultiStageDescriptor descriptor = MultiStageDescriptor.builder() | |
58 | * .addStaticDataLoader("parameters", parametersLoader) | |
59 | * .addStage(StageDescriptor.builder() | |
60 | * .kernelName("preprocessing") | |
61 | * .addDataLoader(0, inputDataLoader) | |
62 | * .addResultAllocator(1, preprocessedResultAllocator) | |
63 | * .build()) | |
64 | * .addStage(StageDescriptor.builder() | |
65 | * .kernelName("fitness_evaluation") | |
66 | * .reusePreviousResultAsArgument(1, 0) // Use previous result as input | |
67 | * .addResultAllocator(1, fitnessResultAllocator) | |
68 | * .build()) | |
69 | * .build(); | |
70 | * | |
71 | * // Define fitness extraction from final stage results | |
72 | * FitnessExtractor<Double> extractor = (context, kernelCtx, executor, generation, genotypes, results) -> { | |
73 | * float[] fitnessValues = results.extractFloatArray(context, 1); | |
74 | * return Arrays.stream(fitnessValues) | |
75 | * .mapToDouble(f -> (double) f) | |
76 | * .boxed() | |
77 | * .collect(Collectors.toList()); | |
78 | * }; | |
79 | * | |
80 | * // Create multi-stage fitness evaluator | |
81 | * MultiStageFitness<Double> fitness = MultiStageFitness.of(descriptor, extractor); | |
82 | * }</pre> | |
83 | * | |
84 | * <p>Stage execution workflow: | |
85 | * <ol> | |
86 | * <li><strong>Initialization</strong>: Load shared static data once before all evaluations</li> | |
87 | * <li><strong>Stage iteration</strong>: For each stage in sequence:</li> | |
88 | * <li><strong>Context computation</strong>: Calculate kernel execution parameters for the stage</li> | |
89 | * <li><strong>Data preparation</strong>: Load stage-specific data and map previous results</li> | |
90 | * <li><strong>Kernel execution</strong>: Execute the stage kernel with configured parameters</li> | |
91 | * <li><strong>Result management</strong>: Store results for potential use in subsequent stages</li> | |
92 | * <li><strong>Final extraction</strong>: Extract fitness values from the last stage results</li> | |
93 | * <li><strong>Cleanup</strong>: Release all intermediate and final result memory</li> | |
94 | * </ol> | |
95 | * | |
96 | * <p>Inter-stage data flow patterns: | |
97 | * <ul> | |
98 | * <li><strong>Result reuse</strong>: Use previous stage output buffers as input to subsequent stages</li> | |
99 | * <li><strong>Size propagation</strong>: Use previous stage result sizes as parameters for memory allocation</li> | |
100 | * <li><strong>Memory optimization</strong>: Automatic cleanup of intermediate results no longer needed</li> | |
101 | * <li><strong>Data type preservation</strong>: Maintain OpenCL data types across stage boundaries</li> | |
102 | * </ul> | |
103 | * | |
104 | * <p>Memory management strategy: | |
105 | * <ul> | |
106 | * <li><strong>Static data persistence</strong>: Shared parameters allocated once across all stages</li> | |
107 | * <li><strong>Intermediate cleanup</strong>: Automatic release of stage results when no longer needed</li> | |
108 | * <li><strong>Result chaining</strong>: Efficient memory reuse between consecutive stages</li> | |
109 | * <li><strong>Final cleanup</strong>: Complete memory cleanup after fitness extraction</li> | |
110 | * </ul> | |
111 | * | |
112 | * <p>Performance optimization features: | |
113 | * <ul> | |
114 | * <li><strong>Pipeline efficiency</strong>: Minimized memory transfers between stages</li> | |
115 | * <li><strong>Memory coalescing</strong>: Optimized data layouts for GPU memory access</li> | |
116 | * <li><strong>Stage-specific tuning</strong>: Individual work group optimization per stage</li> | |
117 | * <li><strong>Asynchronous execution</strong>: Non-blocking fitness computation</li> | |
118 | * </ul> | |
119 | * | |
120 | * @param <T> the fitness value type, must be Comparable for optimization algorithms | |
121 | * @see OpenCLFitness | |
122 | * @see MultiStageDescriptor | |
123 | * @see StageDescriptor | |
124 | * @see FitnessExtractor | |
125 | */ | |
126 | public class MultiStageFitness<T extends Comparable<T>> extends OpenCLFitness<T> { | |
127 | public static final Logger logger = LogManager.getLogger(MultiStageFitness.class); | |
128 | ||
129 | private final MultiStageDescriptor multiStageDescriptor; | |
130 | private final FitnessExtractor<T> fitnessExtractor; | |
131 | ||
132 |
2
1. <init> : removed call to java/util/concurrent/ConcurrentHashMap::<init> → NO_COVERAGE 2. <init> : Removed assignment to member variable staticData → NO_COVERAGE |
private final Map<Device, Map<String, CLData>> staticData = new ConcurrentHashMap<>(); |
133 | ||
134 | protected void clearStaticData(final Device device) { | |
135 |
10
1. clearStaticData : removed call to org/apache/commons/collections4/MapUtils::isEmpty → NO_COVERAGE 2. clearStaticData : removed conditional - replaced equality check with false → NO_COVERAGE 3. clearStaticData : removed call to java/util/Map::get → NO_COVERAGE 4. clearStaticData : negated conditional → NO_COVERAGE 5. clearStaticData : replaced call to java/util/Map::get with argument → NO_COVERAGE 6. clearStaticData : removed conditional - replaced equality check with true → NO_COVERAGE 7. clearStaticData : removed call to org/apache/commons/collections4/MapUtils::isEmpty → NO_COVERAGE 8. clearStaticData : removed conditional - replaced equality check with true → NO_COVERAGE 9. clearStaticData : removed conditional - replaced equality check with false → NO_COVERAGE 10. clearStaticData : negated conditional → NO_COVERAGE |
if (MapUtils.isEmpty(staticData) || MapUtils.isEmpty(staticData.get(device))) { |
136 | return; | |
137 | } | |
138 | ||
139 |
2
1. clearStaticData : removed call to java/util/Map::get → NO_COVERAGE 2. clearStaticData : replaced call to java/util/Map::get with argument → NO_COVERAGE |
final Map<String, CLData> mapData = staticData.get(device); |
140 |
1
1. clearStaticData : removed call to java/util/Map::values → NO_COVERAGE |
for (final CLData clData : mapData.values()) { |
141 |
2
1. clearStaticData : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/CLData::clMem → NO_COVERAGE 2. clearStaticData : removed call to org/jocl/CL::clReleaseMemObject → NO_COVERAGE |
CL.clReleaseMemObject(clData.clMem()); |
142 | } | |
143 | ||
144 |
1
1. clearStaticData : removed call to java/util/Map::clear → NO_COVERAGE |
mapData.clear(); |
145 |
2
1. clearStaticData : removed call to java/util/Map::remove → NO_COVERAGE 2. clearStaticData : replaced call to java/util/Map::remove with argument → NO_COVERAGE |
staticData.remove(device); |
146 | } | |
147 | ||
148 | protected void clearData(final Map<Integer, CLData> data) { | |
149 |
4
1. clearData : removed call to org/apache/commons/collections4/MapUtils::isEmpty → NO_COVERAGE 2. clearData : negated conditional → NO_COVERAGE 3. clearData : removed conditional - replaced equality check with false → NO_COVERAGE 4. clearData : removed conditional - replaced equality check with true → NO_COVERAGE |
if (MapUtils.isEmpty(data)) { |
150 | return; | |
151 | } | |
152 | ||
153 |
1
1. clearData : removed call to java/util/Map::values → NO_COVERAGE |
for (final CLData clData : data.values()) { |
154 |
2
1. clearData : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/CLData::clMem → NO_COVERAGE 2. clearData : removed call to org/jocl/CL::clReleaseMemObject → NO_COVERAGE |
CL.clReleaseMemObject(clData.clMem()); |
155 | } | |
156 | ||
157 |
1
1. clearData : removed call to java/util/Map::clear → NO_COVERAGE |
data.clear(); |
158 | } | |
159 | ||
160 | protected void clearResultData(final Map<Integer, CLData> resultData) { | |
161 |
4
1. clearResultData : removed call to org/apache/commons/collections4/MapUtils::isEmpty → NO_COVERAGE 2. clearResultData : removed conditional - replaced equality check with true → NO_COVERAGE 3. clearResultData : removed conditional - replaced equality check with false → NO_COVERAGE 4. clearResultData : negated conditional → NO_COVERAGE |
if (MapUtils.isEmpty(resultData)) { |
162 | return; | |
163 | } | |
164 | ||
165 |
1
1. clearResultData : removed call to java/util/Map::values → NO_COVERAGE |
for (final CLData clData : resultData.values()) { |
166 |
2
1. clearResultData : removed call to org/jocl/CL::clReleaseMemObject → NO_COVERAGE 2. clearResultData : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/CLData::clMem → NO_COVERAGE |
CL.clReleaseMemObject(clData.clMem()); |
167 | } | |
168 | ||
169 |
1
1. clearResultData : removed call to java/util/Map::clear → NO_COVERAGE |
resultData.clear(); |
170 | } | |
171 | ||
172 | protected void prepareStaticData(final OpenCLExecutionContext openCLExecutionContext, | |
173 | final StageDescriptor stageDescriptor) { | |
174 | Validate.notNull(openCLExecutionContext); | |
175 | Validate.notNull(stageDescriptor); | |
176 | ||
177 |
1
1. prepareStaticData : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE |
final var device = openCLExecutionContext.device(); |
178 | ||
179 | logger.trace("[{}] Preparing static data", device.name()); | |
180 | ||
181 |
1
1. prepareStaticData : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::kernels → NO_COVERAGE |
final var kernels = openCLExecutionContext.kernels(); |
182 |
1
1. prepareStaticData : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::kernelName → NO_COVERAGE |
final var kernelName = stageDescriptor.kernelName(); |
183 | ||
184 |
2
1. prepareStaticData : removed call to java/util/Map::get → NO_COVERAGE 2. prepareStaticData : replaced call to java/util/Map::get with argument → NO_COVERAGE |
final var kernel = kernels.get(kernelName); |
185 | ||
186 |
1
1. prepareStaticData : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::mapStaticDataAsArgument → NO_COVERAGE |
final var mapStaticDataAsArgument = stageDescriptor.mapStaticDataAsArgument(); |
187 |
1
1. prepareStaticData : removed call to java/util/Map::entrySet → NO_COVERAGE |
for (final var entry : mapStaticDataAsArgument.entrySet()) { |
188 |
1
1. prepareStaticData : removed call to java/util/Map$Entry::getKey → NO_COVERAGE |
final var argumentName = entry.getKey(); |
189 |
1
1. prepareStaticData : removed call to java/util/Map$Entry::getValue → NO_COVERAGE |
final var argumentIndex = entry.getValue(); |
190 | ||
191 |
2
1. prepareStaticData : removed call to java/util/Map::get → NO_COVERAGE 2. prepareStaticData : replaced call to java/util/Map::get with argument → NO_COVERAGE |
final var staticDataMap = staticData.get(device); |
192 | ||
193 |
4
1. prepareStaticData : removed call to java/util/Map::containsKey → NO_COVERAGE 2. prepareStaticData : negated conditional → NO_COVERAGE 3. prepareStaticData : removed conditional - replaced equality check with false → NO_COVERAGE 4. prepareStaticData : removed conditional - replaced equality check with true → NO_COVERAGE |
if (staticDataMap.containsKey(argumentName) == false) { |
194 |
1
1. prepareStaticData : removed call to java/lang/IllegalArgumentException::<init> → NO_COVERAGE |
throw new IllegalArgumentException("Unknown static argument " + argumentName); |
195 | } | |
196 | ||
197 |
2
1. prepareStaticData : replaced call to java/util/Map::get with argument → NO_COVERAGE 2. prepareStaticData : removed call to java/util/Map::get → NO_COVERAGE |
final CLData clStaticData = staticDataMap.get(argumentName); |
198 | ||
199 | logger.trace("[{}] Index {} - Loading static data with name {}", device.name(), argumentIndex, argumentName); | |
200 | ||
201 |
5
1. prepareStaticData : removed call to org/jocl/Pointer::to → NO_COVERAGE 2. prepareStaticData : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/CLData::clMem → NO_COVERAGE 3. prepareStaticData : removed call to org/jocl/CL::clSetKernelArg → NO_COVERAGE 4. prepareStaticData : replaced call to org/jocl/CL::clSetKernelArg with argument → NO_COVERAGE 5. prepareStaticData : removed call to java/lang/Integer::intValue → NO_COVERAGE |
CL.clSetKernelArg(kernel, argumentIndex, Sizeof.cl_mem, Pointer.to(clStaticData.clMem())); |
202 | } | |
203 | } | |
204 | ||
205 | private void allocateLocalMemory(OpenCLExecutionContext openCLExecutionContext, StageDescriptor stageDescriptor, | |
206 | long generation, List<Genotype> genotypes, final KernelExecutionContext kernelExecutionContext) { | |
207 | Validate.notNull(openCLExecutionContext); | |
208 | Validate.notNull(stageDescriptor); | |
209 | Validate.notNull(kernelExecutionContext); | |
210 | ||
211 |
1
1. allocateLocalMemory : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE |
final var device = openCLExecutionContext.device(); |
212 | ||
213 | logger.trace("[{}] Allocating local memory", device.name()); | |
214 | ||
215 |
1
1. allocateLocalMemory : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::kernels → NO_COVERAGE |
final var kernels = openCLExecutionContext.kernels(); |
216 |
1
1. allocateLocalMemory : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::kernelName → NO_COVERAGE |
final var kernelName = stageDescriptor.kernelName(); |
217 | ||
218 |
2
1. allocateLocalMemory : replaced call to java/util/Map::get with argument → NO_COVERAGE 2. allocateLocalMemory : removed call to java/util/Map::get → NO_COVERAGE |
final var kernel = kernels.get(kernelName); |
219 | ||
220 |
1
1. allocateLocalMemory : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::localMemoryAllocators → NO_COVERAGE |
final var localMemoryAllocators = stageDescriptor.localMemoryAllocators(); |
221 |
4
1. allocateLocalMemory : removed conditional - replaced equality check with false → NO_COVERAGE 2. allocateLocalMemory : removed call to org/apache/commons/collections4/MapUtils::isNotEmpty → NO_COVERAGE 3. allocateLocalMemory : negated conditional → NO_COVERAGE 4. allocateLocalMemory : removed conditional - replaced equality check with true → NO_COVERAGE |
if (MapUtils.isNotEmpty(localMemoryAllocators)) { |
222 |
1
1. allocateLocalMemory : removed call to java/util/Map::entrySet → NO_COVERAGE |
for (final var entry : localMemoryAllocators.entrySet()) { |
223 |
2
1. allocateLocalMemory : removed call to java/util/Map$Entry::getKey → NO_COVERAGE 2. allocateLocalMemory : removed call to java/lang/Integer::intValue → NO_COVERAGE |
final int argumentIdx = entry.getKey(); |
224 |
1
1. allocateLocalMemory : removed call to java/util/Map$Entry::getValue → NO_COVERAGE |
final var localMemoryAllocator = entry.getValue(); |
225 | ||
226 | final var size = localMemoryAllocator | |
227 |
2
1. allocateLocalMemory : replaced call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/LocalMemoryAllocator::load with argument → NO_COVERAGE 2. allocateLocalMemory : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/LocalMemoryAllocator::load → NO_COVERAGE |
.load(openCLExecutionContext, kernelExecutionContext, generation, genotypes); |
228 | logger.trace("[{}] Index {} - Setting local data with size of {}", device.name(), argumentIdx, size); | |
229 | ||
230 |
2
1. allocateLocalMemory : replaced call to org/jocl/CL::clSetKernelArg with argument → NO_COVERAGE 2. allocateLocalMemory : removed call to org/jocl/CL::clSetKernelArg → NO_COVERAGE |
CL.clSetKernelArg(kernel, argumentIdx, size, null); |
231 | } | |
232 | } | |
233 | } | |
234 | ||
235 | protected void loadData(final OpenCLExecutionContext openCLExecutionContext, final StageDescriptor stageDescriptor, | |
236 | final Map<Integer, CLData> data, final long generation, final List<Genotype> genotypes) { | |
237 | Validate.notNull(openCLExecutionContext); | |
238 | Validate.notNull(stageDescriptor); | |
239 | Validate.notNull(data); | |
240 | ||
241 |
1
1. loadData : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE |
final var device = openCLExecutionContext.device(); |
242 | ||
243 | logger.trace("[{}] Loading data", device.name()); | |
244 | ||
245 |
1
1. loadData : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::kernels → NO_COVERAGE |
final var kernels = openCLExecutionContext.kernels(); |
246 |
1
1. loadData : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::kernelName → NO_COVERAGE |
final var kernelName = stageDescriptor.kernelName(); |
247 | ||
248 |
2
1. loadData : removed call to java/util/Map::get → NO_COVERAGE 2. loadData : replaced call to java/util/Map::get with argument → NO_COVERAGE |
final var kernel = kernels.get(kernelName); |
249 | ||
250 |
1
1. loadData : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::dataLoaders → NO_COVERAGE |
final var dataLoaders = stageDescriptor.dataLoaders(); |
251 |
4
1. loadData : removed conditional - replaced equality check with false → NO_COVERAGE 2. loadData : negated conditional → NO_COVERAGE 3. loadData : removed conditional - replaced equality check with true → NO_COVERAGE 4. loadData : removed call to org/apache/commons/collections4/MapUtils::isNotEmpty → NO_COVERAGE |
if (MapUtils.isNotEmpty(dataLoaders)) { |
252 |
1
1. loadData : removed call to java/util/Map::entrySet → NO_COVERAGE |
for (final var entry : dataLoaders.entrySet()) { |
253 |
2
1. loadData : removed call to java/lang/Integer::intValue → NO_COVERAGE 2. loadData : removed call to java/util/Map$Entry::getKey → NO_COVERAGE |
final int argumentIdx = entry.getKey(); |
254 |
1
1. loadData : removed call to java/util/Map$Entry::getValue → NO_COVERAGE |
final var dataLoader = entry.getValue(); |
255 | ||
256 |
1
1. loadData : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/DataLoader::load → NO_COVERAGE |
final var clDdata = dataLoader.load(openCLExecutionContext, generation, genotypes); |
257 | ||
258 |
6
1. loadData : negated conditional → NO_COVERAGE 2. loadData : removed call to java/lang/Integer::valueOf → NO_COVERAGE 3. loadData : removed call to java/util/Map::put → NO_COVERAGE 4. loadData : replaced call to java/util/Map::put with argument → NO_COVERAGE 5. loadData : removed conditional - replaced equality check with true → NO_COVERAGE 6. loadData : removed conditional - replaced equality check with false → NO_COVERAGE |
if (data.put(argumentIdx, clDdata) != null) { |
259 |
1
1. loadData : removed call to java/lang/IllegalArgumentException::<init> → NO_COVERAGE |
throw new IllegalArgumentException("Multiple data configured for index " + argumentIdx); |
260 | } | |
261 | logger.trace("[{}] Index {} - Loading data of size {}", device.name(), argumentIdx, clDdata.size()); | |
262 | ||
263 |
4
1. loadData : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/CLData::clMem → NO_COVERAGE 2. loadData : removed call to org/jocl/Pointer::to → NO_COVERAGE 3. loadData : removed call to org/jocl/CL::clSetKernelArg → NO_COVERAGE 4. loadData : replaced call to org/jocl/CL::clSetKernelArg with argument → NO_COVERAGE |
CL.clSetKernelArg(kernel, argumentIdx, Sizeof.cl_mem, Pointer.to(clDdata.clMem())); |
264 | } | |
265 | } | |
266 | } | |
267 | ||
268 | @Override | |
269 | public void beforeAllEvaluations(final OpenCLExecutionContext openCLExecutionContext, | |
270 | final ExecutorService executorService) { | |
271 |
1
1. beforeAllEvaluations : removed call to net/bmahe/genetics4j/gpu/spec/fitness/OpenCLFitness::beforeAllEvaluations → NO_COVERAGE |
super.beforeAllEvaluations(openCLExecutionContext, executorService); |
272 | ||
273 |
1
1. beforeAllEvaluations : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE |
final var device = openCLExecutionContext.device(); |
274 | ||
275 | logger.trace("[{}] Loading static data", device.name()); | |
276 |
1
1. beforeAllEvaluations : removed call to net/bmahe/genetics4j/gpu/spec/fitness/MultiStageFitness::clearStaticData → NO_COVERAGE |
clearStaticData(device); |
277 | ||
278 |
1
1. beforeAllEvaluations : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/MultiStageDescriptor::staticDataLoaders → NO_COVERAGE |
final var staticDataLoaders = multiStageDescriptor.staticDataLoaders(); |
279 |
1
1. beforeAllEvaluations : removed call to java/util/Map::entrySet → NO_COVERAGE |
for (final var entry : staticDataLoaders.entrySet()) { |
280 |
1
1. beforeAllEvaluations : removed call to java/util/Map$Entry::getKey → NO_COVERAGE |
final String argumentName = entry.getKey(); |
281 |
1
1. beforeAllEvaluations : removed call to java/util/Map$Entry::getValue → NO_COVERAGE |
final var dataSupplier = entry.getValue(); |
282 | ||
283 | if (logger.isTraceEnabled()) { | |
284 |
1
1. beforeAllEvaluations : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE |
final var deviceName = openCLExecutionContext.device() |
285 |
1
1. beforeAllEvaluations : removed call to net/bmahe/genetics4j/gpu/opencl/model/Device::name → NO_COVERAGE |
.name(); |
286 | logger.trace("[{}] Loading static data for entry name {}", deviceName, argumentName); | |
287 | } | |
288 |
1
1. beforeAllEvaluations : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/StaticDataLoader::load → NO_COVERAGE |
final CLData clData = dataSupplier.load(openCLExecutionContext); |
289 | ||
290 |
4
1. beforeAllEvaluations : removed call to java/util/Map::computeIfAbsent → NO_COVERAGE 2. beforeAllEvaluations : replaced call to java/util/Map::computeIfAbsent with argument → NO_COVERAGE 3. lambda$beforeAllEvaluations$0 : replaced return value with Collections.emptyMap for net/bmahe/genetics4j/gpu/spec/fitness/MultiStageFitness::lambda$beforeAllEvaluations$0 → NO_COVERAGE 4. lambda$beforeAllEvaluations$0 : removed call to java/util/HashMap::<init> → NO_COVERAGE |
final var mapData = staticData.computeIfAbsent(device, k -> new HashMap<>()); |
291 |
5
1. beforeAllEvaluations : negated conditional → NO_COVERAGE 2. beforeAllEvaluations : removed conditional - replaced equality check with true → NO_COVERAGE 3. beforeAllEvaluations : removed conditional - replaced equality check with false → NO_COVERAGE 4. beforeAllEvaluations : removed call to java/util/Map::put → NO_COVERAGE 5. beforeAllEvaluations : replaced call to java/util/Map::put with argument → NO_COVERAGE |
if (mapData.put(argumentName, clData) != null) { |
292 |
1
1. beforeAllEvaluations : removed call to java/lang/IllegalArgumentException::<init> → NO_COVERAGE |
throw new IllegalArgumentException("Multiple data configured with name " + argumentName); |
293 | } | |
294 | } | |
295 | } | |
296 | ||
297 | /** | |
298 | * Constructs a MultiStageFitness with the specified stage descriptor and fitness extractor. | |
299 | * | |
300 | * @param _multiStageDescriptor configuration for multi-stage kernel execution and data management | |
301 | * @param _fitnessExtractor function to extract fitness values from final stage results | |
302 | * @throws IllegalArgumentException if any parameter is null | |
303 | */ | |
304 | public MultiStageFitness(final MultiStageDescriptor _multiStageDescriptor, | |
305 | final FitnessExtractor<T> _fitnessExtractor) { | |
306 | Validate.notNull(_multiStageDescriptor); | |
307 | Validate.notNull(_fitnessExtractor); | |
308 | ||
309 |
1
1. <init> : Removed assignment to member variable multiStageDescriptor → NO_COVERAGE |
this.multiStageDescriptor = _multiStageDescriptor; |
310 |
1
1. <init> : Removed assignment to member variable fitnessExtractor → NO_COVERAGE |
this.fitnessExtractor = _fitnessExtractor; |
311 | } | |
312 | ||
313 | @Override | |
314 | public CompletableFuture<List<T>> compute(final OpenCLExecutionContext openCLExecutionContext, | |
315 | final ExecutorService executorService, final long generation, final List<Genotype> genotypes) { | |
316 | Validate.notNull(openCLExecutionContext); | |
317 | ||
318 |
2
1. compute : removed call to java/util/concurrent/CompletableFuture::supplyAsync → NO_COVERAGE 2. compute : replaced return value with null for net/bmahe/genetics4j/gpu/spec/fitness/MultiStageFitness::compute → NO_COVERAGE |
return CompletableFuture.supplyAsync(() -> { |
319 | ||
320 | List<T> finalResults = null; | |
321 | ||
322 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE |
final var device = openCLExecutionContext.device(); |
323 | ||
324 |
1
1. lambda$compute$1 : removed call to java/util/concurrent/ConcurrentHashMap::<init> → NO_COVERAGE |
final Map<Integer, CLData> data = new ConcurrentHashMap<>(); |
325 |
1
1. lambda$compute$1 : removed call to java/util/concurrent/ConcurrentHashMap::<init> → NO_COVERAGE |
Map<Integer, CLData> resultData = new ConcurrentHashMap<>(); |
326 | ||
327 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/MultiStageDescriptor::stageDescriptors → NO_COVERAGE |
final var stageDescriptors = multiStageDescriptor.stageDescriptors(); |
328 |
6
1. lambda$compute$1 : removed call to java/util/List::size → NO_COVERAGE 2. lambda$compute$1 : removed conditional - replaced comparison check with true → NO_COVERAGE 3. lambda$compute$1 : negated conditional → NO_COVERAGE 4. lambda$compute$1 : changed conditional boundary → NO_COVERAGE 5. lambda$compute$1 : removed conditional - replaced comparison check with false → NO_COVERAGE 6. lambda$compute$1 : Substituted 0 with 1 → NO_COVERAGE |
for (int i = 0; i < stageDescriptors.size(); i++) { |
329 |
1
1. lambda$compute$1 : removed call to java/util/List::get → NO_COVERAGE |
final StageDescriptor stageDescriptor = stageDescriptors.get(i); |
330 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::kernels → NO_COVERAGE |
final var kernels = openCLExecutionContext.kernels(); |
331 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::kernelName → NO_COVERAGE |
final var kernelName = stageDescriptor.kernelName(); |
332 | ||
333 |
2
1. lambda$compute$1 : removed call to java/util/Map::get → NO_COVERAGE 2. lambda$compute$1 : replaced call to java/util/Map::get with argument → NO_COVERAGE |
final var kernel = kernels.get(kernelName); |
334 | ||
335 | logger.debug("[{}] Executing {}-th stage for kernel {}", device.name(), i, kernelName); | |
336 | ||
337 | /** | |
338 | * Compute the Kernel Execution Context | |
339 | */ | |
340 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::kernelExecutionContextComputer → NO_COVERAGE |
final var kernelExecutionContextComputer = stageDescriptor.kernelExecutionContextComputer(); |
341 | final var kernelExecutionContext = kernelExecutionContextComputer | |
342 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/kernelcontext/KernelExecutionContextComputer::compute → NO_COVERAGE |
.compute(openCLExecutionContext, kernelName, generation, genotypes); |
343 | ||
344 | /** | |
345 | * Map previous results to new arguments | |
346 | */ | |
347 |
1
1. lambda$compute$1 : removed call to java/util/HashMap::<init> → NO_COVERAGE |
final Map<Integer, CLData> oldResultData = new HashMap<>(resultData); |
348 |
1
1. lambda$compute$1 : removed call to java/util/concurrent/ConcurrentHashMap::<init> → NO_COVERAGE |
resultData = new ConcurrentHashMap<>(); |
349 | final Map<Integer, Integer> reusePreviousResultSizeAsArguments = stageDescriptor | |
350 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::reusePreviousResultSizeAsArguments → NO_COVERAGE |
.reusePreviousResultSizeAsArguments(); |
351 | final Map<Integer, Integer> reusePreviousResultAsArguments = stageDescriptor | |
352 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::reusePreviousResultAsArguments → NO_COVERAGE |
.reusePreviousResultAsArguments(); |
353 |
1
1. lambda$compute$1 : removed call to java/util/HashSet::<init> → NO_COVERAGE |
final Set<CLData> reusedArguments = new HashSet<>(); |
354 |
4
1. lambda$compute$1 : removed conditional - replaced equality check with true → NO_COVERAGE 2. lambda$compute$1 : removed conditional - replaced equality check with false → NO_COVERAGE 3. lambda$compute$1 : negated conditional → NO_COVERAGE 4. lambda$compute$1 : removed call to org/apache/commons/collections4/MapUtils::isNotEmpty → NO_COVERAGE |
if (MapUtils.isNotEmpty(reusePreviousResultAsArguments) |
355 |
4
1. lambda$compute$1 : removed call to org/apache/commons/collections4/MapUtils::isNotEmpty → NO_COVERAGE 2. lambda$compute$1 : negated conditional → NO_COVERAGE 3. lambda$compute$1 : removed conditional - replaced equality check with false → NO_COVERAGE 4. lambda$compute$1 : removed conditional - replaced equality check with true → NO_COVERAGE |
|| MapUtils.isNotEmpty(reusePreviousResultSizeAsArguments)) { |
356 | ||
357 |
4
1. lambda$compute$1 : removed conditional - replaced equality check with true → NO_COVERAGE 2. lambda$compute$1 : removed conditional - replaced equality check with false → NO_COVERAGE 3. lambda$compute$1 : removed call to org/apache/commons/collections4/MapUtils::isNotEmpty → NO_COVERAGE 4. lambda$compute$1 : negated conditional → NO_COVERAGE |
if (MapUtils.isNotEmpty(reusePreviousResultAsArguments)) { |
358 |
1
1. lambda$compute$1 : removed call to java/util/Map::entrySet → NO_COVERAGE |
for (final Entry<Integer, Integer> entry : reusePreviousResultAsArguments.entrySet()) { |
359 |
1
1. lambda$compute$1 : removed call to java/util/Map$Entry::getKey → NO_COVERAGE |
final var oldKeyArgument = entry.getKey(); |
360 |
1
1. lambda$compute$1 : removed call to java/util/Map$Entry::getValue → NO_COVERAGE |
final var newKeyArgument = entry.getValue(); |
361 | ||
362 |
2
1. lambda$compute$1 : removed call to java/util/Map::get → NO_COVERAGE 2. lambda$compute$1 : replaced call to java/util/Map::get with argument → NO_COVERAGE |
final var previousResultData = oldResultData.get(oldKeyArgument); |
363 |
3
1. lambda$compute$1 : removed conditional - replaced equality check with false → NO_COVERAGE 2. lambda$compute$1 : removed conditional - replaced equality check with true → NO_COVERAGE 3. lambda$compute$1 : negated conditional → NO_COVERAGE |
if (previousResultData == null) { |
364 | logger.error( | |
365 | "[{}] Could not find previous argument with index {}. Known previous arguments: {}", | |
366 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/model/Device::name → NO_COVERAGE |
device.name(), |
367 | oldKeyArgument, | |
368 | oldResultData); | |
369 | ||
370 |
1
1. lambda$compute$1 : removed call to java/lang/IllegalArgumentException::<init> → NO_COVERAGE |
throw new IllegalArgumentException( |
371 | "Could not find previous argument with index " + oldKeyArgument); | |
372 | } | |
373 | ||
374 | logger.trace("[{}] Index {} - Reuse previous result that had index {}", | |
375 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/model/Device::name → NO_COVERAGE |
device.name(), |
376 | newKeyArgument, | |
377 | oldKeyArgument); | |
378 |
5
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/CLData::clMem → NO_COVERAGE 2. lambda$compute$1 : removed call to org/jocl/Pointer::to → NO_COVERAGE 3. lambda$compute$1 : removed call to java/lang/Integer::intValue → NO_COVERAGE 4. lambda$compute$1 : replaced call to org/jocl/CL::clSetKernelArg with argument → NO_COVERAGE 5. lambda$compute$1 : removed call to org/jocl/CL::clSetKernelArg → NO_COVERAGE |
CL.clSetKernelArg(kernel, newKeyArgument, Sizeof.cl_mem, Pointer.to(previousResultData.clMem())); |
379 |
1
1. lambda$compute$1 : removed call to java/util/Set::add → NO_COVERAGE |
reusedArguments.add(previousResultData); |
380 | } | |
381 | } | |
382 | ||
383 |
4
1. lambda$compute$1 : removed conditional - replaced equality check with false → NO_COVERAGE 2. lambda$compute$1 : removed conditional - replaced equality check with true → NO_COVERAGE 3. lambda$compute$1 : negated conditional → NO_COVERAGE 4. lambda$compute$1 : removed call to org/apache/commons/collections4/MapUtils::isNotEmpty → NO_COVERAGE |
if (MapUtils.isNotEmpty(reusePreviousResultSizeAsArguments)) { |
384 |
1
1. lambda$compute$1 : removed call to java/util/Map::entrySet → NO_COVERAGE |
for (final Entry<Integer, Integer> entry : reusePreviousResultSizeAsArguments.entrySet()) { |
385 |
1
1. lambda$compute$1 : removed call to java/util/Map$Entry::getKey → NO_COVERAGE |
final var oldKeyArgument = entry.getKey(); |
386 |
1
1. lambda$compute$1 : removed call to java/util/Map$Entry::getValue → NO_COVERAGE |
final var newKeyArgument = entry.getValue(); |
387 | ||
388 |
2
1. lambda$compute$1 : removed call to java/util/Map::get → NO_COVERAGE 2. lambda$compute$1 : replaced call to java/util/Map::get with argument → NO_COVERAGE |
final var previousResultData = oldResultData.get(oldKeyArgument); |
389 |
3
1. lambda$compute$1 : removed conditional - replaced equality check with true → NO_COVERAGE 2. lambda$compute$1 : removed conditional - replaced equality check with false → NO_COVERAGE 3. lambda$compute$1 : negated conditional → NO_COVERAGE |
if (previousResultData == null) { |
390 | logger.error( | |
391 | "[{}] Could not find previous argument with index {}. Known previous arguments: {}", | |
392 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/model/Device::name → NO_COVERAGE |
device.name(), |
393 | oldKeyArgument, | |
394 | oldResultData); | |
395 | ||
396 |
1
1. lambda$compute$1 : removed call to java/lang/IllegalArgumentException::<init> → NO_COVERAGE |
throw new IllegalArgumentException( |
397 | "Could not find previous argument with index " + oldKeyArgument); | |
398 | } | |
399 | ||
400 | if (logger.isTraceEnabled()) { | |
401 | logger.trace("[{}] Index {} - Setting previous result size of {} of previous argument index {}", | |
402 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/model/Device::name → NO_COVERAGE |
device.name(), |
403 | newKeyArgument, | |
404 |
2
1. lambda$compute$1 : removed call to java/lang/Integer::valueOf → NO_COVERAGE 2. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/CLData::size → NO_COVERAGE |
previousResultData.size(), |
405 | oldKeyArgument); | |
406 | } | |
407 | ||
408 |
2
1. lambda$compute$1 : replaced call to org/jocl/CL::clSetKernelArg with argument → NO_COVERAGE 2. lambda$compute$1 : removed call to org/jocl/CL::clSetKernelArg → NO_COVERAGE |
CL.clSetKernelArg(kernel, |
409 |
4
1. lambda$compute$1 : Substituted 0 with 1 → NO_COVERAGE 2. lambda$compute$1 : removed call to java/lang/Integer::intValue → NO_COVERAGE 3. lambda$compute$1 : Substituted 4 with 5 → NO_COVERAGE 4. lambda$compute$1 : Substituted 1 with 0 → NO_COVERAGE |
newKeyArgument, |
410 | Sizeof.cl_int, | |
411 |
2
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/CLData::size → NO_COVERAGE 2. lambda$compute$1 : removed call to org/jocl/Pointer::to → NO_COVERAGE |
Pointer.to(new int[] { previousResultData.size() })); |
412 | } | |
413 | } | |
414 | ||
415 | // Clean up unused results | |
416 |
1
1. lambda$compute$1 : removed call to java/util/Map::keySet → NO_COVERAGE |
final var previousResultsToKeep = reusePreviousResultAsArguments.keySet(); |
417 |
1
1. lambda$compute$1 : removed call to java/util/Map::entrySet → NO_COVERAGE |
for (Entry<Integer, CLData> entry2 : oldResultData.entrySet()) { |
418 |
5
1. lambda$compute$1 : removed conditional - replaced equality check with true → NO_COVERAGE 2. lambda$compute$1 : removed conditional - replaced equality check with false → NO_COVERAGE 3. lambda$compute$1 : negated conditional → NO_COVERAGE 4. lambda$compute$1 : removed call to java/util/Map$Entry::getKey → NO_COVERAGE 5. lambda$compute$1 : removed call to java/util/Set::contains → NO_COVERAGE |
if (previousResultsToKeep.contains(entry2.getKey()) == false) { |
419 |
2
1. lambda$compute$1 : removed call to org/jocl/CL::clReleaseMemObject → NO_COVERAGE 2. lambda$compute$1 : removed call to java/util/Map$Entry::getValue → NO_COVERAGE |
CL.clReleaseMemObject(entry2.getValue() |
420 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/CLData::clMem → NO_COVERAGE |
.clMem()); |
421 | } | |
422 | } | |
423 | } | |
424 | ||
425 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/MultiStageFitness::prepareStaticData → NO_COVERAGE |
prepareStaticData(openCLExecutionContext, stageDescriptor); |
426 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/MultiStageFitness::loadData → NO_COVERAGE |
loadData(openCLExecutionContext, stageDescriptor, data, generation, genotypes); |
427 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/MultiStageFitness::allocateLocalMemory → NO_COVERAGE |
allocateLocalMemory(openCLExecutionContext, stageDescriptor, generation, genotypes, kernelExecutionContext); |
428 | ||
429 | /** | |
430 | * Allocate memory for results | |
431 | */ | |
432 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::resultAllocators → NO_COVERAGE |
final var resultAllocators = stageDescriptor.resultAllocators(); |
433 |
4
1. lambda$compute$1 : removed conditional - replaced equality check with false → NO_COVERAGE 2. lambda$compute$1 : removed call to org/apache/commons/collections4/MapUtils::isNotEmpty → NO_COVERAGE 3. lambda$compute$1 : removed conditional - replaced equality check with true → NO_COVERAGE 4. lambda$compute$1 : negated conditional → NO_COVERAGE |
if (MapUtils.isNotEmpty(resultAllocators)) { |
434 | logger.trace("[{}] Result allocators: {}", device.name(), resultAllocators); | |
435 | ||
436 |
1
1. lambda$compute$1 : removed call to java/util/Map::entrySet → NO_COVERAGE |
for (final var entry : resultAllocators.entrySet()) { |
437 |
2
1. lambda$compute$1 : removed call to java/util/Map$Entry::getKey → NO_COVERAGE 2. lambda$compute$1 : removed call to java/lang/Integer::intValue → NO_COVERAGE |
final int argumentIdx = entry.getKey(); |
438 |
1
1. lambda$compute$1 : removed call to java/util/Map$Entry::getValue → NO_COVERAGE |
final var resultAllocator = entry.getValue(); |
439 | ||
440 | final var clDdata = resultAllocator | |
441 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/ResultAllocator::load → NO_COVERAGE |
.load(openCLExecutionContext, kernelExecutionContext, generation, genotypes); |
442 | ||
443 |
6
1. lambda$compute$1 : removed call to java/lang/Integer::valueOf → NO_COVERAGE 2. lambda$compute$1 : replaced call to java/util/Map::put with argument → NO_COVERAGE 3. lambda$compute$1 : removed call to java/util/Map::put → NO_COVERAGE 4. lambda$compute$1 : negated conditional → NO_COVERAGE 5. lambda$compute$1 : removed conditional - replaced equality check with true → NO_COVERAGE 6. lambda$compute$1 : removed conditional - replaced equality check with false → NO_COVERAGE |
if (resultData.put(argumentIdx, clDdata) != null) { |
444 |
1
1. lambda$compute$1 : removed call to java/lang/IllegalArgumentException::<init> → NO_COVERAGE |
throw new IllegalArgumentException( |
445 | "Multiple result allocators configured for index " + argumentIdx); | |
446 | } | |
447 | if (logger.isTraceEnabled()) { | |
448 | logger.trace("[{}] Index {} - Allocate result data memory of type {} and size {}", | |
449 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/model/Device::name → NO_COVERAGE |
device.name(), |
450 |
1
1. lambda$compute$1 : removed call to java/lang/Integer::valueOf → NO_COVERAGE |
argumentIdx, |
451 |
2
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/CLData::clType → NO_COVERAGE 2. lambda$compute$1 : removed call to java/lang/Integer::valueOf → NO_COVERAGE |
clDdata.clType(), |
452 |
2
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/CLData::size → NO_COVERAGE 2. lambda$compute$1 : removed call to java/lang/Integer::valueOf → NO_COVERAGE |
clDdata.size()); |
453 | } | |
454 | ||
455 |
4
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/CLData::clMem → NO_COVERAGE 2. lambda$compute$1 : removed call to org/jocl/Pointer::to → NO_COVERAGE 3. lambda$compute$1 : replaced call to org/jocl/CL::clSetKernelArg with argument → NO_COVERAGE 4. lambda$compute$1 : removed call to org/jocl/CL::clSetKernelArg → NO_COVERAGE |
CL.clSetKernelArg(kernel, argumentIdx, Sizeof.cl_mem, Pointer.to(clDdata.clMem())); |
456 | } | |
457 | } else { | |
458 | logger.trace("[{}] No result allocator found", device.name()); | |
459 | } | |
460 | ||
461 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::clCommandQueue → NO_COVERAGE |
final var clCommandQueue = openCLExecutionContext.clCommandQueue(); |
462 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/kernelcontext/KernelExecutionContext::globalWorkDimensions → NO_COVERAGE |
final var globalWorkDimensions = kernelExecutionContext.globalWorkDimensions(); |
463 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/kernelcontext/KernelExecutionContext::globalWorkSize → NO_COVERAGE |
final var globalWorkSize = kernelExecutionContext.globalWorkSize(); |
464 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/kernelcontext/KernelExecutionContext::workGroupSize → NO_COVERAGE |
final long[] workGroupSize = kernelExecutionContext.workGroupSize() |
465 |
2
1. lambda$compute$1 : removed call to java/util/Optional::orElse → NO_COVERAGE 2. lambda$compute$1 : replaced call to java/util/Optional::orElse with argument → NO_COVERAGE |
.orElse(null); |
466 | ||
467 | logger.trace( | |
468 | "[{}] Starting computation on kernel {} for {} genotypes and global work size {} and local work size {}", | |
469 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/model/Device::name → NO_COVERAGE |
device.name(), |
470 | kernelName, | |
471 |
2
1. lambda$compute$1 : removed call to java/util/List::size → NO_COVERAGE 2. lambda$compute$1 : removed call to java/lang/Integer::valueOf → NO_COVERAGE |
genotypes.size(), |
472 | globalWorkSize, | |
473 | workGroupSize); | |
474 | try { | |
475 |
1
1. lambda$compute$1 : removed call to java/lang/System::nanoTime → NO_COVERAGE |
final long startTime = System.nanoTime(); |
476 |
3
1. lambda$compute$1 : removed call to org/jocl/CL::clEnqueueNDRangeKernel → NO_COVERAGE 2. lambda$compute$1 : Substituted 0 with 1 → NO_COVERAGE 3. lambda$compute$1 : replaced call to org/jocl/CL::clEnqueueNDRangeKernel with argument → NO_COVERAGE |
CL.clEnqueueNDRangeKernel(clCommandQueue, |
477 | kernel, | |
478 | globalWorkDimensions, | |
479 | null, | |
480 | globalWorkSize, | |
481 | workGroupSize, | |
482 | 0, | |
483 | null, | |
484 | null); | |
485 | ||
486 | // CL.clFinish(openCLExecutionContext.clCommandQueue()); | |
487 | ||
488 |
1
1. lambda$compute$1 : removed call to java/lang/System::nanoTime → NO_COVERAGE |
final long endTime = System.nanoTime(); |
489 |
1
1. lambda$compute$1 : Replaced long subtraction with addition → NO_COVERAGE |
final long duration = endTime - startTime; |
490 | if (logger.isDebugEnabled()) { | |
491 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE |
final var deviceName = openCLExecutionContext.device() |
492 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/model/Device::name → NO_COVERAGE |
.name(); |
493 | logger.debug("[{}] - Stage {} - Took {} microsec for {} genotypes", | |
494 | deviceName, | |
495 |
3
1. lambda$compute$1 : removed call to java/lang/Integer::valueOf → NO_COVERAGE 2. lambda$compute$1 : Replaced double division with multiplication → NO_COVERAGE 3. lambda$compute$1 : Substituted 1000.0 with 1.0 → NO_COVERAGE |
i, |
496 |
1
1. lambda$compute$1 : removed call to java/lang/Double::valueOf → NO_COVERAGE |
duration / 1000., |
497 |
2
1. lambda$compute$1 : removed call to java/util/List::size → NO_COVERAGE 2. lambda$compute$1 : removed call to java/lang/Integer::valueOf → NO_COVERAGE |
genotypes.size()); |
498 | } | |
499 | } catch (Exception e) { | |
500 | logger.error("[{}] Failure to compute", device.name(), e); | |
501 | throw e; | |
502 | } | |
503 | ||
504 |
6
1. lambda$compute$1 : removed conditional - replaced equality check with false → NO_COVERAGE 2. lambda$compute$1 : removed call to java/util/List::size → NO_COVERAGE 3. lambda$compute$1 : removed conditional - replaced equality check with true → NO_COVERAGE 4. lambda$compute$1 : Substituted 1 with 0 → NO_COVERAGE 5. lambda$compute$1 : negated conditional → NO_COVERAGE 6. lambda$compute$1 : Replaced integer subtraction with addition → NO_COVERAGE |
if (i == stageDescriptors.size() - 1) { |
505 |
2
1. lambda$compute$1 : replaced call to net/bmahe/genetics4j/gpu/spec/fitness/FitnessExtractor::compute with argument → NO_COVERAGE 2. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/FitnessExtractor::compute → NO_COVERAGE |
finalResults = fitnessExtractor.compute(openCLExecutionContext, |
506 | kernelExecutionContext, | |
507 | executorService, | |
508 | generation, | |
509 | genotypes, | |
510 |
2
1. lambda$compute$1 : removed call to java/util/Map::of → NO_COVERAGE 2. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/ResultExtractor::<init> → NO_COVERAGE |
new ResultExtractor(Map.of(device, resultData))); |
511 | ||
512 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/MultiStageFitness::clearResultData → NO_COVERAGE |
clearResultData(resultData); |
513 | } | |
514 | ||
515 | for (final CLData clData : reusedArguments) { | |
516 |
2
1. lambda$compute$1 : removed call to org/jocl/CL::clReleaseMemObject → NO_COVERAGE 2. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/CLData::clMem → NO_COVERAGE |
CL.clReleaseMemObject(clData.clMem()); |
517 | } | |
518 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/MultiStageFitness::clearData → NO_COVERAGE |
clearData(data); |
519 | } | |
520 | ||
521 |
3
1. lambda$compute$1 : removed conditional - replaced equality check with false → NO_COVERAGE 2. lambda$compute$1 : removed conditional - replaced equality check with true → NO_COVERAGE 3. lambda$compute$1 : negated conditional → NO_COVERAGE |
if (finalResults == null) { |
522 |
1
1. lambda$compute$1 : removed call to java/lang/IllegalStateException::<init> → NO_COVERAGE |
throw new IllegalStateException("final results cannot be null"); |
523 | } | |
524 |
1
1. lambda$compute$1 : replaced return value with Collections.emptyList for net/bmahe/genetics4j/gpu/spec/fitness/MultiStageFitness::lambda$compute$1 → NO_COVERAGE |
return finalResults; |
525 | }, executorService); | |
526 | } | |
527 | ||
528 | @Override | |
529 | public void afterEvaluation(OpenCLExecutionContext openCLExecutionContext, ExecutorService executorService, | |
530 | long generation, List<Genotype> genotypes) { | |
531 |
1
1. afterEvaluation : removed call to net/bmahe/genetics4j/gpu/spec/fitness/OpenCLFitness::afterEvaluation → NO_COVERAGE |
super.afterEvaluation(openCLExecutionContext, executorService, generation, genotypes); |
532 | ||
533 |
1
1. afterEvaluation : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE |
final var device = openCLExecutionContext.device(); |
534 | logger.trace("[{}] Releasing data", device.name()); | |
535 | } | |
536 | ||
537 | @Override | |
538 | public void afterAllEvaluations(final OpenCLExecutionContext openCLExecutionContext, | |
539 | final ExecutorService executorService) { | |
540 |
1
1. afterAllEvaluations : removed call to net/bmahe/genetics4j/gpu/spec/fitness/OpenCLFitness::afterAllEvaluations → NO_COVERAGE |
super.afterAllEvaluations(openCLExecutionContext, executorService); |
541 | ||
542 |
1
1. afterAllEvaluations : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE |
final var device = openCLExecutionContext.device(); |
543 | logger.trace("[{}] Releasing static data", device.name()); | |
544 |
1
1. afterAllEvaluations : removed call to net/bmahe/genetics4j/gpu/spec/fitness/MultiStageFitness::clearStaticData → NO_COVERAGE |
clearStaticData(device); |
545 | } | |
546 | ||
547 | /** | |
548 | * Creates a new MultiStageFitness instance with the specified configuration. | |
549 | * | |
550 | * @param <U> the fitness value type | |
551 | * @param multiStageDescriptor configuration for multi-stage kernel execution and data management | |
552 | * @param fitnessExtractor function to extract fitness values from final stage results | |
553 | * @return a new MultiStageFitness instance | |
554 | * @throws IllegalArgumentException if any parameter is null | |
555 | */ | |
556 | public static <U extends Comparable<U>> MultiStageFitness<U> of(final MultiStageDescriptor multiStageDescriptor, | |
557 | final FitnessExtractor<U> fitnessExtractor) { | |
558 | Validate.notNull(multiStageDescriptor); | |
559 | Validate.notNull(fitnessExtractor); | |
560 | ||
561 |
2
1. of : replaced return value with null for net/bmahe/genetics4j/gpu/spec/fitness/MultiStageFitness::of → NO_COVERAGE 2. of : removed call to net/bmahe/genetics4j/gpu/spec/fitness/MultiStageFitness::<init> → NO_COVERAGE |
return new MultiStageFitness<>(multiStageDescriptor, fitnessExtractor); |
562 | } | |
563 | } | |
Mutations | ||
132 |
1.1 2.2 |
|
135 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 10.10 |
|
139 |
1.1 2.2 |
|
140 |
1.1 |
|
141 |
1.1 2.2 |
|
144 |
1.1 |
|
145 |
1.1 2.2 |
|
149 |
1.1 2.2 3.3 4.4 |
|
153 |
1.1 |
|
154 |
1.1 2.2 |
|
157 |
1.1 |
|
161 |
1.1 2.2 3.3 4.4 |
|
165 |
1.1 |
|
166 |
1.1 2.2 |
|
169 |
1.1 |
|
177 |
1.1 |
|
181 |
1.1 |
|
182 |
1.1 |
|
184 |
1.1 2.2 |
|
186 |
1.1 |
|
187 |
1.1 |
|
188 |
1.1 |
|
189 |
1.1 |
|
191 |
1.1 2.2 |
|
193 |
1.1 2.2 3.3 4.4 |
|
194 |
1.1 |
|
197 |
1.1 2.2 |
|
201 |
1.1 2.2 3.3 4.4 5.5 |
|
211 |
1.1 |
|
215 |
1.1 |
|
216 |
1.1 |
|
218 |
1.1 2.2 |
|
220 |
1.1 |
|
221 |
1.1 2.2 3.3 4.4 |
|
222 |
1.1 |
|
223 |
1.1 2.2 |
|
224 |
1.1 |
|
227 |
1.1 2.2 |
|
230 |
1.1 2.2 |
|
241 |
1.1 |
|
245 |
1.1 |
|
246 |
1.1 |
|
248 |
1.1 2.2 |
|
250 |
1.1 |
|
251 |
1.1 2.2 3.3 4.4 |
|
252 |
1.1 |
|
253 |
1.1 2.2 |
|
254 |
1.1 |
|
256 |
1.1 |
|
258 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
259 |
1.1 |
|
263 |
1.1 2.2 3.3 4.4 |
|
271 |
1.1 |
|
273 |
1.1 |
|
276 |
1.1 |
|
278 |
1.1 |
|
279 |
1.1 |
|
280 |
1.1 |
|
281 |
1.1 |
|
284 |
1.1 |
|
285 |
1.1 |
|
288 |
1.1 |
|
290 |
1.1 2.2 3.3 4.4 |
|
291 |
1.1 2.2 3.3 4.4 5.5 |
|
292 |
1.1 |
|
309 |
1.1 |
|
310 |
1.1 |
|
318 |
1.1 2.2 |
|
322 |
1.1 |
|
324 |
1.1 |
|
325 |
1.1 |
|
327 |
1.1 |
|
328 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
329 |
1.1 |
|
330 |
1.1 |
|
331 |
1.1 |
|
333 |
1.1 2.2 |
|
340 |
1.1 |
|
342 |
1.1 |
|
347 |
1.1 |
|
348 |
1.1 |
|
350 |
1.1 |
|
352 |
1.1 |
|
353 |
1.1 |
|
354 |
1.1 2.2 3.3 4.4 |
|
355 |
1.1 2.2 3.3 4.4 |
|
357 |
1.1 2.2 3.3 4.4 |
|
358 |
1.1 |
|
359 |
1.1 |
|
360 |
1.1 |
|
362 |
1.1 2.2 |
|
363 |
1.1 2.2 3.3 |
|
366 |
1.1 |
|
370 |
1.1 |
|
375 |
1.1 |
|
378 |
1.1 2.2 3.3 4.4 5.5 |
|
379 |
1.1 |
|
383 |
1.1 2.2 3.3 4.4 |
|
384 |
1.1 |
|
385 |
1.1 |
|
386 |
1.1 |
|
388 |
1.1 2.2 |
|
389 |
1.1 2.2 3.3 |
|
392 |
1.1 |
|
396 |
1.1 |
|
402 |
1.1 |
|
404 |
1.1 2.2 |
|
408 |
1.1 2.2 |
|
409 |
1.1 2.2 3.3 4.4 |
|
411 |
1.1 2.2 |
|
416 |
1.1 |
|
417 |
1.1 |
|
418 |
1.1 2.2 3.3 4.4 5.5 |
|
419 |
1.1 2.2 |
|
420 |
1.1 |
|
425 |
1.1 |
|
426 |
1.1 |
|
427 |
1.1 |
|
432 |
1.1 |
|
433 |
1.1 2.2 3.3 4.4 |
|
436 |
1.1 |
|
437 |
1.1 2.2 |
|
438 |
1.1 |
|
441 |
1.1 |
|
443 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
444 |
1.1 |
|
449 |
1.1 |
|
450 |
1.1 |
|
451 |
1.1 2.2 |
|
452 |
1.1 2.2 |
|
455 |
1.1 2.2 3.3 4.4 |
|
461 |
1.1 |
|
462 |
1.1 |
|
463 |
1.1 |
|
464 |
1.1 |
|
465 |
1.1 2.2 |
|
469 |
1.1 |
|
471 |
1.1 2.2 |
|
475 |
1.1 |
|
476 |
1.1 2.2 3.3 |
|
488 |
1.1 |
|
489 |
1.1 |
|
491 |
1.1 |
|
492 |
1.1 |
|
495 |
1.1 2.2 3.3 |
|
496 |
1.1 |
|
497 |
1.1 2.2 |
|
504 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
505 |
1.1 2.2 |
|
510 |
1.1 2.2 |
|
512 |
1.1 |
|
516 |
1.1 2.2 |
|
518 |
1.1 |
|
521 |
1.1 2.2 3.3 |
|
522 |
1.1 |
|
524 |
1.1 |
|
531 |
1.1 |
|
533 |
1.1 |
|
540 |
1.1 |
|
542 |
1.1 |
|
544 |
1.1 |
|
561 |
1.1 2.2 |