environment: make a dedicated directory

This commit is contained in:
2024-06-22 15:50:32 +08:00
parent 33036559c8
commit 45335da514
4 changed files with 66 additions and 29 deletions

View File

@@ -1,21 +0,0 @@
import path from "path";
export const HOME = path.join("/home", "lyc");
export const SW_AUTOVEC = path.join(HOME, "workspace", "sw-autovec");
export const LLVM_SRC = path.join(SW_AUTOVEC, "swllvm-13.0.0-vect0919");
export const LLVM_INSTALL = path.join(LLVM_SRC, "local", "installed");
export const projectRoot = path.join(__dirname, "..", "..");
/// Default toolchain version used in SPEC2017
export const PREFIX = path.join(LLVM_INSTALL, "85e4fed0c9e4cd4ab8bce89f307127ccbad31294");
export const PREFIXBIN = path.join(PREFIX, "bin");
export const LLVM_EXTRACT = path.join(PREFIXBIN, "llvm-extract");
export const CXX = path.join(PREFIXBIN, "clang++");
export const CC = path.join(PREFIXBIN, "clang");
export const FLANG = path.join(PREFIXBIN, "flang");
export const SYSROOT_PREFIX = "/usr/sw/standard-830-6b-test";

51
src/environment/index.ts Normal file
View File

@@ -0,0 +1,51 @@
import path from "path";
export const SYSROOT_PREFIX = "/usr/sw/standard-830-6b-test";
export const projectRoot = path.join(__dirname, "..", "..", "..");
export const local = path.resolve(projectRoot, "local");
/**
* User-specific environment on Sw6B machine.
*/
export interface Sw6BEnvironment {
/**
* Home directory
*/
home: string;
/**
* Source to llvm-projdct
*/
llvmSrc?: string;
/**
* Private directory, writable, to put llvm installation.
*/
privateLLVMInstall?: string;
/**
* Shared llvm installation directory, readonly for all users.
*/
sharedLLVMInstall?: string;
/**
* Path to default spec2017 installation.
*/
spec2017: string;
}
export const lycEnv: Sw6BEnvironment = (() => {
const home = path.resolve("home", "lyc");
const swAutoVec = path.resolve(home, "workspace", "sw-autovec");
const llvmSrc = path.resolve(swAutoVec, "swllvm-13.0.0-vect0919");
const llvmInstall = path.resolve(llvmSrc, "local", "install");
return {
home,
privateLLVMInstall: llvmInstall,
sharedLLVMInstall: llvmInstall,
spec2017: path.resolve(swAutoVec, "spec2017")
};
})();

View File

@@ -0,0 +1,11 @@
import path from "path";
export function llvmToolchain(prefix: string) {
const bin = path.resolve(prefix, "bin");
return {
CC: path.resolve(bin, "clang"),
CXX: path.resolve(bin, "clang++"),
FC: path.resolve(bin, "flang"),
LLVM_EXTRACT: path.resolve(bin, "llvm-extract"),
};
}

View File

@@ -1,12 +1,10 @@
import * as path from 'path'; import * as path from 'path';
import * as fs from "fs"; import * as fs from "fs";
import { promisify } from "util"; import { promisify } from "util";
import { SW_AUTOVEC } from "./environment"; import { ChildProcessByStdio } from 'child_process';
import { spec } from 'node:test/reporters';
import { ChildProcess, ChildProcessByStdio } from 'child_process';
import { Readable, Writable } from 'stream'; import { Readable, Writable } from 'stream';
import { Readline } from 'readline/promises';
import { createInterface } from 'readline'; import { createInterface } from 'readline';
import { projectRoot } from './environment';
export interface SPECBenchData { export interface SPECBenchData {
objectNames: string[]; objectNames: string[];
@@ -407,13 +405,11 @@ export function mkBench(spec: SPEC, bench: SPECBenchData): Bench {
}; };
} }
export const defaultSPEC = mkSPEC(path.join(SW_AUTOVEC, "spec2017")); const specTemplate = fs.readFileSync(path.resolve(projectRoot, "assets", "specTemplate.cfg")).toString("utf-8");
const specTemplate = fs.readFileSync("assets/specTemplate.cfg").toString("utf-8");
const writeFile = promisify(fs.writeFile); const writeFile = promisify(fs.writeFile);
interface ConfigOptions { export interface ConfigOptions {
gccdir: string; gccdir: string;
optimize: string; optimize: string;
} }