Got a license from Intel for vtune. The first performance analysis showed an unexpected bottleneck:
apparently the UnionFind / island management had unexpected overhead. Added path compression to the UnionFind::find operation, and iterative over the actual islands, rather then over all number of objects.
This commit is contained in:
@@ -17,6 +17,8 @@ subject to the following restrictions:
|
||||
#define UNION_FIND_H
|
||||
|
||||
///UnionFind calculates connected subsets
|
||||
// Implements weighted Quick Union with path compression
|
||||
// optimization: could use short ints instead of ints (halving memory, would limit the number of rigid bodies to 64k, sounds reasonable)
|
||||
class UnionFind
|
||||
{
|
||||
private:
|
||||
@@ -32,6 +34,15 @@ class UnionFind
|
||||
|
||||
void reset(int N);
|
||||
|
||||
inline int getNumElements() const
|
||||
{
|
||||
return m_N;
|
||||
}
|
||||
inline bool isRoot(int x) const
|
||||
{
|
||||
return (x == m_id[x]);
|
||||
}
|
||||
|
||||
int find(int p, int q);
|
||||
void unite(int p, int q);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user