@@ -1,13 +1,13 @@
|
||||
import yargs from 'yargs';
|
||||
import { spawn } from 'child_process';
|
||||
import { RunCPUOptions, runcpuOptions } from '../commands/spec.js';
|
||||
import path from 'path';
|
||||
import { ConfigOptions, mkSPEC, renderConfig, getBaseRatios } from '../spec/index.js';
|
||||
import { sw64TargetOptions } from '../commands/compiler.js';
|
||||
import crypto from 'crypto';
|
||||
import { hideBin } from 'yargs/helpers';
|
||||
import * as sunway from '../sunway.js';
|
||||
import chalk from 'chalk';
|
||||
import crypto from 'crypto';
|
||||
import path from 'path';
|
||||
import yargs from 'yargs';
|
||||
import { hideBin } from 'yargs/helpers';
|
||||
import { sw64TargetOptions } from '../commands/compiler.js';
|
||||
import { RunCPUOptions } from '../commands/spec.js';
|
||||
import { getBaseRatios, mkSPEC, spawnSPECWithID } from '../spec/index.js';
|
||||
import * as sunway from '../sunway.js';
|
||||
import { cflangLibs, toolchain, ToolchainSuite } from '../toolchain/index.js';
|
||||
|
||||
// Define the yargs options
|
||||
const argv = await yargs(hideBin(process.argv))
|
||||
@@ -83,27 +83,6 @@ console.log(`using sysroot: ${chalk.red(sysroot)}`);
|
||||
|
||||
const specPath = path.resolve(argv.spec);
|
||||
|
||||
|
||||
function runspec(specConfig: string, id: string) {
|
||||
const config = `${id}.cfg`;
|
||||
|
||||
const spec = mkSPEC(specPath);
|
||||
|
||||
spec.newConfig(config, specConfig);
|
||||
|
||||
return spawn('runcpu', [
|
||||
...runcpuOptions({
|
||||
outputRoot: path.resolve(path.resolve(argv.output), id),
|
||||
config,
|
||||
setprocgroup: true,
|
||||
workload: argv.workload as RunCPUOptions["workload"],
|
||||
buildType: argv.buildType as RunCPUOptions["buildType"],
|
||||
benchmarks: argv.benchmarks as RunCPUOptions["benchmarks"],
|
||||
action: argv.action as RunCPUOptions["action"],
|
||||
}),
|
||||
], { env: spec.getEnvironment() });
|
||||
}
|
||||
|
||||
// Function to convert hash to prefix
|
||||
|
||||
// Generate a random UUID for this run
|
||||
@@ -124,12 +103,11 @@ const unalignedFlags = [
|
||||
];
|
||||
|
||||
|
||||
console.log(`Running SPEC compiled from ${prefix} as ${uuid}`);
|
||||
console.log(`View: ${path.resolve(argv.output, uuid)}`)
|
||||
const spec = mkSPEC(argv.spec);
|
||||
|
||||
const specProc = runspec(
|
||||
renderConfig({
|
||||
prefix,
|
||||
const specProc = await spawnSPECWithID(
|
||||
spec,
|
||||
{
|
||||
optimize: [
|
||||
"-O2",
|
||||
...sw64TargetOptions({ simd: argv.simd }),
|
||||
@@ -139,11 +117,19 @@ const specProc = runspec(
|
||||
'-static',
|
||||
`-L${path.resolve(prefix, 'lib')}`,
|
||||
],
|
||||
sysroot,
|
||||
compiler: argv.compilerSuite as ConfigOptions["compiler"],
|
||||
}),
|
||||
compilerPaths: toolchain(argv.compilerPrefix, argv.compilerSuite as ToolchainSuite),
|
||||
libs: argv.compilerSuite === "llvm" ? cflangLibs(prefix) : [],
|
||||
},
|
||||
{
|
||||
setprocgroup: true,
|
||||
workload: argv.workload as RunCPUOptions["workload"],
|
||||
buildType: argv.buildType as RunCPUOptions["buildType"],
|
||||
benchmarks: argv.benchmarks as RunCPUOptions["benchmarks"],
|
||||
action: argv.action as RunCPUOptions["action"],
|
||||
},
|
||||
argv.output,
|
||||
uuid
|
||||
);
|
||||
|
||||
const baseRatios = await getBaseRatios(specProc);
|
||||
console.log(baseRatios);
|
||||
console.log(baseRatios);
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import * as path from 'path';
|
||||
import * as fs from "fs";
|
||||
import { promisify } from "util";
|
||||
import { ChildProcessByStdio } from 'child_process';
|
||||
import { Readable, Writable } from 'stream';
|
||||
import { createInterface } from 'readline';
|
||||
import { SPECBenchData, benchpath, exepath, buildpath } from './benchData.js';
|
||||
import specTemplate from '../../assets/specTemplate.cfg';
|
||||
import assert from 'assert';
|
||||
import { ChildProcessByStdio, spawn } from 'child_process';
|
||||
import * as fs from "fs";
|
||||
import * as path from 'path';
|
||||
import { createInterface } from 'readline';
|
||||
import { Readable, Writable } from 'stream';
|
||||
import { promisify } from "util";
|
||||
import specTemplate from '../../assets/specTemplate.cfg';
|
||||
import { RunCPUOptions, runcpuOptions } from '../commands/spec.js';
|
||||
import { SPECBenchData, benchpath, buildpath, exepath } from './benchData.js';
|
||||
|
||||
|
||||
|
||||
@@ -211,3 +212,27 @@ export function parseSPECCSVResultsTable(data: string): ParsedResult {
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
|
||||
export async function spawnSPECWithID(
|
||||
spec: SPEC,
|
||||
specConfig: ConfigOptions,
|
||||
runcpuConfig: RunCPUOptions,
|
||||
outputPath: string,
|
||||
id: string,
|
||||
) {
|
||||
const outputRoot = path.resolve(outputPath, id);
|
||||
|
||||
console.log(`runspec: launch SPEC benchmark at ${id}, config: ${JSON.stringify(specConfig)}`);
|
||||
console.log(`runspec: view output dir: ${outputRoot}`);
|
||||
|
||||
const config = `${id}.cfg`;
|
||||
|
||||
await spec.newConfig(config, renderConfig(specConfig));
|
||||
|
||||
return spawn('runcpu', runcpuOptions({
|
||||
outputRoot,
|
||||
config,
|
||||
...runcpuConfig,
|
||||
}), { env: spec.getEnvironment() });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user