From 8090701228f6980b776577647b0b0c018b23fc80 Mon Sep 17 00:00:00 2001 From: Shaokai Jerry Lin Date: Thu, 7 Nov 2024 14:56:46 -0800 Subject: [PATCH] Apply spotless --- .../org/lflang/analyses/dag/DagGenerator.java | 25 +++++++++++-------- .../analyses/pretvm/InstructionGenerator.java | 8 ++---- .../analyses/scheduler/EgsScheduler.java | 19 ++++++++------ .../scheduler/LoadBalancedScheduler.java | 4 +-- .../analyses/scheduler/MocasinScheduler.java | 4 +-- .../analyses/scheduler/StaticScheduler.java | 3 ++- .../generator/c/CStaticScheduleGenerator.java | 8 +++--- 7 files changed, 38 insertions(+), 33 deletions(-) diff --git a/core/src/main/java/org/lflang/analyses/dag/DagGenerator.java b/core/src/main/java/org/lflang/analyses/dag/DagGenerator.java index 9a15daa932..b6e556ae9a 100644 --- a/core/src/main/java/org/lflang/analyses/dag/DagGenerator.java +++ b/core/src/main/java/org/lflang/analyses/dag/DagGenerator.java @@ -9,12 +9,9 @@ import java.util.PriorityQueue; import java.util.Set; import java.util.stream.Collectors; - -import org.lflang.MessageReporter; import org.lflang.TimeUnit; import org.lflang.TimeValue; import org.lflang.analyses.dag.DagNode.dagNodeType; -import org.lflang.analyses.scheduler.StaticScheduler; import org.lflang.analyses.statespace.StateSpaceDiagram; import org.lflang.analyses.statespace.StateSpaceExplorer.Phase; import org.lflang.analyses.statespace.StateSpaceNode; @@ -386,23 +383,29 @@ public Dag generateDag(StateSpaceDiagram stateSpaceDiagram) { /** * Check if a DAG meets certain criteria of a scheduler. + * * @return true if it is, false if it is not. */ - public void validateDag(Dag dag, StaticSchedulerType.StaticScheduler schedulerType, int fragmentId) { + public void validateDag( + Dag dag, StaticSchedulerType.StaticScheduler schedulerType, int fragmentId) { // Check if the DAG is acyclic. if (!dag.isValidDAG()) - throw new RuntimeException("The DAG is invalid:" + " fragment " + fragmentId); + throw new RuntimeException("The DAG is invalid:" + " fragment " + fragmentId); // If the EGS scheduler is in use, disallow WCETs of 0, because EGS // might generate a partition mixing reactions and dummy nodes. if (schedulerType == StaticSchedulerType.StaticScheduler.EGS) { - boolean wcetOfZeroDetected = dag.dagNodes.stream() - .filter(node -> node.nodeType == dagNodeType.REACTION) - .map(node -> node.nodeReaction) - .flatMap(reaction -> reaction.wcets.stream()) - .anyMatch(wcet -> wcet.equals(TimeValue.ZERO)); + boolean wcetOfZeroDetected = + dag.dagNodes.stream() + .filter(node -> node.nodeType == dagNodeType.REACTION) + .map(node -> node.nodeReaction) + .flatMap(reaction -> reaction.wcets.stream()) + .anyMatch(wcet -> wcet.equals(TimeValue.ZERO)); if (wcetOfZeroDetected) { - throw new RuntimeException("A WCET of 0 is detected. When EGS scheduler is used, WCETs cannot be 0, otherwise reaction nodes and virtual nodes might be on the same partition. Please update the reaction WCETs."); + throw new RuntimeException( + "A WCET of 0 is detected. When EGS scheduler is used, WCETs cannot be 0, otherwise" + + " reaction nodes and virtual nodes might be on the same partition. Please update" + + " the reaction WCETs."); } } } diff --git a/core/src/main/java/org/lflang/analyses/pretvm/InstructionGenerator.java b/core/src/main/java/org/lflang/analyses/pretvm/InstructionGenerator.java index 11a0cb4271..f9024e1dc5 100644 --- a/core/src/main/java/org/lflang/analyses/pretvm/InstructionGenerator.java +++ b/core/src/main/java/org/lflang/analyses/pretvm/InstructionGenerator.java @@ -592,7 +592,7 @@ public PretVmObjectFile generateInstructions(Dag dagParitioned, StateSpaceFragme // ALTERNATIVE DESIGN: remove the DU here and let the head node, // instead of the tail node, handle DU. This potentially allows // breaking the hyperperiod boundary. - // + // // At this point, the global offset register has been // updated in SYNC_BLOCK. // @@ -602,11 +602,7 @@ public PretVmObjectFile generateInstructions(Dag dagParitioned, StateSpaceFragme // contribute the lag at the beginning of the hyperperiod. if (!targetConfig.get(FastProperty.INSTANCE)) addInstructionForWorker( - instructions, - worker, - current, - null, - new InstructionDU(registers.offset, 0L)); + instructions, worker, current, null, new InstructionDU(registers.offset, 0L)); } } } diff --git a/core/src/main/java/org/lflang/analyses/scheduler/EgsScheduler.java b/core/src/main/java/org/lflang/analyses/scheduler/EgsScheduler.java index 4aec207276..c7b552b80f 100644 --- a/core/src/main/java/org/lflang/analyses/scheduler/EgsScheduler.java +++ b/core/src/main/java/org/lflang/analyses/scheduler/EgsScheduler.java @@ -9,7 +9,6 @@ import java.util.HashSet; import java.util.List; import java.util.Set; - import org.lflang.MessageReporter; import org.lflang.analyses.dag.Dag; import org.lflang.analyses.dag.DagNode; @@ -32,7 +31,8 @@ public EgsScheduler(CFileConfig fileConfig) { this.fileConfig = fileConfig; } - public Dag partitionDag(Dag dag, MessageReporter reporter, int fragmentId, int workers, String filePostfix) { + public Dag partitionDag( + Dag dag, MessageReporter reporter, int fragmentId, int workers, String filePostfix) { // Set all Paths and files Path src = this.fileConfig.srcPath; Path graphDir = fileConfig.getSrcGenPath().resolve("graphs"); @@ -56,7 +56,8 @@ public Dag partitionDag(Dag dag, MessageReporter reporter, int fragmentId, int w "--out_dot", partionedDagDotFile.toString(), "--workers", - String.valueOf(workers+1), // There needs to be +1 for the dummy nodes, otherwise EGS complains. + String.valueOf( + workers + 1), // There needs to be +1 for the dummy nodes, otherwise EGS complains. "--model", new File(egsDir, "models/pretrained").getAbsolutePath()); @@ -105,11 +106,13 @@ public Dag partitionDag(Dag dag, MessageReporter reporter, int fragmentId, int w // Check that the returned number of workers is less than the one set by the user if (egsNumberOfWorkers > workers) { - reporter.nowhere().error( - "The EGS scheduler returned a minimum number of workers of " - + egsNumberOfWorkers - + " while the user specified number is " - + workers); + reporter + .nowhere() + .error( + "The EGS scheduler returned a minimum number of workers of " + + egsNumberOfWorkers + + " while the user specified number is " + + workers); } // Define a color for each worker diff --git a/core/src/main/java/org/lflang/analyses/scheduler/LoadBalancedScheduler.java b/core/src/main/java/org/lflang/analyses/scheduler/LoadBalancedScheduler.java index b9c6dafa40..3590910f2c 100644 --- a/core/src/main/java/org/lflang/analyses/scheduler/LoadBalancedScheduler.java +++ b/core/src/main/java/org/lflang/analyses/scheduler/LoadBalancedScheduler.java @@ -6,7 +6,6 @@ import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; - import org.lflang.MessageReporter; import org.lflang.analyses.dag.Dag; import org.lflang.analyses.dag.DagNode; @@ -40,7 +39,8 @@ public long getTotalWCET() { } } - public Dag partitionDag(Dag dag, MessageReporter reporter, int fragmentId, int numWorkers, String filePostfix) { + public Dag partitionDag( + Dag dag, MessageReporter reporter, int fragmentId, int numWorkers, String filePostfix) { // Prune redundant edges. dag.removeRedundantEdges(); diff --git a/core/src/main/java/org/lflang/analyses/scheduler/MocasinScheduler.java b/core/src/main/java/org/lflang/analyses/scheduler/MocasinScheduler.java index 734be4d2ee..6957e3f5e5 100644 --- a/core/src/main/java/org/lflang/analyses/scheduler/MocasinScheduler.java +++ b/core/src/main/java/org/lflang/analyses/scheduler/MocasinScheduler.java @@ -27,7 +27,6 @@ import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; import javax.xml.validation.Validator; - import org.lflang.MessageReporter; import org.lflang.TimeValue; import org.lflang.analyses.dag.Dag; @@ -297,7 +296,8 @@ public static boolean validateXMLSchema(String xsdPath, String xmlPath) { } /** Main function for assigning nodes to workers */ - public Dag partitionDag(Dag dagRaw, MessageReporter reporter, int fragmentId, int numWorkers, String filePostfix) { + public Dag partitionDag( + Dag dagRaw, MessageReporter reporter, int fragmentId, int numWorkers, String filePostfix) { // Prune redundant edges. dagRaw.removeRedundantEdges(); diff --git a/core/src/main/java/org/lflang/analyses/scheduler/StaticScheduler.java b/core/src/main/java/org/lflang/analyses/scheduler/StaticScheduler.java index 150948c593..bb4f0b9a6b 100644 --- a/core/src/main/java/org/lflang/analyses/scheduler/StaticScheduler.java +++ b/core/src/main/java/org/lflang/analyses/scheduler/StaticScheduler.java @@ -9,7 +9,8 @@ * @author Shaokai Lin */ public interface StaticScheduler { - public Dag partitionDag(Dag dag, MessageReporter reporter, int fragmentId, int workers, String filePostfix); + public Dag partitionDag( + Dag dag, MessageReporter reporter, int fragmentId, int workers, String filePostfix); public int setNumberOfWorkers(); } diff --git a/core/src/main/java/org/lflang/generator/c/CStaticScheduleGenerator.java b/core/src/main/java/org/lflang/generator/c/CStaticScheduleGenerator.java index 30b3378e28..363f5971fd 100644 --- a/core/src/main/java/org/lflang/generator/c/CStaticScheduleGenerator.java +++ b/core/src/main/java/org/lflang/generator/c/CStaticScheduleGenerator.java @@ -135,7 +135,8 @@ public void generate() { StaticScheduler scheduler = createStaticScheduler(); // Store the static scheduler type. - StaticSchedulerType.StaticScheduler schedulerType = targetConfig.get(SchedulerProperty.INSTANCE).staticScheduler(); + StaticSchedulerType.StaticScheduler schedulerType = + targetConfig.get(SchedulerProperty.INSTANCE).staticScheduler(); // Determine the number of workers, if unspecified. if (this.workers == 0) { @@ -173,7 +174,7 @@ public void generate() { // Validate the generated raw DAG. dagGenerator.validateDag(dag, schedulerType, i); - + // Generate a dot file. Path file = graphDir.resolve("dag_raw" + "_frag_" + i + ".dot"); dag.generateDotFile(file); @@ -181,7 +182,8 @@ public void generate() { // Generate a partitioned DAG based on the number of workers. // FIXME: Bring the DOT generation calls to this level instead of hiding // them inside partitionDag(). - Dag dagPartitioned = scheduler.partitionDag(dag, messageReporter, i, this.workers, "_frag_" + i); + Dag dagPartitioned = + scheduler.partitionDag(dag, messageReporter, i, this.workers, "_frag_" + i); // Do not execute the following steps for the MOCASIN scheduler yet. // FIXME: A pass-based architecture would be better at managing this.