Skip to content

Instantly share code, notes, and snippets.

View KleinJohn's full-sized avatar

John Klein KleinJohn

  • Lower Saxony, Germany
View GitHub Profile
@KleinJohn
KleinJohn / cpu_gpu_comparison.md
Last active April 23, 2026 09:50
CPU vs GPU Comparison on Numerical Tasks

CPU vs GPU Comparison on Numerical Tasks

In this Gist we compare the performance of an 8 core CPU and a RTX4000 GPU on vector addition.


We all know the CPU and GPU as basic building blocks of modern computing hardware. The CPU is the basic module for enabling the OS and the most common computation tasks. The Graphics Processing Unit (GPU) on the other hand is a newer, specialized hardware unit build with graphics in mind. But in recent years the demand for graphics computation has been replaced by the growing demand for AI related computation, in particular large scale linear algebra, i.e. matrix and vector multiplication. Why is the GPUs graphics focused design so uniquely capable for these highly parallel computation and how much faster is it than the CPU?

CPU

As the CPU originated as a single core processor it is fundamentally designed to run a single program as quickly and efficiently as possible. This is reflected in its hierachrical architecture where each core is equipped with multiple cac

@KleinJohn
KleinJohn / n_wins.py
Created June 7, 2018 14:16
My n-wins version in Python.
import random
# global variables
running = False
tile = []
cross = "X"
circle = "O"
blank = " "
player1 = blank
player2 = blank