Files
whetstone_DSL/editor/tests/step1978_test.cpp
Bill d7caaa8762 Sprint 290: CUDA End-to-End Proof (steps 1978-1982)
CUDALibraryProfile, CUDASymbolCatalog, ProjectStackDeclarator,
ProofPipelineRunner, Sprint290IntegrationSummary. 25/25 tests passing.
End-to-end proof: "GPU matrix multiply. JSON result serialization."
-> cublas for compute.matrix, nlohmann_json for serialization.json.
Phase 6: Library Dispatch COMPLETE (Sprints 286-290, steps 1958-1982).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-02 10:27:47 -07:00

76 lines
2.7 KiB
C++

// Step 1978: CUDALibraryProfile
//
// t1: buildLedger has cublas at 0.99 for compute.matrix
// t2: cufft/compute.fft = 0.99
// t3: thrust/compute.parallel = 0.97
// t4: cudnn/compute.ml.inference = 0.99
// t5: cublas/compute.statistics is not applicable (score 0 / notApplicable)
#include "CUDALibraryProfile.h"
#include <iostream>
namespace ws = whetstone;
static int p = 0, f = 0;
#define T(n) { std::cout << " " << #n << "... "; }
#define P() { std::cout << "PASS\n"; ++p; }
#define F(m) { std::cout << "FAIL: " << m << "\n"; ++f; }
#define C(c, m) if (!(c)) { F(m); return; }
void t1() {
T(cublas_compute_matrix_0_99);
auto ledger = ws::CUDALibraryProfile::buildLedger();
C(ledger.score("cublas", "compute.matrix") == 0.99f, "cublas/compute.matrix = 0.99");
auto rec = ledger.get("cublas", "compute.matrix");
C(rec.has_value(), "record present");
C(!rec->preferredAPIs.empty(), "preferredAPIs non-empty");
bool hasSgemm = false;
for (const auto& api : rec->preferredAPIs)
if (api.find("cublasSgemm") != std::string::npos) hasSgemm = true;
C(hasSgemm, "cublasSgemm in preferredAPIs");
P();
}
void t2() {
T(cufft_compute_fft_0_99);
auto ledger = ws::CUDALibraryProfile::buildLedger();
C(ledger.score("cufft", "compute.fft") == 0.99f, "cufft/compute.fft = 0.99");
auto rec = ledger.get("cufft", "compute.fft");
C(rec.has_value(), "cufft record present");
C(!rec->preferredAPIs.empty(), "cufft preferredAPIs non-empty");
P();
}
void t3() {
T(thrust_compute_parallel_0_97);
auto ledger = ws::CUDALibraryProfile::buildLedger();
C(ledger.score("thrust", "compute.parallel") == 0.97f, "thrust/compute.parallel = 0.97");
C(ledger.score("thrust", "compute.sort") == 0.97f, "thrust/compute.sort = 0.97");
P();
}
void t4() {
T(cudnn_ml_inference_0_99);
auto ledger = ws::CUDALibraryProfile::buildLedger();
C(ledger.score("cudnn", "compute.ml.inference") == 0.99f, "cudnn/ml.inference = 0.99");
C(ledger.score("cudnn", "compute.ml.training") == 0.97f, "cudnn/ml.training = 0.97");
P();
}
void t5() {
T(cublas_statistics_not_applicable);
auto ledger = ws::CUDALibraryProfile::buildLedger();
// cublas/compute.statistics has notApplicable=true, score=0
C(ledger.score("cublas", "compute.statistics") == 0.0f, "cublas/compute.statistics = 0");
auto rec = ledger.get("cublas", "compute.statistics");
C(rec.has_value(), "record exists");
C(rec->notApplicable, "notApplicable = true");
P();
}
int main() {
std::cout << "Step 1978: CUDALibraryProfile\n";
t1(); t2(); t3(); t4(); t5();
std::cout << "\n" << p << "/" << (p + f) << " passed\n";
return f > 0 ? 1 : 0;
}