A code generator for array-based code on CPUs and GPUs