Cache Optimizations With Affine Partitioning