Locality Optimizations For Regular And Irregular Applications