69 lines
3.5 KiB
Batchfile
69 lines
3.5 KiB
Batchfile
@echo off
|
|
rem Build igneum-bench-cuda for one program pack (Windows).
|
|
rem Run from an "x64 Native Tools Command Prompt" so cl.exe is on PATH.
|
|
rem Visual Studio 2026 (toolset 14.5x) crashes CUDA 12.8 (cudafe++ 0xC0000005). Install the "MSVC v143" component and run
|
|
rem "C:\Program Files\Microsoft Visual Studio\18\Community\VC\Auxiliary\Build\vcvarsall.bat" x64 -vcvars_ver=14.30
|
|
rem first, then this script. The script passes -allow-unsupported-compiler already.
|
|
rem with CUDA Toolkit 12.8 or newer installed (nvcc on PATH).
|
|
rem Usage: build.bat [pack] [arch]
|
|
rem pack directory name under packs\ (default igneum-genesis)
|
|
rem arch nvcc -arch value (default sm_120 = RTX 50 series / Blackwell; "native" picks the installed GPU)
|
|
setlocal
|
|
cd /d "%~dp0"
|
|
|
|
set PACK=%1
|
|
if "%PACK%"=="" set PACK=igneum-genesis
|
|
set ARCH=%2
|
|
if "%ARCH%"=="" set ARCH=sm_120
|
|
|
|
where cl >nul 2>nul
|
|
if errorlevel 1 (
|
|
echo cl.exe not found. Open an "x64 Native Tools Command Prompt for VS 2022" ^(Visual Studio Build Tools, Desktop development with C++^) and run this again.
|
|
exit /b 1
|
|
)
|
|
where nvcc >nul 2>nul
|
|
if errorlevel 1 (
|
|
echo nvcc not found. Install CUDA Toolkit 12.8 or newer; the installer puts nvcc on PATH.
|
|
exit /b 1
|
|
)
|
|
if not exist "packs\%PACK%\kernel.cu" (
|
|
echo no pack at packs\%PACK% ^(expected kernel.cu, program.h, vectors.h^)
|
|
exit /b 1
|
|
)
|
|
|
|
rem Packs written by igneum-pow or igneum-miner export-pack carry kernel_bound.cu (the header-bound kernel for --serve).
|
|
set BOUND=
|
|
if exist "packs\%PACK%\kernel_bound.cu" set BOUND=-DIGNEUM_BOUND "packs\%PACK%\kernel_bound.cu"
|
|
rem Find the MSVC runtime libraries and the Windows SDK libraries ourselves and put them in front of LIB: a vcvarsall
|
|
rem import can leave LIB without the MSVC lib directory (seen with the 14.30 toolset on Visual Studio 2026), and then
|
|
rem nvcc's link step fails with LNK1104 LIBCMT.lib. The newest toolset's libraries link fine with 14.30 objects.
|
|
set "MSVCLIB="
|
|
set "SDKLIB="
|
|
set "VSVC=%VCINSTALLDIR%"
|
|
if "%VSVC%"=="" set "VSVC=C:\Program Files\Microsoft Visual Studio\18\Community\VC\"
|
|
set "KITS=C:\Program Files (x86)\Windows Kits\10\Lib"
|
|
for /f "delims=" %%D in ('dir /b /ad /o-n "%VSVC%Tools\MSVC" 2^>nul') do call :msvc "%%D"
|
|
for /f "delims=" %%D in ('dir /b /ad /o-n "%KITS%" 2^>nul') do call :sdk "%%D"
|
|
if not "%SDKLIB%"=="" set "LIB=%SDKLIB%\ucrt\x64;%SDKLIB%\um\x64;%LIB%"
|
|
if not "%MSVCLIB%"=="" set "LIB=%MSVCLIB%;%LIB%"
|
|
if "%MSVCLIB%"=="" echo warning: no libcmt.lib under any MSVC toolset; the link step may fail.
|
|
echo link libraries: MSVC="%MSVCLIB%" SDK="%SDKLIB%"
|
|
nvcc --version
|
|
echo nvcc -O3 -std=c++17 -arch=%ARCH% -allow-unsupported-compiler -I "packs\%PACK%" -o "igneum-bench-cuda-%PACK%.exe" host.cu "packs\%PACK%\kernel.cu" %BOUND%
|
|
nvcc -O3 -std=c++17 -arch=%ARCH% -allow-unsupported-compiler -I "packs\%PACK%" -o "igneum-bench-cuda-%PACK%.exe" host.cu "packs\%PACK%\kernel.cu" %BOUND%
|
|
if errorlevel 1 (
|
|
echo build failed. The script already passes -allow-unsupported-compiler for Visual Studio versions newer than CUDA expects. If the errors are inside CUDA headers, install the "MSVC v143 - VS 2022 C++ x64 build tools" component from the Visual Studio Installer and build again, or install a newer CUDA Toolkit.
|
|
exit /b 1
|
|
)
|
|
echo built igneum-bench-cuda-%PACK%.exe
|
|
if not "%BOUND%"=="" echo with --serve support (kernel_bound.cu)
|
|
endlocal
|
|
exit /b 0
|
|
:msvc
|
|
if not "%MSVCLIB%"=="" goto :eof
|
|
if exist "%VSVC%Tools\MSVC\%~1\lib\x64\libcmt.lib" set "MSVCLIB=%VSVC%Tools\MSVC\%~1\lib\x64"
|
|
goto :eof
|
|
:sdk
|
|
if not "%SDKLIB%"=="" goto :eof
|
|
if exist "%KITS%\%~1\ucrt\x64\libucrt.lib" set "SDKLIB=%KITS%\%~1"
|
|
goto :eof
|