mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-06 08:18:54 +00:00
- CMake: CMAKE_HIP_ARCHITECTURES may list gfx1100 and gfx1201 (validated) and gfx1101 / gfx1102 / gfx1200 (build with a warning: same wave32, 64 KiB LDS and dot4, not run by us; #192, #176). The list reaches the code as STRATA_HIP_ARCHS. - Runtime: the engine (every GPU a run uses) and strata-device compare the card's gcnArchName (up to the ':' feature suffix) with the compiled archs and require wave32, with a message naming the card, its arch and the build's archs, instead of a later "invalid device function". - __dp4a uses __builtin_amdgcn_sudot4 (v_dot4_i32_iu8) on all five archs; the portable fallback stays for other compilers/targets. - setup.py: AMD_ARCHS gfx1100 + gfx1201; TheRock's wheel index per GPU family (gfx110X-dgpu, gfx120X-all; the pinned 7.10.0a20251120 is on both), only that family's libraries on the path, reinstall when the family changes; a system ROCm older than 7.0 is passed over for the wheels; the engine is rebuilt when the chosen card's arch is not in its BUILD.json. The hipBLASLt table is tools/hip/<arch>-hipblaslt-<version>.txt for the card's arch AND the installed hipBLASLt (read from hipblaslt-version.h, 1.4.1 -> 100401), else none with a message; before, the highest-named table of the arch was taken whatever the installed version, which the engine then refused. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0154bwiad8gY7wRehCXy27pN
82 lines
3.6 KiB
C++
82 lines
3.6 KiB
C++
// include/strata/core/device.hpp - P2.S1: the device arena and the runtime's device facts.
|
|
//
|
|
// `DeviceArena` is ONE cudaMalloc per planner region with bump sub-allocation below it and no frees. That is
|
|
// not a simplification for the first version: the memory plan from P1.S9 is fixed at startup, so the set of
|
|
// regions and their sizes is known before anything is allocated, and an allocator that can free would be
|
|
// solving a problem the engine does not have while adding fragmentation and failure modes it does.
|
|
//
|
|
// The reason to get this in early is that the VRAM budget is the binding constraint of the whole design
|
|
// (5.95 GB pooled between KV and the expert cache, 33.97 GB of experts in DRAM). A runtime that discovers at
|
|
// token 4000 that it has overcommitted has already lost; the plan is printed against `cudaMemGetInfo` at
|
|
// startup so the discrepancy is visible immediately.
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <stdexcept>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace strata::core {
|
|
|
|
struct DeviceInfo {
|
|
int ordinal = -1;
|
|
std::string name;
|
|
int cc_major = 0, cc_minor = 0;
|
|
uint64_t total_bytes = 0; // as reported by cudaMemGetInfo at query time
|
|
uint64_t free_bytes = 0;
|
|
int driver_version = 0, runtime_version = 0;
|
|
int multi_processor_count = 0;
|
|
std::string arch; // HIP: gcnArchName without its feature suffix ("gfx1201"); empty on CUDA
|
|
};
|
|
|
|
// HIP builds: whether GPU `ordinal` can run this binary - its architecture must be one the binary was COMPILED
|
|
// for (STRATA_HIP_ARCHS, set by cmake/hip_backend.cmake) and it must run wave32. "" when it can (or when there
|
|
// is no such device: the caller's own device errors apply), else the reason in a sentence. A binary carried to
|
|
// another card would otherwise fail later with "invalid device function". CUDA builds: always "".
|
|
std::string gpu_arch_problem(int ordinal);
|
|
|
|
// The GPU architectures this binary was compiled for ("gfx1100,gfx1201"); "" on CUDA builds.
|
|
const char* compiled_gpu_archs();
|
|
|
|
// Throws when there is no CUDA device. The engine targets sm_120 specifically and must say so rather than
|
|
// run slowly on something else: `CMakeLists.txt` already refuses to COMPILE for another architecture, and
|
|
// this is the matching check at run time (a binary can be carried to a different machine).
|
|
DeviceInfo device_info(int ordinal = 0);
|
|
|
|
class CudaError : public std::runtime_error {
|
|
public:
|
|
CudaError(const std::string& what, int code) : std::runtime_error(what), code_(code) {}
|
|
int code() const { return code_; }
|
|
|
|
private:
|
|
int code_;
|
|
};
|
|
|
|
// One cudaMalloc, bump-allocated below. `poison` fills new allocations with a NaN-ish pattern in a debug
|
|
// build so that reading uninitialised VRAM gives a NaN rather than a plausible number - the same reasoning as
|
|
// the harness work in Phase 1: a wrong value that looks right is the expensive kind.
|
|
class DeviceArena {
|
|
public:
|
|
explicit DeviceArena(uint64_t bytes, int ordinal = 0, bool poison = false);
|
|
~DeviceArena();
|
|
DeviceArena(const DeviceArena&) = delete;
|
|
DeviceArena& operator=(const DeviceArena&) = delete;
|
|
|
|
// `align` must be a power of two; 256 keeps every sub-allocation at a sector boundary.
|
|
void* alloc(uint64_t bytes, uint64_t align = 256);
|
|
|
|
uint64_t capacity() const { return capacity_; }
|
|
uint64_t used() const { return used_; }
|
|
uint64_t peak() const { return used_; } // no frees, so used IS the peak
|
|
int ordinal() const { return ordinal_; }
|
|
void* base() const { return base_; }
|
|
|
|
private:
|
|
void* base_ = nullptr;
|
|
uint64_t capacity_ = 0, used_ = 0;
|
|
int ordinal_ = 0;
|
|
bool poison_ = false;
|
|
};
|
|
|
|
} // namespace strata::core
|