Skip to content

Commit

Permalink
Latest updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Rojods committed Jul 12, 2024
1 parent d7360ec commit c748af6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 26 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ lazy val common = (project in file("scala-common"))
// name := "idesyde-scala-common",
libraryDependencies ++= Seq(
"com.lihaoyi" %% "upickle" % upickleVersion,
"com.github.forsyde.IDeSyDe" % "java-core" % globalIDeSyDeJavaVersion,
"com.github.forsyde.IDeSyDe" % "build-java-core" % globalIDeSyDeJavaVersion,
// "com.github.forsyde.IDeSyDe" % "build-java-blueprints" % globalIDeSyDeJavaVersion,
"org.jgrapht" % "jgrapht-core" % jgraphtVersion,
// ("org.scala-graph" %% "graph-core" % scalaGraphVersion).cross(CrossVersion.for3Use2_13),
Expand Down
14 changes: 6 additions & 8 deletions rust-common/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
use idesyde_core::{decision_models_schemas_gen, RustEmbeddedModule};
use models::{
AnalysedSDFApplication, AperiodicAsynchronousDataflow,
AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticore,
AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticoreAndPL,
AperiodicAsynchronousDataflowToPartitionedTiledMulticore, InstrumentedComputationTimes,
InstrumentedMemoryRequirements, MemoryMappableMulticoreWithPL, MemoryMappableMultiCore,
PartitionedMemoryMappableMulticore, PartitionedMemoryMappableMulticoreAndPL,
PartitionedTiledMulticore, RuntimesAndProcessors, SDFApplication, TiledMultiCore,
AnalysedSDFApplication, AperiodicAsynchronousDataflow, AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticore, AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticoreAndPL, AperiodicAsynchronousDataflowToPartitionedTiledMulticore, InstrumentedComputationTimes, InstrumentedMemoryRequirements, MemoryMappableMultiCore, MemoryMappableMulticoreWithPL, PartitionedMemoryMappableMulticore, PartitionedMemoryMappableMulticoreAndPL, PartitionedTiledMulticore, PeriodicWorkloadAndAperiodicAsynchronousDataflowToPartitionedMemoryMappable, RuntimesAndProcessors, SDFApplication, TiledMultiCore
};
use schemars::schema_for;
use std::{collections::HashSet, sync::Arc};
Expand Down Expand Up @@ -41,6 +35,9 @@ pub fn make_module() -> RustEmbeddedModule {
)),
Arc::new(idesyde_core::MarkedIdentificationRule::DecisionModelOnlyIdentificationRule(
irules::identify_analyzed_sdf_from_common_sdf,
)),
Arc::new(idesyde_core::MarkedIdentificationRule::DecisionModelOnlyIdentificationRule(
irules::identify_combined_periodic_workload_and_aad_mem_mappable,
))
])
// .opaque_to_model(opaque_to_model_gen![
Expand Down Expand Up @@ -72,7 +69,8 @@ pub fn make_module() -> RustEmbeddedModule {
PartitionedMemoryMappableMulticore,
PartitionedMemoryMappableMulticoreAndPL,
AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticore,
AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticoreAndPL
AperiodicAsynchronousDataflowToPartitionedMemoryMappableMulticoreAndPL,
PeriodicWorkloadAndAperiodicAsynchronousDataflowToPartitionedMemoryMappable
])
.build()
.expect("Failed to build common standalone identification module. Should never happen.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ trait WorkloadRules {
.mapToLong(r =>
ForSyDeHierarchy.InstrumentedSoftwareBehaviour
.tryView(r)
.map(_.maxSizeInBits().values().asScala.max.toLong)
.map(_.maxSizeInBits().values().asScala.maxOption.map(_.toLong).getOrElse(0L))
.orElse(0L)
)
.sum() + lt
Expand All @@ -298,7 +298,7 @@ trait WorkloadRules {
.mapToLong(r =>
ForSyDeHierarchy.InstrumentedSoftwareBehaviour
.tryView(r)
.map(_.maxSizeInBits().values().asScala.max.toLong)
.map(_.maxSizeInBits().values().asScala.maxOption.map(_.toLong).getOrElse(0L))
.orElse(0L)
)
.sum()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,15 +474,15 @@ final class CanSolvePeriodicWorkloadAndSDFServersToMulticore
)*
)

chocoModel
.getSolver()
.plugMonitor(new IMonitorContradiction {
def onContradiction(cex: ContradictionException): Unit = {
println(cex.toString())
// println(chocoModel.getVars().filter(_.getName().contains("utilization")).mkString(", "))
println(chocoModel.getSolver().getDecisionPath().toString())
}
})
// chocoModel
// .getSolver()
// .plugMonitor(new IMonitorContradiction {
// def onContradiction(cex: ContradictionException): Unit = {
// println(cex.toString())
// // println(chocoModel.getVars().filter(_.getName().contains("utilization")).mkString(", "))
// println(chocoModel.getSolver().getDecisionPath().toString())
// }
// })
(chocoModel, objs.map(o => o.getName() -> o).toMap)
}

Expand All @@ -491,7 +491,6 @@ final class CanSolvePeriodicWorkloadAndSDFServersToMulticore
solution: Solution,
configuration: Explorer.Configuration
): ExplorationSolution = {
println("Rebulding")
val timeValues =
m.wcets.flatten ++ m.platform.hardware.maxTraversalTimePerBit.flatten
.map(
Expand All @@ -518,7 +517,6 @@ final class CanSolvePeriodicWorkloadAndSDFServersToMulticore
// if (configuration.memoryDiscretizationFactor > Int.MaxValue) Int.MaxValue else configuration.memoryDiscretizationFactor.toInt
// )
val intVars = solution.retrieveIntVars(true).asScala
println(intVars.filter(v => v.getName().contains("effect") || v.getName().contains("utilization")).mkString(", "))
val tasksMemoryMapping: Vector[Int] =
m.tasksAndSDFs.workload.processes.zipWithIndex.map((_, i) =>
intVars
Expand Down Expand Up @@ -584,7 +582,6 @@ final class CanSolvePeriodicWorkloadAndSDFServersToMulticore
)
)
val numMappedElements = intVars.find(_.getName() == "nUsedPEs").get
println("Here")
val invThs = intVars.filter(_.getName().startsWith("invTh"))
val dataChannelsSlotAllocations = m.tasksAndSDFs.workload.data_channels.zipWithIndex
.map((c, ci) =>
Expand Down Expand Up @@ -647,7 +644,6 @@ final class CanSolvePeriodicWorkloadAndSDFServersToMulticore
.map((s, i) =>
intVars.find(_.getName().startsWith("utilization(" + i + ")")).get.getLB().toDouble / 100.0
)
println("Before solution")
ExplorationSolution(
(Map(
"nUsedPEs" -> numMappedElements.getValue().toDouble.asInstanceOf[java.lang.Double]
Expand Down
5 changes: 3 additions & 2 deletions scala-choco/src/main/scala/idesyde/choco/ChocoExplorer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import java.util.concurrent.CopyOnWriteArraySet
import idesyde.common.legacy.CommonModule.tryCast
import org.chocosolver.solver.search.loop.monitors.SearchMonitorList
import idesyde.core.OpaqueDecisionModel
import idesyde.core.ExplorationEvent

class ChocoExplorer extends Explorer:

Expand Down Expand Up @@ -290,9 +291,9 @@ class ChocoExplorer extends Explorer:
Stream
.generate(() => {
if (iter.hasNext) {
ExplorationEvent(Some(iter.next()), false)
ExplorationEvent(Some(iter.next()).toJava, false)
} else {
ExplorationEvent(None, true)
ExplorationEvent(java.util.Optional.empty(), true)
}
})
.takeWhile(!_.optimalityProved)
Expand Down

0 comments on commit c748af6

Please sign in to comment.