spec: add function spawnSPECWithID
#1
@@ -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 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
|
// Define the yargs options
|
||||||
const argv = await yargs(hideBin(process.argv))
|
const argv = await yargs(hideBin(process.argv))
|
||||||
@@ -83,27 +83,6 @@ console.log(`using sysroot: ${chalk.red(sysroot)}`);
|
|||||||
|
|
||||||
const specPath = path.resolve(argv.spec);
|
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
|
// Function to convert hash to prefix
|
||||||
|
|
||||||
// Generate a random UUID for this run
|
// Generate a random UUID for this run
|
||||||
@@ -124,12 +103,11 @@ const unalignedFlags = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
console.log(`Running SPEC compiled from ${prefix} as ${uuid}`);
|
const spec = mkSPEC(argv.spec);
|
||||||
console.log(`View: ${path.resolve(argv.output, uuid)}`)
|
|
||||||
|
|
||||||
const specProc = runspec(
|
const specProc = await spawnSPECWithID(
|
||||||
renderConfig({
|
spec,
|
||||||
prefix,
|
{
|
||||||
optimize: [
|
optimize: [
|
||||||
"-O2",
|
"-O2",
|
||||||
...sw64TargetOptions({ simd: argv.simd }),
|
...sw64TargetOptions({ simd: argv.simd }),
|
||||||
@@ -139,11 +117,19 @@ const specProc = runspec(
|
|||||||
'-static',
|
'-static',
|
||||||
`-L${path.resolve(prefix, 'lib')}`,
|
`-L${path.resolve(prefix, 'lib')}`,
|
||||||
],
|
],
|
||||||
sysroot,
|
compilerPaths: toolchain(argv.compilerPrefix, argv.compilerSuite as ToolchainSuite),
|
||||||
compiler: argv.compilerSuite as ConfigOptions["compiler"],
|
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
|
uuid
|
||||||
);
|
);
|
||||||
|
|
||||||
const baseRatios = await getBaseRatios(specProc);
|
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 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;
|
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