bin/runcpu: support optimize flag configuration

This commit is contained in:
2025-04-25 12:07:50 +08:00
parent e9b8d04a11
commit 49284ba162

View File

@@ -29,6 +29,15 @@ const argv = await yargs(hideBin(process.argv))
choices: ['test', 'train', 'ref'], choices: ['test', 'train', 'ref'],
default: 'ref', default: 'ref',
}) })
.option('optimize-profile', {
type: 'string',
choices: ['O2', 'base'],
demandOption: true,
})
.option('allow-misaligned', {
type: 'boolean',
default: false,
})
.option('spec', { .option('spec', {
alias: 's', alias: 's',
type: 'string', type: 'string',
@@ -90,7 +99,7 @@ const uuid = crypto.randomUUID();
const prefix = path.resolve(argv.compilerPrefix); const prefix = path.resolve(argv.compilerPrefix);
const o3LTOFlags = [ const baseFlags = [
"-O3", "-O3",
"-flto", "-flto",
"-fuse-ld=lld", "-fuse-ld=lld",
@@ -109,7 +118,8 @@ const specProc = await spawnSPECWithID(
spec, spec,
{ {
optimize: [ optimize: [
"-O2", ...argv.optimizeProfile === "O2" ? ["-O2"] : baseFlags,
...argv.allowMisaligned ? unalignedFlags : [],
...sw64TargetOptions({ simd: argv.simd }), ...sw64TargetOptions({ simd: argv.simd }),
...argv.compilerSuite == "llvm" ? [sunway.mcpu(sunwayGeneration)] : [], // Only add -mcpu for llvm ...argv.compilerSuite == "llvm" ? [sunway.mcpu(sunwayGeneration)] : [], // Only add -mcpu for llvm
], ],