Skip to content

Commit f3641b5

Browse files
Fix large matrix sizes and add GPU hardware detection warnings
- Updated large_matrices size range to go up to 10000 (was 2000) - Added sizes: 2500:500:5000, 6000:1000:10000 for GPU benchmarking - Added warnings when CUDA hardware is detected but CUDA.jl not loaded - Added warnings when Apple Silicon detected but Metal.jl not loaded - Improved GPU detection with environment variable and system file checks - Total of 45 matrix sizes when large_matrices=true, max size 10000 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 990775f commit f3641b5

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

lib/LinearSolveAutotune/src/benchmarking.jl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ Get the matrix sizes to benchmark based on the large_matrices flag.
8686
"""
8787
function get_benchmark_sizes(large_matrices::Bool = false)
8888
if large_matrices
89-
# For GPU benchmarking, include much larger sizes
90-
return vcat(4:8:128, 150:50:500, 600:100:1000, 1200:200:2000)
89+
# For GPU benchmarking, include much larger sizes up to 10000
90+
return vcat(4:8:128, 150:50:500, 600:100:1000,
91+
1200:200:2000, 2500:500:5000, 6000:1000:10000)
9192
else
9293
# Default sizes similar to existing benchmarks
9394
return 4:8:500

lib/LinearSolveAutotune/src/gpu_detection.jl

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,23 @@
44
is_cuda_available()
55
66
Check if CUDA hardware and packages are available.
7+
Issues warnings if CUDA hardware is detected but packages aren't loaded.
78
"""
89
function is_cuda_available()
910
# Check if CUDA extension is loaded
1011
ext = Base.get_extension(LinearSolve, :LinearSolveCUDAExt)
1112
if ext === nothing
13+
# Check if we might have CUDA hardware but missing packages
14+
try
15+
# Try to detect NVIDIA GPUs via nvidia-smi or similar system indicators
16+
if haskey(ENV, "CUDA_VISIBLE_DEVICES") ||
17+
(Sys.islinux() && isfile("/proc/driver/nvidia/version")) ||
18+
(Sys.iswindows() && success(`where nvidia-smi`))
19+
@warn "CUDA hardware may be available but CUDA.jl extension is not loaded. Consider adding `using CUDA` to enable GPU algorithms."
20+
end
21+
catch
22+
# Silently continue if detection fails
23+
end
1224
return false
1325
end
1426

@@ -25,16 +37,23 @@ end
2537
is_metal_available()
2638
2739
Check if Metal (Apple Silicon) hardware and packages are available.
40+
Issues warnings if Metal hardware is detected but packages aren't loaded.
2841
"""
2942
function is_metal_available()
3043
# Check if we're on macOS with Apple Silicon
3144
if !Sys.isapple()
3245
return false
3346
end
3447

48+
# Check if this is Apple Silicon
49+
is_apple_silicon = Sys.ARCH == :aarch64
50+
3551
# Check if Metal extension is loaded
3652
ext = Base.get_extension(LinearSolve, :LinearSolveMetalExt)
3753
if ext === nothing
54+
if is_apple_silicon
55+
@warn "Apple Silicon hardware detected but Metal.jl extension is not loaded. Consider adding `using Metal` to enable GPU algorithms."
56+
end
3857
return false
3958
end
4059

0 commit comments

Comments
 (0)