diff options
author | Ed Willink | 2017-02-04 11:02:56 +0000 |
---|---|---|
committer | Ed Willink | 2017-02-04 22:37:26 +0000 |
commit | da9c4bb8e0e44f0d00ec7503722e2ebb44bd9eeb (patch) | |
tree | 41dede0f6a76ddd7a1c0d665d5c4b3566b9cbbd6 | |
parent | fcbf56491ccffa608df0b4ef371fcfe239977cf2 (diff) | |
download | org.eclipse.qvtd-da9c4bb8e0e44f0d00ec7503722e2ebb44bd9eeb.tar.gz org.eclipse.qvtd-da9c4bb8e0e44f0d00ec7503722e2ebb44bd9eeb.tar.xz org.eclipse.qvtd-da9c4bb8e0e44f0d00ec7503722e2ebb44bd9eeb.zip |
[511646] Support dynamic scheduling when static fails
2 files changed, 56 insertions, 20 deletions
diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/ScheduleIndexer.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/ScheduleIndexer.java index 13e9c4580..51ebc9d46 100644 --- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/ScheduleIndexer.java +++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/ScheduleIndexer.java @@ -16,7 +16,7 @@ import java.util.List; import org.eclipse.jdt.annotation.NonNull; import org.eclipse.ocl.pivot.utilities.NameUtil; -import org.eclipse.qvtd.compiler.internal.qvtp2qvts.Connection; +import org.eclipse.qvtd.compiler.internal.qvtp2qvts.DatumConnection; import org.eclipse.qvtd.compiler.internal.qvtp2qvts.Region; import org.eclipse.qvtd.compiler.internal.qvtp2qvts.RootScheduledRegion; import org.eclipse.qvtd.compiler.internal.qvtp2qvts.ScheduledRegion; @@ -74,7 +74,7 @@ public class ScheduleIndexer extends ScheduleState Collections.sort(mandatoryBlockedRegionsList, NameUtil.NAMEABLE_COMPARATOR); // List<@NonNull Connection> partiallyBlockedConnectionsList = new ArrayList<@NonNull Connection>(partiallyBlockedConnections); // Collections.sort(partiallyBlockedConnectionsList, NameUtil.NAMEABLE_COMPARATOR); - List<@NonNull Connection> blockedConnectionsList = Lists.newArrayList(getBlockedConnections()); + List<@NonNull DatumConnection> blockedConnectionsList = Lists.newArrayList(getBlockedConnections()); Collections.sort(blockedConnectionsList, NameUtil.NAMEABLE_COMPARATOR); if (QVTp2QVTs.REGION_ORDER.isActive()) { QVTp2QVTs.REGION_ORDER.println(" unblocked regions:"); @@ -141,8 +141,16 @@ public class ScheduleIndexer extends ScheduleState // Scheduler.REGION_ORDER.println(" " + connection); // } QVTp2QVTs.REGION_ORDER.println(" blocked connections:"); - for (@NonNull Connection connection : blockedConnectionsList) { - QVTp2QVTs.REGION_ORDER.println(" " + connection); + for (@NonNull DatumConnection connection : blockedConnectionsList) { + int all = 0; + int unblocked = 0; + for (@NonNull Region sourceRegion : connection.getSourceRegions()) { + all++; + if (Iterables.contains(getUnblockedRegions(), sourceRegion) || Iterables.contains(getOrdering(), sourceRegion)) { + unblocked++; + } + } + QVTp2QVTs.REGION_ORDER.println(" " + connection + " " + unblocked + "/" + all); } } // int debugRegionSize = region2incomingConnections.size(); @@ -191,6 +199,34 @@ public class ScheduleIndexer extends ScheduleState Collections.sort(bestRegions, NameUtil.NAMEABLE_COMPARATOR); return bestRegions.get(0); } + // + // Dynamically scheduled choice + // + for (@NonNull DatumConnection connection : blockedConnectionsList) { + if (connection.isPassed()) { + int all = 0; + int unblocked = 0; + for (@NonNull Region sourceRegion : connection.getSourceRegions()) { + all++; + if (Iterables.contains(getUnblockedRegions(), sourceRegion) || Iterables.contains(getOrdering(), sourceRegion)) { + unblocked++; + } + } + if (0 < unblocked) { + for (@NonNull Region targetRegion : connection.getTargetRegions()) { + all++; + if (!bestRegions.contains(targetRegion) && !Iterables.contains(getOrdering(), targetRegion)) { + bestRegions.add(targetRegion); + } + } + } + + } + } + if (bestRegions.size() > 0) { + Collections.sort(bestRegions, NameUtil.NAMEABLE_COMPARATOR); + return bestRegions.get(0); + } throw new IllegalStateException("Failed to schedule " + scheduledRegion); } }
\ No newline at end of file diff --git a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/ScheduleState.java b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/ScheduleState.java index ad89f1a8e..617561b3d 100644 --- a/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/ScheduleState.java +++ b/plugins/org.eclipse.qvtd.compiler/src/org/eclipse/qvtd/compiler/internal/qvts2qvts/ScheduleState.java @@ -36,24 +36,24 @@ public abstract class ScheduleState extends ScheduleCache /** * Working state: the regions that have not yet been ordered. */ - private final @NonNull Set<@NonNull Region> blockedRegions = new HashSet<@NonNull Region>(); + private final @NonNull Set<@NonNull Region> blockedRegions = new HashSet<>(); /** * Working state: the regions that have not yet been ordered but which are blocked by a mandatory access. */ - private final @NonNull Set<@NonNull Region> mandatoryBlockedRegions = new HashSet<@NonNull Region>(); + private final @NonNull Set<@NonNull Region> mandatoryBlockedRegions = new HashSet<>(); /** * Working state: the regions that have not yet been ordered but whose sources are all fully unblocked. */ - private final @NonNull Set<@NonNull Region> unblockedRegions = new HashSet<@NonNull Region>(); + private final @NonNull Set<@NonNull Region> unblockedRegions = new HashSet<>(); - private final @NonNull Map<@NonNull Region, @NonNull Integer> callableRegion2blockedConnectionCount = new HashMap<@NonNull Region, @NonNull Integer>(); + private final @NonNull Map<@NonNull Region, @NonNull Integer> callableRegion2blockedConnectionCount = new HashMap<>(); /** * Working state: Whether the source has unserviced content for each region's connection source. */ - private final @NonNull Map<@NonNull DatumConnection, @NonNull Map<@NonNull Region, @NonNull Boolean>> connection2sourceRegion2hasContent = new HashMap<@NonNull DatumConnection, @NonNull Map<@NonNull Region, @NonNull Boolean>>(); + private final @NonNull Map<@NonNull DatumConnection, @NonNull Map<@NonNull Region, @NonNull Boolean>> connection2sourceRegion2hasContent = new HashMap<>(); /** * Working state: call stack to access current region. @@ -63,17 +63,17 @@ public abstract class ScheduleState extends ScheduleCache /** * Working state: the regions that have a schedule index to define their order. */ - private final @NonNull List<@NonNull Region> orderedRegions = new ArrayList<@NonNull Region>(); + private final @NonNull List<@NonNull Region> orderedRegions = new ArrayList<>(); /** * Working state: connections that block a region. */ - private final @NonNull Set<@NonNull Connection> blockedConnections = new HashSet<@NonNull Connection>(); + private final @NonNull Set<@NonNull DatumConnection> blockedConnections = new HashSet<>(); /** * Working state: connections that block a region. */ - private final @NonNull Set<@NonNull ScheduledRegion> blockedScheduledRegions = new HashSet<@NonNull ScheduledRegion>(); + private final @NonNull Set<@NonNull ScheduledRegion> blockedScheduledRegions = new HashSet<>(); protected ScheduleState(@NonNull RootScheduledRegion rootScheduledRegion) { super(rootScheduledRegion); @@ -101,7 +101,7 @@ public abstract class ScheduleState extends ScheduleCache Map<@NonNull Region, @NonNull Boolean> sourceRegion2hasContent = connection2sourceRegion2hasContent.get(connection); assert sourceRegion2hasContent != null; /* if (sourceRegion2hasContent == null) { - sourceRegion2hasContent = new HashMap<@NonNull Region, @NonNull Boolean>(); + sourceRegion2hasContent = new HashMap<>(); for (@NonNull Region sourceRegion : connection.getSourceRegions(scheduledRegion)) { sourceRegion2hasContent.put(sourceRegion, Boolean.TRUE); } @@ -110,7 +110,7 @@ public abstract class ScheduleState extends ScheduleCache // Map<@NonNull Region, @NonNull Boolean> targetRegion2hasContent = connection2targetRegion2hasContent.get(connection); // assert targetRegion2hasContent != null; /* if (targetRegion2hasContent == null) { - targetRegion2hasContent = new HashMap<@NonNull Region, @NonNull Boolean>(); + targetRegion2hasContent = new HashMap<>(); for (@NonNull Region targetRegion : connection.getTargetRegions(scheduledRegion)) { targetRegion2hasContent.put(targetRegion, Boolean.TRUE); } @@ -143,7 +143,7 @@ public abstract class ScheduleState extends ScheduleCache } Map<@NonNull Region, @NonNull Boolean> sourceRegion2hasContent = connection2sourceRegion2hasContent.get(connection); if (sourceRegion2hasContent == null) { - sourceRegion2hasContent = new HashMap<@NonNull Region, @NonNull Boolean>(); + sourceRegion2hasContent = new HashMap<>(); for (@NonNull Region sourceRegion : connection.getSourceRegions()) { sourceRegion2hasContent.put(sourceRegion, false); } @@ -168,7 +168,7 @@ public abstract class ScheduleState extends ScheduleCache return callableRegion2blockedConnectionCount.get(region); } - protected @NonNull Iterable<? extends @NonNull Connection> getBlockedConnections() { + protected @NonNull Iterable<? extends @NonNull DatumConnection> getBlockedConnections() { return blockedConnections; } @@ -395,7 +395,7 @@ public abstract class ScheduleState extends ScheduleCache // // Fill outgoingConnections wrt selectedRegion // - Set<@NonNull Region> nextRegions = new HashSet<@NonNull Region>(); + Set<@NonNull Region> nextRegions = new HashSet<>(); for (@NonNull DatumConnection loopingConnection : loopingConnections) { loopingConnection.addIndex(thisIndex); // refreshConnectionBlockage(outgoingConnection, selectedRegion, nextRegions); @@ -410,7 +410,7 @@ public abstract class ScheduleState extends ScheduleCache // assert !alreadyIndexed; // assert loopingConnections != null; // assert outgoingConnections != null; - /* List<@NonNull Connection> connections = new ArrayList<@NonNull Connection>(); + /* List<@NonNull Connection> connections = new ArrayList<>(); connections.addAll(loopingConnections); connections.addAll(outgoingConnections); Collections.sort(connections, NameUtil.NAMEABLE_COMPARATOR); @@ -462,7 +462,7 @@ public abstract class ScheduleState extends ScheduleCache assert wasRemoved0; boolean wasRemoved1 = unblockedRegions.remove(region); boolean wasRemoved2 = callableRegion2blockedConnectionCount.remove(region) != null; - // boolean wasRemoved3 = partiallyBlockedRegions2availableFraction.remove(selectedRegion) != null; - assert wasRemoved1 || wasRemoved2;// || wasRemoved3; + boolean wasRemoved3 = true;//partiallyBlockedRegions2availableFraction.remove(selectedRegion) != null; + assert wasRemoved1 || wasRemoved2 || wasRemoved3; } }
\ No newline at end of file |