Deepity
Ultra-fast, SIMD-accelerated Predictive Coding
Loading...
Searching...
No Matches
DeviceMemoryArena.h File Reference

A 64-byte-aligned bump-pointer allocator over a single device buffer, mirroring this codebase's host-side MemoryArena, but backed by IComputeBackend::Allocate()/Free() rather than raw cudaMalloc/cudaFree directly – the same allocation path Tensor already uses and CUDAFunctionsVerify already exercises, rather than a second, separate, unverified call site. More...

#include <deepity/backend/IComputeBackend.h>
#include <new>
#include <stdexcept>
#include <iostream>

Go to the source code of this file.

Classes

class  Deep::DeviceMemoryArena
 A 64-byte-aligned bump-pointer allocator over a single contiguous block of device memory, obtained via a supplied IComputeBackend (expected to be a CUDABackend in practice, though this class itself doesn't hard-require that specific type). More...

Namespaces

namespace  Deep
 This file exists to provide both Tensor.h and IComputeBackend.h with device types without introducing circular dependencies.

Detailed Description

A 64-byte-aligned bump-pointer allocator over a single device buffer, mirroring this codebase's host-side MemoryArena, but backed by IComputeBackend::Allocate()/Free() rather than raw cudaMalloc/cudaFree directly – the same allocation path Tensor already uses and CUDAFunctionsVerify already exercises, rather than a second, separate, unverified call site.

Deliberately NOT routed through IComputeBackend on the CPU side (MemoryArena stays exactly as it is): CPUBackend::Allocate() has no huge-pages parameter, so wiring MemoryArena through it would mean either silently losing that real, measured feature, or bolting a CPU-only concept onto IComputeBackend's interface for no benefit, since nothing ever needs to swap MemoryArena's allocator polymorphically at runtime. The GPU side has no such feature to lose, and the virtual call only happens once per arena (construction and destruction), not per AllocateFloats() call – a clean win with no real cost.

Warning
Individual chunks handed out by AllocateFloats() cannot be freed independently – the entire arena is released at once in the destructor, matching MemoryArena's bump-pointer/no-reclaim design.
Version
1.1
Date
2026-09-05