Skip to content

Commit 3dd9246

Browse files
Add detailed CPU information from Sys.cpu_info() to telemetry (#707)
* Add detailed CPU information from Sys.cpu_info() to telemetry - Extract CPU model and speed from Sys.cpu_info() - Display CPU model instead of generic CPU_NAME where available - Show CPU speed in MHz for better hardware identification - Detect heterogeneous CPU configurations - Calculate average/min/max speeds for systems with varying CPU speeds - Update telemetry output to show CPU model in GitHub issue comments - Maintain backward compatibility with existing cpu_name field This provides more specific hardware information for better benchmark analysis. * Delete lib/LinearSolveAutotune/test/test_cpu_info.jl
1 parent 80872bf commit 3dd9246

File tree

3 files changed

+89
-10
lines changed

3 files changed

+89
-10
lines changed

lib/LinearSolveAutotune/src/LinearSolveAutotune.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,13 @@ function Base.show(io::IO, results::AutotuneResults)
6666

6767
# System info summary
6868
println(io, "\n📊 System Information:")
69-
println(io, " • CPU: ", get(results.sysinfo, "cpu_name", "Unknown"))
69+
# Use cpu_model if available, otherwise fall back to cpu_name
70+
cpu_display = get(results.sysinfo, "cpu_model", get(results.sysinfo, "cpu_name", "Unknown"))
71+
println(io, " • CPU: ", cpu_display)
72+
cpu_speed = get(results.sysinfo, "cpu_speed_mhz", 0)
73+
if cpu_speed > 0
74+
println(io, " • Speed: ", cpu_speed, " MHz")
75+
end
7076
println(io, " • OS: ", get(results.sysinfo, "os_name", "Unknown"), " (", get(results.sysinfo, "os", "Unknown"), ")")
7177
println(io, " • Julia: ", get(results.sysinfo, "julia_version", "Unknown"))
7278
println(io, " • Threads: ", get(results.sysinfo, "num_threads", "Unknown"), " (BLAS: ", get(results.sysinfo, "blas_num_threads", "Unknown"), ")")

lib/LinearSolveAutotune/src/gpu_detection.jl

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
using CPUSummary
44
using Pkg
5+
using Statistics: mean
56

67
"""
78
is_cuda_available()
@@ -82,11 +83,32 @@ function get_system_info()
8283
info["os_name"] = Sys.iswindows() ? "Windows" : Sys.islinux() ? "Linux" : Sys.isapple() ? "macOS" : "Other"
8384
info["arch"] = string(Sys.ARCH)
8485

85-
# Use CPUSummary where available, fallback to Sys otherwise
86+
# Get detailed CPU information from Sys.cpu_info()
87+
cpu_info = Sys.cpu_info()
88+
if !isempty(cpu_info)
89+
first_cpu = cpu_info[1]
90+
info["cpu_model"] = first_cpu.model
91+
info["cpu_speed_mhz"] = first_cpu.speed
92+
93+
# Count unique CPU models (for heterogeneous systems)
94+
cpu_models = unique([cpu.model for cpu in cpu_info])
95+
if length(cpu_models) > 1
96+
info["cpu_models"] = join(cpu_models, ", ")
97+
info["heterogeneous_cpus"] = true
98+
else
99+
info["heterogeneous_cpus"] = false
100+
end
101+
else
102+
info["cpu_model"] = "Unknown"
103+
info["cpu_speed_mhz"] = 0
104+
end
105+
106+
# Legacy CPU name for backward compatibility
86107
try
87108
info["cpu_name"] = string(Sys.CPU_NAME)
88109
catch
89-
info["cpu_name"] = "Unknown"
110+
# Fallback to cpu_model if CPU_NAME not available
111+
info["cpu_name"] = get(info, "cpu_model", "Unknown")
90112
end
91113

92114
# CPUSummary.num_cores() returns the physical cores (as Static.StaticInt)
@@ -295,11 +317,45 @@ function get_detailed_system_info()
295317
system_data["machine"] = "unknown"
296318
end
297319

298-
# CPU details
320+
# CPU details from Sys.cpu_info()
321+
try
322+
cpu_info = Sys.cpu_info()
323+
if !isempty(cpu_info)
324+
first_cpu = cpu_info[1]
325+
system_data["cpu_model"] = first_cpu.model
326+
system_data["cpu_speed_mhz"] = first_cpu.speed
327+
328+
# Check for heterogeneous CPUs
329+
cpu_models = unique([cpu.model for cpu in cpu_info])
330+
if length(cpu_models) > 1
331+
system_data["cpu_models"] = join(cpu_models, ", ")
332+
system_data["heterogeneous_cpus"] = true
333+
else
334+
system_data["heterogeneous_cpus"] = false
335+
end
336+
337+
# Calculate average CPU speed if speeds vary
338+
cpu_speeds = [cpu.speed for cpu in cpu_info]
339+
if length(unique(cpu_speeds)) > 1
340+
system_data["cpu_speed_avg_mhz"] = round(mean(cpu_speeds), digits=0)
341+
system_data["cpu_speed_min_mhz"] = minimum(cpu_speeds)
342+
system_data["cpu_speed_max_mhz"] = maximum(cpu_speeds)
343+
end
344+
else
345+
system_data["cpu_model"] = "unknown"
346+
system_data["cpu_speed_mhz"] = 0
347+
end
348+
catch
349+
system_data["cpu_model"] = "unknown"
350+
system_data["cpu_speed_mhz"] = 0
351+
end
352+
353+
# Legacy CPU name for backward compatibility
299354
try
300355
system_data["cpu_name"] = string(Sys.CPU_NAME)
301356
catch
302-
system_data["cpu_name"] = "unknown"
357+
# Fallback to cpu_model if available
358+
system_data["cpu_name"] = get(system_data, "cpu_model", "unknown")
303359
end
304360

305361
try

lib/LinearSolveAutotune/src/telemetry.jl

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,24 @@ function format_system_info_markdown(system_info::Dict)
206206
push!(lines, "- **OS**: $os_display ($os_kernel)")
207207
# Handle both "arch" and "architecture" keys
208208
push!(lines, "- **Architecture**: $(get(system_info, "architecture", get(system_info, "arch", "unknown")))")
209-
push!(lines, "- **CPU**: $(get(system_info, "cpu_name", "unknown"))")
209+
210+
# Enhanced CPU information
211+
cpu_model = get(system_info, "cpu_model", nothing)
212+
if cpu_model !== nothing && cpu_model != "unknown"
213+
push!(lines, "- **CPU Model**: $cpu_model")
214+
cpu_speed = get(system_info, "cpu_speed_mhz", 0)
215+
if cpu_speed > 0
216+
push!(lines, "- **CPU Speed**: $(cpu_speed) MHz")
217+
end
218+
# Show if heterogeneous CPUs detected
219+
if get(system_info, "heterogeneous_cpus", false)
220+
push!(lines, "- **CPU Models**: $(get(system_info, "cpu_models", ""))")
221+
end
222+
else
223+
# Fallback to legacy CPU name
224+
push!(lines, "- **CPU**: $(get(system_info, "cpu_name", "unknown"))")
225+
end
226+
210227
# Handle both "num_cores" and "cpu_cores" keys
211228
push!(lines, "- **Cores**: $(get(system_info, "cpu_cores", get(system_info, "num_cores", "unknown")))")
212229
# Handle both "num_threads" and "julia_threads" keys
@@ -416,20 +433,20 @@ function upload_to_github(content::String, plot_files, auth_info::Tuple,
416433
target_repo = "SciML/LinearSolve.jl"
417434
issue_number = 669 # The existing issue for collecting autotune results
418435

419-
# Construct comment body
420-
cpu_name = get(system_info, "cpu_name", "unknown")
436+
# Construct comment body - use cpu_model if available for more specific info
437+
cpu_display = get(system_info, "cpu_model", get(system_info, "cpu_name", "unknown"))
421438
os_name = get(system_info, "os", "unknown")
422439
timestamp = Dates.format(Dates.now(), "yyyy-mm-dd HH:MM")
423440

424441
comment_body = """
425-
## Benchmark Results: $cpu_name on $os_name ($timestamp)
442+
## Benchmark Results: $cpu_display on $os_name ($timestamp)
426443
427444
$content
428445
429446
---
430447
431448
### System Summary
432-
- **CPU:** $cpu_name
449+
- **CPU:** $cpu_display
433450
- **OS:** $os_name
434451
- **Timestamp:** $timestamp
435452

0 commit comments

Comments
 (0)