by qwertox · 3y ago · 0 comments
Then I use a vectorized haversine algorithm on these arrays to obtain a third one with the distances between each "row" of the two arrays.
With NumPy this is fast, but I guess that a GPU could also perform this and likely do it much faster. Would it be worth it if one has to consider that the data needs to be moved to the GPU and the result be retrieved?
This is implemented in an nvidia geospatial library call cuspatial: https://docs.rapids.ai/api/cuspatial/legacy/api_docs/spatial...
> I duplicate the array and remove the first item in the duplicated array, append the last entry of the original array to the duplicate in order for them to be equal in length.
I assume/hope this is only what you're doing logically, not physically?
Otherwise you might as well just compute the length using n - 1 points from the existing array, then do the remaining portion manually and add it to the existing sum. That would avoid the copying of the whole array.
Depends on your batch size. If the computation on the CPU is less than lets say 200 ms it's probably not worth it.
Also consider that integrated GPUs don't have separate memory, I'm not sure, but they might not have a high cost of moving data to memory.