-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbench.ps1
More file actions
63 lines (52 loc) · 2.12 KB
/
bench.ps1
File metadata and controls
63 lines (52 loc) · 2.12 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
$fullArgs = $args
if ($fullArgs.Count -eq 0) {
Write-Host "Usage: .\bench.ps1 <votre_executable.exe> [args...]" -ForegroundColor Yellow
exit 1
}
$trace = "cuda"
$output = "nsys_easy"
$report = "cuda_gpu_sum"
Write-Host "--- Profiling $($fullArgs -join ' ') ---" -ForegroundColor Green
# Détection des options supportées par CETTE installation de nsys
$helpText = (& nsys profile --help 2>&1 | Out-String)
$profileArgs = @(
"profile",
"--trace=$trace",
"--sample=none",
"--cpuctxsw=none",
"--force-overwrite=true",
"-o", $output,
"--"
) + $fullArgs
# Option utile, généralement dispo sur Windows aussi
if ($helpText -match "--cuda-memory-usage") {
# forme "option valeur" pour éviter les surprises de parsing
$profileArgs = $profileArgs[0..3] + @("--cuda-memory-usage", "true") + $profileArgs[4..($profileArgs.Count-1)]
}
# Options UM: souvent absentes sur Windows, présentes sur Linux
if ($helpText -match "--cuda-um-cpu-page-faults" -and $helpText -match "--cuda-um-gpu-page-faults") {
$profileArgs = $profileArgs[0..3] + @(
"--cuda-um-cpu-page-faults", "true",
"--cuda-um-gpu-page-faults", "true"
) + $profileArgs[4..($profileArgs.Count-1)]
} else {
Write-Host "Note: UM page faults non supportes par ce nsys (typique sur Windows), options ignorees." -ForegroundColor DarkYellow
}
& nsys @profileArgs
if ($LASTEXITCODE -ne 0) {
Write-Host "nsys profile a echoue (code $LASTEXITCODE). Abandon." -ForegroundColor Red
exit $LASTEXITCODE
}
Write-Host "`n--- Report: $report ---" -ForegroundColor Green
# Ne pas forcer la re-exportation
& nsys stats -r $report "$output.nsys-rep"
if ($LASTEXITCODE -ne 0) {
Write-Host "nsys stats a echoue (code $LASTEXITCODE)." -ForegroundColor Red
exit $LASTEXITCODE
}
# Nettoyage: supprimer le SQLite que nsys genere pour certains rapports
$sqliteBase = "$output.sqlite"
Remove-Item $sqliteBase -Force -ErrorAction SilentlyContinue
Remove-Item "$sqliteBase-wal" -Force -ErrorAction SilentlyContinue
Remove-Item "$sqliteBase-shm" -Force -ErrorAction SilentlyContinue
Remove-Item "$sqliteBase-journal" -Force -ErrorAction SilentlyContinue