runcpu: support -fopenmp (dynamic linking)

This commit is contained in:
2025-07-12 18:36:58 +08:00
parent b56f5e1b56
commit 7f914686a5
3 changed files with 21 additions and 6 deletions

View File

@@ -25,7 +25,7 @@ verify_binaries = 0
intrate,fprate:
copies = 1 # EDIT to change number of copies (see above)
intspeed,fpspeed:
threads = 1 # EDIT to change number of OpenMP threads (see above)
threads = @@OpenMPThreads@@ # EDIT to change number of OpenMP threads (see above)
#------- Compilers ------------------------------------------------------------
@@ -115,4 +115,4 @@ default=base:
intrate,intspeed=base:
EXTRA_COPTIMIZE = -fno-strict-aliasing
LDCFLAGS = -z muldefs
LDCFLAGS = -z muldefs

View File

@@ -31,7 +31,7 @@ const argv = await yargs(hideBin(process.argv))
})
.option('optimize-profile', {
type: 'string',
choices: ['O2', 'base'],
choices: ['O2', 'base', 'openmp'],
demandOption: true,
})
.option('allow-misaligned', {
@@ -99,6 +99,12 @@ const optimizeProfiles = {
"-O3",
"-flto=thin",
],
openmp: [
"-O3",
"-flto=thin",
"-DSPEC_OPENMP",
"-fopenmp",
],
O2: [
"-O2",
]
@@ -132,20 +138,25 @@ const specProc = await spawnSPECWithID(
...argv.compilerSuite == "llvm" ? [sunway.mcpu(sunwayGeneration)] : [], // Only add -mcpu for llvm
],
ldflags: [
'-static',
`-L${path.resolve(prefix, 'lib')}`,
...optimizeFlags,
"-fuse-ld=lld",
...["--sysroot", sysroot],
...argv.optimizeProfile === "base" ? [
...["base", "openmp"].includes(argv.optimizeProfile) ? [
...argv.simd ? ["-Wl,-plugin-opt,-mattr=+simd"] : [],
...argv.allowMisaligned ? [`-Wl,-plugin-opt,${sw64UnalignedFlag}`] : [],
...sunwayGeneration === "8a" ? ["-Wl,-plugin-opt,-mattr=+core4"] : [],
] : [],
...argv.optimizeProfile === "openmp" ? [
`-Wl,-rpath=${argv.compilerPrefix}/lib`,
] : ['-static'],
],
compilerPaths: toolchain(argv.compilerPrefix, argv.compilerSuite as ToolchainSuite),
libs: argv.compilerSuite === "llvm" ? cflangLibs(prefix) : [],
libs: (argv.compilerSuite === "llvm" || argv.compilerSuite !== "openmp") ? cflangLibs(prefix) : [],
specialFlags: getSpecialFlags(),
openmp: {
threads: (argv.optimizeProfile === "openmp" ? 64 : 1),
}
},
{
setprocgroup: true,

View File

@@ -64,6 +64,9 @@ export interface ConfigOptions {
optimize: string[];
ldflags: string[];
libs: string[];
openmp: {
threads: number;
};
compilerPaths: {
CXX: string,
CC: string,
@@ -83,6 +86,7 @@ export const renderConfig = (options: ConfigOptions): string => {
.replace("@@CompilerFC@@", options.compilerPaths.FC)
.replace("@@LIBS@@", options.libs.join(" "))
.replace("@@SpecialFlags@@", options.specialFlags)
.replace("@@OpenMPThreads@@", options.openmp.threads.toString())
;
};