96 lines
3.3 KiB
C++
96 lines
3.3 KiB
C++
|
|
// Step 1980: ProjectStackDeclarator
|
||
|
|
//
|
||
|
|
// t1: declare and librariesForDomain returns qualifying libs
|
||
|
|
// t2: library with score 0 not returned by librariesForDomain
|
||
|
|
// t3: hasDomain checks operationDomains list
|
||
|
|
// t4: empty declared set returns empty
|
||
|
|
// t5: multiple qualifying libraries for one domain all returned
|
||
|
|
|
||
|
|
#include "ProjectStackDeclarator.h"
|
||
|
|
#include "CUDALibraryProfile.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; }
|
||
|
|
|
||
|
|
void t1() {
|
||
|
|
T(declare_and_librariesForDomain_returns_qualifying);
|
||
|
|
auto ledger = ws::CUDALibraryProfile::buildLedger();
|
||
|
|
ws::ProjectStackDeclarator decl;
|
||
|
|
decl.projectId = "test";
|
||
|
|
decl.declare("cublas");
|
||
|
|
decl.declare("cufft");
|
||
|
|
decl.declare("thrust");
|
||
|
|
auto libs = decl.librariesForDomain("compute.matrix", ledger);
|
||
|
|
C(libs.size() == 1, "1 qualifying lib for compute.matrix");
|
||
|
|
C(libs[0] == "cublas", "cublas qualifies");
|
||
|
|
auto fft_libs = decl.librariesForDomain("compute.fft", ledger);
|
||
|
|
C(fft_libs.size() == 1, "1 qualifying lib for compute.fft");
|
||
|
|
C(fft_libs[0] == "cufft", "cufft qualifies");
|
||
|
|
P();
|
||
|
|
}
|
||
|
|
|
||
|
|
void t2() {
|
||
|
|
T(zero_score_library_not_returned);
|
||
|
|
auto ledger = ws::CUDALibraryProfile::buildLedger();
|
||
|
|
ws::ProjectStackDeclarator decl;
|
||
|
|
decl.declare("cublas");
|
||
|
|
decl.declare("cufft");
|
||
|
|
// cublas/compute.fft = 0, cufft/compute.fft = 0.99
|
||
|
|
auto libs = decl.librariesForDomain("compute.fft", ledger);
|
||
|
|
C(libs.size() == 1, "only cufft qualifies");
|
||
|
|
C(libs[0] == "cufft", "cufft is the only result");
|
||
|
|
P();
|
||
|
|
}
|
||
|
|
|
||
|
|
void t3() {
|
||
|
|
T(hasDomain_checks_domains_list);
|
||
|
|
ws::ProjectStackDeclarator decl;
|
||
|
|
decl.addDomain("compute.matrix");
|
||
|
|
decl.addDomain("serialization.json");
|
||
|
|
C(decl.hasDomain("compute.matrix"), "compute.matrix present");
|
||
|
|
C(decl.hasDomain("serialization.json"), "serialization.json present");
|
||
|
|
C(!decl.hasDomain("compute.fft"), "compute.fft absent");
|
||
|
|
P();
|
||
|
|
}
|
||
|
|
|
||
|
|
void t4() {
|
||
|
|
T(empty_declared_returns_empty);
|
||
|
|
auto ledger = ws::CUDALibraryProfile::buildLedger();
|
||
|
|
ws::ProjectStackDeclarator decl;
|
||
|
|
auto libs = decl.librariesForDomain("compute.matrix", ledger);
|
||
|
|
C(libs.empty(), "empty declared set -> empty result");
|
||
|
|
P();
|
||
|
|
}
|
||
|
|
|
||
|
|
void t5() {
|
||
|
|
T(multiple_qualifying_libs_all_returned);
|
||
|
|
auto ledger = ws::Sprint286IntegrationSummary::buildSeedLedger();
|
||
|
|
ws::ProjectStackDeclarator decl;
|
||
|
|
decl.declare("cublas");
|
||
|
|
decl.declare("numpy");
|
||
|
|
// Both cublas (0.99) and numpy (0.95) qualify for compute.matrix
|
||
|
|
auto libs = decl.librariesForDomain("compute.matrix", ledger);
|
||
|
|
C(libs.size() == 2, "both cublas and numpy qualify");
|
||
|
|
bool hasCublas = false, hasNumpy = false;
|
||
|
|
for (const auto& l : libs) {
|
||
|
|
if (l == "cublas") hasCublas = true;
|
||
|
|
if (l == "numpy") hasNumpy = true;
|
||
|
|
}
|
||
|
|
C(hasCublas, "cublas present");
|
||
|
|
C(hasNumpy, "numpy present");
|
||
|
|
P();
|
||
|
|
}
|
||
|
|
|
||
|
|
int main() {
|
||
|
|
std::cout << "Step 1980: ProjectStackDeclarator\n";
|
||
|
|
t1(); t2(); t3(); t4(); t5();
|
||
|
|
std::cout << "\n" << p << "/" << (p + f) << " passed\n";
|
||
|
|
return f > 0 ? 1 : 0;
|
||
|
|
}
|