-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
538 additions
and
183 deletions.
There are no files selected for viewing
140 changes: 70 additions & 70 deletions
140
...eriodicAsynchronousDataflowToPartitionedMemoryMappableMulticoreReverseIdentification.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,70 +1,70 @@ | ||
package idesyde.forsydeio; | ||
|
||
import idesyde.common.AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticore; | ||
import idesyde.core.DecisionModel; | ||
import idesyde.core.DesignModel; | ||
import idesyde.core.ReverseIdentificationRule; | ||
|
||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import forsyde.io.core.SystemGraph; | ||
import forsyde.io.lib.hierarchy.ForSyDeHierarchy; | ||
|
||
public class AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticoreReverseIdentification implements ReverseIdentificationRule { | ||
|
||
private Set<DesignModel> innerReverseIdentifyAperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticore( | ||
Set<AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticore> solvedModels, | ||
Set<ForSyDeIODesignModel> designModels) { | ||
return solvedModels.stream().map(model -> { | ||
var reversedSystemGraph = new SystemGraph(); | ||
model.processesToMemoryMapping().forEach((process, mem) -> { | ||
designModels.stream().flatMap(m -> m.systemGraph().queryVertex(process).stream()).findAny().ifPresent(procVertex -> { | ||
designModels.stream().flatMap(m -> m.systemGraph().queryVertex(mem).stream()).findAny().ifPresent(memVertex -> { | ||
reversedSystemGraph.addVertex(procVertex); | ||
reversedSystemGraph.addVertex(memVertex); | ||
var memMapped = ForSyDeHierarchy.MemoryMapped.enforce(reversedSystemGraph, procVertex); | ||
memMapped.mappingHost(ForSyDeHierarchy.GenericMemoryModule.enforce(reversedSystemGraph, memVertex)); | ||
ForSyDeHierarchy.GreyBox.enforce(reversedSystemGraph, memVertex).addContained(ForSyDeHierarchy.Visualizable.enforce(memMapped)); | ||
}); | ||
}); | ||
}); | ||
model.bufferToMemoryMappings().forEach((buf, mem) -> { | ||
designModels.stream().flatMap(m -> m.systemGraph().queryVertex(buf).stream()).findAny().ifPresent(procVertex -> { | ||
designModels.stream().flatMap(m -> m.systemGraph().queryVertex(mem).stream()).findAny().ifPresent(memVertex -> { | ||
reversedSystemGraph.addVertex(procVertex); | ||
reversedSystemGraph.addVertex(memVertex); | ||
var memMapped = ForSyDeHierarchy.MemoryMapped.enforce(reversedSystemGraph, procVertex); | ||
memMapped.mappingHost(ForSyDeHierarchy.GenericMemoryModule.enforce(reversedSystemGraph, memVertex)); | ||
ForSyDeHierarchy.GreyBox.enforce(reversedSystemGraph, memVertex).addContained(ForSyDeHierarchy.Visualizable.enforce(memMapped)); | ||
}); | ||
}); | ||
}); | ||
model.processesToRuntimeScheduling().forEach((process, sched) -> { | ||
designModels.stream().flatMap(m -> m.systemGraph().queryVertex(process).stream()).findAny().ifPresent(procVertex -> { | ||
designModels.stream().flatMap(m -> m.systemGraph().queryVertex(sched).stream()).findAny().ifPresent(schedVertex -> { | ||
reversedSystemGraph.addVertex(procVertex); | ||
reversedSystemGraph.addVertex(schedVertex); | ||
var scheduled = ForSyDeHierarchy.Scheduled.enforce(reversedSystemGraph, procVertex); | ||
scheduled.runtimeHost(ForSyDeHierarchy.AbstractRuntime.enforce(reversedSystemGraph, schedVertex)); | ||
ForSyDeHierarchy.GreyBox.enforce(reversedSystemGraph, schedVertex).addContained(ForSyDeHierarchy.Visualizable.enforce(scheduled)); | ||
}); | ||
}); | ||
}); | ||
model.superLoopSchedules().forEach((sched, looplist) -> { | ||
designModels.stream().flatMap(m -> m.systemGraph().queryVertex(sched).stream()).findAny().ifPresent(schedVertex -> { | ||
var scheduler = ForSyDeHierarchy.SuperLoopRuntime.enforce(reversedSystemGraph, schedVertex); | ||
scheduler.superLoopEntries(looplist); | ||
}); | ||
}); | ||
return new ForSyDeIODesignModel(reversedSystemGraph); | ||
}).collect(Collectors.toSet()); | ||
} | ||
|
||
@Override | ||
public Set<DesignModel> apply(Set<? extends DecisionModel> t, Set<? extends DesignModel> u) { | ||
var filteredSolved = t.stream().filter(x -> x instanceof AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticore).map(x -> (AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticore) x).collect(Collectors.toSet()); | ||
var filteredDesign = u.stream().filter(x -> x instanceof ForSyDeIODesignModel).map(x -> (ForSyDeIODesignModel) x).collect(Collectors.toSet()); | ||
return innerReverseIdentifyAperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticore(filteredSolved, filteredDesign); | ||
} | ||
} | ||
package idesyde.forsydeio; | ||
|
||
import idesyde.common.AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticore; | ||
import idesyde.core.DecisionModel; | ||
import idesyde.core.DesignModel; | ||
import idesyde.core.ReverseIdentificationRule; | ||
|
||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import forsyde.io.core.SystemGraph; | ||
import forsyde.io.lib.hierarchy.ForSyDeHierarchy; | ||
|
||
public class AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticoreReverseIdentification implements ReverseIdentificationRule { | ||
|
||
private Set<DesignModel> innerReverseIdentifyAperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticore( | ||
Set<AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticore> solvedModels, | ||
Set<ForSyDeIODesignModel> designModels) { | ||
return solvedModels.stream().map(model -> { | ||
var reversedSystemGraph = new SystemGraph(); | ||
model.processesToMemoryMapping().forEach((process, mem) -> { | ||
designModels.stream().flatMap(m -> m.systemGraph().queryVertex(process).stream()).findAny().ifPresent(procVertex -> { | ||
designModels.stream().flatMap(m -> m.systemGraph().queryVertex(mem).stream()).findAny().ifPresent(memVertex -> { | ||
reversedSystemGraph.addVertex(procVertex); | ||
reversedSystemGraph.addVertex(memVertex); | ||
var memMapped = ForSyDeHierarchy.MemoryMapped.enforce(reversedSystemGraph, procVertex); | ||
memMapped.mappingHost(ForSyDeHierarchy.GenericMemoryModule.enforce(reversedSystemGraph, memVertex)); | ||
ForSyDeHierarchy.GreyBox.enforce(reversedSystemGraph, memVertex).addContained(ForSyDeHierarchy.Visualizable.enforce(memMapped)); | ||
}); | ||
}); | ||
}); | ||
model.bufferToMemoryMappings().forEach((buf, mem) -> { | ||
designModels.stream().flatMap(m -> m.systemGraph().queryVertex(buf).stream()).findAny().ifPresent(procVertex -> { | ||
designModels.stream().flatMap(m -> m.systemGraph().queryVertex(mem).stream()).findAny().ifPresent(memVertex -> { | ||
reversedSystemGraph.addVertex(procVertex); | ||
reversedSystemGraph.addVertex(memVertex); | ||
var memMapped = ForSyDeHierarchy.MemoryMapped.enforce(reversedSystemGraph, procVertex); | ||
memMapped.mappingHost(ForSyDeHierarchy.GenericMemoryModule.enforce(reversedSystemGraph, memVertex)); | ||
ForSyDeHierarchy.GreyBox.enforce(reversedSystemGraph, memVertex).addContained(ForSyDeHierarchy.Visualizable.enforce(memMapped)); | ||
}); | ||
}); | ||
}); | ||
model.processesToRuntimeScheduling().forEach((process, sched) -> { | ||
designModels.stream().flatMap(m -> m.systemGraph().queryVertex(process).stream()).findAny().ifPresent(procVertex -> { | ||
designModels.stream().flatMap(m -> m.systemGraph().queryVertex(sched).stream()).findAny().ifPresent(schedVertex -> { | ||
reversedSystemGraph.addVertex(procVertex); | ||
reversedSystemGraph.addVertex(schedVertex); | ||
var scheduled = ForSyDeHierarchy.Scheduled.enforce(reversedSystemGraph, procVertex); | ||
scheduled.runtimeHost(ForSyDeHierarchy.AbstractRuntime.enforce(reversedSystemGraph, schedVertex)); | ||
ForSyDeHierarchy.GreyBox.enforce(reversedSystemGraph, schedVertex).addContained(ForSyDeHierarchy.Visualizable.enforce(scheduled)); | ||
}); | ||
}); | ||
}); | ||
model.superLoopSchedules().forEach((sched, looplist) -> { | ||
designModels.stream().flatMap(m -> m.systemGraph().queryVertex(sched).stream()).findAny().ifPresent(schedVertex -> { | ||
var scheduler = ForSyDeHierarchy.SuperLoopRuntime.enforce(reversedSystemGraph, schedVertex); | ||
scheduler.superLoopEntries(looplist); | ||
}); | ||
}); | ||
return new ForSyDeIODesignModel(reversedSystemGraph); | ||
}).collect(Collectors.toSet()); | ||
} | ||
|
||
@Override | ||
public Set<DesignModel> apply(Set<? extends DecisionModel> t, Set<? extends DesignModel> u) { | ||
var filteredSolved = t.stream().filter(x -> x instanceof AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticore).map(x -> (AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticore) x).collect(Collectors.toSet()); | ||
var filteredDesign = u.stream().filter(x -> x instanceof ForSyDeIODesignModel).map(x -> (ForSyDeIODesignModel) x).collect(Collectors.toSet()); | ||
return innerReverseIdentifyAperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticore(filteredSolved, filteredDesign); | ||
} | ||
} |
84 changes: 42 additions & 42 deletions
84
java-bridge-forsyde-io/src/main/java/idesyde/forsydeio/ForSyDeIODesignModel.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
package idesyde.forsydeio; | ||
|
||
import forsyde.io.bridge.sdf3.drivers.SDF3Driver; | ||
import forsyde.io.core.EdgeInfo; | ||
import forsyde.io.core.ModelHandler; | ||
import forsyde.io.core.SystemGraph; | ||
import forsyde.io.core.Vertex; | ||
import forsyde.io.lib.hierarchy.ForSyDeHierarchy; | ||
import forsyde.io.lib.LibForSyDeModelHandler; | ||
import idesyde.core.DesignModel; | ||
import idesyde.core.headers.DesignModelHeader; | ||
|
||
import java.util.Optional; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
public record ForSyDeIODesignModel( | ||
SystemGraph systemGraph) implements DesignModel { | ||
|
||
@Override | ||
public DesignModelHeader header() { | ||
return new DesignModelHeader( | ||
"ForSyDeIODesignModel", | ||
Stream.concat(systemGraph.vertexSet().stream().map(Vertex::getIdentifier), | ||
systemGraph.edgeSet().stream().map(EdgeInfo::toIDString)).collect(Collectors.toSet()), | ||
Set.of()); | ||
} | ||
|
||
@Override | ||
public Optional<String> bodyAsString() { | ||
try { | ||
return Optional.of(modelHandler.printModel(systemGraph, "fiodl")); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
return Optional.empty(); | ||
} | ||
} | ||
|
||
public static ModelHandler modelHandler = LibForSyDeModelHandler.registerLibForSyDe(new ModelHandler()) | ||
.registerDriver(new SDF3Driver()); | ||
} | ||
package idesyde.forsydeio; | ||
|
||
import forsyde.io.bridge.sdf3.drivers.SDF3Driver; | ||
import forsyde.io.core.EdgeInfo; | ||
import forsyde.io.core.ModelHandler; | ||
import forsyde.io.core.SystemGraph; | ||
import forsyde.io.core.Vertex; | ||
import forsyde.io.lib.hierarchy.ForSyDeHierarchy; | ||
import forsyde.io.lib.LibForSyDeModelHandler; | ||
import idesyde.core.DesignModel; | ||
import idesyde.core.headers.DesignModelHeader; | ||
|
||
import java.util.Optional; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.Stream; | ||
|
||
public record ForSyDeIODesignModel( | ||
SystemGraph systemGraph) implements DesignModel { | ||
|
||
@Override | ||
public DesignModelHeader header() { | ||
return new DesignModelHeader( | ||
"ForSyDeIODesignModel", | ||
Stream.concat(systemGraph.vertexSet().stream().map(Vertex::getIdentifier), | ||
systemGraph.edgeSet().stream().map(EdgeInfo::toIDString)).collect(Collectors.toSet()), | ||
Set.of()); | ||
} | ||
|
||
@Override | ||
public Optional<String> bodyAsString() { | ||
try { | ||
return Optional.of(modelHandler.printModel(systemGraph, "fiodl")); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
return Optional.empty(); | ||
} | ||
} | ||
|
||
public static ModelHandler modelHandler = LibForSyDeModelHandler.registerLibForSyDe(new ModelHandler()) | ||
.registerDriver(new SDF3Driver()); | ||
} |
142 changes: 71 additions & 71 deletions
142
java-bridge-forsyde-io/src/main/java/idesyde/forsydeio/ForSyDeIOIdentificationModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,71 @@ | ||
package idesyde.forsydeio; | ||
|
||
import idesyde.blueprints.DecisionModelMessage; | ||
import idesyde.blueprints.DesignModelMessage; | ||
import idesyde.blueprints.StandaloneIdentificationModule; | ||
import idesyde.common.AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticore; | ||
import idesyde.core.DecisionModel; | ||
import idesyde.core.DesignModel; | ||
import idesyde.core.IdentificationRule; | ||
import idesyde.core.ReverseIdentificationRule; | ||
|
||
import java.nio.file.Paths; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
import forsyde.io.core.ModelHandler; | ||
|
||
public class ForSyDeIOIdentificationModule implements StandaloneIdentificationModule { | ||
|
||
ModelHandler modelHandler = ForSyDeIODesignModel.modelHandler; | ||
|
||
@Override | ||
public Optional<DesignModel> designMessageToModel(DesignModelMessage message) { | ||
var pathOpt = message.header().modelPaths().stream().map(x -> Paths.get(x)) | ||
.filter(x -> modelHandler.canLoadModel(x)).findAny(); | ||
var extIdxOpt = pathOpt.map(x -> x.getFileName().toString().indexOf(".")); | ||
var extOpt = extIdxOpt.flatMap(x -> pathOpt.map(p -> p.getFileName().toString().substring(x + 1))); | ||
return message.body().flatMap(b -> extOpt.flatMap(ext -> { | ||
try { | ||
return Optional.of(new ForSyDeIODesignModel(modelHandler.readModel(b, ext))); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
return Optional.empty(); | ||
} | ||
})); | ||
} | ||
|
||
@Override | ||
public Optional<DecisionModel> decisionMessageToModel(DecisionModelMessage message) { | ||
switch (message.header().category()) { | ||
case "AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticore": | ||
return message.body().flatMap(b -> readFromString(b, | ||
AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticore.class)); | ||
default: | ||
return Optional.empty(); | ||
} | ||
} | ||
|
||
@Override | ||
public String uniqueIdentifier() { | ||
return "ForSyDeIOIdentificationModule"; | ||
} | ||
|
||
@Override | ||
public Set<ReverseIdentificationRule> reverseIdentificationRules() { | ||
return Set.of( | ||
new AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticoreReverseIdentification()); | ||
} | ||
|
||
@Override | ||
public Set<IdentificationRule> identificationRules() { | ||
return Set.of( | ||
new MemoryMappableMultiCoreIRule(), | ||
new ForSyDeIOSYNetworkToAADataflowIRule()); | ||
} | ||
|
||
public static void main(String[] args) { | ||
var server = new ForSyDeIOIdentificationModule().standaloneIdentificationModule(args); | ||
server.ifPresent(s -> s.start(0)); | ||
} | ||
} | ||
package idesyde.forsydeio; | ||
|
||
import idesyde.blueprints.DecisionModelMessage; | ||
import idesyde.blueprints.DesignModelMessage; | ||
import idesyde.blueprints.StandaloneIdentificationModule; | ||
import idesyde.common.AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticore; | ||
import idesyde.core.DecisionModel; | ||
import idesyde.core.DesignModel; | ||
import idesyde.core.IdentificationRule; | ||
import idesyde.core.ReverseIdentificationRule; | ||
|
||
import java.nio.file.Paths; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
import forsyde.io.core.ModelHandler; | ||
|
||
public class ForSyDeIOIdentificationModule implements StandaloneIdentificationModule { | ||
|
||
ModelHandler modelHandler = ForSyDeIODesignModel.modelHandler; | ||
|
||
@Override | ||
public Optional<DesignModel> designMessageToModel(DesignModelMessage message) { | ||
var pathOpt = message.header().modelPaths().stream().map(x -> Paths.get(x)) | ||
.filter(x -> modelHandler.canLoadModel(x)).findAny(); | ||
var extIdxOpt = pathOpt.map(x -> x.getFileName().toString().indexOf(".")); | ||
var extOpt = extIdxOpt.flatMap(x -> pathOpt.map(p -> p.getFileName().toString().substring(x + 1))); | ||
return message.body().flatMap(b -> extOpt.flatMap(ext -> { | ||
try { | ||
return Optional.of(new ForSyDeIODesignModel(modelHandler.readModel(b, ext))); | ||
} catch (Exception e) { | ||
e.printStackTrace(); | ||
return Optional.empty(); | ||
} | ||
})); | ||
} | ||
|
||
@Override | ||
public Optional<DecisionModel> decisionMessageToModel(DecisionModelMessage message) { | ||
switch (message.header().category()) { | ||
case "AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticore": | ||
return message.body().flatMap(b -> readFromString(b, | ||
AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticore.class)); | ||
default: | ||
return Optional.empty(); | ||
} | ||
} | ||
|
||
@Override | ||
public String uniqueIdentifier() { | ||
return "ForSyDeIOIdentificationModule"; | ||
} | ||
|
||
@Override | ||
public Set<ReverseIdentificationRule> reverseIdentificationRules() { | ||
return Set.of( | ||
new AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticoreReverseIdentification()); | ||
} | ||
|
||
@Override | ||
public Set<IdentificationRule> identificationRules() { | ||
return Set.of( | ||
new MemoryMappableMultiCoreIRule(), | ||
new ForSyDeIOSYNetworkToAADataflowIRule()); | ||
} | ||
|
||
public static void main(String[] args) { | ||
var server = new ForSyDeIOIdentificationModule().standaloneIdentificationModule(args); | ||
server.ifPresent(s -> s.start(0)); | ||
} | ||
} |
Oops, something went wrong.