Changeset 2162


Ignore:
Timestamp:
02/23/07 18:37:15 (17 years ago)
Author:
mattausch
Message:

improved hash performance with google hashmap

Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
62 added
5 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/preprocess_visibility_internal.sh

    r2130 r2162  
    1414 
    1515#NUM_SAMPLE_RAYS=1000000000 
    16 NUM_SAMPLE_RAYS=10000000 
     16NUM_SAMPLE_RAYS=20000000 
    1717 
    1818$PREPROCESSOR -total_samples=$NUM_SAMPLE_RAYS \ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/HashPvs.h

    r2161 r2162  
    88#include "PvsBase.h" 
    99#include "google/dense_hash_set" 
     10#include "google/dense_hash_map" 
    1011 
    1112 
     
    2425   }; 
    2526 
    26    size_t operator()(T a) const 
     27   /*int operator()(T a) const 
    2728   { 
     29           if (!a) 
     30                   return -2; 
    2831           return (size_t)(a->GetId()); 
     32   }*/ 
     33 
     34   int operator()(int a) const 
     35   { 
     36           return a; 
    2937   } 
     38 
    3039 
    3140   bool operator()(T a, T b) const 
     
    3645 
    3746 
    38 #define HASH_SET google::dense_hash_set<T, my_hash_compare<T> > 
     47//#define HASH_SET google::dense_hash_set<T, my_hash_compare<T> > 
     48#define HASH_SET google::dense_hash_map<int, T>//, hash_compare<int> > 
    3949//#define HASH_SET stdext::hash_set<T, my_hash_compare<T> > 
    4050#define HASH_ITERATOR HASH_SET::iterator 
     
    6373        T Next(S &pdf) 
    6474        { 
    65                 T sample = *mItCurrent; 
     75                T sample = (*mItCurrent).second; 
    6676                ++ mItCurrent; 
    6777 
     
    7181        T Next() 
    7282        { 
    73                 T sample = *mItCurrent; 
     83                T sample = (*mItCurrent).second; 
    7484                ++ mItCurrent; 
    7585 
     
    94104 
    95105        //HashPvs(): mEntries((Intersectable *)100) {}; 
    96         HashPvs() {}; 
     106        HashPvs()  
     107        { 
     108                 mEntries.set_deleted_key(-1); 
     109                 mEntries.set_empty_key(-2); 
     110                 //mEntries.Reset(); 
     111        }; 
    97112        //virtual ~HashPvs() {}; 
    98113 
     
    207222bool HashPvs<T, S>::Find(T sample, typename HASH_ITERATOR &it) 
    208223{ 
    209         it = mEntries.find(sample); 
     224        it = mEntries.find(sample->GetId()); 
    210225 
    211226        // already in map 
    212227        return (it != mEntries.end()); 
    213         return false; 
    214228} 
    215229 
     
    237251                return 0.0f; 
    238252         
    239         mEntries.insert(sample); 
     253        mEntries.insert(pair<int, T>(sample->GetId(), sample)); 
    240254        return 1.0f; 
    241  
    242         /*pair<HASH_SET::iterator, bool> p = mEntries.insert(sample); 
    243  
    244         if (p.second) 
    245                 return 0.0f; 
    246         else 
    247                 return 1.0f;*/ 
    248255} 
    249256         
     
    257264        if (!Find(sample, it)) 
    258265        { 
    259                 mEntries.insert(sample);         
    260         } 
    261  
    262         //pair<HASH_SET::iterator, bool> p = mEntries.insert(sample); 
     266                mEntries.insert(pair<int, T>(sample->GetId(), sample)); 
     267        } 
    263268} 
    264269 
     
    268273                                                                                const float pdf) 
    269274{ 
    270         /*pair<HASH_ITERATOR, bool> p = mEntries.insert(sample); 
     275        static CONST_HASH_ITERATOR it; 
     276 
     277        it = mEntries.find(sample->GetId());//, sample); 
    271278 
    272279        // already in map 
    273         return p.second; 
    274 */ 
    275         static HASH_ITERATOR it; 
     280        const bool found = (it != mEntries.end()); 
    276281 
    277282        // already in map 
    278         if (Find(sample, it)) 
     283        if (found) 
     284        //if (Find(pair<int, T>(sample->GetId(), sample), it)) 
    279285                return false; 
    280          
    281         mEntries.insert(sample); 
     286 
     287        mEntries.insert(pair<int, T>(sample->GetId(), sample)); 
     288         
    282289        return true; 
    283290} 
     
    375382        for (ait = a.mEntries.begin(); ait != ait_end; ++ ait) 
    376383        { 
    377                 mergedPvs.AddSample(*ait, 1.0f); 
     384                mergedPvs.AddSample((*ait).second, 1.0f); 
    378385        } 
    379386 
     
    382389        for (bit = b.mEntries.begin(); bit != bit_end; ++ bit) 
    383390        { 
    384                 mergedPvs.AddSample(*bit, 1.0f); 
    385         } 
    386  
     391                mergedPvs.AddSample((*bit).second, 1.0f); 
     392        } 
    387393} 
    388394 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj

    r2161 r2162  
    7272                                OptimizeForWindowsApplication="TRUE" 
    7373                                AdditionalIncludeDirectories="..\include;..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;Timer" 
    74                                 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;" 
     74                                PreprocessorDefinitions="WIN32;NDEBUG;_LIB;USE_VERBOSE_PVS" 
    7575                                ExceptionHandling="TRUE" 
    7676                                RuntimeLibrary="2" 
     
    11511151                        </File> 
    11521152                        <File 
     1153                                RelativePath=".\sparsehash\src\google\dense_hash_map"> 
     1154                        </File> 
     1155                        <File 
     1156                                RelativePath=".\sparsehash\src\google\dense_hash_set"> 
     1157                        </File> 
     1158                        <File 
    11531159                                RelativePath=".\sparsehash\src\google\sparsehash\densehashtable.h"> 
    11541160                        </File> 
    11551161                        <File 
     1162                                RelativePath=".\sparsehash\src\google\sparsehash\hash_fun.h"> 
     1163                        </File> 
     1164                        <File 
    11561165                                RelativePath=".\sparsehash\src\windows\hash_fun.h"> 
    11571166                        </File> 
    11581167                        <File 
    1159                                 RelativePath=".\sparsehash\src\google\sparsehash\hash_fun.h"> 
    1160                         </File> 
    1161                         <File 
    11621168                                RelativePath=".\sparsehash\src\windows\hash_map.h"> 
    11631169                        </File> 
    11641170                        <File 
     1171                                RelativePath=".\sparsehash\src\google\sparse_hash_map"> 
     1172                        </File> 
     1173                        <File 
     1174                                RelativePath=".\sparsehash\src\google\sparse_hash_set"> 
     1175                        </File> 
     1176                        <File 
    11651177                                RelativePath=".\sparsehash\src\google\sparsehash\sparsehashtable.h"> 
     1178                        </File> 
     1179                        <File 
     1180                                RelativePath=".\sparsehash\src\google\sparsetable"> 
    11661181                        </File> 
    11671182                        <File 
  • GTP/trunk/Lib/Vis/Preprocessing/src/RayCaster.h

    r2161 r2162  
    8989        void Reserve(const int number) { 
    9090                cout<<"here3"<<endl; 
    91         //DEL_PTR(mRays); 
     91        DEL_PTR(mRays); 
    9292        cout<<"here44"<<endl; 
    9393          mRays = new VssRay[number]; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/TestPreprocessor.vcproj

    r2161 r2162  
    8181                                OptimizeForWindowsApplication="TRUE" 
    8282                                AdditionalIncludeDirectories="..\include;..\..\..\..\..\..\NonGTP\Boost;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\MultiLevelRayTracing;Timer" 
    83                                 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;NO_QT" 
     83                                PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;NO_QT;USE_VERBOSE_PVS" 
    8484                                RuntimeLibrary="2" 
    8585                                EnableEnhancedInstructionSet="2" 
Note: See TracChangeset for help on using the changeset viewer.