-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrebuild.ps1
More file actions
86 lines (73 loc) · 3.01 KB
/
Copy pathrebuild.ps1
File metadata and controls
86 lines (73 loc) · 3.01 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
# CUDA Kernel Rebuild Script
# Quick rebuild and deploy for development
Write-Host "=" -NoNewline -ForegroundColor Cyan
Write-Host ("=" * 79) -ForegroundColor Cyan
Write-Host " CUDA KERNEL REBUILD SCRIPT " -ForegroundColor Yellow
Write-Host "=" -NoNewline -ForegroundColor Cyan
Write-Host ("=" * 79) -ForegroundColor Cyan
# Configuration
$BuildDir = "cuda\build"
$ReleaseDir = "$BuildDir\Release"
$ProjectRoot = "."
# Step 1: Clean build directory
Write-Host "`n[1/5] Cleaning build directory..." -ForegroundColor Green
if (Test-Path $BuildDir) {
Remove-Item -Path "$BuildDir\*" -Recurse -Force -ErrorAction SilentlyContinue
Write-Host " ✓ Build directory cleaned" -ForegroundColor Gray
} else {
New-Item -ItemType Directory -Path $BuildDir -Force | Out-Null
Write-Host " ✓ Build directory created" -ForegroundColor Gray
}
# Step 2: Configure with CMake
Write-Host "`n[2/5] Configuring with CMake..." -ForegroundColor Green
Push-Location $BuildDir
$configResult = cmake .. 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host " ✗ CMake configuration failed!" -ForegroundColor Red
Write-Host $configResult
Pop-Location
exit 1
}
Write-Host " ✓ CMake configuration successful" -ForegroundColor Gray
# Step 3: Build Release version
Write-Host "`n[3/5] Building Release version..." -ForegroundColor Green
$buildResult = cmake --build . --config Release 2>&1
if ($LASTEXITCODE -ne 0) {
Write-Host " ✗ Build failed!" -ForegroundColor Red
Write-Host $buildResult
Pop-Location
exit 1
}
Write-Host " ✓ Build successful" -ForegroundColor Gray
Pop-Location
# Step 4: Copy .pyd file to project root
Write-Host "`n[4/5] Deploying module..." -ForegroundColor Green
$pydFiles = Get-ChildItem -Path $ReleaseDir -Filter "cuda_ops*.pyd"
if ($pydFiles.Count -eq 0) {
Write-Host " ✗ No .pyd file found in Release directory!" -ForegroundColor Red
exit 1
}
foreach ($file in $pydFiles) {
Copy-Item -Path $file.FullName -Destination $ProjectRoot -Force
Write-Host " ✓ Copied: $($file.Name)" -ForegroundColor Gray
}
# Step 5: Verify deployment
Write-Host "`n[5/5] Verifying deployment..." -ForegroundColor Green
$deployedFiles = Get-ChildItem -Path $ProjectRoot -Filter "cuda_ops*.pyd"
if ($deployedFiles.Count -eq 0) {
Write-Host " ✗ Module not found in project root!" -ForegroundColor Red
exit 1
}
Write-Host " ✓ Module deployed successfully" -ForegroundColor Gray
# Success summary
Write-Host "`n" -NoNewline
Write-Host "=" -NoNewline -ForegroundColor Cyan
Write-Host ("=" * 79) -ForegroundColor Cyan
Write-Host " ✓ REBUILD COMPLETE " -ForegroundColor Green
Write-Host "=" -NoNewline -ForegroundColor Cyan
Write-Host ("=" * 79) -ForegroundColor Cyan
Write-Host "`nNext steps:" -ForegroundColor Yellow
Write-Host " 1. Test kernels: python test_optimized_kernels.py" -ForegroundColor Gray
Write-Host " 2. Run benchmark: python benchmark_optimized.py" -ForegroundColor Gray
Write-Host " 3. Profile kernels: ncu --set full python benchmark_optimized.py" -ForegroundColor Gray
Write-Host ""