forked from sculite/sqlite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_gpu.bat
More file actions
121 lines (98 loc) · 2.79 KB
/
build_gpu.bat
File metadata and controls
121 lines (98 loc) · 2.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
@echo off
setlocal enabledelayedexpansion
echo ========================================
echo SQLite CUDA GPU Accelerated Build
echo ========================================
echo.
set BUILD_DIR=build_gpu
set CUDA_ARCH=sm_89
set NVCC_FLAGS=-O2 -arch=%CUDA_ARCH% --compiler-options /MT,/W3 -allow-unsupported-compiler -diag-suppress=546
set CL_FLAGS=/MT /O2 /W3 /D SQLITE_THREADSAFE=1 /D SQLITE_ENABLE_COLUMN_METADATA=1 /D SQLITE_ENABLE_FTS5=1 /D SQLITE_ENABLE_GPU_SCAN=1 /D NDEBUG
set LINK_FLAGS=/INCREMENTAL:NO /MACHINE:X64
if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%"
cd "%BUILD_DIR%"
echo [Step 1/6] Generating amalgamation files...
echo.
if not exist "sqlite3.c" (
cd ..
nmake /f Makefile.msc sqlite3.c sqlite3.h
if errorlevel 1 (
echo ERROR: Failed to generate amalgamation files
exit /b 1
)
copy sqlite3.c "%BUILD_DIR%\" >nul
copy sqlite3.h "%BUILD_DIR%\" >nul
copy sqlite3ext.h "%BUILD_DIR%\" >nul
copy shell.c "%BUILD_DIR%\" >nul
cd "%BUILD_DIR%"
) else (
echo Amalgamation files already exist, skipping generation.
)
echo [Step 2/6] Copying GPU source files...
echo.
copy ..\src\gpu_where.cu . >nul 2>&1
copy ..\src\gpu_manager.h . >nul 2>&1
copy ..\src\gpu_manager.c . >nul 2>&1
copy ..\src\gpu_config.h . >nul 2>&1
if not exist "gpu_where.cu" (
echo ERROR: GPU source files not found
exit /b 1
)
echo [Step 3/6] Compiling CUDA kernels...
echo.
nvcc %NVCC_FLAGS% -c gpu_where.cu -o gpu_where.obj
if errorlevel 1 (
echo ERROR: CUDA kernel compilation failed
exit /b 1
)
echo Successfully compiled CUDA kernels
echo.
echo [Step 4/6] Compiling GPU manager...
echo.
cl %CL_FLAGS% /I"%CUDA_PATH%\include" /c gpu_manager.c
if errorlevel 1 (
echo ERROR: GPU manager compilation failed
exit /b 1
)
echo Successfully compiled GPU manager
echo.
echo [Step 5/6] Compiling SQLite core with GPU support...
echo.
cl %CL_FLAGS% /D SQLITE_OMIT_GPU=0 /I"%CUDA_PATH%\include" /c sqlite3.c
if errorlevel 1 (
echo ERROR: SQLite core compilation failed
exit /b 1
)
echo Successfully compiled SQLite core
echo.
echo [Step 6/6] Compiling shell and linking final executable...
echo.
cl %CL_FLAGS% /D SQLITE_OMIT_GPU=0 /I"%CUDA_PATH%\include" /c shell.c
if errorlevel 1 (
echo ERROR: Shell compilation failed
exit /b 1
)
link %LINK_FLAGS% /OUT:sqlite3_gpu.exe ^
shell.obj ^
sqlite3.obj ^
gpu_manager.obj ^
gpu_where.obj ^
"%CUDA_PATH%\lib\x64\cudart_static.lib" ^
kernel32.lib user32.lib advapi32.lib
if errorlevel 1 (
echo ERROR: Linking failed
exit /b 1
)
echo.
echo ========================================
echo Build completed successfully!
echo ========================================
echo.
echo Output: %BUILD_DIR%\sqlite3_gpu.exe
echo.
echo To test:
echo cd %BUILD_DIR%
echo sqlite3_gpu.exe
echo.
cd ..
endlocal