I have encountered a strange behaviour when using the CUDPP radix sort:
I have two arrays which have to be sorted during my computation. Both cases are a spatial hashing also used in the Particles demo from the SDK (sort particle indices by grid hash ID). I am actually using the C+±code and CUDA kernels from said demo. Because the number of particles differs in the two cases, I use separate arrays and CUDPP-handles for each operation.
In the first use of the routines, everything works fine. However, in the second run (for the second set of particles), some of the sorted positions are not the same as the original positions. Could it be that the CUDPP radix sort writes wrong results?
Here is what I do:
Initialization of sort handle:
CUDPPConfiguration probeSortConfig; sortConfig.algorithm = CUDPP_SORT_RADIX; sortConfig.datatype = CUDPP_UINT; sortConfig.op = CUDPP_ADD; sortConfig.options = CUDPP_OPTION_KEY_VALUE_PAIRS; cudppPlan( &this->sortHandle, sortConfig, particleCount, 1, 0);
// calculate grid hash calcHash( m_dGridParticleHash, m_dGridParticleIndex, particlePos, particleCount); // sort particles based on hash cudppSort( this->sortHandle, m_dGridParticleHash, m_dGridParticleIndex, 18, particleCount); // reorder particle arrays into sorted order and find start and end of each cell reorderDataAndFindCellStart( m_dCellStart, m_dCellEnd, m_dSortedPos, m_dGridParticleHash, m_dGridParticleIndex, particlePos, particleCount, this->numGridCells);
The same code is used for both cases (with different variables). The only difference is, that the second run (the one which creates wrong results) has a variable number of particles. Therefore, I initialize the sort handle with the maximum number of particles and use the actual number of particles for the computation. Could this be the fault?
I searched through the forum (and of course googled for my problem), but appearantly no one has as similar problem. Any ideas anyone?
Best regards, Michael