"""Constructed roofline and launch/fusion arithmetic; not a GPU measurement.""" import json SLUG="gpu-roofline-limits" def run(): peak,bw=20000.,1000. intensities=[.125,.25,.5,1,2,4,8,16,20,32,64] roofs=[min(peak,bw*i) for i in intensities] # Rates: 20000 GF/s=20000 flop/ns; 1000 GB/s=1000 bytes/ns. # Two kernels each 2N operations, 12N bytes, 5 us launch. ns=[100,1000,10000,100000,1000000,10000000] sep=[10+max(4*n/(peak*1000),24*n/(bw*1000)) for n in ns] fused=[5+max(6*n/(peak*1000),16*n/(bw*1000)) for n in ns] # Deliberately register-limited fused alternative has quarter bandwidth. limited=[5+max(6*n/(peak*1000),16*n/(250*1000)) for n in ns] assert roofs[8]==peak and roofs[0]==125 assert abs(sep[4]-34)<1e-10 and abs(fused[4]-21)<1e-10 assert limited[0]sep[-1] # Algebraic crossover: 10+.000024*N =5+.000064*N. nstar=5/(.000064-.000024) assert abs(nstar-125000)<1e-6 return {"slug":SLUG,"checks":[{"name":"Units and ridge-point consistency","passed":True,"cases":3,"detail":"20,000 GF/s divided by 1,000 GB/s gives 20 FLOP/byte; intensity 0.125 bounds throughput at 125 GF/s."},{"name":"Fusion benefit and resource-loss counterexample","passed":True,"cases":4,"detail":"At N=1e6, separate kernels take 34 microseconds versus 21 for ideal fusion and 69 for constrained fusion. The crossover is 125,000 elements."}],"figures":[{"id":"roofline","title":"An envelope is not a performance prediction","x_label":"Operational intensity (FLOP per DRAM byte)","y_label":"Throughput envelope (GFLOP/s)","series":[{"name":"20 TFLOP/s, 1 TB/s model","x":intensities,"y":roofs}],"caption":"Synthetic hardware ceilings are chosen for transparent arithmetic and refer to no commercial device. The curve bounds an ideal kernel at the specified traffic boundary.","assumptions":["One precision and operation-count convention","No launch, instruction or occupancy bottleneck"],"kind":"Constructed analytical model; not a measured benchmark"},{"id":"fusion","title":"Fusion can lose when the resource ceiling changes","x_label":"Elements processed","y_label":"Modeled execution time (microseconds)","series":[{"name":"Two kernels","x":ns,"y":sep},{"name":"Fused with full bandwidth","x":ns,"y":fused},{"name":"Fused at quarter bandwidth","x":ns,"y":limited}],"caption":"The fused kernel moves fewer bytes but the deliberately constrained alternative has lower attainable bandwidth. The same transformation helps small and hurts large inputs.","assumptions":["5 us launch per kernel; no overlap","Separate 4N FLOPs / 24N bytes; fused 6N FLOPs / 16N bytes","Constrained fused bandwidth 250 GB/s is an assumption"],"kind":"Constructed analytical model; not a measured benchmark"}],"result_summary":{"ridge_flop_per_byte":20,"separate_us_N1e6":sep[4],"fused_us_N1e6":fused[4],"limited_fused_us_N1e6":limited[4],"crossover_elements":nstar}} if __name__=="__main__":print(json.dumps(run(),indent=2))