···44edition = "2024"
5566[dependencies]
77+bytemuck = "1.24.0"
78clap = { version = "4.5.48", features = ["derive"] }
89ctrlc = "3.5.0"
910num_cpus = "1.17.0"
1111+pollster = "0.4.0"
1212+wgpu = { version = "27.0.1", features = ["fragile-send-sync-non-atomic-wasm"] }
+79-17
README.md
···11-# Heater
11+# Heater 🔥
2233-A Rust command-line application that churns your CPU cores at maximum capacity so your laptop isn't cold
33+A Rust command-line application that churns your CPU and GPU at maximum capacity for testing, benchmarking, or keeping your system warm.
44+55+## Features
66+77+- 🔥 Maximizes CPU usage across multiple cores
88+- 🎮 Optional GPU heating using compute shaders
99+- 🛡️ Leaves one core free by default (configurable)
1010+- ⏱️ Run for a specific duration or indefinitely
1111+- 🛑 Graceful shutdown with Ctrl+C
1212+- 📊 Real-time thread and GPU iteration status
1313+- 🌐 Cross-platform GPU support (Metal, Vulkan, DX12, OpenGL)
414515## Build
616···12221323## Usage
14241515-### Run indefinitely (until Ctrl+C)
2525+### CPU heating only (default)
1626```bash
2727+# Run indefinitely (until Ctrl+C)
1728cargo run --release
1818-# or
1919-./target/release/heater
2020-```
21292222-### Run for a specific duration (in seconds)
2323-```bash
3030+# Run for 30 seconds
2431cargo run --release -- --duration 30
2525-# or
2626-./target/release/heater --duration 30
2727-```
28322929-### Customize the number of free cores
3030-```bash
3133# Leave 2 cores free
3234cargo run --release -- --free-cores 2
3535+```
33363434-# Use ALL cores (leave 0 free)
3535-cargo run --release -- --free-cores 0
3737+### GPU heating
3838+```bash
3939+# Enable GPU heating with the --gpu flag
4040+cargo run --release -- --gpu
36413737-# Run for 60 seconds, leaving 2 cores free
3838-cargo run --release -- --duration 60 --free-cores 2
4242+# GPU + CPU for 60 seconds
4343+cargo run --release -- --gpu --duration 60
4444+4545+# Max heat: all cores + GPU
4646+cargo run --release -- --gpu --free-cores 0
4747+```
4848+4949+### Advanced examples
5050+```bash
5151+# Use ALL cores (leave 0 free) + GPU for 2 minutes
5252+./target/release/heater --gpu --free-cores 0 --duration 120
5353+5454+# CPU only, leaving 3 cores free, run indefinitely
5555+./target/release/heater --free-cores 3
3956```
40574158## Options
···4360```
4461-d, --duration <DURATION> Duration to run in seconds (omit for indefinite run)
4562-f, --free-cores <FREE_CORES> Number of cores to leave free (default: 1)
6363+-g, --gpu Enable GPU heating (requires compatible GPU)
4664-h, --help Print help
4765-V, --version Print version
4866```
6767+6868+## How It Works
6969+7070+### CPU Heating
7171+The application:
7272+1. Detects the number of logical CPU cores on your system
7373+2. Spawns threads equal to (total cores - free cores)
7474+3. Each thread performs intensive mathematical operations in a tight loop
7575+4. Continues until the specified duration expires or you press Ctrl+C
7676+7777+### GPU Heating
7878+When `--gpu` is enabled:
7979+1. Initializes GPU using wgpu (supports Metal, Vulkan, DX12, OpenGL)
8080+2. Creates compute shaders that perform intensive trigonometric and exponential operations
8181+3. Dispatches large workgroups (256x256) continuously to maximize GPU utilization
8282+4. Runs in parallel with CPU heating threads
8383+8484+## Use Cases
8585+8686+- CPU/GPU stress testing
8787+- Thermal testing and validation
8888+- Benchmarking cooling solutions
8989+- Testing throttling behavior
9090+- Power consumption testing
9191+- Keeping your laptop warm in winter ❄️
9292+9393+## GPU Compatibility
9494+9595+The GPU heater uses `wgpu` which supports:
9696+- **macOS**: Metal
9797+- **Windows**: DirectX 12, Vulkan
9898+- **Linux**: Vulkan, OpenGL
9999+- **Web**: WebGPU
100100+101101+If GPU initialization fails, the app will fall back to CPU-only heating.
102102+103103+## Safety Notes
104104+105105+⚠️ **Warning**: This application will significantly increase CPU and GPU temperature and power consumption.
106106+107107+- Ensure your system has adequate cooling before running for extended periods
108108+- Monitor temperatures if running for long durations
109109+- Some laptops may throttle or shut down if temperatures get too high
110110+- Use `--free-cores` to leave headroom for system processes
+30
src/heater.wgsl
···11+// GPU compute shader for heating
22+// Performs intensive matrix-like operations on data
33+44+@group(0) @binding(0)
55+var<storage, read> input: array<f32>;
66+77+@group(0) @binding(1)
88+var<storage, read_write> output: array<f32>;
99+1010+@compute @workgroup_size(256)
1111+fn main(@builtin(global_invocation_id) global_id: vec3<u32>) {
1212+ let index = global_id.x;
1313+1414+ // Perform intensive math operations
1515+ var value = f32(index);
1616+1717+ // Matrix-like computations (unrolled for more heat)
1818+ for (var i = 0u; i < 100u; i++) {
1919+ value = sin(value) * cos(value * 1.234);
2020+ value = value * value + sqrt(abs(value));
2121+ value = pow(abs(value), 1.5) * 0.001;
2222+ value = exp(value * 0.01) - log(abs(value) + 1.0);
2323+ value = tan(value * 0.1) + atan(value);
2424+ }
2525+2626+ // Write result (if index is in bounds)
2727+ if (index < arrayLength(&output)) {
2828+ output[index] = value;
2929+ }
3030+}