81 lines
2.7 KiB
C++
81 lines
2.7 KiB
C++
|
|
// Step 1968: LibrarySymbolRecord
|
||
|
|
//
|
||
|
|
// t1: default fields
|
||
|
|
// t2: populated record fields
|
||
|
|
// t3: caveats list
|
||
|
|
// t4: usagePattern field
|
||
|
|
// t5: multiple records for different domains are independent
|
||
|
|
|
||
|
|
#include "LibrarySymbolRecord.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(default_fields_empty);
|
||
|
|
ws::LibrarySymbolRecord r;
|
||
|
|
C(r.libraryId.empty(), "empty libraryId");
|
||
|
|
C(r.functionName.empty(), "empty functionName");
|
||
|
|
C(r.signature.empty(), "empty signature");
|
||
|
|
C(r.operationDomain.empty(), "empty operationDomain");
|
||
|
|
C(r.caveats.empty(), "empty caveats");
|
||
|
|
P();
|
||
|
|
}
|
||
|
|
|
||
|
|
void t2() {
|
||
|
|
T(populated_record_fields);
|
||
|
|
ws::LibrarySymbolRecord r;
|
||
|
|
r.libraryId = "cublas";
|
||
|
|
r.functionName = "cublasSgemm";
|
||
|
|
r.signature = "cublasStatus_t cublasSgemm(cublasHandle_t, ...)";
|
||
|
|
r.operationDomain = "compute.matrix";
|
||
|
|
C(r.libraryId == "cublas", "libraryId");
|
||
|
|
C(r.functionName == "cublasSgemm", "functionName");
|
||
|
|
C(r.operationDomain == "compute.matrix", "operationDomain");
|
||
|
|
C(!r.signature.empty(), "signature set");
|
||
|
|
P();
|
||
|
|
}
|
||
|
|
|
||
|
|
void t3() {
|
||
|
|
T(caveats_list);
|
||
|
|
ws::LibrarySymbolRecord r;
|
||
|
|
r.caveats = {"requires-device-memory", "no-automatic-handle"};
|
||
|
|
C(r.caveats.size() == 2, "2 caveats");
|
||
|
|
C(r.caveats[0] == "requires-device-memory", "first caveat");
|
||
|
|
C(r.caveats[1] == "no-automatic-handle", "second caveat");
|
||
|
|
P();
|
||
|
|
}
|
||
|
|
|
||
|
|
void t4() {
|
||
|
|
T(usage_pattern_field);
|
||
|
|
ws::LibrarySymbolRecord r;
|
||
|
|
r.libraryId = "nlohmann_json";
|
||
|
|
r.functionName = "json::parse";
|
||
|
|
r.usagePattern = "auto j = nlohmann::json::parse(input_string);";
|
||
|
|
C(!r.usagePattern.empty(), "usagePattern set");
|
||
|
|
C(r.usagePattern.find("parse") != std::string::npos, "contains 'parse'");
|
||
|
|
P();
|
||
|
|
}
|
||
|
|
|
||
|
|
void t5() {
|
||
|
|
T(records_for_different_domains_independent);
|
||
|
|
ws::LibrarySymbolRecord r1{"cublas", "cublasSgemm", "sig1", "compute.matrix", "", {}};
|
||
|
|
ws::LibrarySymbolRecord r2{"cublas", "cublasDnorm", "sig2", "compute.statistics","", {}};
|
||
|
|
C(r1.libraryId == r2.libraryId, "same library");
|
||
|
|
C(r1.operationDomain != r2.operationDomain, "different domains");
|
||
|
|
C(r1.functionName != r2.functionName, "different functions");
|
||
|
|
P();
|
||
|
|
}
|
||
|
|
|
||
|
|
int main() {
|
||
|
|
std::cout << "Step 1968: LibrarySymbolRecord\n";
|
||
|
|
t1(); t2(); t3(); t4(); t5();
|
||
|
|
std::cout << "\n" << p << "/" << (p + f) << " passed\n";
|
||
|
|
return f > 0 ? 1 : 0;
|
||
|
|
}
|