Skip to content

Set the memory barrier scope of SASS MEMBAR instructions - #580

Draft
karthikbhata97 wants to merge 1 commit into
accel-sim:devfrom
karthikbhata97:membar-wait-for-store-acks
Draft

karthikbhata97 wants to merge 1 commit into
accel-sim:devfrom
karthikbhata97:membar-wait-for-store-acks

Conversation

@karthikbhata97

Copy link
Copy Markdown

Companion to accel-sim/gpgpu-sim_distribution#152, which must be merged first: this change uses inst_t::set_membar_scope(), which that PR adds. The accel-sim-framework CI builds the same-named branch of the gpgpu-sim_distribution fork, membar-wait-for-store-acks.

Problem

GPGPU-Sim's shader_core_ctx::warp_waiting_at_mem_barrier() never waited for a warp's outstanding stores to be acknowledged, so GPU- and system-scope fences were modeled as too cheap. The gpgpu-sim PR fixes this:

  • a memory barrier that is not CTA-scope now waits until the warp's stores are acked;
  • a CTA-scope barrier keeps the old register-only wait;
  • a barrier of unknown scope is treated as GPU scope (conservative).

In trace mode nothing sets the scope today. Without this PR, every SASS MEMBAR, including MEMBAR.CTA, would get the conservative wait.

Fix

trace_warp_inst_t::parseSASSInstruction() sets the scope from the opcode tokens:

SASS scope
MEMBAR.CTA, MEMBAR.SC.CTA, MEMBAR.ALL.CTA CTA
MEMBAR.GL, MEMBAR.SC.GPU, MEMBAR.ALL.GPU GPU
MEMBAR.SYS, MEMBAR.SC.SYS, MEMBAR.ALL.SYS system
anything else unknown, so it waits

The spelling is MEMBAR.{CTA,GL,SYS} before Volta and MEMBAR.{SC,ALL}.{CTA,GPU,SYS} from Volta on. CUDA 12.4 emits MEMBAR.SC.CTA / MEMBAR.SC.GPU / MEMBAR.SC.SYS for __threadfence_block() / __threadfence() / __threadfence_system() on sm_70 and sm_86.

Tests

Built with CMake as in CI (CUDA 12.4), against gpgpu-sim_distribution dev plus the companion PR. gpu-simulator/format-code.sh (clang-format 16.0.6) leaves the tree unchanged.

Microbenchmark. 80 CTAs x 256 threads, each doing 16 iterations of a global store followed by a fence. It was traced with the NVBit tracer on an L40S as an sm_86 binary and run on SM86_RTX3070. The table shows gpu_tot_sim_cycle:

fence dev gpgpu-sim PR alone gpgpu-sim PR + this PR
none 7415 7415 7415
MEMBAR.SC.CTA 7391 9424 7391
MEMBAR.SC.GPU 7422 9467 9467 (+27.6%)
MEMBAR.SC.SYS 7422 9467 9467

With both PRs, the no-fence and MEMBAR.SC.CTA runs give the same output as dev, line for line.

rodinia_2.0-ft V100 traces (the CI set) on SM7_QV100: the output is identical to dev in all 10 apps. These traces contain no MEMBAR.

Measured effect on real workloads. On a research fork of Accel-Sim, a prototype of this change changed the simulated time of fence-heavy kernels by up to 24%.

🤖 Generated with Claude Code

GPGPU-Sim now makes a GPU- or system-scope memory barrier wait for the
warp's store acks, keeps the old register-only wait for a CTA-scope one,
and treats a barrier of unknown scope as GPU scope. Parse the scope from
the opcode so trace-driven MEMBAR.CTA / MEMBAR.SC.CTA / MEMBAR.ALL.CTA
keep the cheap CTA-scope wait, and MEMBAR.GL / MEMBAR.SC.GPU and
MEMBAR.SYS / MEMBAR.SC.SYS get GPU and system scope.

Depends on the gpgpu-sim_distribution change that adds
inst_t::set_membar_scope().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant