Skip to content

Commit

Permalink
Optimize ThreadModel
Browse files Browse the repository at this point in the history
Signed-off-by: Tianrui Zheng <[email protected]>
  • Loading branch information
Tianrui Zheng committed Dec 4, 2024
1 parent 8cf4620 commit c23fe23
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 14 deletions.
6 changes: 4 additions & 2 deletions dartagnan/src/main/java/com/dat3m/dartagnan/Dartagnan.java
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,10 @@ public static File generateExecutionGraphFile(VerificationTask task, ProverEnvir
// we get some data flow information by observing the edge
// FR edges only give ordering information which is known if the pair is also in PO
// CO edges only give ordering information which is known if the pair is also in PO
return generateGraphvizFile(encodingContext, prover.getModel(), 1, (x, y) -> true, (x, y) -> !x.getThread().equals(y.getThread()),
(x, y) -> !x.getThread().equals(y.getThread()), getOrCreateOutputDirectory() + "/", name,
return generateGraphvizFile(encodingContext, prover.getModel(), 1, (x, y) -> true,
(x, y) -> !x.getThreadModel().getThread().equals(y.getThreadModel().getThread()),
(x, y) -> !x.getThreadModel().getThread().equals(y.getThreadModel().getThread()),
getOrCreateOutputDirectory() + "/", name,
synContext, witnessType.convertToPng());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ public void addEvent(EventModel event) {
eventList.add(event);
}

public Thread getThread() {
return thread;
}

public int getId() {
return thread.getId();
}
Expand All @@ -37,10 +41,4 @@ public List<EventModel> getEventModels() {
public List<EventModel> getVisibleEventModels() {
return eventList.stream().filter(e -> e.isVisible()).toList();
}

public List<EventModel> getEventModelsToShow() {
return eventList.stream()
.filter(e -> e.isVisible() || e.isLocal() || e.isAssert())
.toList();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public Event getEvent() {
}

@Override
public ThreadModel getThread() {
public ThreadModel getThreadModel() {
return thread;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public interface EventModel extends Comparable<EventModel> {
Event getEvent();

ThreadModel getThread();
ThreadModel getThreadModel();

int getId();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,10 @@ private ExecutionGraphVisualizer addProgramOrder(ExecutionModelNext model, Strin
String label = String.format("label=\"%s\"", name);
BiPredicate<EventModel, EventModel> filter = getFilter(PO);
for (ThreadModel tm : model.getThreadModels()) {
List<EventModel> eventsToShow = tm.getEventModelsToShow();
List<EventModel> eventsToShow = tm.getEventModels()
.stream()
.filter(e -> e.isVisible() || e.isLocal() || e.isAssert())
.toList();
if (eventsToShow.size() <= 1) { continue; }
for (int i = 1; i < eventsToShow.size(); i++) {
EventModel from = eventsToShow.get(i - 1);
Expand Down Expand Up @@ -247,7 +250,10 @@ private ExecutionGraphVisualizer addAllThreadPos(ExecutionModelNext model) {
}

private ExecutionGraphVisualizer addThreadPo(ThreadModel tm, ExecutionModelNext model) {
List<EventModel> threadEvents = tm.getEventModelsToShow();
List<EventModel> threadEvents = tm.getEventModels()
.stream()
.filter(e -> e.isVisible() || e.isLocal() || e.isAssert())
.toList();
if (threadEvents.size() <= 1) {
// This skips init threads.
return this;
Expand Down Expand Up @@ -300,8 +306,8 @@ private String eventToNode(EventModel e) {
final String callStack = makeContextString(
synContext.getContextInfo(e.getEvent()).getContextOfType(CallContext.class), " -> \\n");
final String nodeString = String.format("%s:T%s/E%s\\n%s%s\n%s",
e.getThread().getName(),
e.getThread().getId(),
e.getThreadModel().getName(),
e.getThreadModel().getId(),
e.getEvent().getGlobalId(),
callStack.isEmpty() ? callStack : callStack + " -> \\n",
getSourceLocationString(e.getEvent()),
Expand Down

0 comments on commit c23fe23

Please sign in to comment.