From f3cd95a7576b87305362c8cc380f57b456d92e33 Mon Sep 17 00:00:00 2001 From: Nelson Tavares de Sousa <stu103017@mail.uni-kiel.de> Date: Fri, 12 Jun 2015 15:56:49 +0200 Subject: [PATCH] added color testing and recursive call to traverse through all stages --- src/main/java/teetime/framework/Analysis.java | 43 ++++++++++++------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/src/main/java/teetime/framework/Analysis.java b/src/main/java/teetime/framework/Analysis.java index 75e68e86..27d42f2f 100644 --- a/src/main/java/teetime/framework/Analysis.java +++ b/src/main/java/teetime/framework/Analysis.java @@ -134,7 +134,7 @@ public final class Analysis<T extends AnalysisConfiguration> implements Uncaught } initialized = true; - instantiatePipes(); + prototypeInstantiatePipes(); final Set<Stage> threadableStageJobs = this.configuration.getThreadableStageJobs(); if (threadableStageJobs.isEmpty()) { @@ -204,25 +204,38 @@ public final class Analysis<T extends AnalysisConfiguration> implements Uncaught Map<Stage, Integer> colors = new HashMap<Stage, Integer>(); Set<Stage> threadableStageJobs = configuration.getThreadableStageJobs(); for (Stage threadableStage : threadableStageJobs) { + i++; colors.put(threadableStage, i); // Markiere den threadHead - for (Connection connection : configuration.getConnections()) { - // Die Connection gehört zu der Stage - if (connection.getSourcePort().getOwningStage() == threadableStage) { - Stage targetStage = connection.getTargetPort().getOwningStage(); - if (threadableStageJobs.contains(targetStage) /* colors.get(targetStage) == i */) { // Auch auf Farbe prüfen - if (connection.getCapacity() != 0) { - interBoundedThreadPipeFactory.create(connection.getSourcePort(), connection.getTargetPort(), connection.getCapacity()); - } else { - interUnboundedThreadPipeFactory.create(connection.getSourcePort(), connection.getTargetPort(), 4); - } + colorAndConnectStages(i, colors, threadableStage); + } + } + + public void colorAndConnectStages(final Integer i, final Map<Stage, Integer> colors, final Stage threadableStage) { + Set<Stage> threadableStageJobs = configuration.getThreadableStageJobs(); + for (Connection connection : configuration.getConnections()) { + // Die Connection gehört zu der Stage + if (connection.getSourcePort().getOwningStage() == threadableStage) { + Stage targetStage = connection.getTargetPort().getOwningStage(); + Integer targetColor = new Integer(0); + if (colors.containsKey(targetStage)) { + targetColor = colors.get(targetStage); + } + if (threadableStageJobs.contains(targetStage) && targetColor.compareTo(i) != 0) { // Auch auf Farbe prüfen + if (connection.getCapacity() != 0) { + interBoundedThreadPipeFactory.create(connection.getSourcePort(), connection.getTargetPort(), connection.getCapacity()); } else { - intraThreadPipeFactory.create(connection.getSourcePort(), connection.getTargetPort()); - colors.put(targetStage, i); + interUnboundedThreadPipeFactory.create(connection.getSourcePort(), connection.getTargetPort(), 4); } - // configuration.getConnections().remove(connection); remove connection to increase performance + } else { + if (colors.containsKey(targetStage)) { + throw new IllegalStateException("Crossing threads"); + } + intraThreadPipeFactory.create(connection.getSourcePort(), connection.getTargetPort()); + colors.put(targetStage, i); } + // configuration.getConnections().remove(connection); remove connection to increase performance + colorAndConnectStages(i, colors, targetStage); } - i++; } } -- GitLab