@echo off
setlocal EnableExtensions
cd /d "%~dp0"

set "UC_LARGE_SCALE=%~1"
if not defined UC_LARGE_SCALE set "UC_LARGE_SCALE=full"
set "UC_LARGE_WORKERS=%~2"
if not defined UC_LARGE_WORKERS set "UC_LARGE_WORKERS=12"
set "UC_LARGE_HUGE_WORKERS=%~3"
if not defined UC_LARGE_HUGE_WORKERS set "UC_LARGE_HUGE_WORKERS=3"
set "UC_LARGE_ONLY_HUGE="
if /I "%~4"=="huge" set "UC_LARGE_ONLY_HUGE=-OnlyHuge"

if /I not "%UC_LARGE_SCALE%"=="smoke" if /I not "%UC_LARGE_SCALE%"=="full" (
    echo Usage: large_benchmark.bat [smoke^|full] [workers 2..12] [huge-workers 1..12] [huge]
    exit /b 2
)

call build.bat all test
if errorlevel 1 exit /b 1

set "UC_LARGE_PROFILES=scalar baseline"
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "tools\test_avx2.ps1"
if not errorlevel 1 set "UC_LARGE_PROFILES=scalar baseline avx2"

if defined UC_LARGE_ONLY_HUGE (
    powershell.exe -NoProfile -ExecutionPolicy Bypass ^
        -File "tools\run_large_parallel.ps1" ^
        -Scale "%UC_LARGE_SCALE%" -Workers "%UC_LARGE_WORKERS%" ^
        -MaxHugeWorkers "%UC_LARGE_HUGE_WORKERS%" -OnlyHuge ^
        -Profiles "%UC_LARGE_PROFILES%"
) else (
    powershell.exe -NoProfile -ExecutionPolicy Bypass ^
        -File "tools\run_large_parallel.ps1" ^
        -Scale "%UC_LARGE_SCALE%" -Workers "%UC_LARGE_WORKERS%" ^
        -MaxHugeWorkers "%UC_LARGE_HUGE_WORKERS%" ^
        -Profiles "%UC_LARGE_PROFILES%"
)
exit /b %errorlevel%
