| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
|
|
| param( |
| [switch]$Run, |
| [switch]$Clean |
| ) |
|
|
| $ErrorActionPreference = 'Stop' |
| $root = $PSScriptRoot |
| Set-Location $root |
|
|
| $out = Join-Path $root 'ste_train.exe' |
|
|
| if ($Clean) { |
| Remove-Item $out -Force -ErrorAction SilentlyContinue |
| Write-Host "cleaned $out" |
| exit 0 |
| } |
|
|
| $gcc = Get-Command gcc -ErrorAction SilentlyContinue |
| if (-not $gcc) { |
| Write-Host "ERROR: gcc not found. Install MSYS2 and add mingw64\bin to PATH." -ForegroundColor Red |
| Write-Host " https://www.msys2.org/" -ForegroundColor Red |
| exit 1 |
| } |
|
|
| |
| $cflags = @('-O1', '-march=native', '-fno-strict-aliasing', '-fopenmp', '-funroll-loops', '-Wall', '-Wno-unused-function', '-Wno-unused-variable') |
| $src = @('models/ste_train.c', 'runtime/lal_runtime.c') |
| $ldlibs = @('-lm') |
|
|
| |
| |
| |
| |
| |
| $useOpenBLAS = $env:LAL_USE_OPENBLAS -eq '1' |
| if ($useOpenBLAS) { |
| $openblasInc = "C:\msys64\mingw64\include\openblas" |
| $openblasHeader = @' |
| #include <cblas.h> |
| int main(){ return 0; } |
| '@ |
| $tmpC = Join-Path $env:TEMP "test_openblas.c" |
| $tmpExe = Join-Path $env:TEMP "test_openblas.exe" |
| Set-Content -Path $tmpC -Value $openblasHeader -Encoding ascii |
| $incFlags = @() |
| if (Test-Path $openblasInc) { $incFlags += "-I$openblasInc" } |
| & gcc @incFlags $tmpC -o $tmpExe -lopenblas 2>$null |
| if ($LASTEXITCODE -eq 0) { |
| $cflags += '-DHAVE_OPENBLAS' |
| $cflags += $incFlags |
| $ldlibs += '-lopenblas' |
| Write-Host "[*] OpenBLAS detected — CORE matmul will use cblas_sgemv (2-3x faster)" -ForegroundColor Cyan |
| Remove-Item $tmpExe -ErrorAction SilentlyContinue |
| } else { |
| Write-Host "[*] OpenBLAS not found — using OpenMP fallback" -ForegroundColor Yellow |
| } |
| Remove-Item $tmpC -ErrorAction SilentlyContinue |
| } else { |
| Write-Host "[*] OpenBLAS disabled (set LAL_USE_OPENBLAS=1 to enable) — using OpenMP fallback" -ForegroundColor Yellow |
| } |
|
|
| Write-Host "compiling -> ste_train.exe ..." |
| & gcc @cflags -o $out @src @ldlibs |
| if ($LASTEXITCODE -ne 0) { |
| Write-Host "BUILD FAILED" -ForegroundColor Red |
| exit $LASTEXITCODE |
| } |
| Write-Host "[*] built ste_train.exe - just run .\ste_train.exe, no arguments needed" -ForegroundColor Green |
|
|
| if ($Run) { |
| Write-Host "" |
| & $out |
| } |
|
|