This code is a stress test program designed to overload...
August 27, 2025 at 04:59 PM
This code is a stress test program designed to overload the CPU and GPU simultaneously. Here's what it does in detail:
1. CPU Stress ("CPU HELL")
-
burnCPU(int id)
function:- Runs an infinite loop (
while (true)
) that performs computationally expensive operations (like square roots, trigonometric calculations) to keep the CPU occupied. - For
id == 0
, it prints status updates to indicate the thread's activity.
- Runs an infinite loop (
-
Main Function (
CPU Hell
):- Uses
std::thread::hardware_concurrency()
to determine the number of CPU threads supported by the system. - Launches a thread for each CPU core, and each thread runs the
burnCPU
function. - This effectively maxes out all available CPU cores with computational work, causing extreme CPU load.
- Uses
2. GPU Stress ("GPU HELL")
-
Fragment Shader Code (
shaderSrc
):- Implements a simple Mandelbrot fractal generator on the GPU using OpenGL GLSL (OpenGL Shading Language).
- The fragment shader calculates the Mandelbrot set for each pixel and colors it based on the number of iterations it takes to exceed a threshold (
dot(z, z) > 4.0
). - Includes a zooming effect (
zoom
value reduces over time) to gradually zoom into the fractal.
-
OpenGL Initialization:
- Sets up an OpenGL context using FreeGLUT.
- Builds the fragment shader using the
buildShader()
function and links it into a program. - Creates a display callback (
display()
function) that renders the fractal to the screen. It continuously zooms into the fractal by modifying thezoom
uniform variable.
-
Main Function (
GPU Hell
):- Initializes a window for rendering (800x600 size) using FreeGLUT.
- Uses
glewInit()
to ensure OpenGL extensions are set up. - Enters the GLUT main loop (
glutMainLoop()
), where the GPU is continuously tasked with rendering the fractal, leading to high GPU load.
3. Combined Stress Test
- Combines "CPU HELL" and "GPU HELL" into a single program:
- CPU stress is triggered by launching threads for each CPU core to perform heavy computations.
- GPU stress is triggered by continuously rendering a Mandelbrot fractal with zoom using a fragment shader in an OpenGL context.
- This simultaneous stress test creates a "meltdown" effect, pegging both the CPU and GPU to their maximum workloads.
Potential Effects of Running This Code
-
Extreme Resource Usage:
- CPU cores will be pinned to 100% usage due to computationally heavy threads.
- GPU usage will also skyrocket, as the fractal shader performs intense per-pixel computations across the entire render buffer.
-
System Lag or Hang:
- The program can cause the system to slow down significantly or become unresponsive, especially on systems with less powerful hardware or inadequate cooling.
-
Thermal Throttling:
- Due to the extreme workload, the system may throttle CPU/GPU performance to prevent overheating.
-
System Crash:
- If left running for extended periods or run on a system with insufficient cooling, this program could cause crashes or hardware shutdowns.
Summary
This code is a malicious style stress test designed to max out both the CPU and GPU. It is not meant for practical purposes and should be used carefully because it could harm less powerful or poorly cooled systems.
Generate your own explanations
Download our vscode extension
Read other generated explanations
Built by @thebuilderjr
Sponsored by beam analytics
Read our terms and privacy policy
Forked from openai-quickstart-node