Arithmetic Intensity and Classify Bottleneck

Calculus & Optimization DS practice problem on Onlearn.

Difficulty: easy.

Topics: Arithmetic Intensity and Classify Bottleneck, Operational Intensity, Roofline Model, Memory Bandwidth Bound, Compute Bound, Cache Locality, Computer Architecture, Numerical Analysis, Computational Complexity, Parallel Computing, Hardware Acceleration, Memory Hierarchy Management, Floating Point Arithmetic, Algorithmic Efficiency, Vectorization Strategies, Throughput Optimization.

Implement a function that computes the arithmetic intensity of a computational kernel and classifies whether it is memory bound or compute bound using the Roofline Model. The Roofline Model is a widely used framework for understanding the performance bottleneck of computational workloads on hardware. It relates the operational performance a machine can achieve to how data intensive (or compute intensive) a given operation is. Your function should take the following inputs: flops: Total number of floating point operations performed by the kernel bytes accessed: Total bytes read from and written to memory peak performance: The hardware's peak computational throughput (in FLOP/s) peak bandwidth: The hardware's peak memory bandwidth (in bytes/s) Your function should return a dictionary with: 'arithmetic intensity': The ratio of computation to memory traffic (in FLOP/byte), rounded to 4 decimal places 'ridge point': The hardware's critical threshold that separates memory bound from compute bound regimes (in FLOP/byte), rounded to 4 decimal places 'bottleneck': A string, either 'memory bound' or 'compute bound' 'achieved performance': The theoretical attainable performance under the roofline model (in FLOP/s), rounded to 4 decimal places 'utilization percent': What percentage of the hardware's peak compute is theoretically achievable, rounded to 4 decimal places When the arithmetic intensity is exactly equal to the ridge point, classify it as 'compute bound'.