cuda: more general version of Sub