PIM-Malloc: A Fast and Scalable Dynamic Memory Allocator for Processing-In-Memory (PIM) Architectures

Dongjae Lee, Bongjoon Hyun, Youngjin Kwon, Minsoo Rhu

TL;DR

Processing-in-Memory (PIM) architectures promise significant performance gains by bringing computation closer to data, but they lack robust dynamic memory allocation support. This paper introduces PIM-malloc, a novel memory allocator designed specifically for PIM, which achieves up to a 66x performance improvement over existing straw-man solutions. By exploring the design space of PIM memory allocators and introducing both software-only and hardware/software co-designed versions, PIM-malloc significantly enhances programmability and efficiency for PIM systems.

What Problem Does This Paper Address?

Modern programming languages heavily rely on dynamic memory allocation (e.g., malloc and free) to manage memory efficiently at runtime. However, current Processing-In-Memory (PIM) architectures, which aim to reduce data movement by performing computations directly within or near memory, often lack adequate support for this crucial feature. This deficiency complicates PIM programming and can lead to inefficient memory usage.

The paper identifies two primary challenges in designing PIM memory allocators:

  1. Explosion of Memory Address Spaces: PIM systems, particularly those with a bank-level architecture like UPMEM-PIM, have thousands of individual PIM cores, each with its own local memory address space. This necessitates managing a vast number of separate heaps and their associated metadata, unlike the single address space found in traditional CPUs and GPUs.
  2. "Wimpy" PIM Cores: PIM cores are typically less powerful than CPU cores due to their fabrication process (often DRAM technology), operating at much lower frequencies. This raises the question of whether these less powerful cores are suitable for executing complex memory allocation algorithms, or if the host CPU should handle this task.

Methods

The authors propose PIM-malloc, a dynamic memory allocator tailored for PIM architectures, and present two versions:

  • PIM-malloc-SW (Software-only): This version optimizes the allocator purely through software. It employs a hierarchical memory allocation scheme:
  • Frontend (Thread Cache): Each thread has a private cache for managing small memory allocation requests (16 bytes to 2 KB). This allows for O(1) latency for these common requests, avoiding lock contention.
  • Backend (Buddy Allocator): For larger requests, a shared buddy allocator is used. This hierarchical design reduces the metadata overhead and improves efficiency compared to a flat buddy allocator.
  • PIM-malloc-HW/SW (Hardware/Software Co-designed): This version builds upon PIM-malloc-SW by incorporating a lightweight hardware accelerator:
  • Buddy Cache: A dedicated, fully-associative hardware cache is added to each PIM core. This cache stores frequently accessed buddy allocator metadata, managed by an LRU replacement policy. This significantly speeds up metadata retrieval for larger allocations, which are handled by the backend buddy allocator.

The authors also conducted a design space exploration, analyzing four strategies based on metadata storage location (host vs. PIM) and execution processor (host vs. PIM), concluding that a "PIM-Metadata/PIM-Executed" approach is optimal for scalability.

Datasets

The paper evaluates PIM-malloc using:

  • loc-gowalla [23]: A dataset used for the dynamic graph update case study. The authors follow prior work by using synthetic sampling to represent newly added graph data.
  • Llama-2-7B model configuration [129]: Used for the LLM attention layer inference case study.
  • ShareGPT dataset [126]: Mentioned in the context of LLM inference measurements.

The paper also introduces a microbenchmark to systematically evaluate memory allocation latency under various conditions (number of threads, allocation size).

Key Insights and Ideas

  • Hierarchical Allocation is Key for PIM: The success of PIM-malloc-SW hinges on its two-level approach, separating small, frequent requests into thread-local caches to bypass the slower backend allocator and reduce contention.
  • Hardware Acceleration for Backend Bottlenecks: While the frontend (thread cache) handles most requests, the backend buddy allocator can become a bottleneck for larger allocations. PIM-malloc-HW/SW's buddy cache effectively addresses this by accelerating metadata access for these less frequent but potentially latency-sensitive operations.
  • Metadata Management is Crucial: The "explosion" of address spaces in PIM means metadata management is a significant challenge. PIM-malloc's hierarchical design and the buddy cache in HW/SW version are designed to minimize this overhead and improve access speed.
  • PIM Constraints Demand Simplicity: The limited resources (e.g., IRAM size) on PIM cores necessitate simpler, more efficient designs compared to complex allocators developed for CPUs (like TCMalloc). PIM-malloc's relatively small codebase is a testament to this.
  • Trade-off Between Initialization and Fragmentation: The initial pre-allocation strategy in PIM-malloc-SW can lead to fragmentation, prompting the exploration of a "lazy" allocation approach (PIM-malloc-lazy) for future work.

Key Results

  • PIM-malloc-SW: Achieves a 66x speedup over a straw-man PIM buddy allocator.
  • PIM-malloc-HW/SW: Provides an additional 31% performance improvement over PIM-malloc-SW.
  • Dynamic Graph Update: PIM-malloc-HW/SW shows a 7.1x and 32x speedup over the static baseline for array-of-linked-lists and variable-sized array implementations, respectively.
  • LLM Inference: PIM-malloc-HW/SW delivers 1.7x higher throughput compared to static allocation and improves 95th/99th percentile TPOT by 8% over PIM-malloc-SW.
  • Microbenchmark: PIM-malloc-SW achieves a 66x speedup over the straw-man allocator, and PIM-malloc-HW/SW outperforms PIM-malloc-SW by 31%. For 4 KB allocations, PIM-malloc-HW/SW reduces latency by 39% compared to PIM-malloc-SW.
  • Buddy Cache Hit Rate: PIM-malloc-HW/SW achieves a 99% hit rate with a 64B buddy cache size.

Limitations and Future Work

  • Fragmentation: The paper acknowledges that the initial pre-allocation strategy in PIM-malloc-SW can lead to memory fragmentation. They evaluate a "lazy" allocation approach (PIM-malloc-lazy) which significantly reduces fragmentation but at the cost of initial allocation performance. Optimizing this trade-off, potentially through compiler analysis or a user-configurable interface, is identified as future work.
  • Metadata Overhead: While PIM-malloc minimizes metadata overhead, the paper notes that it remains a factor, especially in scenarios with very fine-grained allocations.
  • Hardware Cache Size Sensitivity: The paper investigates the sensitivity of PIM-malloc-HW/SW to buddy cache size, finding that performance saturates beyond 64B, suggesting this as a reasonable design point.
  • Future PIM Architectures: The authors discuss the applicability of their work to future PIM architectures, suggesting that even with enhanced processing capabilities or general-purpose caches, specialized metadata caches like their buddy cache will remain essential due to granularity mismatches.

Summary updated

Abstract

The ability to dynamically allocate memory is fundamental in modern programming languages. However, this feature is not adequately supported in current general-purpose PIM devices. To identify key design principles that PIM must consider, we conduct a design space exploration of PIM memory allocators, examining various strategies for metadata placement and management of the allocator. Based on this exploration, we introduce PIM-malloc, a fast and scalable memory allocator for general-purpose PIM that operates on real PIM hardware, achieving a x66 improvement in memory allocation performance. This design is further enhanced with a lightweight, per-PIM core hardware cache, specifically designed for dynamic memory allocation, achieving an additional 31% performance improvement. Finally, we demonstrate the applicability of PIM-malloc by developing several representative PIM workloads, demonstrating its effectiveness in enhancing programmability.
BibTeX
@inproceedings{lee2026pim,
  author = {Dongjae Lee and Bongjoon Hyun and Youngjin Kwon and Minsoo Rhu},
  title = {{PIM-Malloc: A Fast and Scalable Dynamic Memory Allocator for Processing-In-Memory (PIM) Architectures}},
  booktitle = {HPCA},
  year = {2026},
  doi = {10.1109/hpca68181.2026.11408588},
}
Figure