Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sorting points doesn't actually sort points #8

Open
yuhao opened this issue Jul 2, 2021 · 2 comments
Open

Sorting points doesn't actually sort points #8

yuhao opened this issue Jul 2, 2021 · 2 comments

Comments

@yuhao
Copy link

yuhao commented Jul 2, 2021

Real3 diff = particles[reversedSortIndices[neighborIndex]] - particle;

I might be wrong about this, but I was under the impression that the point of sorting points is to minimize scattered global memory access and thus facilitating memory coalescing. If so, then we need to actually sort and reorder points in the actual global memory, but the referenced code above shows that we don't actually reorder the point layout in the memory; rather, we simply use the indices in reversedSortIndices to index into the original memory layout.

I would think to actually reorder points in the memory, you would have to do something like:

thrust::sort_by_key(pointSetImpl->d_ReversedSortIndices.begin(), pointSetImpl->d_ReversedSortIndices.end(), pointSetImpl->d_Particles.begin())

Am I correct in this understanding?

@yuhao
Copy link
Author

yuhao commented Jul 6, 2021

Actually my fix was wrong. what should have been done is in the kCountingSortIndices kernel function we should populate a new array, say posInSortedPoints by posInSortedPoints[particleIndex] = sortIndex;, and then do a sort_by_key using posInSortedPoints. This would then actually reorder the point layout in the memory.

@WeilerMarcel
Copy link
Member

Yes, currently only reversedSortIndices is sorted by cells. It might be beneficial to also sort the particles themselves. Do you have a working fix? Otherwise I will implement it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants