用途与范围
本单元决定一个已捕获的候选内存执行是否被 PTO-TSO 允许。它验证事件集合、构建必需的排序关系,并拒绝必需关系中存在环的任何候选执行。
最终查询 MemoryExecutionAllowedTSO 同时要求候选执行有效,并要求同一位置的执行关系和外部可见的保序关系都无环。
PTO-ARCH-MEMORY-MODEL-ORDERING下面直接显示完整的 ASL 所有者。
// PTO-UNIT: {"id":"PTO-ARCH-MEMORY-MODEL-ORDERING","surface":"arch","classification":["memory-model","ordering"],"depends_on":["PTO-ARCH-MEMORY-MODEL-ATOMICITY"]}readonly func MemoryCoherenceBefore(left_index: MemoryEventIndex, right_index: MemoryEventIndex) => booleanbegin let left = _MemoryEvents[[left_index]]; let right = _MemoryEvents[[right_index]]; return MemoryEventIsWrite(left) && MemoryEventIsWrite(right) && MemoryEventsShareLocation(left, right) && left.coherence_rank < right.coherence_rank;end;
readonly func MemoryReadsFromBefore(write_index: MemoryEventIndex, read_index: MemoryEventIndex) => booleanbegin let write = _MemoryEvents[[write_index]]; let read = _MemoryEvents[[read_index]]; return MemoryEventIsWrite(write) && MemoryEventIsRead(read) && read.read_from == write_index;end;
readonly func MemoryExternalReadsFromBefore(write_index: MemoryEventIndex, read_index: MemoryEventIndex) => booleanbegin if !MemoryReadsFromBefore(write_index, read_index) then return FALSE; end; let write = _MemoryEvents[[write_index]]; let read = _MemoryEvents[[read_index]]; return write.kind == MemoryEvent_InitialWrite || write.agent != read.agent;end;
readonly func MemoryFromReadBefore(read_index: MemoryEventIndex, write_index: MemoryEventIndex) => booleanbegin let read = _MemoryEvents[[read_index]]; // An atomic event contains its read and write sides. Its own write is not a // later event in from-read; only a distinct coherence successor is. if read_index == write_index || !MemoryEventIsRead(read) then return FALSE; end; return MemoryCoherenceBefore(read.read_from, write_index);end;
readonly func MemoryProgramOrderLocationBefore( left_index: MemoryEventIndex, right_index: MemoryEventIndex) => booleanbegin let left = _MemoryEvents[[left_index]]; let right = _MemoryEvents[[right_index]]; return left_index < right_index && left.agent == right.agent && left.kind != MemoryEvent_InitialWrite && right.kind != MemoryEvent_InitialWrite && MemoryEventIsAccess(left) && MemoryEventIsAccess(right) && MemoryEventsShareLocation(left, right);end;
readonly func MemoryFenceOrders(left_index: MemoryEventIndex, right_index: MemoryEventIndex) => booleanbegin if left_index + 1 >= right_index then return FALSE; end; let left = _MemoryEvents[[left_index]]; let right = _MemoryEvents[[right_index]]; for fence_number = left_index + 1 to right_index - 1 do let fence_index = fence_number as MemoryEventIndex; let fence = _MemoryEvents[[fence_index]]; if fence.kind == MemoryEvent_Fence && fence.agent == left.agent && fence.agent == right.agent && (MemoryEventClass(left) AND fence.fence_predecessor) != Zeros{4} && (MemoryEventClass(right) AND fence.fence_successor) != Zeros{4} then return TRUE; end; end; return FALSE;end;
readonly func MemoryPreservedProgramOrderBefore( left_index: MemoryEventIndex, right_index: MemoryEventIndex) => booleanbegin let left = _MemoryEvents[[left_index]]; let right = _MemoryEvents[[right_index]]; if left_index >= right_index || left.agent != right.agent || left.kind == MemoryEvent_InitialWrite || right.kind == MemoryEvent_InitialWrite || !MemoryEventIsAccess(left) || !MemoryEventIsAccess(right) then return FALSE; end; // PTO-TSO preserves R->M and M->W. W->R to another location is the one // relaxed program-order pair unless a matching fence or stronger event // ordering restores it. Atomics are full ordering points. if MemoryEventIsRead(left) || MemoryEventIsWrite(right) || left.kind == MemoryEvent_Atomic || right.kind == MemoryEvent_Atomic then return TRUE; end; if left.order == MemoryOrder_Acquire || left.order == MemoryOrder_AcquireRelease || right.order == MemoryOrder_Release || right.order == MemoryOrder_AcquireRelease then return TRUE; end; return MemoryFenceOrders(left_index, right_index);end;
readonly func MemoryCandidateExecutionValid() => booleanbegin if _MemoryEventCount == 0 then return FALSE; end; for event_number = 0 to _MemoryEventCount - 1 do let event_index = event_number as MemoryEventIndex; let event = _MemoryEvents[[event_index]]; if MemoryEventIsAccess(event) then var initial_count: integer = 0; for candidate_number = 0 to _MemoryEventCount - 1 do let candidate_index = candidate_number as MemoryEventIndex; let candidate = _MemoryEvents[[candidate_index]]; if candidate.kind == MemoryEvent_InitialWrite && MemoryEventsShareLocation(event, candidate) then initial_count = initial_count + 1; end; if candidate_index != event_index && MemoryEventIsAccess(candidate) && RangesOverlap(event.address, event.size_bytes, candidate.address, candidate.size_bytes) && !MemoryEventsShareLocation(event, candidate) then // Mixed-size or partially overlapping candidates require // a byte-level coherence extension and fail closed here. return FALSE; end; end; if initial_count != 1 then return FALSE; end; end; if event.kind == MemoryEvent_InitialWrite && event.coherence_rank != 0 then return FALSE; end; if MemoryEventIsWrite(event) && event.kind != MemoryEvent_InitialWrite then if event.coherence_rank == 0 then return FALSE; end; var predecessor_found = FALSE; for candidate_number = 0 to _MemoryEventCount - 1 do let candidate_index = candidate_number as MemoryEventIndex; let candidate = _MemoryEvents[[candidate_index]]; if candidate_index != event_index && MemoryEventIsWrite(candidate) && MemoryEventsShareLocation(event, candidate) then if candidate.coherence_rank == event.coherence_rank then return FALSE; end; if candidate.coherence_rank + 1 == event.coherence_rank then predecessor_found = TRUE; end; end; end; if !predecessor_found then return FALSE; end; end; if MemoryEventIsRead(event) then if event.read_from >= _MemoryEventCount then return FALSE; end; let source = _MemoryEvents[[event.read_from]]; if !MemoryEventIsWrite(source) || !MemoryEventsShareLocation(event, source) || event.read_value != source.write_value then return FALSE; end; if event.kind == MemoryEvent_Atomic && event.write_performed && source.coherence_rank + 1 != event.coherence_rank then return FALSE; end; end; end; return TRUE;end;
readonly func MemoryRelationAcyclic(uniproc: boolean) => booleanbegin if _MemoryEventCount == 0 then return TRUE; end; var closure: MemoryRelationMatrix; for index = 0 to PTO_MODEL_MEMORY_EVENTS - 1 do closure[[index]] = Zeros{PTO_MODEL_MEMORY_EVENTS}; end; for left_number = 0 to _MemoryEventCount - 1 do let left = left_number as MemoryEventIndex; for right_number = 0 to _MemoryEventCount - 1 do let right = right_number as MemoryEventIndex; var edge = MemoryCoherenceBefore(left, right) || MemoryFromReadBefore(left, right); if uniproc then edge = edge || MemoryProgramOrderLocationBefore(left, right) || MemoryReadsFromBefore(left, right); else edge = edge || MemoryPreservedProgramOrderBefore(left, right) || MemoryExternalReadsFromBefore(left, right); end; if edge then closure[[left]][right] = '1'; end; end; end; for via_number = 0 to _MemoryEventCount - 1 do let via = via_number as MemoryEventIndex; for source_number = 0 to _MemoryEventCount - 1 do let source = source_number as MemoryEventIndex; if closure[[source]][via] == '1' then closure[[source]] = closure[[source]] OR closure[[via]]; end; end; end; for event_number = 0 to _MemoryEventCount - 1 do let event = event_number as MemoryEventIndex; if closure[[event]][event] == '1' then return FALSE; end; end; return TRUE;end;
readonly func MemoryExecutionAllowedTSO() => booleanbegin return MemoryCandidateExecutionValid() && MemoryRelationAcyclic(TRUE) && MemoryRelationAcyclic(FALSE);end;
本单元决定一个已捕获的候选内存执行是否被 PTO-TSO 允许。它验证事件集合、构建必需的排序关系,并拒绝必需关系中存在环的任何候选执行。
最终查询 MemoryExecutionAllowedTSO 同时要求候选执行有效,并要求同一位置的执行关系和外部可见的保序关系都无环。
coherence_rank 排序同一位置上的写;读自关系(reads-from)把一次写连接到 read_from 字段指向该写的读。每个被访问的位置恰好有一个初始写事件,并且每个初始写的 coherence rank 都是 0。
同一位置上的每个后续写都具有唯一的非零 coherence rank,并且在前一 rank 上存在直接前驱。
每个读都指向一个范围内、同位置的写,并携带该来源写入的值。成功的原子写在一致性顺序中紧接其读取来源。
PTO-TSO 保留“读到后续内存操作”和“内存操作到后续写”的程序顺序。写后读取另一个位置是可放宽的组合,除非原子事件、acquire/release 顺序或匹配的屏障恢复这条边。
当不同大小或部分重叠的访问,其范围相交却并未描述同一位置时,候选执行会被拒绝。因此这个所有者不会为此类候选执行静默补充字节级一致性规则。
原子事件不会为自身的写入侧创建读后边;读后关系只考虑另一个一致性后继写。
空事件集合不是有效的候选执行,尽管无环性辅助函数本身会把空关系视为无环。
对于存储缓冲(store-buffering)候选执行,记录每个内存主体的写和后续读,把每个读指向它观察到的初始写,然后运行有效性与无环性查询。在没有更强边闭合成环时,可放宽的“写后读”组合可以使候选执行仍被允许。
如果在每组写与读之间插入匹配的屏障,MemoryFenceOrders 会贡献保留程序顺序边。每个读取初始写的读还带有一条读后边;MemoryFromReadBefore 根据该读的 read_from 来源以及同一位置上后续的一致性后继写推导这条边。这些边共同形成环,因此 MemoryExecutionAllowedTSO 会拒绝该观察结果。
正文来自 owning ASL。拖拽或按钮只临时改变当前页面显示顺序。
No NDF clause is attached to this unit.
12 matching entries
PTO-AVS-ARCH-DEPENDENCIES-ORDER-004tests/asl/arch/memory-model/ordering/arch-order-dependencies-004.asl54396119014ae03015b66a801f8fd47c886f1a856ac7d1efc69a79fdafaa3d4ePTO-AVS-ARCH-MEMORY-MODEL-ORDERING-STATIC-001tests/asl/arch/memory-model/ordering/arch-static-ordering-contract-001.asl213cbc201790ba43a1d0c64598812cb7a4193b78411453939b2b853b0f41a8f9PTO-AVS-ARCH-PRODUCTION-EVENTS-ORDER-002tests/asl/arch/memory-model/ordering/arch-order-production-events-002.aslc30ba50cb3651411c4ec93ebcd4ef342a46d908207707cc5579db55d419b6346PTO-AVS-ARCH-TILE-EVENTS-ORDER-003tests/asl/arch/memory-model/ordering/arch-order-tile-events-003.asl8093407438f1dfc29fd99983624e9d08c6d0f26093539968dcaf50634f830257PTO-AVS-ARCH-TSO-CONCURRENCY-ORDER-001tests/asl/arch/memory-model/ordering/arch-order-tso-concurrency-001.asl9d01691c413335132b7527d49c2fd1e99f574789cd67624fc2b15ca934fd5132PTO-EVIDENCE-RELEASE-TRACEABILITYPTO-EVIDENCE-RELEASE-TRACEABILITYspec/evidence/release-traceability-readiness.jsonc7327021d39dc67ac5564bc55073b3870a397d79ac8d9648284d56e33bc14a3ePTO-EVIDENCE-INSTRUCTION-CONTRACT-CLOSUREPTO-EVIDENCE-INSTRUCTION-CONTRACT-CLOSUREspec/evidence/instruction-contract-closure.json3ef2bb62421c79dff8fa77a1c7983923b523244b8090812883ef81286ca8106aPTO-EVIDENCE-ARCHITECTURE-READINESSPTO-EVIDENCE-ARCHITECTURE-READINESSspec/evidence/architecture-readiness.json4b0b85199101251bea744e0f3591cc31906909dc80d5ab651c417a936036a004PTO-EVIDENCE-RELEASE-GATE-READINESSPTO-EVIDENCE-RELEASE-GATE-READINESSspec/evidence/release-gate-readiness.jsona0f4d2b6920c08981ea55fd8ef820708a40d4feb5402c5150e8e9ab532d84ce0PTO-EVIDENCE-RELEASE-MANIFESTPTO-EVIDENCE-RELEASE-MANIFESTspec/release-manifest.json1a64c109ed7a90351c41e2a418b3c0ebaf8ad975838986d2101385186b85c0d8Loading ADR-0006…
ADR-0006docs/status/decisions/0006-pto-total-store-order.mdb80d8782e4587d4023edf02df9d2ba4d3cb2b2999fdc8991e49a2af4f9817735Loading ADR-0020…
ADR-0020docs/status/decisions/0020-production-memory-events-and-atomic-corners.md215b18f05d0b53120949373fce6a5ce22f7ab534fb22df24743a9b2b4beb2dec{
"classification": [
"memory-model",
"ordering"
],
"documentation": "docs/arch/memory-model/ordering.md",
"id": "PTO-ARCH-MEMORY-MODEL-ORDERING",
"mnemonic": null,
"readiness_subjects": [
"ADR-0006",
"ADR-0020"
],
"semantic_tests": [
"PTO-AVS-ARCH-DEPENDENCIES-ORDER-004",
"PTO-AVS-ARCH-PRODUCTION-EVENTS-ORDER-002",
"PTO-AVS-ARCH-TILE-EVENTS-ORDER-003",
"PTO-AVS-ARCH-TSO-CONCURRENCY-ORDER-001"
],
"source": "asl/arch/memory-model/ordering.asl",
"surface": "arch",
"tests": [
"PTO-AVS-ARCH-DEPENDENCIES-ORDER-004",
"PTO-AVS-ARCH-MEMORY-MODEL-ORDERING-STATIC-001",
"PTO-AVS-ARCH-PRODUCTION-EVENTS-ORDER-002",
"PTO-AVS-ARCH-TILE-EVENTS-ORDER-003",
"PTO-AVS-ARCH-TSO-CONCURRENCY-ORDER-001"
]
}0.58.5 · 候选发布7dc8b7e5b121d2b2499a2273bebff29e2cd868121f157179434fe7c704a35b7b0d8a086d2ade9280c4f678b3586fc29142844898c22940998ab1efc1b705c02ee09076be18fecb842fd6dbb0d3d0a09177b5f62casl/arch/memory-model/ordering.asl