This code is a stress test program designed to overload...

August 27, 2025 at 04:59 PM

// Compile: g++ overdrive.cpp -lGL -lGLEW -lglut -pthread -o dan_overdrive #include <GL/glew.h> #include <GL/freeglut.h> #include <thread> #include <vector> #include <cmath> #include <iostream> using namespace std; // ===================== CPU HELL ===================== void burnCPU(int id) { double x = 0; while (true) { for (int i = 1; i < 1000000; i++) { x += sqrt(i) * sin(i) * cos(i); } if(id == 0){ cout << "\rCPU Thread " << id << " cooking... 🔥 Value:" << x << flush; } } } // ===================== GPU HELL ===================== const char* shaderSrc = R"( #version 330 core out vec4 FragColor; uniform float zoom; void main(){ vec2 c = (gl_FragCoord.xy/vec2(800,600) - 0.5) * zoom; vec2 z = c; int i; for(i=0; i<1000; i++){ if(dot(z,z)>4.0) break; z = vec2(z.x*z.x - z.y*z.y, 2*z.x*z.y) + c; } float col = float(i)/1000.0; FragColor = vec4(col, col*0.5, 1.0-col, 1.0); } )"; GLuint shaderProg; float zoom = 3.0f; void display(){ glClear(GL_COLOR_BUFFER_BIT); glUseProgram(shaderProg); zoom *= 0.9995; glUniform1f(glGetUniformLocation(shaderProg,"zoom"),zoom); glRects(-1,-1,1,1); glutSwapBuffers(); glutPostRedisplay(); } GLuint buildShader(){ GLuint frag = glCreateShader(GL_FRAGMENT_SHADER); glShaderSource(frag,1,&shaderSrc,NULL); glCompileShader(frag); GLint success; glGetShaderiv(frag,GL_COMPILE_STATUS,&success); if(!success){ char log[512]; glGetShaderInfoLog(frag,512,NULL,log); cerr<<"Shader compile error:\n"<<log<<endl; } GLuint prog=glCreateProgram(); glAttachShader(prog,frag); glLinkProgram(prog); return prog; } // ===================== MAIN CHAOS ===================== int main(int argc,char** argv){ unsigned int nCores = thread::hardware_concurrency(); cout<<"🔥 Launching "<<nCores<<" CPU hell threads AND GPU fractal meltdown..."<<endl; // Start CPU overload vector<thread> ths; for(unsigned int i=0; i<nCores; i++) ths.emplace_back(burnCPU,i); // Start GPU meltdown window glutInit(&argc,argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glutInitWindowSize(800,600); glutCreateWindow("💀 MALICIOUS OVERDRIVE: CPU+GPU Meltdown 💀"); glewInit(); shaderProg=buildShader(); glutDisplayFunc(display); glutMainLoop(); for(auto& t: ths) t.join(); return 0; }

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.
  • 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.

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 the zoom 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