From e9fd3de6c5dc79adfc11b9e61646fc0bc07d285d Mon Sep 17 00:00:00 2001 From: Yingchi Long Date: Thu, 20 Jun 2024 15:16:49 +0800 Subject: [PATCH] treewide: rename to src/ --- algorithm.ts => src/algorithm.ts | 2 +- build-llvm.ts => src/build-llvm.ts | 2 +- {build => src/build}/build.ts | 0 {build => src/build}/llvmPackages.ts | 6 ++-- cli.ts => src/cli.ts | 0 {commands => src/commands}/cmake.ts | 0 {commands => src/commands}/common.ts | 0 {commands => src/commands}/compiler.ts | 0 {commands => src/commands}/spec.ts | 0 {commands => src/commands}/systemd.ts | 0 environment.ts => src/environment.ts | 0 gua-spec.ts => src/gua-spec.ts | 12 ++++---- mix-object.ts => src/mix-object.ts | 0 spec.ts => src/spec.ts | 42 ++++++++++++++++++++++++++ tsconfig.json | 10 ++++-- 15 files changed, 60 insertions(+), 14 deletions(-) rename algorithm.ts => src/algorithm.ts (98%) rename build-llvm.ts => src/build-llvm.ts (58%) rename {build => src/build}/build.ts (100%) rename {build => src/build}/llvmPackages.ts (97%) rename cli.ts => src/cli.ts (100%) rename {commands => src/commands}/cmake.ts (100%) rename {commands => src/commands}/common.ts (100%) rename {commands => src/commands}/compiler.ts (100%) rename {commands => src/commands}/spec.ts (100%) rename {commands => src/commands}/systemd.ts (100%) rename environment.ts => src/environment.ts (100%) rename gua-spec.ts => src/gua-spec.ts (74%) rename mix-object.ts => src/mix-object.ts (100%) rename spec.ts => src/spec.ts (91%) diff --git a/algorithm.ts b/src/algorithm.ts similarity index 98% rename from algorithm.ts rename to src/algorithm.ts index 67504b9..452200c 100644 --- a/algorithm.ts +++ b/src/algorithm.ts @@ -6,7 +6,7 @@ * @returns A tuple containing the indices representing the binary search state: [begin, half, end]. */ export function binSearch(begin: number, end: number, beforeHalf: boolean[]): [number, number, number] { - const gHalf = () => { return Math.floor((end - begin) / 2) + begin; } + const gHalf = () => { return Math.floor((end - begin) / 2) + begin; }; for (const pred of beforeHalf) { const half = gHalf(); diff --git a/build-llvm.ts b/src/build-llvm.ts similarity index 58% rename from build-llvm.ts rename to src/build-llvm.ts index 3f2ae29..7cc8086 100644 --- a/build-llvm.ts +++ b/src/build-llvm.ts @@ -2,4 +2,4 @@ import { LLVM_SRC } from "./environment"; import { buildLLVMHash } from "./build/llvmPackages"; -buildLLVMHash(LLVM_SRC, "31c8e21f40ea654f9d49b3a926acc6ef1f2ca5d5"); +buildLLVMHash(LLVM_SRC, "e201a0b21b8933b7df79d5cfca2c1e89348aad1f"); diff --git a/build/build.ts b/src/build/build.ts similarity index 100% rename from build/build.ts rename to src/build/build.ts diff --git a/build/llvmPackages.ts b/src/build/llvmPackages.ts similarity index 97% rename from build/llvmPackages.ts rename to src/build/llvmPackages.ts index 9fbc276..9baaa1a 100644 --- a/build/llvmPackages.ts +++ b/src/build/llvmPackages.ts @@ -1,8 +1,8 @@ import path from "path"; -import { GeneralVariable, LLVMVariable, command, variable } from "commands/cmake"; -import { SYSROOT_PREFIX } from "environment"; +import { GeneralVariable, LLVMVariable, command, variable } from "lyc/commands/cmake"; +import { SYSROOT_PREFIX } from "lyc/environment"; import { PackageTask, buildPackage } from "./build"; -import { checkedSpawnSync } from "cli"; +import { checkedSpawnSync } from "lyc/cli"; import os from "os"; import { SpawnOptions, spawn } from "child_process"; diff --git a/cli.ts b/src/cli.ts similarity index 100% rename from cli.ts rename to src/cli.ts diff --git a/commands/cmake.ts b/src/commands/cmake.ts similarity index 100% rename from commands/cmake.ts rename to src/commands/cmake.ts diff --git a/commands/common.ts b/src/commands/common.ts similarity index 100% rename from commands/common.ts rename to src/commands/common.ts diff --git a/commands/compiler.ts b/src/commands/compiler.ts similarity index 100% rename from commands/compiler.ts rename to src/commands/compiler.ts diff --git a/commands/spec.ts b/src/commands/spec.ts similarity index 100% rename from commands/spec.ts rename to src/commands/spec.ts diff --git a/commands/systemd.ts b/src/commands/systemd.ts similarity index 100% rename from commands/systemd.ts rename to src/commands/systemd.ts diff --git a/environment.ts b/src/environment.ts similarity index 100% rename from environment.ts rename to src/environment.ts diff --git a/gua-spec.ts b/src/gua-spec.ts similarity index 74% rename from gua-spec.ts rename to src/gua-spec.ts index 94f96ea..27feaaf 100644 --- a/gua-spec.ts +++ b/src/gua-spec.ts @@ -1,14 +1,14 @@ import { spawn } from "child_process"; -import { promisifySpawn } from "cli"; -import { runcpuOptions } from "commands/spec"; -import { systemdRunOptions } from "commands/systemd"; -import { LLVM_INSTALL } from "environment"; +import { promisifySpawn } from "lyc/cli"; +import { runcpuOptions } from "lyc/commands/spec"; +import { systemdRunOptions } from "lyc/commands/systemd"; +import { LLVM_INSTALL } from "lyc/environment"; import path from "path"; -import { defaultSPEC, renderConfig } from "spec"; +import { defaultSPEC, renderConfig } from "lyc/spec"; (async () => { - const llvmHash = "31c8e21f40ea654f9d49b3a926acc6ef1f2ca5d5"; + const llvmHash = "31c8e21f40ea654f9d49b3a926acc6ef1f2ca5d5"; // ipa-pure-const.c const llvmPrefix = path.join(LLVM_INSTALL, llvmHash); const config = `clang-O2-${llvmHash}.cfg`; diff --git a/mix-object.ts b/src/mix-object.ts similarity index 100% rename from mix-object.ts rename to src/mix-object.ts diff --git a/spec.ts b/src/spec.ts similarity index 91% rename from spec.ts rename to src/spec.ts index 367692c..b411685 100644 --- a/spec.ts +++ b/src/spec.ts @@ -3,6 +3,10 @@ import * as fs from "fs"; import { promisify } from "util"; import { SW_AUTOVEC } from "./environment"; import { spec } from 'node:test/reporters'; +import { ChildProcess, ChildProcessByStdio } from 'child_process'; +import { Readable, Writable } from 'stream'; +import { Readline } from 'readline/promises'; +import { createInterface } from 'readline'; export interface SPECBenchData { objectNames: string[]; @@ -419,3 +423,41 @@ export function renderConfig(options: ConfigOptions) { .replace("@@GCCDIR@@", options.gccdir) .replace("@@OPTIMIZE@@", options.optimize); } + + +interface SPECResult { + format: string; + paths: string[]; +} + +/** + * Monitor SPEC2017 runcpu process in a subprocess. + */ +export async function watchSPEC>(process: T) { + const rl = createInterface({ + input: process.stdout, + terminal: false, + }); + + // Match & extract string like " format CSV -> /path/to/csv" + const formatRe = /^\s*format:\s*(\w+)\s*->\s*(.*)$/; + + return await new Promise((resolve, reject) => { + let results: SPECResult[] = []; + rl.on("line", line => { + let match; + if ((match = formatRe.exec(line)) != null) { + const type = match[1]; + const paths = match[2].split(',').map(path => path.trim()); + results.push({ + format: type, + paths: paths, + }); + } + // To match if the line contains: "runcpu finished + if (line.startsWith("runcpu finished")) { + resolve(results); + } + }); + }); +} diff --git a/tsconfig.json b/tsconfig.json index 5281be6..fffd6c3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -25,8 +25,12 @@ "module": "commonjs", /* Specify what module code is generated. */ // "rootDir": "./", /* Specify the root folder within your source files. */ // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ - "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + "paths": { + "lyc/*": [ + "./src/*" + ] + }, /* Specify a set of entries that re-map imports to additional lookup locations. */ // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ // "types": [], /* Specify type package names to be included without being referenced in a source file. */ @@ -50,7 +54,7 @@ "sourceMap": true, /* Create source map files for emitted JavaScript files. */ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - "outDir": "out", /* Specify an output folder for all emitted files. */ + "outDir": "out/lyc", /* Specify an output folder for all emitted files. */ // "removeComments": true, /* Disable emitting comments. */ // "noEmit": true, /* Disable emitting files from a compilation. */ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */