mix-object: auto bisect ref miscompilation

This commit is contained in:
2024-06-21 18:35:56 +08:00
parent 411a14451f
commit b899bf077f

View File

@@ -6,7 +6,7 @@
* 3. Link the set to an executable -> SPEC path, invoke "runcpu"
*/
import { binSearch } from "./algorithm";
import { autoBisect, binSearch } from "./algorithm";
import { pop2, SPEC, Bench, mkBench, mkSPEC, defaultSPEC, watchSPEC, parseSPECCSVResultsTable } from "./spec";
import path from "path";
import { FLANG, LLVM_EXTRACT, PREFIX, SW_AUTOVEC, SYSROOT_PREFIX, projectRoot } from "./environment";
@@ -274,7 +274,7 @@ async function verifyGridFunction() {
};
(async () => {
async function checkBaro() {
// It is known that object index == 207 is also wrong for pop2.
const spec = defaultSPEC;
@@ -479,4 +479,65 @@ async function verifyGridFunction() {
console.log("SPEC does not produce CSV output!");
}
}
};
async function bisectRef() {
const spec = defaultSPEC;
const [vector, scalar] = buildDirs.map(dir => buildPathObj(spec.buildpath(pop2))(dir));
const pop2Bench = mkPop2Bench(spec);
return await autoBisect(0, pop2.objectNames.length, async (begin, end) => {
console.log(`Checking range [${begin}, ${end})`);
console.log("Linking pop2 executable");
await pop2Bench.link(names =>
names.map((name, index) => {
// These two objects are known to have miscompilation.
if (name === "grid.fppized.o" || index == 207) {
return scalar(name);
}
// If index is in range [begin, end), use the vector version.
return begin <= index && index < end ? vector(name) : scalar(name);
}));
console.log("Running SPEC2017 benchmark.");
const specProcess = spawn("runcpu",
[
...runcpuOptions({
benchmarks: [pop2Bench.benchData().num.toString()],
config: "clang-O2.cfg",
workload: "ref",
buildType: "nobuild",
outputFormat: ["csv", "config"]
}),
], { env: spec.getEnvironment() });
const result = await watchSPEC(specProcess);
if ("CSV" in result.outputFiles) {
assert(result.outputFiles.CSV.length > 0);
const Results = parseSPECCSVResultsTable((await fs.readFile(result.outputFiles.CSV[0]))
.toString("utf-8"));
const benchResult = Results[`${pop2.num}.${pop2.name}`];
if (benchResult) {
const status = benchResult.baseStatus;
console.log(`status of this run: ${status}`);
return status !== "S";
}
assert(false, "Result should have pop2 field!");
} else {
console.log("SPEC does not produce CSV output!");
return true;
}
});
}
(async () => {
console.log(await bisectRef());
})();