| 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 GPU | |
| 33 | * kernel executions, where each stage can use results from previous stages as input. This is ideal for complex fitness | |
| 34 | * functions that require multiple computational phases, such as neural network training, multi-objective optimization, | |
| 35 | * 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 | * | |
| 56 | * <pre>{@code | |
| 57 | * // Define multi-stage descriptor with sequential kernels | |
| 58 | * MultiStageDescriptor descriptor = MultiStageDescriptor.builder() | |
| 59 | * .addStaticDataLoader("parameters", parametersLoader) | |
| 60 | * .addStage( | |
| 61 | * StageDescriptor.builder() | |
| 62 | * .kernelName("preprocessing") | |
| 63 | * .addDataLoader(0, inputDataLoader) | |
| 64 | * .addResultAllocator(1, preprocessedResultAllocator) | |
| 65 | * .build()) | |
| 66 | * .addStage( | |
| 67 | * StageDescriptor.builder() | |
| 68 | * .kernelName("fitness_evaluation") | |
| 69 | * .reusePreviousResultAsArgument(1, 0) // Use previous result as input | |
| 70 | * .addResultAllocator(1, fitnessResultAllocator) | |
| 71 | * .build()) | |
| 72 | * .build(); | |
| 73 | * | |
| 74 | * // Define fitness extraction from final stage results | |
| 75 | * FitnessExtractor<Double> extractor = (context, kernelCtx, executor, generation, genotypes, results) -> { | |
| 76 | * float[] fitnessValues = results.extractFloatArray(context, 1); | |
| 77 | * return Arrays.stream(fitnessValues).mapToDouble(f -> (double) f).boxed().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 |
2
1. beforeAllEvaluations : removed call to net/bmahe/genetics4j/gpu/opencl/model/Device::name → NO_COVERAGE 2. beforeAllEvaluations : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE |
final var deviceName = openCLExecutionContext.device().name(); |
| 285 | logger.trace("[{}] Loading static data for entry name {}", deviceName, argumentName); | |
| 286 | } | |
| 287 |
1
1. beforeAllEvaluations : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/StaticDataLoader::load → NO_COVERAGE |
final CLData clData = dataSupplier.load(openCLExecutionContext); |
| 288 | ||
| 289 |
4
1. beforeAllEvaluations : replaced call to java/util/Map::computeIfAbsent with argument → NO_COVERAGE 2. beforeAllEvaluations : removed call to java/util/Map::computeIfAbsent → 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<>()); |
| 290 |
5
1. beforeAllEvaluations : removed conditional - replaced equality check with false → NO_COVERAGE 2. beforeAllEvaluations : removed call to java/util/Map::put → NO_COVERAGE 3. beforeAllEvaluations : negated conditional → NO_COVERAGE 4. beforeAllEvaluations : removed conditional - replaced equality check with true → NO_COVERAGE 5. beforeAllEvaluations : replaced call to java/util/Map::put with argument → NO_COVERAGE |
if (mapData.put(argumentName, clData) != null) { |
| 291 |
1
1. beforeAllEvaluations : removed call to java/lang/IllegalArgumentException::<init> → NO_COVERAGE |
throw new IllegalArgumentException("Multiple data configured with name " + argumentName); |
| 292 | } | |
| 293 | } | |
| 294 | } | |
| 295 | ||
| 296 | /** | |
| 297 | * Constructs a MultiStageFitness with the specified stage descriptor and fitness extractor. | |
| 298 | * | |
| 299 | * @param _multiStageDescriptor configuration for multi-stage kernel execution and data management | |
| 300 | * @param _fitnessExtractor function to extract fitness values from final stage results | |
| 301 | * @throws IllegalArgumentException if any parameter is null | |
| 302 | */ | |
| 303 | public MultiStageFitness(final MultiStageDescriptor _multiStageDescriptor, | |
| 304 | final FitnessExtractor<T> _fitnessExtractor) { | |
| 305 | Validate.notNull(_multiStageDescriptor); | |
| 306 | Validate.notNull(_fitnessExtractor); | |
| 307 | ||
| 308 |
1
1. <init> : Removed assignment to member variable multiStageDescriptor → NO_COVERAGE |
this.multiStageDescriptor = _multiStageDescriptor; |
| 309 |
1
1. <init> : Removed assignment to member variable fitnessExtractor → NO_COVERAGE |
this.fitnessExtractor = _fitnessExtractor; |
| 310 | } | |
| 311 | ||
| 312 | @Override | |
| 313 | public CompletableFuture<List<T>> compute(final OpenCLExecutionContext openCLExecutionContext, | |
| 314 | final ExecutorService executorService, final long generation, final List<Genotype> genotypes) { | |
| 315 | Validate.notNull(openCLExecutionContext); | |
| 316 | ||
| 317 |
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(() -> { |
| 318 | ||
| 319 | List<T> finalResults = null; | |
| 320 | ||
| 321 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE |
final var device = openCLExecutionContext.device(); |
| 322 | ||
| 323 |
1
1. lambda$compute$1 : removed call to java/util/concurrent/ConcurrentHashMap::<init> → NO_COVERAGE |
final Map<Integer, CLData> data = new ConcurrentHashMap<>(); |
| 324 |
1
1. lambda$compute$1 : removed call to java/util/concurrent/ConcurrentHashMap::<init> → NO_COVERAGE |
Map<Integer, CLData> resultData = new ConcurrentHashMap<>(); |
| 325 | ||
| 326 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/MultiStageDescriptor::stageDescriptors → NO_COVERAGE |
final var stageDescriptors = multiStageDescriptor.stageDescriptors(); |
| 327 |
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++) { |
| 328 |
1
1. lambda$compute$1 : removed call to java/util/List::get → NO_COVERAGE |
final StageDescriptor stageDescriptor = stageDescriptors.get(i); |
| 329 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::kernels → NO_COVERAGE |
final var kernels = openCLExecutionContext.kernels(); |
| 330 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::kernelName → NO_COVERAGE |
final var kernelName = stageDescriptor.kernelName(); |
| 331 | ||
| 332 |
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); |
| 333 | ||
| 334 | logger.debug("[{}] Executing {}-th stage for kernel {}", device.name(), i, kernelName); | |
| 335 | ||
| 336 | /** | |
| 337 | * Compute the Kernel Execution Context | |
| 338 | */ | |
| 339 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::kernelExecutionContextComputer → NO_COVERAGE |
final var kernelExecutionContextComputer = stageDescriptor.kernelExecutionContextComputer(); |
| 340 | final var kernelExecutionContext = kernelExecutionContextComputer | |
| 341 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/kernelcontext/KernelExecutionContextComputer::compute → NO_COVERAGE |
.compute(openCLExecutionContext, kernelName, generation, genotypes); |
| 342 | ||
| 343 | /** | |
| 344 | * Map previous results to new arguments | |
| 345 | */ | |
| 346 |
1
1. lambda$compute$1 : removed call to java/util/HashMap::<init> → NO_COVERAGE |
final Map<Integer, CLData> oldResultData = new HashMap<>(resultData); |
| 347 |
1
1. lambda$compute$1 : removed call to java/util/concurrent/ConcurrentHashMap::<init> → NO_COVERAGE |
resultData = new ConcurrentHashMap<>(); |
| 348 | final Map<Integer, Integer> reusePreviousResultSizeAsArguments = stageDescriptor | |
| 349 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::reusePreviousResultSizeAsArguments → NO_COVERAGE |
.reusePreviousResultSizeAsArguments(); |
| 350 | final Map<Integer, Integer> reusePreviousResultAsArguments = stageDescriptor | |
| 351 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::reusePreviousResultAsArguments → NO_COVERAGE |
.reusePreviousResultAsArguments(); |
| 352 |
1
1. lambda$compute$1 : removed call to java/util/HashSet::<init> → NO_COVERAGE |
final Set<CLData> reusedArguments = new HashSet<>(); |
| 353 |
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) |
| 354 |
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)) { |
| 355 | ||
| 356 |
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)) { |
| 357 |
1
1. lambda$compute$1 : removed call to java/util/Map::entrySet → NO_COVERAGE |
for (final Entry<Integer, Integer> entry : reusePreviousResultAsArguments.entrySet()) { |
| 358 |
1
1. lambda$compute$1 : removed call to java/util/Map$Entry::getKey → NO_COVERAGE |
final var oldKeyArgument = entry.getKey(); |
| 359 |
1
1. lambda$compute$1 : removed call to java/util/Map$Entry::getValue → NO_COVERAGE |
final var newKeyArgument = entry.getValue(); |
| 360 | ||
| 361 |
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); |
| 362 |
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) { |
| 363 | logger.error( | |
| 364 | "[{}] Could not find previous argument with index {}. Known previous arguments: {}", | |
| 365 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/model/Device::name → NO_COVERAGE |
device.name(), |
| 366 | oldKeyArgument, | |
| 367 | oldResultData); | |
| 368 | ||
| 369 |
1
1. lambda$compute$1 : removed call to java/lang/IllegalArgumentException::<init> → NO_COVERAGE |
throw new IllegalArgumentException( |
| 370 | "Could not find previous argument with index " + oldKeyArgument); | |
| 371 | } | |
| 372 | ||
| 373 | logger.trace( | |
| 374 | "[{}] 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( | |
| 402 | "[{}] Index {} - Setting previous result size of {} of previous argument index {}", | |
| 403 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/model/Device::name → NO_COVERAGE |
device.name(), |
| 404 | newKeyArgument, | |
| 405 |
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(), |
| 406 | oldKeyArgument); | |
| 407 | } | |
| 408 | ||
| 409 |
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( |
| 410 | kernel, | |
| 411 |
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, |
| 412 | Sizeof.cl_int, | |
| 413 |
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() })); |
| 414 | } | |
| 415 | } | |
| 416 | ||
| 417 | // Clean up unused results | |
| 418 |
1
1. lambda$compute$1 : removed call to java/util/Map::keySet → NO_COVERAGE |
final var previousResultsToKeep = reusePreviousResultAsArguments.keySet(); |
| 419 |
1
1. lambda$compute$1 : removed call to java/util/Map::entrySet → NO_COVERAGE |
for (Entry<Integer, CLData> entry2 : oldResultData.entrySet()) { |
| 420 |
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) { |
| 421 |
3
1. lambda$compute$1 : removed call to java/util/Map$Entry::getValue → NO_COVERAGE 2. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/CLData::clMem → NO_COVERAGE 3. lambda$compute$1 : removed call to org/jocl/CL::clReleaseMemObject → NO_COVERAGE |
CL.clReleaseMemObject(entry2.getValue().clMem()); |
| 422 | } | |
| 423 | } | |
| 424 | } | |
| 425 | ||
| 426 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/MultiStageFitness::prepareStaticData → NO_COVERAGE |
prepareStaticData(openCLExecutionContext, stageDescriptor); |
| 427 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/MultiStageFitness::loadData → NO_COVERAGE |
loadData(openCLExecutionContext, stageDescriptor, data, generation, genotypes); |
| 428 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/MultiStageFitness::allocateLocalMemory → NO_COVERAGE |
allocateLocalMemory(openCLExecutionContext, stageDescriptor, generation, genotypes, kernelExecutionContext); |
| 429 | ||
| 430 | /** | |
| 431 | * Allocate memory for results | |
| 432 | */ | |
| 433 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::resultAllocators → NO_COVERAGE |
final var resultAllocators = stageDescriptor.resultAllocators(); |
| 434 |
4
1. lambda$compute$1 : negated conditional → NO_COVERAGE 2. lambda$compute$1 : removed conditional - replaced equality check with false → NO_COVERAGE 3. lambda$compute$1 : removed conditional - replaced equality check with true → NO_COVERAGE 4. lambda$compute$1 : removed call to org/apache/commons/collections4/MapUtils::isNotEmpty → NO_COVERAGE |
if (MapUtils.isNotEmpty(resultAllocators)) { |
| 435 | logger.trace("[{}] Result allocators: {}", device.name(), resultAllocators); | |
| 436 | ||
| 437 |
1
1. lambda$compute$1 : removed call to java/util/Map::entrySet → NO_COVERAGE |
for (final var entry : resultAllocators.entrySet()) { |
| 438 |
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(); |
| 439 |
1
1. lambda$compute$1 : removed call to java/util/Map$Entry::getValue → NO_COVERAGE |
final var resultAllocator = entry.getValue(); |
| 440 | ||
| 441 | final var clDdata = resultAllocator | |
| 442 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/ResultAllocator::load → NO_COVERAGE |
.load(openCLExecutionContext, kernelExecutionContext, generation, genotypes); |
| 443 | ||
| 444 |
6
1. lambda$compute$1 : replaced call to java/util/Map::put with argument → NO_COVERAGE 2. lambda$compute$1 : removed call to java/lang/Integer::valueOf → NO_COVERAGE 3. lambda$compute$1 : removed conditional - replaced equality check with true → NO_COVERAGE 4. lambda$compute$1 : removed conditional - replaced equality check with false → NO_COVERAGE 5. lambda$compute$1 : removed call to java/util/Map::put → NO_COVERAGE 6. lambda$compute$1 : negated conditional → NO_COVERAGE |
if (resultData.put(argumentIdx, clDdata) != null) { |
| 445 |
1
1. lambda$compute$1 : removed call to java/lang/IllegalArgumentException::<init> → NO_COVERAGE |
throw new IllegalArgumentException( |
| 446 | "Multiple result allocators configured for index " + argumentIdx); | |
| 447 | } | |
| 448 | if (logger.isTraceEnabled()) { | |
| 449 | logger.trace( | |
| 450 | "[{}] Index {} - Allocate result data memory of type {} and size {}", | |
| 451 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/model/Device::name → NO_COVERAGE |
device.name(), |
| 452 |
1
1. lambda$compute$1 : removed call to java/lang/Integer::valueOf → NO_COVERAGE |
argumentIdx, |
| 453 |
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(), |
| 454 |
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()); |
| 455 | } | |
| 456 | ||
| 457 |
4
1. lambda$compute$1 : replaced call to org/jocl/CL::clSetKernelArg with argument → NO_COVERAGE 2. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/CLData::clMem → NO_COVERAGE 3. lambda$compute$1 : removed call to org/jocl/Pointer::to → 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())); |
| 458 | } | |
| 459 | } else { | |
| 460 | logger.trace("[{}] No result allocator found", device.name()); | |
| 461 | } | |
| 462 | ||
| 463 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::clCommandQueue → NO_COVERAGE |
final var clCommandQueue = openCLExecutionContext.clCommandQueue(); |
| 464 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/kernelcontext/KernelExecutionContext::globalWorkDimensions → NO_COVERAGE |
final var globalWorkDimensions = kernelExecutionContext.globalWorkDimensions(); |
| 465 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/kernelcontext/KernelExecutionContext::globalWorkSize → NO_COVERAGE |
final var globalWorkSize = kernelExecutionContext.globalWorkSize(); |
| 466 |
3
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/kernelcontext/KernelExecutionContext::workGroupSize → NO_COVERAGE 2. lambda$compute$1 : replaced call to java/util/Optional::orElse with argument → NO_COVERAGE 3. lambda$compute$1 : removed call to java/util/Optional::orElse → NO_COVERAGE |
final long[] workGroupSize = kernelExecutionContext.workGroupSize().orElse(null); |
| 467 | ||
| 468 | logger.trace( | |
| 469 | "[{}] Starting computation on kernel {} for {} genotypes and global work size {} and local work size {}", | |
| 470 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/model/Device::name → NO_COVERAGE |
device.name(), |
| 471 | kernelName, | |
| 472 |
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(), |
| 473 | globalWorkSize, | |
| 474 | workGroupSize); | |
| 475 | try { | |
| 476 |
1
1. lambda$compute$1 : removed call to java/lang/System::nanoTime → NO_COVERAGE |
final long startTime = System.nanoTime(); |
| 477 |
3
1. lambda$compute$1 : Substituted 0 with 1 → NO_COVERAGE 2. lambda$compute$1 : removed call to org/jocl/CL::clEnqueueNDRangeKernel → NO_COVERAGE 3. lambda$compute$1 : replaced call to org/jocl/CL::clEnqueueNDRangeKernel with argument → NO_COVERAGE |
CL.clEnqueueNDRangeKernel( |
| 478 | clCommandQueue, | |
| 479 | kernel, | |
| 480 | globalWorkDimensions, | |
| 481 | null, | |
| 482 | globalWorkSize, | |
| 483 | workGroupSize, | |
| 484 | 0, | |
| 485 | null, | |
| 486 | null); | |
| 487 | ||
| 488 | // CL.clFinish(openCLExecutionContext.clCommandQueue()); | |
| 489 | ||
| 490 |
1
1. lambda$compute$1 : removed call to java/lang/System::nanoTime → NO_COVERAGE |
final long endTime = System.nanoTime(); |
| 491 |
1
1. lambda$compute$1 : Replaced long subtraction with addition → NO_COVERAGE |
final long duration = endTime - startTime; |
| 492 | if (logger.isDebugEnabled()) { | |
| 493 |
2
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE 2. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/model/Device::name → NO_COVERAGE |
final var deviceName = openCLExecutionContext.device().name(); |
| 494 | logger.debug( | |
| 495 | "[{}] - Stage {} - Took {} microsec for {} genotypes", | |
| 496 | deviceName, | |
| 497 |
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, |
| 498 |
1
1. lambda$compute$1 : removed call to java/lang/Double::valueOf → NO_COVERAGE |
duration / 1000., |
| 499 |
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()); |
| 500 | } | |
| 501 | } catch (Exception e) { | |
| 502 | logger.error("[{}] Failure to compute", device.name(), e); | |
| 503 | throw e; | |
| 504 | } | |
| 505 | ||
| 506 |
6
1. lambda$compute$1 : removed conditional - replaced equality check with true → NO_COVERAGE 2. lambda$compute$1 : removed call to java/util/List::size → NO_COVERAGE 3. lambda$compute$1 : negated conditional → NO_COVERAGE 4. lambda$compute$1 : removed conditional - replaced equality check with false → NO_COVERAGE 5. lambda$compute$1 : Replaced integer subtraction with addition → NO_COVERAGE 6. lambda$compute$1 : Substituted 1 with 0 → NO_COVERAGE |
if (i == stageDescriptors.size() - 1) { |
| 507 |
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( |
| 508 | openCLExecutionContext, | |
| 509 | kernelExecutionContext, | |
| 510 | executorService, | |
| 511 | generation, | |
| 512 | genotypes, | |
| 513 |
2
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/ResultExtractor::<init> → NO_COVERAGE 2. lambda$compute$1 : removed call to java/util/Map::of → NO_COVERAGE |
new ResultExtractor(Map.of(device, resultData))); |
| 514 | ||
| 515 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/MultiStageFitness::clearResultData → NO_COVERAGE |
clearResultData(resultData); |
| 516 | } | |
| 517 | ||
| 518 | for (final CLData clData : reusedArguments) { | |
| 519 |
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()); |
| 520 | } | |
| 521 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/MultiStageFitness::clearData → NO_COVERAGE |
clearData(data); |
| 522 | } | |
| 523 | ||
| 524 |
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 (finalResults == null) { |
| 525 |
1
1. lambda$compute$1 : removed call to java/lang/IllegalStateException::<init> → NO_COVERAGE |
throw new IllegalStateException("final results cannot be null"); |
| 526 | } | |
| 527 |
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; |
| 528 | }, executorService); | |
| 529 | } | |
| 530 | ||
| 531 | @Override | |
| 532 | public void afterEvaluation(OpenCLExecutionContext openCLExecutionContext, ExecutorService executorService, | |
| 533 | long generation, List<Genotype> genotypes) { | |
| 534 |
1
1. afterEvaluation : removed call to net/bmahe/genetics4j/gpu/spec/fitness/OpenCLFitness::afterEvaluation → NO_COVERAGE |
super.afterEvaluation(openCLExecutionContext, executorService, generation, genotypes); |
| 535 | ||
| 536 |
1
1. afterEvaluation : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE |
final var device = openCLExecutionContext.device(); |
| 537 | logger.trace("[{}] Releasing data", device.name()); | |
| 538 | } | |
| 539 | ||
| 540 | @Override | |
| 541 | public void afterAllEvaluations(final OpenCLExecutionContext openCLExecutionContext, | |
| 542 | final ExecutorService executorService) { | |
| 543 |
1
1. afterAllEvaluations : removed call to net/bmahe/genetics4j/gpu/spec/fitness/OpenCLFitness::afterAllEvaluations → NO_COVERAGE |
super.afterAllEvaluations(openCLExecutionContext, executorService); |
| 544 | ||
| 545 |
1
1. afterAllEvaluations : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE |
final var device = openCLExecutionContext.device(); |
| 546 | logger.trace("[{}] Releasing static data", device.name()); | |
| 547 |
1
1. afterAllEvaluations : removed call to net/bmahe/genetics4j/gpu/spec/fitness/MultiStageFitness::clearStaticData → NO_COVERAGE |
clearStaticData(device); |
| 548 | } | |
| 549 | ||
| 550 | /** | |
| 551 | * Creates a new MultiStageFitness instance with the specified configuration. | |
| 552 | * | |
| 553 | * @param <U> the fitness value type | |
| 554 | * @param multiStageDescriptor configuration for multi-stage kernel execution and data management | |
| 555 | * @param fitnessExtractor function to extract fitness values from final stage results | |
| 556 | * @return a new MultiStageFitness instance | |
| 557 | * @throws IllegalArgumentException if any parameter is null | |
| 558 | */ | |
| 559 | public static <U extends Comparable<U>> MultiStageFitness<U> of(final MultiStageDescriptor multiStageDescriptor, | |
| 560 | final FitnessExtractor<U> fitnessExtractor) { | |
| 561 | Validate.notNull(multiStageDescriptor); | |
| 562 | Validate.notNull(fitnessExtractor); | |
| 563 | ||
| 564 |
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); |
| 565 | } | |
| 566 | } | |
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 2.2 |
|
| 287 |
1.1 |
|
| 289 |
1.1 2.2 3.3 4.4 |
|
| 290 |
1.1 2.2 3.3 4.4 5.5 |
|
| 291 |
1.1 |
|
| 308 |
1.1 |
|
| 309 |
1.1 |
|
| 317 |
1.1 2.2 |
|
| 321 |
1.1 |
|
| 323 |
1.1 |
|
| 324 |
1.1 |
|
| 326 |
1.1 |
|
| 327 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
| 328 |
1.1 |
|
| 329 |
1.1 |
|
| 330 |
1.1 |
|
| 332 |
1.1 2.2 |
|
| 339 |
1.1 |
|
| 341 |
1.1 |
|
| 346 |
1.1 |
|
| 347 |
1.1 |
|
| 349 |
1.1 |
|
| 351 |
1.1 |
|
| 352 |
1.1 |
|
| 353 |
1.1 2.2 3.3 4.4 |
|
| 354 |
1.1 2.2 3.3 4.4 |
|
| 356 |
1.1 2.2 3.3 4.4 |
|
| 357 |
1.1 |
|
| 358 |
1.1 |
|
| 359 |
1.1 |
|
| 361 |
1.1 2.2 |
|
| 362 |
1.1 2.2 3.3 |
|
| 365 |
1.1 |
|
| 369 |
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 |
|
| 403 |
1.1 |
|
| 405 |
1.1 2.2 |
|
| 409 |
1.1 2.2 |
|
| 411 |
1.1 2.2 3.3 4.4 |
|
| 413 |
1.1 2.2 |
|
| 418 |
1.1 |
|
| 419 |
1.1 |
|
| 420 |
1.1 2.2 3.3 4.4 5.5 |
|
| 421 |
1.1 2.2 3.3 |
|
| 426 |
1.1 |
|
| 427 |
1.1 |
|
| 428 |
1.1 |
|
| 433 |
1.1 |
|
| 434 |
1.1 2.2 3.3 4.4 |
|
| 437 |
1.1 |
|
| 438 |
1.1 2.2 |
|
| 439 |
1.1 |
|
| 442 |
1.1 |
|
| 444 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
| 445 |
1.1 |
|
| 451 |
1.1 |
|
| 452 |
1.1 |
|
| 453 |
1.1 2.2 |
|
| 454 |
1.1 2.2 |
|
| 457 |
1.1 2.2 3.3 4.4 |
|
| 463 |
1.1 |
|
| 464 |
1.1 |
|
| 465 |
1.1 |
|
| 466 |
1.1 2.2 3.3 |
|
| 470 |
1.1 |
|
| 472 |
1.1 2.2 |
|
| 476 |
1.1 |
|
| 477 |
1.1 2.2 3.3 |
|
| 490 |
1.1 |
|
| 491 |
1.1 |
|
| 493 |
1.1 2.2 |
|
| 497 |
1.1 2.2 3.3 |
|
| 498 |
1.1 |
|
| 499 |
1.1 2.2 |
|
| 506 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
| 507 |
1.1 2.2 |
|
| 513 |
1.1 2.2 |
|
| 515 |
1.1 |
|
| 519 |
1.1 2.2 |
|
| 521 |
1.1 |
|
| 524 |
1.1 2.2 3.3 |
|
| 525 |
1.1 |
|
| 527 |
1.1 |
|
| 534 |
1.1 |
|
| 536 |
1.1 |
|
| 543 |
1.1 |
|
| 545 |
1.1 |
|
| 547 |
1.1 |
|
| 564 |
1.1 2.2 |