Skip to content

Constant memory support for small read-only tables #78

Description

@tetsuo-cpp

Summary

Add a way to declare and access CUDA constant memory for small read-only parameters and lookup tables broadcast to all threads.

Motivation

Constant memory is a good fit for:

  • Small coefficient tables
  • Kernel config vectors reused by every thread
  • Broadcast scalars that are awkward as registers-from-params at scale

WarpForth currently has global params and shared scratch only.

Proposed syntax (sketch)

\! const LUT f32[32]
\! const SCALE f64          \ optional: scalar in constant space

Access:

I CELLS LUT + C@     \ or dedicated C@/C! (store only from host)

Host:

  • Runner/Python API copies bytes into the constant symbol or uses driver module constants
  • Kernel sees read-only pointer / NVVM constant address space

Acceptance criteria

  • Header directive for constant buffers (size limits documented, e.g. 64KB device limit)
  • Load path lowers to constant address space in PTX
  • Host path to populate constant data before launch
  • GPU test: all threads read same LUT entry correctly
  • Docs: when to use const vs param vs shared

Non-goals

  • Runtime-writable constant memory from device
  • Exceeding hardware constant capacity (must error clearly)

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions