diff --git a/assets/specTemplate.cfg b/assets/specTemplate.cfg index d7a373d..ce5669e 100644 --- a/assets/specTemplate.cfg +++ b/assets/specTemplate.cfg @@ -96,6 +96,8 @@ default: # data model applies to all benchmarks CPORTABILITY = -DSPEC_CASE_FLAG FPORTABILITY = -Mbyteswapio +@@SpecialFlags@@ + %if %{bits} == 32 intspeed,fpspeed: diff --git a/src/bin/runcpu.ts b/src/bin/runcpu.ts index f3c9bf5..329a53f 100644 --- a/src/bin/runcpu.ts +++ b/src/bin/runcpu.ts @@ -94,36 +94,58 @@ const uuid = crypto.randomUUID(); const prefix = path.resolve(argv.compilerPrefix); -const baseFlags = [ - "-O3", - "-flto", - "-fuse-ld=lld", - ...argv.simd ? ["-Wl,-plugin-opt,--mattr=simd"] : [], -]; +const optimizeProfiles = { + base: [ + "-O3", + "-flto=thin", + ], + O2: [ + "-O2", + ] +}; -const unalignedFlags = [ - "-mllvm", - "-sw64-allows-misaligned-memory-accesses", -]; +const optimizeFlags = optimizeProfiles[argv.optimizeProfile as (keyof (typeof optimizeProfiles))]; const spec = mkSPEC(path.resolve(argv.spec)); +const sw64UnalignedFlag = "-sw64-allows-misaligned-memory-accesses"; + +function getSpecialFlags() { + if (argv.optimizeProfile === "base") { + return [ + "648.exchange2_s:", + " EXTRA_OPTIMIZE = -mllvm -enable-ipsccp-pass", + " EXTRA_LDFLAGS = -Wl,-mllvm,-enable-ipsccp-pass", + ].join("\n"); + } + return ""; +} const specProc = await spawnSPECWithID( spec, { optimize: [ - ...argv.optimizeProfile === "O2" ? ["-O2"] : baseFlags, - ...argv.allowMisaligned ? unalignedFlags : [], + ...optimizeFlags, + ...argv.allowMisaligned ? ["-mllvm", sw64UnalignedFlag] : [], ...sw64TargetOptions({ simd: argv.simd }), + ...["--sysroot", "/usr/sw/swgcc1030_native_tools"], ...argv.compilerSuite == "llvm" ? [sunway.mcpu(sunwayGeneration)] : [], // Only add -mcpu for llvm ], ldflags: [ '-static', `-L${path.resolve(prefix, 'lib')}`, + ...optimizeFlags, + "-fuse-ld=lld", + ...["--sysroot", "/usr/sw/swgcc1030_native_tools"], + ...argv.optimizeProfile === "base" ? [ + ...argv.simd ? ["-Wl,-plugin-opt,-mattr=+simd"] : [], + ...argv.allowMisaligned ? [`-Wl,-plugin-opt,${sw64UnalignedFlag}`] : [], + ...sunwayGeneration === "8a" ? ["-Wl,-plugin-opt,-mattr=+core4"] : [], + ] : [], ], compilerPaths: toolchain(argv.compilerPrefix, argv.compilerSuite as ToolchainSuite), libs: argv.compilerSuite === "llvm" ? cflangLibs(prefix) : [], + specialFlags: getSpecialFlags(), }, { setprocgroup: true, diff --git a/src/spec/index.ts b/src/spec/index.ts index a5b8480..10d6bc6 100644 --- a/src/spec/index.ts +++ b/src/spec/index.ts @@ -69,6 +69,7 @@ export interface ConfigOptions { CC: string, FC: string, }; + specialFlags: string, } // Pure function to render configuration @@ -81,6 +82,7 @@ export const renderConfig = (options: ConfigOptions): string => { .replace("@@CompilerCXX@@", options.compilerPaths.CXX) .replace("@@CompilerFC@@", options.compilerPaths.FC) .replace("@@LIBS@@", options.libs.join(" ")) + .replace("@@SpecialFlags@@", options.specialFlags) ; };