Skip to main content

Practice ยท 2 of 2

Amdahl's law, measured

CHALLENGE
Difficulty: advanced+25 XP

A pipeline has a parallelizable part P and a serial fraction S (S + P = 1). Implement static double Speedup(double serialFraction, int cores) returning Amdahl's speedup S(n) = 1 / (S + P/n) โ€” and static int BreakEvenCores(double serialFraction, double minSpeedup) returning the smallest core count whose speedup reaches minSpeedup (return -1 if no finite core count reaches it). The test checks the hard ceiling: with 10% serial work, no number of cores beats 10x.

Back to lesson: Practice: Parallel drills