Foundationপ্রথম নীতি থেকে
LEVEL 11 · Advanced Architecture & Performance

Roofline Model

রুফলাইন মডেল

একটা log-log প্লট যা বলে দেয় একটা kernel compute-bound না memory-bound — arithmetic intensity (FLOPs/byte) আর hardware-এর peak GFLOPS/bandwidth থেকে।

also: arithmetic intensity, ridge point, operational intensity

দুইটা hard ceiling — peak compute (অনুভূমিক) আর AI × peak bandwidth (কোণাকার, log-log-এ slope 1):

Attainable GFLOPS=min⁡(Peak GFLOPS, AI×Peak BW)\text{Attainable GFLOPS} = \min(\text{Peak GFLOPS},\ AI \times \text{Peak BW})

যেখানে ধরনের সীমারেখা মেলে সেটাই ridge point:

AIridge=Peak GFLOPSPeak BWAI_{ridge} = \frac{\text{Peak GFLOPS}}{\text{Peak BW}}

উদাহরণ: Peak 400 GFLOPS, peak BW 50 GB/s → AI_{ridge} = 8।

KernelAI (FLOPs/byte)RegionCeiling
SAXPY (y=ax+y)0.083memory-bound4.2 GFLOPS
Naive matmul0.75memory-bound37.5 GFLOPS
Tiled matmul30compute-bound400 GFLOPS

গুরুত্বপূর্ণ: AI algorithm-এর ধ্রুব বৈশিষ্ট্য না — implementation-এর data-reuse pattern-এর বৈশিষ্ট্য। Naive আর tiled matmul-এর FLOP সংখ্যা হুবহু সমান, শুধু loop order বদলে AI 0.75 থেকে 30-এ লাফ দেয়, কারণ tiling loaded data cache-এ থাকা অবস্থায় পুনর্ব্যবহার করে — নতুন DRAM trip লাগে না।

Memory-bound region-এ SIMD/threading কোনো লাভ দেয় না (bottleneck ALU না, memory bus) — সেখানে দরকার cache blocking। Compute-bound region-এ উল্টোটা সত্য। ভুল দিকে optimize করা এই মডেলের সবচেয়ে সাধারণ অপচয়।