mix-object: refactor with lambdas, use two spec instances
This commit is contained in:
123
mix-object.ts
123
mix-object.ts
@@ -7,9 +7,9 @@
|
||||
*/
|
||||
|
||||
import { binSearch } from "./algorithm";
|
||||
import { pop2, defaultSPEC, SPEC, Bench, mkBench } from "./spec";
|
||||
import { pop2, SPEC, Bench, mkBench, mkSPEC } from "./spec";
|
||||
import path from "path";
|
||||
import { FLANG, PREFIX, SYSROOT_PREFIX } from "./environment";
|
||||
import { FLANG, PREFIX, SW_AUTOVEC, SYSROOT_PREFIX } from "./environment";
|
||||
import { generalCommand, linkerCommand } from "./commands/compiler";
|
||||
import { runcpuOptions } from "./commands/spec";
|
||||
import { renderConfig } from "./spec";
|
||||
@@ -63,12 +63,6 @@ function mkPop2Bench(spec: SPEC): Bench & Linkable {
|
||||
|
||||
|
||||
async function main() {
|
||||
const spec = defaultSPEC;
|
||||
|
||||
// Path to SPEC2017 test suite.
|
||||
spec.setenv();
|
||||
|
||||
|
||||
// Just use scalar vanilla version of grid, will it work?
|
||||
//
|
||||
// No, does not work.
|
||||
@@ -77,42 +71,121 @@ async function main() {
|
||||
const length = pop2.objectNames.length;
|
||||
|
||||
|
||||
const beforeHalf = [
|
||||
// Empty: /home/lyc/workspace/sw-autovec/spec2017/result/CPU2017.664.fpspeed.refspeed.txt
|
||||
const beforeHalfGrid = [
|
||||
// 0.336
|
||||
|
||||
// Scalar [0, 161): Error,
|
||||
// /home/lyc/workspace/sw-autovec/spec2017/result/CPU2017.671.fpspeed.refspeed.txt
|
||||
// : /home/lyc/workspace/sw-autovec/spec2017/result/CPU2017.664.fpspeed.refspeed.txt
|
||||
// Scalar [161, 322): Correct.
|
||||
|
||||
false,
|
||||
// Scalar [161, 241): Error,
|
||||
// /home/lyc/workspace/sw-autovec/spec2017/result/CPU2017.672.fpspeed.refspeed.txt
|
||||
// Scalar [241, 322): Error,
|
||||
// /home/lyc/workspace/sw-autovec/spec2017-2/result/CPU2017.672.fpspeed.refspeed.rsf
|
||||
// Vector [161, 241): Error,
|
||||
// Vector [241, 322): Error,
|
||||
// /home/lyc/workspace/sw-autovec/spec2017-2/result/CPU2017.673.fpspeed.refspeed.txt
|
||||
|
||||
false,
|
||||
// Vector [241, 281): Error,
|
||||
// /home/lyc/workspace/sw-autovec/spec2017/result/CPU2017.674.fpspeed.refspeed.txt
|
||||
// Vector [281, 322): Correct.
|
||||
|
||||
true,
|
||||
// Vector [241, 261): Error,
|
||||
// /home/lyc/workspace/sw-autovec/spec2017/result/CPU2017.675.fpspeed.refspeed.rsf
|
||||
// Vector [261, 281): Correct.
|
||||
|
||||
true,
|
||||
// Vector [241, 251): Error,
|
||||
// /home/lyc/workspace/sw-autovec/spec2017/result/CPU2017.676.fpspeed.refspeed.txt
|
||||
// Vector [251, 261): Stopped.
|
||||
|
||||
true,
|
||||
// Vector [241, 246): Error,
|
||||
// /home/lyc/workspace/sw-autovec/spec2017/result/CPU2017.677.fpspeed.refspeed.rsf
|
||||
];
|
||||
|
||||
const [vBegin, vHalf, vEnd] = binSearch(0, length, beforeHalf);
|
||||
|
||||
const beforeHalfNoGrid: boolean[] = [
|
||||
|
||||
false,
|
||||
|
||||
// Vector [161, 241): Error
|
||||
// /home/lyc/workspace/sw-autovec/spec2017/result/CPU2017.679.
|
||||
// Vector [241, 322): Unknown
|
||||
true,
|
||||
|
||||
// Vector [161, 201): Unknown
|
||||
// Vector [201, 241): Error
|
||||
false,
|
||||
|
||||
// Vector [201, 221): Error
|
||||
// /home/lyc/workspace/sw-autovec/spec2017/result/CPU2017.681
|
||||
// Vector [221, 241): Unknown
|
||||
true,
|
||||
|
||||
// Vector [201, 211): Error
|
||||
// Vector [211, 221): Unknown
|
||||
true,
|
||||
|
||||
// Vector [201, 206): Unknown
|
||||
// Vector [206, 211): Error
|
||||
false,
|
||||
|
||||
// Vector [206, 208): Error
|
||||
// Vector [208, 211): ?
|
||||
true,
|
||||
|
||||
// Vector [206, 207): ?
|
||||
// !!! Vector [207, 208): Error
|
||||
];
|
||||
|
||||
|
||||
const [vBegin, vHalf, vEnd] = binSearch(0, length, beforeHalfNoGrid);
|
||||
|
||||
|
||||
// use scalar version if index is in this range.
|
||||
const scalarRange = [
|
||||
[0, length / 2],
|
||||
[length / 2, length],
|
||||
const vectorRange: number[][] = [
|
||||
[0, length],
|
||||
// [vBegin, vHalf],
|
||||
// [vHalf, vEnd],
|
||||
];
|
||||
|
||||
const useVectors = scalarRange.map(([a, b]) => ({
|
||||
useVector: (_: string, index: number) => {
|
||||
// If index is not in range [a, b), use the vector version.
|
||||
return !(a <= index && index < b);
|
||||
const specs = [
|
||||
path.join(SW_AUTOVEC, "spec2017"),
|
||||
path.join(SW_AUTOVEC, "spec2017-2")
|
||||
].map(mkSPEC);
|
||||
|
||||
const useVectors = vectorRange.map(([a, b], index) => ({
|
||||
useVector: (name: string, index: number) => {
|
||||
if (name === "grid.fppized.o")
|
||||
return false;
|
||||
if (index == 207) {
|
||||
console.log(`${name} is a bad object!`);
|
||||
return false;
|
||||
}
|
||||
// If index is in range [a, b), use the vector version.
|
||||
return a <= index && index < b;
|
||||
},
|
||||
range: [a, b],
|
||||
spec: specs[index],
|
||||
}));
|
||||
|
||||
// Linking each "useVector" instances in sequence
|
||||
for (const { useVector: predicate, range } of useVectors) {
|
||||
await Promise.all(useVectors.map(async ({ useVector, range, spec }) => {
|
||||
const buildPathObj = (build: string) => (objname: string) => path.join(spec.buildpath(pop2), build, objname);
|
||||
const vector = buildPathObj("build_vector");
|
||||
const scalar = buildPathObj("build_scalar_vanilla");
|
||||
|
||||
const pop2Bench = mkPop2Bench(spec);
|
||||
|
||||
console.log(`Linking objects. Range in [${range[0]}, ${range[1]}) used scalar version. others are vector version.`);
|
||||
console.log(`Linking objects. Range in [${range[0]}, ${range[1]}) used vector version. others are scalar version.`);
|
||||
|
||||
await pop2Bench.link(names =>
|
||||
names.map((obj, index) =>
|
||||
predicate(obj, index) ? vector(obj) : scalar(obj)));
|
||||
useVector(obj, index) ? vector(obj) : scalar(obj)));
|
||||
|
||||
const config = "clang-O2.cfg";
|
||||
|
||||
@@ -141,10 +214,8 @@ async function main() {
|
||||
buildType: "nobuild",
|
||||
outputFormat: ["text", "config"]
|
||||
}),
|
||||
], { stdio: "inherit" });
|
||||
|
||||
}
|
||||
|
||||
], { stdio: "inherit", env: spec.getEnvironment() });
|
||||
}));
|
||||
}
|
||||
|
||||
main();
|
||||
|
||||
Reference in New Issue
Block a user