Model scalar GM ops in auto sync#951
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces support for tracking and synchronizing scalar memory operations (such as load and store scalar operations) executing on the S-pipeline (PIPE_S) to prevent races with asynchronous tile stores. It updates the IR translators to handle pointer additions and casts, retrieves address spaces dynamically from pointer and memref types, and adds a test suite to verify the synchronization behavior. The reviewer suggests adding a defensive null check when retrieving the memory space from a pointer type to prevent potential null pointer dereferences.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| if (auto ptrType = dyn_cast<pto::PtrType>(argType)) { | ||
| space = ptrType.getMemorySpace().getAddressSpace(); |
There was a problem hiding this comment.
Defensive Programming: To prevent potential null pointer dereferences, it is safer to defensively check if ptrType.getMemorySpace() is non-null before calling .getAddressSpace(), similar to how memRefType.getMemorySpace() is handled below.
if (auto ptrType = dyn_cast<pto::PtrType>(argType)) {
if (auto spaceAttr = ptrType.getMemorySpace())
space = spaceAttr.getAddressSpace();
}This reverts commit 1fd0299.
c2bcd85 to
e05a0ce
Compare
Summary
pto.load_scalar/pto.store_scalarasPIPE_Smemory operations in auto-sync analysis.pto.addptrand pointer-to-pointerpto.castptr.TSTORE <-> load_scalar/store_scalarGM hazards on both--enable-insert-syncand--enable-graph-sync-solver.Motivation
TSTOREand scalar GM access touch the same payload line. Before this change, scalar PTO ops only implemented MemoryEffects and did not enter InsertSync asPIPE_S, so PTOAS could miss the required MTE3/FIX-to-scalar ordering edge.Design
load_scalar/store_scalarremain ordinary PTO ops; this PR does not add public IR or memory consistency actions.PIPE_Scompound for scalar pointer memory ops when their pointer is known in the alias map.addptrkeeps the parent alias range while adding a static byte offset when available; dynamic offsets stay conservative.dcci/CMO remains explicit user/PyPTO responsibility.Testing
ninja -C build ptoasgit diff --checkllvm-lit -v build/test/lit --filter 'scalar_gm_tstore_sync'llvm-lit -v build/test/lit --filter 'issue696_scalar_gm_store_flush|issue735_tci_pipe_s_sync|ptr_int_cast'ptoas --pto-arch=a5 --enable-insert-sync --pto-backend=vpto --emit-vpto test/vpto/cases/micro-op/scalar-load-store/load-store-scalar-ub/kernel.pto -o /tmp/load_store_scalar_ub.vptoRisk / Rollback