From f09441141999dbfd1980f5d0be071170a23b57fa Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Sat, 4 Jan 2025 20:53:21 +0800 Subject: [PATCH] sunway: init Feature detect library for Sunway CPUs --- src/sunway.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 src/sunway.ts diff --git a/src/sunway.ts b/src/sunway.ts new file mode 100644 index 0000000..eccf819 --- /dev/null +++ b/src/sunway.ts @@ -0,0 +1,19 @@ +/** + * Utilities to determine platform variants on sunway. + */ + +import { cpus } from "os"; + +export type SunwayGeneration = "8a" | "6b"; + +export function getHostGeneration(): SunwayGeneration { + const cpu = cpus()[0]; + if (cpu.model.includes("H8000")) { + return "8a"; + } + return '6b'; +} + +export function mcpu(gen: SunwayGeneration): string { + return `-mcpu=sw${gen}`; +} \ No newline at end of file