| 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(StageDescriptor.builder() | |
| 61 | * .kernelName("preprocessing") | |
| 62 | * .addDataLoader(0, inputDataLoader) | |
| 63 | * .addResultAllocator(1, preprocessedResultAllocator) | |
| 64 | * .build()) | |
| 65 | * .addStage(StageDescriptor.builder() | |
| 66 | * .kernelName("fitness_evaluation") | |
| 67 | * .reusePreviousResultAsArgument(1, 0) // Use previous result as input | |
| 68 | * .addResultAllocator(1, fitnessResultAllocator) | |
| 69 | * .build()) | |
| 70 | * .build(); | |
| 71 | * | |
| 72 | * // Define fitness extraction from final stage results | |
| 73 | * FitnessExtractor<Double> extractor = (context, kernelCtx, executor, generation, genotypes, results) -> { | |
| 74 | * float[] fitnessValues = results.extractFloatArray(context, 1); | |
| 75 | * return Arrays.stream(fitnessValues) | |
| 76 | * .mapToDouble(f -> (double) f) | |
| 77 | * .boxed() | |
| 78 | * .collect(Collectors.toList()); | |
| 79 | * }; | |
| 80 | * | |
| 81 | * // Create multi-stage fitness evaluator | |
| 82 | * MultiStageFitness<Double> fitness = MultiStageFitness.of(descriptor, extractor); | |
| 83 | * }</pre> | |
| 84 | * | |
| 85 | * <p>Stage execution workflow: | |
| 86 | * <ol> | |
| 87 | * <li><strong>Initialization</strong>: Load shared static data once before all evaluations</li> | |
| 88 | * <li><strong>Stage iteration</strong>: For each stage in sequence:</li> | |
| 89 | * <li><strong>Context computation</strong>: Calculate kernel execution parameters for the stage</li> | |
| 90 | * <li><strong>Data preparation</strong>: Load stage-specific data and map previous results</li> | |
| 91 | * <li><strong>Kernel execution</strong>: Execute the stage kernel with configured parameters</li> | |
| 92 | * <li><strong>Result management</strong>: Store results for potential use in subsequent stages</li> | |
| 93 | * <li><strong>Final extraction</strong>: Extract fitness values from the last stage results</li> | |
| 94 | * <li><strong>Cleanup</strong>: Release all intermediate and final result memory</li> | |
| 95 | * </ol> | |
| 96 | * | |
| 97 | * <p>Inter-stage data flow patterns: | |
| 98 | * <ul> | |
| 99 | * <li><strong>Result reuse</strong>: Use previous stage output buffers as input to subsequent stages</li> | |
| 100 | * <li><strong>Size propagation</strong>: Use previous stage result sizes as parameters for memory allocation</li> | |
| 101 | * <li><strong>Memory optimization</strong>: Automatic cleanup of intermediate results no longer needed</li> | |
| 102 | * <li><strong>Data type preservation</strong>: Maintain OpenCL data types across stage boundaries</li> | |
| 103 | * </ul> | |
| 104 | * | |
| 105 | * <p>Memory management strategy: | |
| 106 | * <ul> | |
| 107 | * <li><strong>Static data persistence</strong>: Shared parameters allocated once across all stages</li> | |
| 108 | * <li><strong>Intermediate cleanup</strong>: Automatic release of stage results when no longer needed</li> | |
| 109 | * <li><strong>Result chaining</strong>: Efficient memory reuse between consecutive stages</li> | |
| 110 | * <li><strong>Final cleanup</strong>: Complete memory cleanup after fitness extraction</li> | |
| 111 | * </ul> | |
| 112 | * | |
| 113 | * <p>Performance optimization features: | |
| 114 | * <ul> | |
| 115 | * <li><strong>Pipeline efficiency</strong>: Minimized memory transfers between stages</li> | |
| 116 | * <li><strong>Memory coalescing</strong>: Optimized data layouts for GPU memory access</li> | |
| 117 | * <li><strong>Stage-specific tuning</strong>: Individual work group optimization per stage</li> | |
| 118 | * <li><strong>Asynchronous execution</strong>: Non-blocking fitness computation</li> | |
| 119 | * </ul> | |
| 120 | * | |
| 121 | * @param <T> the fitness value type, must be Comparable for optimization algorithms | |
| 122 | * @see OpenCLFitness | |
| 123 | * @see MultiStageDescriptor | |
| 124 | * @see StageDescriptor | |
| 125 | * @see FitnessExtractor | |
| 126 | */ | |
| 127 | public class MultiStageFitness<T extends Comparable<T>> extends OpenCLFitness<T> { | |
| 128 | public static final Logger logger = LogManager.getLogger(MultiStageFitness.class); | |
| 129 | ||
| 130 | private final MultiStageDescriptor multiStageDescriptor; | |
| 131 | private final FitnessExtractor<T> fitnessExtractor; | |
| 132 | ||
| 133 |
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<>(); |
| 134 | ||
| 135 | protected void clearStaticData(final Device device) { | |
| 136 |
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))) { |
| 137 | return; | |
| 138 | } | |
| 139 | ||
| 140 |
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); |
| 141 |
1
1. clearStaticData : removed call to java/util/Map::values → NO_COVERAGE |
for (final CLData clData : mapData.values()) { |
| 142 |
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()); |
| 143 | } | |
| 144 | ||
| 145 |
1
1. clearStaticData : removed call to java/util/Map::clear → NO_COVERAGE |
mapData.clear(); |
| 146 |
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); |
| 147 | } | |
| 148 | ||
| 149 | protected void clearData(final Map<Integer, CLData> data) { | |
| 150 |
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)) { |
| 151 | return; | |
| 152 | } | |
| 153 | ||
| 154 |
1
1. clearData : removed call to java/util/Map::values → NO_COVERAGE |
for (final CLData clData : data.values()) { |
| 155 |
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()); |
| 156 | } | |
| 157 | ||
| 158 |
1
1. clearData : removed call to java/util/Map::clear → NO_COVERAGE |
data.clear(); |
| 159 | } | |
| 160 | ||
| 161 | protected void clearResultData(final Map<Integer, CLData> resultData) { | |
| 162 |
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)) { |
| 163 | return; | |
| 164 | } | |
| 165 | ||
| 166 |
1
1. clearResultData : removed call to java/util/Map::values → NO_COVERAGE |
for (final CLData clData : resultData.values()) { |
| 167 |
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()); |
| 168 | } | |
| 169 | ||
| 170 |
1
1. clearResultData : removed call to java/util/Map::clear → NO_COVERAGE |
resultData.clear(); |
| 171 | } | |
| 172 | ||
| 173 | protected void prepareStaticData(final OpenCLExecutionContext openCLExecutionContext, | |
| 174 | final StageDescriptor stageDescriptor) { | |
| 175 | Validate.notNull(openCLExecutionContext); | |
| 176 | Validate.notNull(stageDescriptor); | |
| 177 | ||
| 178 |
1
1. prepareStaticData : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE |
final var device = openCLExecutionContext.device(); |
| 179 | ||
| 180 | logger.trace("[{}] Preparing static data", device.name()); | |
| 181 | ||
| 182 |
1
1. prepareStaticData : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::kernels → NO_COVERAGE |
final var kernels = openCLExecutionContext.kernels(); |
| 183 |
1
1. prepareStaticData : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::kernelName → NO_COVERAGE |
final var kernelName = stageDescriptor.kernelName(); |
| 184 | ||
| 185 |
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); |
| 186 | ||
| 187 |
1
1. prepareStaticData : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::mapStaticDataAsArgument → NO_COVERAGE |
final var mapStaticDataAsArgument = stageDescriptor.mapStaticDataAsArgument(); |
| 188 |
1
1. prepareStaticData : removed call to java/util/Map::entrySet → NO_COVERAGE |
for (final var entry : mapStaticDataAsArgument.entrySet()) { |
| 189 |
1
1. prepareStaticData : removed call to java/util/Map$Entry::getKey → NO_COVERAGE |
final var argumentName = entry.getKey(); |
| 190 |
1
1. prepareStaticData : removed call to java/util/Map$Entry::getValue → NO_COVERAGE |
final var argumentIndex = entry.getValue(); |
| 191 | ||
| 192 |
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); |
| 193 | ||
| 194 |
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) { |
| 195 |
1
1. prepareStaticData : removed call to java/lang/IllegalArgumentException::<init> → NO_COVERAGE |
throw new IllegalArgumentException("Unknown static argument " + argumentName); |
| 196 | } | |
| 197 | ||
| 198 |
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); |
| 199 | ||
| 200 | logger.trace("[{}] Index {} - Loading static data with name {}", device.name(), argumentIndex, argumentName); | |
| 201 | ||
| 202 |
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())); |
| 203 | } | |
| 204 | } | |
| 205 | ||
| 206 | private void allocateLocalMemory(OpenCLExecutionContext openCLExecutionContext, StageDescriptor stageDescriptor, | |
| 207 | long generation, List<Genotype> genotypes, final KernelExecutionContext kernelExecutionContext) { | |
| 208 | Validate.notNull(openCLExecutionContext); | |
| 209 | Validate.notNull(stageDescriptor); | |
| 210 | Validate.notNull(kernelExecutionContext); | |
| 211 | ||
| 212 |
1
1. allocateLocalMemory : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE |
final var device = openCLExecutionContext.device(); |
| 213 | ||
| 214 | logger.trace("[{}] Allocating local memory", device.name()); | |
| 215 | ||
| 216 |
1
1. allocateLocalMemory : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::kernels → NO_COVERAGE |
final var kernels = openCLExecutionContext.kernels(); |
| 217 |
1
1. allocateLocalMemory : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::kernelName → NO_COVERAGE |
final var kernelName = stageDescriptor.kernelName(); |
| 218 | ||
| 219 |
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); |
| 220 | ||
| 221 |
1
1. allocateLocalMemory : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::localMemoryAllocators → NO_COVERAGE |
final var localMemoryAllocators = stageDescriptor.localMemoryAllocators(); |
| 222 |
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)) { |
| 223 |
1
1. allocateLocalMemory : removed call to java/util/Map::entrySet → NO_COVERAGE |
for (final var entry : localMemoryAllocators.entrySet()) { |
| 224 |
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(); |
| 225 |
1
1. allocateLocalMemory : removed call to java/util/Map$Entry::getValue → NO_COVERAGE |
final var localMemoryAllocator = entry.getValue(); |
| 226 | ||
| 227 | final var size = localMemoryAllocator | |
| 228 |
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); |
| 229 | logger.trace("[{}] Index {} - Setting local data with size of {}", device.name(), argumentIdx, size); | |
| 230 | ||
| 231 |
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); |
| 232 | } | |
| 233 | } | |
| 234 | } | |
| 235 | ||
| 236 | protected void loadData(final OpenCLExecutionContext openCLExecutionContext, final StageDescriptor stageDescriptor, | |
| 237 | final Map<Integer, CLData> data, final long generation, final List<Genotype> genotypes) { | |
| 238 | Validate.notNull(openCLExecutionContext); | |
| 239 | Validate.notNull(stageDescriptor); | |
| 240 | Validate.notNull(data); | |
| 241 | ||
| 242 |
1
1. loadData : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE |
final var device = openCLExecutionContext.device(); |
| 243 | ||
| 244 | logger.trace("[{}] Loading data", device.name()); | |
| 245 | ||
| 246 |
1
1. loadData : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::kernels → NO_COVERAGE |
final var kernels = openCLExecutionContext.kernels(); |
| 247 |
1
1. loadData : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::kernelName → NO_COVERAGE |
final var kernelName = stageDescriptor.kernelName(); |
| 248 | ||
| 249 |
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); |
| 250 | ||
| 251 |
1
1. loadData : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::dataLoaders → NO_COVERAGE |
final var dataLoaders = stageDescriptor.dataLoaders(); |
| 252 |
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)) { |
| 253 |
1
1. loadData : removed call to java/util/Map::entrySet → NO_COVERAGE |
for (final var entry : dataLoaders.entrySet()) { |
| 254 |
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(); |
| 255 |
1
1. loadData : removed call to java/util/Map$Entry::getValue → NO_COVERAGE |
final var dataLoader = entry.getValue(); |
| 256 | ||
| 257 |
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); |
| 258 | ||
| 259 |
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) { |
| 260 |
1
1. loadData : removed call to java/lang/IllegalArgumentException::<init> → NO_COVERAGE |
throw new IllegalArgumentException("Multiple data configured for index " + argumentIdx); |
| 261 | } | |
| 262 | logger.trace("[{}] Index {} - Loading data of size {}", device.name(), argumentIdx, clDdata.size()); | |
| 263 | ||
| 264 |
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())); |
| 265 | } | |
| 266 | } | |
| 267 | } | |
| 268 | ||
| 269 | @Override | |
| 270 | public void beforeAllEvaluations(final OpenCLExecutionContext openCLExecutionContext, | |
| 271 | final ExecutorService executorService) { | |
| 272 |
1
1. beforeAllEvaluations : removed call to net/bmahe/genetics4j/gpu/spec/fitness/OpenCLFitness::beforeAllEvaluations → NO_COVERAGE |
super.beforeAllEvaluations(openCLExecutionContext, executorService); |
| 273 | ||
| 274 |
1
1. beforeAllEvaluations : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE |
final var device = openCLExecutionContext.device(); |
| 275 | ||
| 276 | logger.trace("[{}] Loading static data", device.name()); | |
| 277 |
1
1. beforeAllEvaluations : removed call to net/bmahe/genetics4j/gpu/spec/fitness/MultiStageFitness::clearStaticData → NO_COVERAGE |
clearStaticData(device); |
| 278 | ||
| 279 |
1
1. beforeAllEvaluations : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/MultiStageDescriptor::staticDataLoaders → NO_COVERAGE |
final var staticDataLoaders = multiStageDescriptor.staticDataLoaders(); |
| 280 |
1
1. beforeAllEvaluations : removed call to java/util/Map::entrySet → NO_COVERAGE |
for (final var entry : staticDataLoaders.entrySet()) { |
| 281 |
1
1. beforeAllEvaluations : removed call to java/util/Map$Entry::getKey → NO_COVERAGE |
final String argumentName = entry.getKey(); |
| 282 |
1
1. beforeAllEvaluations : removed call to java/util/Map$Entry::getValue → NO_COVERAGE |
final var dataSupplier = entry.getValue(); |
| 283 | ||
| 284 | if (logger.isTraceEnabled()) { | |
| 285 |
1
1. beforeAllEvaluations : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE |
final var deviceName = openCLExecutionContext.device() |
| 286 |
1
1. beforeAllEvaluations : removed call to net/bmahe/genetics4j/gpu/opencl/model/Device::name → NO_COVERAGE |
.name(); |
| 287 | logger.trace("[{}] Loading static data for entry name {}", deviceName, argumentName); | |
| 288 | } | |
| 289 |
1
1. beforeAllEvaluations : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/StaticDataLoader::load → NO_COVERAGE |
final CLData clData = dataSupplier.load(openCLExecutionContext); |
| 290 | ||
| 291 |
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<>()); |
| 292 |
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) { |
| 293 |
1
1. beforeAllEvaluations : removed call to java/lang/IllegalArgumentException::<init> → NO_COVERAGE |
throw new IllegalArgumentException("Multiple data configured with name " + argumentName); |
| 294 | } | |
| 295 | } | |
| 296 | } | |
| 297 | ||
| 298 | /** | |
| 299 | * Constructs a MultiStageFitness with the specified stage descriptor and fitness extractor. | |
| 300 | * | |
| 301 | * @param _multiStageDescriptor configuration for multi-stage kernel execution and data management | |
| 302 | * @param _fitnessExtractor function to extract fitness values from final stage results | |
| 303 | * @throws IllegalArgumentException if any parameter is null | |
| 304 | */ | |
| 305 | public MultiStageFitness(final MultiStageDescriptor _multiStageDescriptor, | |
| 306 | final FitnessExtractor<T> _fitnessExtractor) { | |
| 307 | Validate.notNull(_multiStageDescriptor); | |
| 308 | Validate.notNull(_fitnessExtractor); | |
| 309 | ||
| 310 |
1
1. <init> : Removed assignment to member variable multiStageDescriptor → NO_COVERAGE |
this.multiStageDescriptor = _multiStageDescriptor; |
| 311 |
1
1. <init> : Removed assignment to member variable fitnessExtractor → NO_COVERAGE |
this.fitnessExtractor = _fitnessExtractor; |
| 312 | } | |
| 313 | ||
| 314 | @Override | |
| 315 | public CompletableFuture<List<T>> compute(final OpenCLExecutionContext openCLExecutionContext, | |
| 316 | final ExecutorService executorService, final long generation, final List<Genotype> genotypes) { | |
| 317 | Validate.notNull(openCLExecutionContext); | |
| 318 | ||
| 319 |
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(() -> { |
| 320 | ||
| 321 | List<T> finalResults = null; | |
| 322 | ||
| 323 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE |
final var device = openCLExecutionContext.device(); |
| 324 | ||
| 325 |
1
1. lambda$compute$1 : removed call to java/util/concurrent/ConcurrentHashMap::<init> → NO_COVERAGE |
final Map<Integer, CLData> data = new ConcurrentHashMap<>(); |
| 326 |
1
1. lambda$compute$1 : removed call to java/util/concurrent/ConcurrentHashMap::<init> → NO_COVERAGE |
Map<Integer, CLData> resultData = new ConcurrentHashMap<>(); |
| 327 | ||
| 328 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/MultiStageDescriptor::stageDescriptors → NO_COVERAGE |
final var stageDescriptors = multiStageDescriptor.stageDescriptors(); |
| 329 |
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++) { |
| 330 |
1
1. lambda$compute$1 : removed call to java/util/List::get → NO_COVERAGE |
final StageDescriptor stageDescriptor = stageDescriptors.get(i); |
| 331 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::kernels → NO_COVERAGE |
final var kernels = openCLExecutionContext.kernels(); |
| 332 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::kernelName → NO_COVERAGE |
final var kernelName = stageDescriptor.kernelName(); |
| 333 | ||
| 334 |
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); |
| 335 | ||
| 336 | logger.debug("[{}] Executing {}-th stage for kernel {}", device.name(), i, kernelName); | |
| 337 | ||
| 338 | /** | |
| 339 | * Compute the Kernel Execution Context | |
| 340 | */ | |
| 341 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::kernelExecutionContextComputer → NO_COVERAGE |
final var kernelExecutionContextComputer = stageDescriptor.kernelExecutionContextComputer(); |
| 342 | final var kernelExecutionContext = kernelExecutionContextComputer | |
| 343 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/kernelcontext/KernelExecutionContextComputer::compute → NO_COVERAGE |
.compute(openCLExecutionContext, kernelName, generation, genotypes); |
| 344 | ||
| 345 | /** | |
| 346 | * Map previous results to new arguments | |
| 347 | */ | |
| 348 |
1
1. lambda$compute$1 : removed call to java/util/HashMap::<init> → NO_COVERAGE |
final Map<Integer, CLData> oldResultData = new HashMap<>(resultData); |
| 349 |
1
1. lambda$compute$1 : removed call to java/util/concurrent/ConcurrentHashMap::<init> → NO_COVERAGE |
resultData = new ConcurrentHashMap<>(); |
| 350 | final Map<Integer, Integer> reusePreviousResultSizeAsArguments = stageDescriptor | |
| 351 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::reusePreviousResultSizeAsArguments → NO_COVERAGE |
.reusePreviousResultSizeAsArguments(); |
| 352 | final Map<Integer, Integer> reusePreviousResultAsArguments = stageDescriptor | |
| 353 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/multistage/StageDescriptor::reusePreviousResultAsArguments → NO_COVERAGE |
.reusePreviousResultAsArguments(); |
| 354 |
1
1. lambda$compute$1 : removed call to java/util/HashSet::<init> → NO_COVERAGE |
final Set<CLData> reusedArguments = new HashSet<>(); |
| 355 |
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) |
| 356 |
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)) { |
| 357 | ||
| 358 |
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)) { |
| 359 |
1
1. lambda$compute$1 : removed call to java/util/Map::entrySet → NO_COVERAGE |
for (final Entry<Integer, Integer> entry : reusePreviousResultAsArguments.entrySet()) { |
| 360 |
1
1. lambda$compute$1 : removed call to java/util/Map$Entry::getKey → NO_COVERAGE |
final var oldKeyArgument = entry.getKey(); |
| 361 |
1
1. lambda$compute$1 : removed call to java/util/Map$Entry::getValue → NO_COVERAGE |
final var newKeyArgument = entry.getValue(); |
| 362 | ||
| 363 |
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); |
| 364 |
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) { |
| 365 | logger.error( | |
| 366 | "[{}] Could not find previous argument with index {}. Known previous arguments: {}", | |
| 367 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/model/Device::name → NO_COVERAGE |
device.name(), |
| 368 | oldKeyArgument, | |
| 369 | oldResultData); | |
| 370 | ||
| 371 |
1
1. lambda$compute$1 : removed call to java/lang/IllegalArgumentException::<init> → NO_COVERAGE |
throw new IllegalArgumentException( |
| 372 | "Could not find previous argument with index " + oldKeyArgument); | |
| 373 | } | |
| 374 | ||
| 375 | logger.trace("[{}] Index {} - Reuse previous result that had index {}", | |
| 376 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/model/Device::name → NO_COVERAGE |
device.name(), |
| 377 | newKeyArgument, | |
| 378 | oldKeyArgument); | |
| 379 |
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())); |
| 380 |
1
1. lambda$compute$1 : removed call to java/util/Set::add → NO_COVERAGE |
reusedArguments.add(previousResultData); |
| 381 | } | |
| 382 | } | |
| 383 | ||
| 384 |
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)) { |
| 385 |
1
1. lambda$compute$1 : removed call to java/util/Map::entrySet → NO_COVERAGE |
for (final Entry<Integer, Integer> entry : reusePreviousResultSizeAsArguments.entrySet()) { |
| 386 |
1
1. lambda$compute$1 : removed call to java/util/Map$Entry::getKey → NO_COVERAGE |
final var oldKeyArgument = entry.getKey(); |
| 387 |
1
1. lambda$compute$1 : removed call to java/util/Map$Entry::getValue → NO_COVERAGE |
final var newKeyArgument = entry.getValue(); |
| 388 | ||
| 389 |
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); |
| 390 |
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) { |
| 391 | logger.error( | |
| 392 | "[{}] Could not find previous argument with index {}. Known previous arguments: {}", | |
| 393 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/model/Device::name → NO_COVERAGE |
device.name(), |
| 394 | oldKeyArgument, | |
| 395 | oldResultData); | |
| 396 | ||
| 397 |
1
1. lambda$compute$1 : removed call to java/lang/IllegalArgumentException::<init> → NO_COVERAGE |
throw new IllegalArgumentException( |
| 398 | "Could not find previous argument with index " + oldKeyArgument); | |
| 399 | } | |
| 400 | ||
| 401 | if (logger.isTraceEnabled()) { | |
| 402 | logger.trace("[{}] 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(kernel, |
| 410 |
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, |
| 411 | Sizeof.cl_int, | |
| 412 |
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() })); |
| 413 | } | |
| 414 | } | |
| 415 | ||
| 416 | // Clean up unused results | |
| 417 |
1
1. lambda$compute$1 : removed call to java/util/Map::keySet → NO_COVERAGE |
final var previousResultsToKeep = reusePreviousResultAsArguments.keySet(); |
| 418 |
1
1. lambda$compute$1 : removed call to java/util/Map::entrySet → NO_COVERAGE |
for (Entry<Integer, CLData> entry2 : oldResultData.entrySet()) { |
| 419 |
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) { |
| 420 |
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() |
| 421 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/cldata/CLData::clMem → NO_COVERAGE |
.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 : 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)) { |
| 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 : 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) { |
| 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("[{}] Index {} - Allocate result data memory of type {} and size {}", | |
| 450 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/model/Device::name → NO_COVERAGE |
device.name(), |
| 451 |
1
1. lambda$compute$1 : removed call to java/lang/Integer::valueOf → NO_COVERAGE |
argumentIdx, |
| 452 |
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(), |
| 453 |
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()); |
| 454 | } | |
| 455 | ||
| 456 |
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())); |
| 457 | } | |
| 458 | } else { | |
| 459 | logger.trace("[{}] No result allocator found", device.name()); | |
| 460 | } | |
| 461 | ||
| 462 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::clCommandQueue → NO_COVERAGE |
final var clCommandQueue = openCLExecutionContext.clCommandQueue(); |
| 463 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/kernelcontext/KernelExecutionContext::globalWorkDimensions → NO_COVERAGE |
final var globalWorkDimensions = kernelExecutionContext.globalWorkDimensions(); |
| 464 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/kernelcontext/KernelExecutionContext::globalWorkSize → NO_COVERAGE |
final var globalWorkSize = kernelExecutionContext.globalWorkSize(); |
| 465 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/kernelcontext/KernelExecutionContext::workGroupSize → NO_COVERAGE |
final long[] workGroupSize = kernelExecutionContext.workGroupSize() |
| 466 |
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); |
| 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 : 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, |
| 478 | kernel, | |
| 479 | globalWorkDimensions, | |
| 480 | null, | |
| 481 | globalWorkSize, | |
| 482 | workGroupSize, | |
| 483 | 0, | |
| 484 | null, | |
| 485 | null); | |
| 486 | ||
| 487 | // CL.clFinish(openCLExecutionContext.clCommandQueue()); | |
| 488 | ||
| 489 |
1
1. lambda$compute$1 : removed call to java/lang/System::nanoTime → NO_COVERAGE |
final long endTime = System.nanoTime(); |
| 490 |
1
1. lambda$compute$1 : Replaced long subtraction with addition → NO_COVERAGE |
final long duration = endTime - startTime; |
| 491 | if (logger.isDebugEnabled()) { | |
| 492 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE |
final var deviceName = openCLExecutionContext.device() |
| 493 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/opencl/model/Device::name → NO_COVERAGE |
.name(); |
| 494 | logger.debug("[{}] - Stage {} - Took {} microsec for {} genotypes", | |
| 495 | deviceName, | |
| 496 |
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, |
| 497 |
1
1. lambda$compute$1 : removed call to java/lang/Double::valueOf → NO_COVERAGE |
duration / 1000., |
| 498 |
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()); |
| 499 | } | |
| 500 | } catch (Exception e) { | |
| 501 | logger.error("[{}] Failure to compute", device.name(), e); | |
| 502 | throw e; | |
| 503 | } | |
| 504 | ||
| 505 |
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) { |
| 506 |
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, |
| 507 | kernelExecutionContext, | |
| 508 | executorService, | |
| 509 | generation, | |
| 510 | genotypes, | |
| 511 |
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))); |
| 512 | ||
| 513 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/MultiStageFitness::clearResultData → NO_COVERAGE |
clearResultData(resultData); |
| 514 | } | |
| 515 | ||
| 516 | for (final CLData clData : reusedArguments) { | |
| 517 |
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()); |
| 518 | } | |
| 519 |
1
1. lambda$compute$1 : removed call to net/bmahe/genetics4j/gpu/spec/fitness/MultiStageFitness::clearData → NO_COVERAGE |
clearData(data); |
| 520 | } | |
| 521 | ||
| 522 |
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) { |
| 523 |
1
1. lambda$compute$1 : removed call to java/lang/IllegalStateException::<init> → NO_COVERAGE |
throw new IllegalStateException("final results cannot be null"); |
| 524 | } | |
| 525 |
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; |
| 526 | }, executorService); | |
| 527 | } | |
| 528 | ||
| 529 | @Override | |
| 530 | public void afterEvaluation(OpenCLExecutionContext openCLExecutionContext, ExecutorService executorService, | |
| 531 | long generation, List<Genotype> genotypes) { | |
| 532 |
1
1. afterEvaluation : removed call to net/bmahe/genetics4j/gpu/spec/fitness/OpenCLFitness::afterEvaluation → NO_COVERAGE |
super.afterEvaluation(openCLExecutionContext, executorService, generation, genotypes); |
| 533 | ||
| 534 |
1
1. afterEvaluation : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE |
final var device = openCLExecutionContext.device(); |
| 535 | logger.trace("[{}] Releasing data", device.name()); | |
| 536 | } | |
| 537 | ||
| 538 | @Override | |
| 539 | public void afterAllEvaluations(final OpenCLExecutionContext openCLExecutionContext, | |
| 540 | final ExecutorService executorService) { | |
| 541 |
1
1. afterAllEvaluations : removed call to net/bmahe/genetics4j/gpu/spec/fitness/OpenCLFitness::afterAllEvaluations → NO_COVERAGE |
super.afterAllEvaluations(openCLExecutionContext, executorService); |
| 542 | ||
| 543 |
1
1. afterAllEvaluations : removed call to net/bmahe/genetics4j/gpu/opencl/OpenCLExecutionContext::device → NO_COVERAGE |
final var device = openCLExecutionContext.device(); |
| 544 | logger.trace("[{}] Releasing static data", device.name()); | |
| 545 |
1
1. afterAllEvaluations : removed call to net/bmahe/genetics4j/gpu/spec/fitness/MultiStageFitness::clearStaticData → NO_COVERAGE |
clearStaticData(device); |
| 546 | } | |
| 547 | ||
| 548 | /** | |
| 549 | * Creates a new MultiStageFitness instance with the specified configuration. | |
| 550 | * | |
| 551 | * @param <U> the fitness value type | |
| 552 | * @param multiStageDescriptor configuration for multi-stage kernel execution and data management | |
| 553 | * @param fitnessExtractor function to extract fitness values from final stage results | |
| 554 | * @return a new MultiStageFitness instance | |
| 555 | * @throws IllegalArgumentException if any parameter is null | |
| 556 | */ | |
| 557 | public static <U extends Comparable<U>> MultiStageFitness<U> of(final MultiStageDescriptor multiStageDescriptor, | |
| 558 | final FitnessExtractor<U> fitnessExtractor) { | |
| 559 | Validate.notNull(multiStageDescriptor); | |
| 560 | Validate.notNull(fitnessExtractor); | |
| 561 | ||
| 562 |
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); |
| 563 | } | |
| 564 | } | |
Mutations | ||
| 133 |
1.1 2.2 |
|
| 136 |
1.1 2.2 3.3 4.4 5.5 6.6 7.7 8.8 9.9 10.10 |
|
| 140 |
1.1 2.2 |
|
| 141 |
1.1 |
|
| 142 |
1.1 2.2 |
|
| 145 |
1.1 |
|
| 146 |
1.1 2.2 |
|
| 150 |
1.1 2.2 3.3 4.4 |
|
| 154 |
1.1 |
|
| 155 |
1.1 2.2 |
|
| 158 |
1.1 |
|
| 162 |
1.1 2.2 3.3 4.4 |
|
| 166 |
1.1 |
|
| 167 |
1.1 2.2 |
|
| 170 |
1.1 |
|
| 178 |
1.1 |
|
| 182 |
1.1 |
|
| 183 |
1.1 |
|
| 185 |
1.1 2.2 |
|
| 187 |
1.1 |
|
| 188 |
1.1 |
|
| 189 |
1.1 |
|
| 190 |
1.1 |
|
| 192 |
1.1 2.2 |
|
| 194 |
1.1 2.2 3.3 4.4 |
|
| 195 |
1.1 |
|
| 198 |
1.1 2.2 |
|
| 202 |
1.1 2.2 3.3 4.4 5.5 |
|
| 212 |
1.1 |
|
| 216 |
1.1 |
|
| 217 |
1.1 |
|
| 219 |
1.1 2.2 |
|
| 221 |
1.1 |
|
| 222 |
1.1 2.2 3.3 4.4 |
|
| 223 |
1.1 |
|
| 224 |
1.1 2.2 |
|
| 225 |
1.1 |
|
| 228 |
1.1 2.2 |
|
| 231 |
1.1 2.2 |
|
| 242 |
1.1 |
|
| 246 |
1.1 |
|
| 247 |
1.1 |
|
| 249 |
1.1 2.2 |
|
| 251 |
1.1 |
|
| 252 |
1.1 2.2 3.3 4.4 |
|
| 253 |
1.1 |
|
| 254 |
1.1 2.2 |
|
| 255 |
1.1 |
|
| 257 |
1.1 |
|
| 259 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
| 260 |
1.1 |
|
| 264 |
1.1 2.2 3.3 4.4 |
|
| 272 |
1.1 |
|
| 274 |
1.1 |
|
| 277 |
1.1 |
|
| 279 |
1.1 |
|
| 280 |
1.1 |
|
| 281 |
1.1 |
|
| 282 |
1.1 |
|
| 285 |
1.1 |
|
| 286 |
1.1 |
|
| 289 |
1.1 |
|
| 291 |
1.1 2.2 3.3 4.4 |
|
| 292 |
1.1 2.2 3.3 4.4 5.5 |
|
| 293 |
1.1 |
|
| 310 |
1.1 |
|
| 311 |
1.1 |
|
| 319 |
1.1 2.2 |
|
| 323 |
1.1 |
|
| 325 |
1.1 |
|
| 326 |
1.1 |
|
| 328 |
1.1 |
|
| 329 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
| 330 |
1.1 |
|
| 331 |
1.1 |
|
| 332 |
1.1 |
|
| 334 |
1.1 2.2 |
|
| 341 |
1.1 |
|
| 343 |
1.1 |
|
| 348 |
1.1 |
|
| 349 |
1.1 |
|
| 351 |
1.1 |
|
| 353 |
1.1 |
|
| 354 |
1.1 |
|
| 355 |
1.1 2.2 3.3 4.4 |
|
| 356 |
1.1 2.2 3.3 4.4 |
|
| 358 |
1.1 2.2 3.3 4.4 |
|
| 359 |
1.1 |
|
| 360 |
1.1 |
|
| 361 |
1.1 |
|
| 363 |
1.1 2.2 |
|
| 364 |
1.1 2.2 3.3 |
|
| 367 |
1.1 |
|
| 371 |
1.1 |
|
| 376 |
1.1 |
|
| 379 |
1.1 2.2 3.3 4.4 5.5 |
|
| 380 |
1.1 |
|
| 384 |
1.1 2.2 3.3 4.4 |
|
| 385 |
1.1 |
|
| 386 |
1.1 |
|
| 387 |
1.1 |
|
| 389 |
1.1 2.2 |
|
| 390 |
1.1 2.2 3.3 |
|
| 393 |
1.1 |
|
| 397 |
1.1 |
|
| 403 |
1.1 |
|
| 405 |
1.1 2.2 |
|
| 409 |
1.1 2.2 |
|
| 410 |
1.1 2.2 3.3 4.4 |
|
| 412 |
1.1 2.2 |
|
| 417 |
1.1 |
|
| 418 |
1.1 |
|
| 419 |
1.1 2.2 3.3 4.4 5.5 |
|
| 420 |
1.1 2.2 |
|
| 421 |
1.1 |
|
| 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 |
|
| 450 |
1.1 |
|
| 451 |
1.1 |
|
| 452 |
1.1 2.2 |
|
| 453 |
1.1 2.2 |
|
| 456 |
1.1 2.2 3.3 4.4 |
|
| 462 |
1.1 |
|
| 463 |
1.1 |
|
| 464 |
1.1 |
|
| 465 |
1.1 |
|
| 466 |
1.1 2.2 |
|
| 470 |
1.1 |
|
| 472 |
1.1 2.2 |
|
| 476 |
1.1 |
|
| 477 |
1.1 2.2 3.3 |
|
| 489 |
1.1 |
|
| 490 |
1.1 |
|
| 492 |
1.1 |
|
| 493 |
1.1 |
|
| 496 |
1.1 2.2 3.3 |
|
| 497 |
1.1 |
|
| 498 |
1.1 2.2 |
|
| 505 |
1.1 2.2 3.3 4.4 5.5 6.6 |
|
| 506 |
1.1 2.2 |
|
| 511 |
1.1 2.2 |
|
| 513 |
1.1 |
|
| 517 |
1.1 2.2 |
|
| 519 |
1.1 |
|
| 522 |
1.1 2.2 3.3 |
|
| 523 |
1.1 |
|
| 525 |
1.1 |
|
| 532 |
1.1 |
|
| 534 |
1.1 |
|
| 541 |
1.1 |
|
| 543 |
1.1 |
|
| 545 |
1.1 |
|
| 562 |
1.1 2.2 |