The cards are checked before anything is placed on them (src/card_check.hpp has the rules): a card that fails one would otherwise take the whole load first and then fail far from the cause, an sm_70 build on 24 GB cards out of memory, a short BAR1 as a ring that never completes. The IOMMU check comes before BAR1's, as it is the one that refuses a card with no sysfs directory: BAR1's would only say
| 110 | // memory, a short BAR1 as a ring that never completes. The IOMMU check comes before BAR1's, as it is the one that |
| 111 | // refuses a card with no sysfs directory: BAR1's would only say it cannot open the file |
| 112 | void check_cards() { |
| 113 | const bool skip_bar1 = env_flag("FNX_SKIP_BAR1_CHECK"); |
| 114 | if (skip_bar1) std::fprintf(stderr, "fnx: FNX_SKIP_BAR1_CHECK=1: the cards' BAR1 is not checked against their memory\n"); |
| 115 | for (int dev = 0; dev < NCARD; ++dev) { |
| 116 | cudaDeviceProp prop; |
| 117 | ck(cudaGetDeviceProperties(&prop, dev), "cudaGetDeviceProperties"); |
| 118 | #if FNX_HIP |
| 119 | // the code objects in the binary: gfx1201 (R9700, RX 9070; run), gfx1200 (RX 9060) and gfx1100..1103 (RDNA3; not run on a multi-card PC): the card's gfx name, not a |
| 120 | // compute capability. Any other card would find no kernels |
| 121 | { |
| 122 | bool built = false; |
| 123 | for (const char* a : {"gfx1201", "gfx1200", "gfx1100", "gfx1101", "gfx1102", "gfx1103"}) |
| 124 | if (std::strncmp(prop.gcnArchName, a, 7) == 0) built = true; |
| 125 | if (!built) |
| 126 | throw std::runtime_error("card " + std::to_string(dev) + " (" + prop.name + ") is " + prop.gcnArchName + |
| 127 | " and this build has kernels for gfx1201, gfx1200 and gfx1100..gfx1103 only"); |
| 128 | } |
| 129 | (void) FNX_ARCH; |
| 130 | #else |
| 131 | require_card_arch(dev, prop.name, prop.major, prop.minor, FNX_ARCH); |
| 132 | #endif |
| 133 | #if FNX_HOSTRING |
| 134 | (void) skip_bar1; // no card writes into another: the identity-domain and BAR1 requirements do not apply |
| 135 | #else |
| 136 | const std::string bdf = card_bdf(dev), dir = "/sys/bus/pci/devices/" + bdf; |
| 137 | require_identity_iommu(dev, dir); |
| 138 | if (!skip_bar1) check_bar1(dev, bdf, dir, prop); |
| 139 | #endif |
| 140 | } |
| 141 | #if FNX_HIP |
| 142 | // a card Strata has not run the split on (anything but gfx1201): say so once, then check its kernels against a scalar reference before the model is loaded (hip/selftest_policy.hpp) |
| 143 | { |
| 144 | cudaDeviceProp prop; |
| 145 | ck(cudaGetDeviceProperties(&prop, 0), "cudaGetDeviceProperties"); |
| 146 | const SelftestDecision d = selftest_decide(prop.gcnArchName, std::getenv("FNX_SELFTEST"), std::getenv("FNX_SELFTEST_FAIL"), [&](std::string& covered) { |
| 147 | for (int dev = 0; dev < NCARD; ++dev) { |
| 148 | std::string c; |
| 149 | const std::string bad = selftest_card(dev, c); |
| 150 | if (!bad.empty()) return "card " + std::to_string(dev) + ": " + bad; |
| 151 | covered += (covered.empty() ? "" : "; ") + c; |
| 152 | } |
| 153 | return std::string(); |
| 154 | }); |
| 155 | for (const std::string& line : d.lines) std::fprintf(stderr, "fnx: %s\n", line.c_str()); |
| 156 | if (!d.ok) throw std::runtime_error("the kernel self-test failed on " + std::string(prop.gcnArchName).substr(0, std::string(prop.gcnArchName).find(':')) + ", the split engine does not run on this card"); |
| 157 | } |
| 158 | #endif |
| 159 | } |
| 160 | |
| 161 | float f16_to_f32(uint16_t h) { |
| 162 | const uint32_t s = (h >> 15) & 1, e = (h >> 10) & 31, m = h & 1023; |
no test coverage detected