okami.mom/strata

git clone https://git.nkp.pet/okami.mom/strata

Niko1221Merge f-plain-tail 79ce2d388 into the batch 19 candidate (build without MMQ: the plain pack's long-prompt floor on a discrete CUDA card, the start-up lines name the floor in force)4ea595bbe

main
3.3 KiB54 linesraw
1// plain_floor_rule.hpp: the long-prompt floor of the plain pack by card class and share state.  No GPU, no model.
2// Classes: plain pack (build without MMQ, non-native pack) or not; discrete CUDA card (answered, not integrated) or integrated / not asked / HIP; share armed (limit 3,072 or 1,024) or not; switch.
3#include <cstdint>
4#include <cstdio>
5#include <initializer_list>
6
7#include "strata/prefill/plain_floor_rule.hpp"
8
9using strata::prefill::floor_with_share;
10using strata::prefill::kPlainDiscreteFloor;
11using strata::prefill::plain_floor_off;
12using strata::prefill::plain_takes_discrete_floor;
13
14static int failed = 0;
15#define CHECK(x) do { if (!(x)) { std::fprintf(stderr, "FAIL %s:%d: %s\n", __FILE__, __LINE__, #x); ++failed; } } while (0)
16
17int main() {
18    constexpr int64_t kFused = 64;      // stream_floor_rule.hpp kFusedOnlyFloor, the plain pack's default floor
19    constexpr int64_t kDefault = 1024;  // kStreamFloorDefault
20    // the way back: only "0"
21    CHECK(!plain_floor_off(nullptr));
22    CHECK(!plain_floor_off(""));
23    CHECK(!plain_floor_off("00"));
24    CHECK(!plain_floor_off("1"));
25    CHECK(!plain_floor_off("off"));
26    CHECK(plain_floor_off("0"));
27    // class: only (plain pack) x (discrete CUDA card) x (switch not "0") takes the discrete floor
28    for (const char* env : {(const char*) nullptr, "", "1", "x"}) {
29        CHECK(plain_takes_discrete_floor(true, true, env));
30        CHECK(!plain_takes_discrete_floor(true, false, env));    // integrated / not asked yet / HIP: unchanged
31        CHECK(!plain_takes_discrete_floor(false, true, env));    // a native pack or a build with MMQ: unchanged
32        CHECK(!plain_takes_discrete_floor(false, false, env));
33    }
34    for (const bool plain : {false, true})
35        for (const bool disc : {false, true}) CHECK(!plain_takes_discrete_floor(plain, disc, "0"));   // the way back, every class
36    // the answer: the plain pack on a discrete card, share armed (3,072 / 1,024) or not, takes the discrete floor
37    CHECK(floor_with_share(true, 3072, kFused) == kPlainDiscreteFloor);
38    CHECK(floor_with_share(true, 1024, kFused) == kPlainDiscreteFloor);
39    CHECK(floor_with_share(true, 0, kFused) == kPlainDiscreteFloor);
40    CHECK(kPlainDiscreteFloor == 1536);   // the measured constant (RTX 5070); above the default floor and the plain pack's 64, below the share's limit
41    CHECK(kPlainDiscreteFloor > kDefault && kPlainDiscreteFloor > kFused && kPlainDiscreteFloor < 3072);
42    // a default floor above the constant is never lowered
43    CHECK(floor_with_share(true, 0, 4096) == 4096);
44    CHECK(floor_with_share(true, 3072, 4096) == 4096);
45    // every other class keeps the old answer: the share's limit when armed, else the default floor
46    CHECK(floor_with_share(false, 3072, kFused) == 3072);      // integrated GPU / unknown card / HIP, plain pack, share armed
47    CHECK(floor_with_share(false, 1024, kFused) == 1024);
48    CHECK(floor_with_share(false, 0, kFused) == kFused);       // integrated GPU, plain pack, no share: 64 stays
49    CHECK(floor_with_share(false, 3072, kDefault) == 3072);    // native pack, share armed
50    CHECK(floor_with_share(false, 0, kDefault) == kDefault);   // native pack, no share
51    CHECK(floor_with_share(false, -1, kDefault) == kDefault);  // no share (negative = not armed)
52    if (failed == 0) std::printf("plain_floor_rule_test: ok\n");
53    return failed == 0 ? 0 : 1;
54}