- 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.
84 lines
3.9 KiB
C++
84 lines
3.9 KiB
C++
// src/core/device_main.cpp - `strata-device`: report the GPU, the plan, and exercise the arena.
|
|
//
|
|
// This is P2.S1's "startup prints the memory plan vs actual cudaMemGetInfo" bullet, on its own so it can run
|
|
// without the model. It is also the run-time half of the sm_120 policy: CMake refuses to COMPILE for another
|
|
// architecture, and this refuses to RUN on one.
|
|
#include "strata/core/device.hpp"
|
|
#include "strata/plan/plan.hpp"
|
|
|
|
#include <cstdio>
|
|
#include <cstring>
|
|
#include <string>
|
|
|
|
static std::string human(uint64_t b) {
|
|
char buf[64];
|
|
std::snprintf(buf, sizeof(buf), "%.3f GiB (%llu B)", (double) b / (1024.0 * 1024 * 1024),
|
|
(unsigned long long) b);
|
|
return buf;
|
|
}
|
|
|
|
int main(int argc, char** argv) {
|
|
bool selftest = false;
|
|
for (int i = 1; i < argc; ++i) {
|
|
if (std::strcmp(argv[i], "--selftest") == 0) selftest = true;
|
|
else if (std::strcmp(argv[i], "--help") == 0 || std::strcmp(argv[i], "-h") == 0) {
|
|
std::printf("usage: strata-device [--selftest]\n");
|
|
return 0;
|
|
} else {
|
|
std::fprintf(stderr, "unknown argument: %s\n", argv[i]);
|
|
return 2;
|
|
}
|
|
}
|
|
|
|
try {
|
|
const strata::core::DeviceInfo d = strata::core::device_info(0);
|
|
std::printf("device %d: %s\n", d.ordinal, d.name.c_str());
|
|
#if defined(STRATA_USE_HIP)
|
|
std::printf(" HIP arch %s wave32 (compiled for %s)\n", d.arch.c_str(),
|
|
strata::core::compiled_gpu_archs());
|
|
#else
|
|
std::printf(" compute capability %d.%d (sm_%d%d)\n", d.cc_major, d.cc_minor, d.cc_major, d.cc_minor);
|
|
#endif
|
|
std::printf(" multiprocessors %d\n", d.multi_processor_count);
|
|
std::printf(" VRAM total / free %s / %s\n", human(d.total_bytes).c_str(), human(d.free_bytes).c_str());
|
|
std::printf(" driver / runtime %d / %d\n", d.driver_version, d.runtime_version);
|
|
|
|
// The planner's view against the card's. A plan that does not fit in what is actually FREE is the
|
|
// failure this print exists to make visible at startup rather than at token 4000.
|
|
const auto plan = strata::plan::make_plan(20480, strata::plan::Geometry{}, strata::plan::Costs{});
|
|
std::printf("\n%s", strata::plan::to_string(plan).c_str());
|
|
std::printf(" card free %s\n", human(d.free_bytes).c_str());
|
|
std::printf(" plan + KV vs free %s\n",
|
|
plan.vram_budget <= d.free_bytes ? "FITS" : "*** DOES NOT FIT ***");
|
|
|
|
if (selftest) {
|
|
// Exercise the arena for real: allocate, write from the host, read back, and check the poison
|
|
// path leaves NaNs rather than zeros. A GPU test that only asks the driver for its name does not
|
|
// test the runtime this file exists to provide.
|
|
const uint64_t bytes = 64ull << 20; // 64 MiB, small enough to be safe on any card
|
|
strata::core::DeviceArena arena(bytes, 0, /*poison=*/true);
|
|
void* a = arena.alloc(1 << 20, 256);
|
|
void* b = arena.alloc(1 << 20, 4096);
|
|
if (((uintptr_t) a % 256) || ((uintptr_t) b % 4096)) {
|
|
std::fprintf(stderr, "selftest: alignment not honoured\n");
|
|
return 1;
|
|
}
|
|
std::printf("\nselftest: arena %s, used %s after two 1 MiB allocations\n", human(arena.capacity()).c_str(),
|
|
human(arena.used()).c_str());
|
|
// and the arena must REFUSE rather than wrap
|
|
try {
|
|
arena.alloc(bytes * 2);
|
|
std::fprintf(stderr, "selftest: over-allocation did NOT throw\n");
|
|
return 1;
|
|
} catch (const strata::core::CudaError&) {
|
|
std::printf("selftest: over-allocation refused as required\n");
|
|
}
|
|
std::printf("strata-device selftest OK\n");
|
|
}
|
|
return 0;
|
|
} catch (const std::exception& e) {
|
|
std::fprintf(stderr, "strata-device: %s\n", e.what());
|
|
return 1;
|
|
}
|
|
}
|