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:
ejcoumans
2006-08-29 23:37:32 +00:00
parent 4cdcee8871
commit e1b85d1969
3 changed files with 91 additions and 64 deletions

View File

@@ -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);