Making the CUDA and thrust parts a bit more general.