Skip to content

Conversation

@hroc135
Copy link

@hroc135 hroc135 commented Feb 23, 2024

とりあえず一段階目としてco = (po + wr)+の定義に従ってcoを生成できるようにしてみました

@shumbo shumbo changed the base branch from main to bad-pattern February 23, 2024 16:04
self.poset.order_try(f"{process}.{i + 1}", f"{process}.{i + 2}")

# co = (po U wr)^+
def causal_order(self):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def causal_order(self):
def causal_order(self) -> Self:

self.poset.order_try(f"{process}.{i + 1}", f"{process}.{i + 2}")

# co = (po U wr)^+
def causal_order(self):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you want a separate method for creating wr relation?

self.poset.order_try(f"{process}.{i + 1}", f"{process}.{i + 2}")

# co = (po U wr)^+
def causal_order(self):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to add this causal_order method on History because this method only makes sense for histories of read/write memory. I think the easiest approach would be to make a subclass WRMemoryHistory that extends History and move this method there.


arg = op1.arg
ret = op1.ret
for id2, op2 in self.label.items():
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this inner loop makes the function $O(n^2)$ but it should be able to do this in $O(n)$

ret = op1.ret
for id2, op2 in self.label.items():
if op2.method == "wr" and op2.arg == (arg, ret):
ch.poset.link(id2, id1)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's my fault for not explicitly stating this, but currently, the graph (G) in the Poset class maintains two invariants (that comes from the definition of strong partial order).

First, the graph must be acyclic. This is to keep the relation irreflexive.

Second, the graph must be transitive closure. That is, if there is a path from a to b and b to c, there must also be an edge from a to c.

I'm fine with violating the property temporarily, but I have a feeling that we should NOT return an instance of Poset that is actually not a partial order.

I would probably change the function to def make_co(self) -> Self | None and return None if there is a cycle in the resulting poset. You probably don't need to check every time you add an edge and just need to check once at the end.

You also want to make sure the returned graph is transitive. You should be able to use a library function from networkx.

@shumbo
Copy link
Owner

shumbo commented Feb 23, 2024

I created a new branch, bad-pattern,, and changed the base of the PR to that branch because I didn't want to merge the unfinished features to main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants