InfiniteMemory Host Commands (PXL API)

PXL (XCENA Programming Library) APIs invoked from the host:

  • Cache Management — prefetchMemory, pinMemory, unpinMemory, unpinAllMemory

PXL lets applications go beyond the default policy. When an application knows its access pattern in advance, it can instruct the device directly: prefetch a region before reads arrive, or pin a region so it cannot be evicted. This turns a reactive cache into a cooperative one, reducing latency spikes caused by cold misses.

Prerequisites

A working PXL environment is required:

  1. PXL installed — PXL runtime and headers must be installed on the host. PXL is provided as part of the XCENA SDK; refer to the XCENA SDK — Installation Guide.
  2. InfiniteMemory firmware — the target device must be running the InfiniteMemory firmware (these APIs are not available on other firmwares shipped on the same hardware).
  3. Header:

    #include <pxl/pxl.hpp>
    
  4. Allocate / release — every command operates on a device-memory pointer obtained via pxl::allocateMemory, and the memory must be released with pxl::releaseMemory once you are done with it.

    auto* ptr = pxl::allocateMemory(deviceId, size);
    if (!ptr) {
        // Allocation failed
    }
    // ... call commands ...
    pxl::releaseMemory(ptr);
    

Command Summary

Command PXL API Description
Prefetch prefetchMemory(ptr, size) Async prefetch of a memory region into DRAM
Pin pinMemory(ptr, size) Lock a memory region in DRAM
Unpin unpinMemory(ptr, size) Release a DRAM lock
UnpinAll unpinAllMemory(deviceId) Release all pins on the device at once

Status Codes

Every command returns a MemoryStatus value.

Status Value Description
Success 0 Operation succeeded
ResourceExhaust 1 Device resource exhausted (e.g., pin threshold exceeded)
InvalidRequest 2 Invalid parameter or invalid pointer
NotSupported 3 Called on a device running a different firmware (not InfiniteMemory), or against IO Memory

Cache Management API

prefetchMemory

MemoryStatus pxl::prefetchMemory(const void* ptr, size_t size);

Asynchronously prefetches the given memory region into device DRAM.

  • Reduces SSD read latency on subsequent host reads.
  • Early Response — returns as soon as the request is issued; the actual load completes in the background.
  • Prefetched pages may still be evicted by the standard cache policy. Use pinMemory if you need them to stay resident.
  • Timing-dependent — if a host read hits the region before the prefetch completes, the benefit is reduced or lost.

prefetchMemory — a page is loaded from the SSD into the Cache Region ahead of host access

Parameters

Name Type Description
ptr const void* Start pointer of the region to prefetch
size size_t Size of the region to prefetch, in bytes

Example — explicit prefetch

constexpr size_t kSize = 1024 * 1024;

// 1) Allocate device memory
auto* ptr = pxl::allocateMemory(0, kSize);
if (!ptr) {
    return -1;
}

// 2) Prefetch into DRAM
auto status = pxl::prefetchMemory(ptr, kSize);
if (status != pxl::MemoryStatus::Success) {
    pxl::releaseMemory(ptr);
    return -1;
}

// 3) Use the data ...

// 4) Release
pxl::releaseMemory(ptr);

pinMemory / unpinMemory / unpinAllMemory

MemoryStatus pxl::pinMemory(const void* ptr, size_t size);
MemoryStatus pxl::unpinMemory(const void* ptr, size_t size);
MemoryStatus pxl::unpinAllMemory(uint32_t deviceId);

Lock a memory region into device DRAM so it cannot be evicted.

  • pinMemory — pin a single region. Already-pinned regions are skipped. Loads from SSD into DRAM if not already resident, and returns only after the DRAM load completes (synchronous; contrast with prefetchMemory, which returns early).
  • unpinMemory — unpin a single region.
  • unpinAllMemory — unpin all pinned regions on the device at once.
    • ※ Optional convenience API intended for idle-state cleanup (e.g., between workload phases). Not recommended during active workload; use unpinMemory for targeted release instead.
  • Once unpinned, the region is again subject to the standard cache policy and may be evicted.
  • 4 GiB of the capacity is always kept evictable and can never be pinned, so the pin ceiling is the capacity minus 4 GiB.
  • Default pin budget: approximately 50% of total DRAM capacity, capped by that ceiling — below 8 GiB the default is the ceiling instead. Exceeding the budget in effect returns ResourceExhaust.

pinMemory — a pinned page in the Cache Region is not evictable until Unpin / UnpinAll

Parameters

Name Type Description
ptr const void* Start pointer of the region to pin/unpin
size size_t Size of the region to pin/unpin, in bytes
deviceId uint32_t Target device ID for unpinAllMemory

Example — alloc → pin → unpin → release

constexpr size_t kSize = 4096;

// 1) Allocate device memory
auto* ptr = pxl::allocateMemory(0, kSize);
if (!ptr) {
    return -1;
}

// 2) Pin into DRAM (prevent eviction)
auto status = pxl::pinMemory(ptr, kSize);
if (status != pxl::MemoryStatus::Success) {
    pxl::releaseMemory(ptr);
    return -1;
}

// 3) Use the data (this region will not be evicted) ...

// 4) Unpin when done
pxl::unpinMemory(ptr, kSize);

// (Note) Use unpinAllMemory to release all pins at once
// pxl::unpinAllMemory(0);

// 5) Release
pxl::releaseMemory(ptr);