Skip to content

Support XMallocSIMD with FlatterScatter - #2

Open
chillenzer-agents wants to merge 3 commits into
fix/xmallocsimdfrom
feature/flatterscatter-xmalloc
Open

chillenzer-agents wants to merge 3 commits into
fix/xmallocsimdfrom
feature/flatterscatter-xmalloc

Conversation

@chillenzer-agents

Copy link
Copy Markdown
Owner

Stacked on fix/xmallocsimd, the branch behind
alpaka-group#312, so this PR shows only the
feature delta.

  • XMallocSIMD bounds each lane's request by pagesize / getWarpSize() so the
    coalesced total stays below one page on wave64. The divisor is guarded with
    if constexpr because HIP defines MALLOCMC_DEVICE_COMPILE in its host
    pass, where the compile-time warp size is zero.
  • FlatterScatter now supports XMallocSIMD: a zero-byte create is a no-op,
    isOOM is size-aware, and freeing a coalesced sub-pointer decrements the
    participant counter at the chunk base and frees the chunk only for the last
    participant. This covers chunked and single-page multi-page allocations;
    multi-page allocations that cannot originate from XMallocSIMD fail safely.
  • The pagesize constraints compare both policies' effective _pagesize, the
    allocator test covers all four creation/distribution combinations, and
    Usage.md documents the newly supported combination.

Testing:

  • CPU: build and ctest 2/2; AccessBlock 8642 assertions; allocator 4 cases.
  • CUDA on fwk394 (nvcc 12.5, RTX 2080 Ti sm_75): suite 2/2 with 9,471,118
    assertions. A pre-existing nvcc 12.5 ICE on
    test/unit/source/PageInterpretation.cpp was worked around by compiling
    that host-only TU with g++ (no source change). A scratch device kernel
    instantiates and runs FlatterScatter + XMallocSIMD.
  • HIP on fwk388 (hipcc 7.2, gfx906 wave64): suite 2/2 with 9,471,118
    assertions; this run found and fixed the HIP host-pass issue above. The
    scratch device kernel coalesced 32/64 lanes into one chunk (header counters
    32/64, spreads 992/2016 bytes) with no overlap.

Coverage caveat: the in-tree suite pins AccCpuSerial, so it does not
instantiate XMallocSIMD device code; the scratch kernels are the device
evidence. An in-tree device test or CI smoke kernel is recommended as a
follow-up.

No issue is closed by this PR. Upstream review is intentionally deferred until
the human approves this internal PR.

chillenzer and others added 3 commits November 26, 2026 17:30
The coalescing bound assumed a hard-coded 32-lane warp. On AMD gfx9 (wave64)
up to 64 lanes participate, so the coalesced request could reach or exceed one
page and break the creation policies' single-page chunk layout.

Bound each request by pagesize / getWarpSize() instead. Keep the divisor
value-dependent with if constexpr: HIP defines MALLOCMC_DEVICE_COMPILE in its
host pass too, where the compile-time warp size is zero, so an unguarded
division or a static_assert would break that pass. CUDA (warp 32) is
unchanged.

Co-authored-by: chillenzer-agents <326908604+chillenzer-agents@users.noreply.github.com>
XMallocSIMD expects a creation policy to treat a zero-byte request as no
allocation, report out-of-memory only for non-zero requests, and free a
coalesced chunk only when its last participant releases a sub-pointer.

Add the zero-size guards, make isOOM size-aware like Scatter, and implement
the participant-counter free path for chunked and single-page multi-page
allocations. Allocations spanning more than one page cannot originate from
XMallocSIMD and are rejected safely.

Co-authored-by: chillenzer-agents <326908604+chillenzer-agents@users.noreply.github.com>
Add the pagesize constraint using both policies' effective _pagesize so that
command-line overrides are covered. Extend the AccessBlock tests with the
zero-size and coalesced-free protocol (both free orders and the single-page
multi-page case), add all four creation/distribution combinations to the
allocator test, and document the new supported combination.

Co-authored-by: chillenzer-agents <326908604+chillenzer-agents@users.noreply.github.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.

2 participants