Skip to content

Fix XMallocSIMD compilation and add allocator coverage - #312

Merged
chillenzer merged 4 commits into
alpaka-group:devfrom
chillenzer-agents:fix/xmallocsimd
Nov 26, 2026
Merged

chillenzer merged 4 commits into
alpaka-group:devfrom
chillenzer-agents:fix/xmallocsimd

Conversation

@chillenzer-agents

Copy link
Copy Markdown
Contributor

XMallocSIMD did not compile against current alpaka:

  • alpaka::popcount takes the intrinsic and the value; the ballot mask was passed
    as the intrinsic.
  • threadfenceBlock was removed from mallocMC_utils.hpp; use
    alpaka::mem_fence(acc, alpaka::memory_scope::Block{}) instead.
  • alpaka::warp::getSizeCompileTime is zero during the host pass of GPU
    compilation and for SYCL, so it cannot be used as a shared-array extent or
    divisor.

On the unknown-warp-size paths XMallocSIMD now uses one shared slot and warp id
zero. Coalescing is already compiled out when MALLOCMC_DEVICE_COMPILE is
undefined, so the policy is a pass-through there; the warp-0 counter
initialisation is skipped to avoid a same-slot write race on SYCL. Code
generation for known warp sizes is unchanged.

The allocator unit test now instantiates XMallocSIMD with the Scatter creation
policy, so the distribution policy is compiled and executed by default.

Testing: CPU build and ctest against the pinned alpaka 2.2.0 (both suites pass).
The warp-size 0/1/32/64 paths were checked with a mock accelerator under g++
and clang++ with warnings as errors. No GPU or SYCL toolchain was available, so
device compilation and runtime were not tested.

No documentation change: this is a compilation fix with no user-visible API or
behaviour change.

chillenzer and others added 4 commits November 26, 2026 16:29
alpaka::popcount takes (intrinsic, value) and only overloads on
std::uint32_t/std::uint64_t; ballot() already returns the accelerator's
mask_type, so pass the accelerator as the intrinsic.

Co-authored-by: chillenzer-agents <326908604+chillenzer-agents@users.noreply.github.com>
The helper was dropped from mallocMC_utils.hpp, leaving the call dangling.
It implemented __threadfence_block(), so use the block-scope fence.

Co-authored-by: chillenzer-agents <326908604+chillenzer-agents@users.noreply.github.com>
The allocator-level test only instantiated the Noop distribution policy. Add
a parameterised test that runs the same allocation through Noop and
XMallocSIMD so that the latter is compiled and executed by default.

XMallocSIMD is combined with the Scatter creation policy: FlatterScatter
cannot free the coalesced sub-chunks that XMallocSIMD hands out and does not
treat zero-byte requests as a no-op. The test uses the CPU serial accelerator
because alpaka reports a warp size of zero for GPU accelerators during host
compilation, which makes XMallocSIMD's shared-memory arrays ill-formed.

Co-authored-by: chillenzer-agents <326908604+chillenzer-agents@users.noreply.github.com>
alpaka reports a warp size of zero during the host pass of a GPU compilation
and for SYCL. XMallocSIMD used that value as a shared-array extent and as a
divisor, so those configurations were ill-formed.

Fall back to a single shared slot and warp id zero there. Coalescing is already
compiled out when MALLOCMC_DEVICE_COMPILE is undefined, so the policy remains a
pass-through. Skip the warp-0 shared-counter initialisation to avoid a
same-slot write race on SYCL. For accelerators with a known compile-time warp
size the generated code is unchanged.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants