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>
100 lines
3.5 KiB
C++
100 lines
3.5 KiB
C++
// Step 1981: ProofPipelineRunner
|
|
//
|
|
// t1: run() on "GPU matrix multiply. JSON result serialization." -> 2 contracts
|
|
// t2: first contract selects cublas for compute.matrix
|
|
// t3: second contract selects nlohmann_json for serialization.json
|
|
// t4: run() skips unknown-domain sentences
|
|
// t5: empty spec produces no contracts
|
|
|
|
#include "ProofPipelineRunner.h"
|
|
#include "CUDALibraryProfile.h"
|
|
#include "CUDASymbolCatalog.h"
|
|
#include "Sprint286IntegrationSummary.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; }
|
|
|
|
static ws::ProofPipelineRunner makeCUDARunner() {
|
|
auto ledger = ws::CUDALibraryProfile::buildLedger();
|
|
// Add nlohmann_json for JSON tasks
|
|
ledger.set({"nlohmann_json", "serialization.json", 0.92f,
|
|
{"nlohmann::json::dump()", "nlohmann::json::parse()"}, {},
|
|
false, "2026-03-02", "benchmark"});
|
|
auto catalog = ws::CUDASymbolCatalog::buildCatalog();
|
|
ws::ProjectStackDeclarator decl;
|
|
decl.declare("cublas"); decl.declare("cufft");
|
|
decl.declare("thrust"); decl.declare("cudnn");
|
|
decl.declare("nlohmann_json");
|
|
return ws::ProofPipelineRunner(std::move(decl),
|
|
std::move(ledger),
|
|
std::move(catalog));
|
|
}
|
|
|
|
void t1() {
|
|
T(run_cuda_json_spec_produces_2_contracts);
|
|
auto runner = makeCUDARunner();
|
|
auto contracts = runner.run("GPU matrix multiply. JSON result serialization.");
|
|
C(contracts.size() == 2, "2 enriched contracts, got " + std::to_string(contracts.size()));
|
|
for (const auto& c : contracts) {
|
|
C(c.isEnriched(), "each contract is enriched");
|
|
}
|
|
P();
|
|
}
|
|
|
|
void t2() {
|
|
T(cublas_selected_for_compute_matrix);
|
|
auto runner = makeCUDARunner();
|
|
auto contracts = runner.run("GPU matrix multiply. JSON result serialization.");
|
|
bool found = false;
|
|
for (const auto& c : contracts) {
|
|
if (c.operationDomain == "compute.matrix" && c.selectedLibrary == "cublas")
|
|
found = true;
|
|
}
|
|
C(found, "cublas/compute.matrix contract present");
|
|
P();
|
|
}
|
|
|
|
void t3() {
|
|
T(nlohmann_selected_for_serialization_json);
|
|
auto runner = makeCUDARunner();
|
|
auto contracts = runner.run("GPU matrix multiply. JSON result serialization.");
|
|
bool found = false;
|
|
for (const auto& c : contracts) {
|
|
if (c.operationDomain == "serialization.json" && c.selectedLibrary == "nlohmann_json")
|
|
found = true;
|
|
}
|
|
C(found, "nlohmann_json/serialization.json contract present");
|
|
P();
|
|
}
|
|
|
|
void t4() {
|
|
T(unknown_domain_sentences_skipped);
|
|
auto runner = makeCUDARunner();
|
|
// "xyzzy frobnicate" has no known domain
|
|
auto contracts = runner.run("GPU matrix multiply. xyzzy frobnicate. JSON result serialization.");
|
|
C(contracts.size() == 2, "still 2 contracts (unknown sentence skipped)");
|
|
P();
|
|
}
|
|
|
|
void t5() {
|
|
T(empty_spec_produces_no_contracts);
|
|
auto runner = makeCUDARunner();
|
|
auto contracts = runner.run("");
|
|
C(contracts.empty(), "no contracts for empty spec");
|
|
auto contracts2 = runner.run("...");
|
|
C(contracts2.empty(), "no contracts for dots-only spec");
|
|
P();
|
|
}
|
|
|
|
int main() {
|
|
std::cout << "Step 1981: ProofPipelineRunner\n";
|
|
t1(); t2(); t3(); t4(); t5();
|
|
std::cout << "\n" << p << "/" << (p + f) << " passed\n";
|
|
return f > 0 ? 1 : 0;
|
|
}
|