Gpu non contiguous copies sorted

(A pull request into another pull request...)

This implements the sorting of dimensions by stride that @zvookin suggested on #348. This should improve locality for sparse copies that need this sorting, and it simplifies the logic for folding contiguous dimensions.

One last thing, I actually found the clFinish change to be necessary to get the tests to work on my macbook (Intel GPU OpenCL).