okami.mom/strata

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

Niko1221Merge commit 'b8d604d28' into f-clean-1ab0fc432ed

main
1.3 KiB28 linesraw
1// Standalone run of the engine's kernel self-test (src/selftest.cu) on one card: no model, no engine. Built by the optional CMake target strata-split-selftest
2// (src/split/CMakeLists.txt; HIP only, off by default). Prints the card and the result; exit 0 when every test passed.
3//   selftest_main [device]
4#include <hip/hip_runtime.h>
5
6#include <chrono>
7#include <cstdio>
8#include <cstdlib>
9#include <string>
10
11#include "../src/selftest.hpp"
12
13int main(int argc, char** argv) {
14    const int dev = argc > 1 ? std::atoi(argv[1]) : 0;
15    hipDeviceProp_t p;
16    if (hipGetDeviceProperties(&p, dev) != hipSuccess) {
17        std::printf("no device %d\n", dev);
18        return 2;
19    }
20    std::printf("device %d: %s (%s), %d CUs, %.1f GiB\n", dev, p.name, p.gcnArchName, p.multiProcessorCount, (double) p.totalGlobalMem / (1 << 30));
21    std::string covered;
22    const auto t0 = std::chrono::steady_clock::now();
23    const std::string bad = fnx::selftest_card(dev, covered);
24    const double ms = std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - t0).count();
25    if (bad.empty()) std::printf("self-test PASSED in %.0f ms: %s\n", ms, covered.c_str());
26    else std::printf("self-test FAILED in %.0f ms: %s\n", ms, bad.c_str());
27    return bad.empty() ? 0 : 1;
28}