Session 09 applies Unit III to real algorithms. These interactive demos make the load-balancing idea physical — open them full-screen and show them live in class.
▶ Open the Interactive SlidesEight uneven tasks, four workers. Watch static leave workers idle while one is swamped — and dynamic keep everyone busy. The core lesson, animated.
Watch an output matrix fill in parallel across workers, each owning a band of rows. The embarrassingly-parallel classic (Lab 1 & 3 preview).
Real code, not an animation. Counts primes to 10,000,000 three ways — serial, schedule(static), schedule(dynamic) — and prints a per-thread breakdown. Static leaves 27% of the machine idle; dynamic leaves 0%. Same answer every time.
Running Lab 4:
gcc -O2 -fopenmp 03-parallel-primes.c -o primes then OMP_NUM_THREADS=4 ./primes.
No compiler? Paste it into OnlineGDB and add -fopenmp to the compiler flags.
All three runs must report 664,579 primes — only the clock changes.
The first two demos need no installs and run in any modern browser. Lab 4 is your first taste of the real OpenMP code that Unit IV is built on.