Skip to content

Commit

Permalink
Add SemanticsExporter to easily access Semantics info
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin-delmas committed Dec 12, 2024
1 parent 129079c commit 5616745
Show file tree
Hide file tree
Showing 10 changed files with 278 additions and 167 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ package onera.pmlanalyzer.pml.examples.mySys
import onera.pmlanalyzer.pml.exporters.*
import onera.pmlanalyzer.pml.model.utils.Message
import onera.pmlanalyzer.pml.operators.*
import onera.pmlanalyzer.views.interference.examples.mySys.{MySysApplicativeTableBasedInterferenceSpecification, MySysPhysicalTableBasedInterferenceSpecification}

import onera.pmlanalyzer.views.interference.examples.mySys.{MySysInterferenceSpecification, MyProcInterferenceSpecification}
import onera.pmlanalyzer.views.interference.exporters.*
/**
* Program entry point to export several version of Keystone
*/
Expand All @@ -35,8 +35,8 @@ object MySysExport extends App {
object MySys extends MyProcPlatform
with MySysLibraryConfiguration
with MyProcRoutingConfiguration
with MySysPhysicalTableBasedInterferenceSpecification
with MySysApplicativeTableBasedInterferenceSpecification
with MyProcInterferenceSpecification
with MySysInterferenceSpecification

// Export only HW used by SW (explicit)
MySys.exportRestrictedHWAndSWGraph()
Expand Down Expand Up @@ -64,4 +64,5 @@ object MySysExport extends App {
// Export the transactions defined by the user
MySys.exportUserScenarios()

MySys.exportSemanticsSize()
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import onera.pmlanalyzer.views.interference.operators.*
* }
* }}}
*/
trait MySysPhysicalTableBasedInterferenceSpecification extends PhysicalTableBasedInterferenceSpecification {
trait MyProcInterferenceSpecification extends PhysicalTableBasedInterferenceSpecification {
self: MyProcPlatform =>

//Encoding of Rule 1 and Rule 2
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*******************************************************************************
* Copyright (c) 2023. ONERA
* This file is part of PML Analyzer
*
* PML Analyzer is free software ;
* you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation ;
* either version 2 of the License, or (at your option) any later version.
*
* PML Analyzer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY ;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this program ;
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
******************************************************************************/

package onera.pmlanalyzer.views.interference.examples.mySys

import onera.pmlanalyzer.pml.examples.mySys.MySysExport.*
import onera.pmlanalyzer.views.interference.operators.*

import scala.concurrent.duration.*
import scala.language.postfixOps

/**
* Compute the interference of the SimpleKeystone defined in [[pml.examples.mySys.MySysExport]]
*/
object MySysInterferenceGeneration extends App {
// Compute only up to 2-ite and 2-free
MySys.computeKInterference(2, 2 hours)

// Compute all ite and itf for benchmarks
MySys.computeAllInterference( 2 hours, ignoreExistingAnalysisFiles = true)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import onera.pmlanalyzer.views.interference.operators.*
* {{{app3 notInterfereWith TeraNet.periph_bus.loads}}}
* @see [[views.interference.operators.Exclusive.Ops]] for interfere operator definition
*/
trait MySysApplicativeTableBasedInterferenceSpecification extends ApplicativeTableBasedInterferenceSpecification {
trait MySysInterferenceSpecification extends ApplicativeTableBasedInterferenceSpecification {
self: MyProcPlatform with MySysTransactionLibrary with MySysLibraryConfiguration with MySysSoftwareAllocation =>

app22 exclusiveWith app3
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*******************************************************************************
* Copyright (c) 2023. ONERA
* This file is part of PML Analyzer
*
* PML Analyzer is free software ;
* you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation ;
* either version 2 of the License, or (at your option) any later version.
*
* PML Analyzer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY ;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this program ;
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
******************************************************************************/

package onera.pmlanalyzer.views.interference.examples

/**
* Package containing an example on a simplification of a TI Keystone platform
* @see [[MyProcPhysicalTableBasedInterferenceSpecification]] provides an example of hardware interference assumption modelling
* @see [[MySysInterferenceSpecification]] provides an example of application interference assumption modelling
* @see [[MySysInterferenceGeneration]] provides an example of interference analysis for the simplified
* Keystone platform
*/
package object mySys
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ import onera.pmlanalyzer.pml.exporters.UMLExporter.DOTServiceOnly
import onera.pmlanalyzer.pml.exporters.{FileManager, UMLExporter}
import onera.pmlanalyzer.pml.model.hardware.Platform
import onera.pmlanalyzer.views.interference.model.specification.InterferenceSpecification
import onera.pmlanalyzer.views.interference.model.specification.InterferenceSpecification.{PhysicalScenarioId, scenarioSetId}
import onera.pmlanalyzer.views.interference.model.specification.InterferenceSpecification.{PhysicalScenarioId, multiTransactionId}

import java.io.FileWriter

object InterferenceGraphExporter {
trait Ops {
implicit class InterferenceGraphExporterOps(x: Platform with InterferenceSpecification) extends UMLExporter.Ops {
def exportGraph(it: Set[PhysicalScenarioId]): Unit = {
val scenarioSetName = scenarioSetId(it.map(x => PhysicalScenarioId(x.id)))
val multiTransactionName = multiTransactionId(it.map(x => PhysicalScenarioId(x.id)))
implicit val writer: FileWriter = new FileWriter(FileManager.exportDirectory.getFile(
s"${x.fullName}_${if(scenarioSetName.id.name.length >= 100) scenarioSetName.hashCode.toString else scenarioSetName}.dot"
s"${x.fullName}_${if(multiTransactionName.id.name.length >= 100) multiTransactionName.hashCode.toString else multiTransactionName}.dot"
))
DOTServiceOnly.resetService()
DOTServiceOnly.writeHeader
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*******************************************************************************
* Copyright (c) 2023. ONERA
* This file is part of PML Analyzer
*
* PML Analyzer is free software ;
* you can redistribute it and/or modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation ;
* either version 2 of the License, or (at your option) any later version.
*
* PML Analyzer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY ;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this program ;
* if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
******************************************************************************/

package onera.pmlanalyzer.views.interference.exporters

import onera.pmlanalyzer.pml.model.hardware.{Hardware, Platform}
import onera.pmlanalyzer.pml.operators.Provided
import onera.pmlanalyzer.views.interference.operators.*
import onera.pmlanalyzer.pml.exporters.FileManager

import java.io.{File, FileWriter}

object SemanticsExporter {
trait Ops {
extension[T<: Platform](self:T) {
def exportSemanticsSize()(using ev: Analyse[T],p:Provided[T,Hardware]): File = {
val file = FileManager.exportDirectory.getFile(self.fullName + "SemanticsSize.txt")
val writer = new FileWriter(file)
val semantics = self.getSemanticsSize
writer.write("Multi-transaction cardinal, Number\n")
for( (i,n) <- semantics)
writer.write(s"$i, $n\n")
writer.close()
file
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ package onera.pmlanalyzer.views.interference
* Example of usages are provided in ???
*/
package object exporters extends IDPExporter.Ops
with InterferenceGraphExporter.Ops
with InterferenceGraphExporter.Ops
with SemanticsExporter.Ops
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ trait InterferenceSpecification
* @param t the identifier of the transaction
* @return the path of the transaction
*/
final def purify(t: PhysicalTransactionId): PhysicalTransaction = transactionsByName.get(t) match {
private final def purify(t: PhysicalTransactionId): PhysicalTransaction = transactionsByName.get(t) match {
case Some(h :: tail) =>
(h +: (transactionInterfereWith(t).toList.sortBy(_.name.name) ++ tail)).filterNot(transactionNotInterfereWith(t))
case _ => Nil
Expand Down Expand Up @@ -337,18 +337,18 @@ object InterferenceSpecification {

case class PhysicalScenarioId(id: Symbol) extends Id

case class PhysicalScenarioSetId(id: Symbol) extends Id
case class PhysicalMultiTransactionId(id: Symbol) extends Id

case class ChannelId(id: Symbol) extends Id

def scenarioSetId(t: Iterable[PhysicalScenarioId]): PhysicalScenarioSetId =
PhysicalScenarioSetId(Symbol(t.map(_.id.name).toArray.sorted.mkString("< ", " || ", " >")))
def multiTransactionId(t: Iterable[PhysicalScenarioId]): PhysicalMultiTransactionId =
PhysicalMultiTransactionId(Symbol(t.map(_.id.name).toArray.sorted.mkString("< ", " || ", " >")))

def channelId(t: Set[Service]): ChannelId =
ChannelId(Symbol(t.map(_.toString).toArray.sorted.mkString("{ ", ", ", " }")))

def groupedScenarioLitId(s: Set[PhysicalScenarioId]): PhysicalScenarioSetId =
PhysicalScenarioSetId(Symbol(scenarioSetId(s).id.name.replace(" ", "")))
def groupedScenarioLitId(s: Set[PhysicalScenarioId]): PhysicalMultiTransactionId =
PhysicalMultiTransactionId(Symbol(multiTransactionId(s).id.name.replace(" ", "")))


trait Default extends InterferenceSpecification {
Expand Down
Loading

0 comments on commit 5616745

Please sign in to comment.