Support ALIGNED_LARGE_PAGES but not enable
This commit is contained in:
parent
351421263f
commit
1508ee6c1f
|
@ -130,6 +130,8 @@
|
|||
|
||||
#define HASHMAP_NOLOCK
|
||||
|
||||
//#define ALIGNED_LARGE_PAGES
|
||||
|
||||
#ifdef WIN32
|
||||
#define sscanf sscanf_s
|
||||
#define sprintf sprintf_s
|
||||
|
|
|
@ -56,7 +56,12 @@ namespace CTSL //Concurrent Thread Safe Library
|
|||
HashMap(hashFn hashSize_ = HASH_SIZE_DEFAULT) : hashSize(hashSize_)
|
||||
{
|
||||
#ifdef DISABLE_HASHBUCKET
|
||||
#ifdef ALIGNED_LARGE_PAGES
|
||||
hashTable = (HashNode<K, V>*)aligned_large_pages_alloc(sizeof(HashNode<K, V>) * hashSize);
|
||||
#else
|
||||
hashTable = new HashNode<K, V>[hashSize]; //create the key table as an array of key nodes
|
||||
#endif // ALIGNED_LARGE_PAGES
|
||||
|
||||
memset(hashTable, 0, sizeof(HashNode<K, V>) * hashSize);
|
||||
#else
|
||||
hashTable = new HashBucket<K, V>[hashSize]; //create the key table as an array of key buckets
|
||||
|
@ -65,7 +70,11 @@ namespace CTSL //Concurrent Thread Safe Library
|
|||
|
||||
~HashMap()
|
||||
{
|
||||
#ifdef ALIGNED_LARGE_PAGES
|
||||
aligned_large_pages_free(hashTable);
|
||||
#else
|
||||
delete [] hashTable;
|
||||
#endif
|
||||
}
|
||||
//Copy and Move of the HashMap are not supported at this moment
|
||||
HashMap(const HashMap&) = delete;
|
||||
|
|
|
@ -410,6 +410,8 @@ void std_aligned_free(void *ptr)
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifdef ALIGNED_LARGE_PAGES
|
||||
|
||||
/// aligned_large_pages_alloc() will return suitably aligned memory, if possible using large pages.
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
@ -517,7 +519,7 @@ void aligned_large_pages_free(void *mem)
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif // ALIGNED_LARGE_PAGES
|
||||
|
||||
namespace WinProcGroup
|
||||
{
|
||||
|
|
|
@ -35,8 +35,10 @@ void prefetch_range(void *addr, size_t len);
|
|||
void start_logger(const std::string &fname);
|
||||
void* std_aligned_alloc(size_t alignment, size_t size);
|
||||
void std_aligned_free(void* ptr);
|
||||
#ifdef ALIGNED_LARGE_PAGES
|
||||
void* aligned_large_pages_alloc(size_t size); // memory aligned by page size, min alignment: 4096 bytes
|
||||
void aligned_large_pages_free(void* mem); // nop if mem == nullptr
|
||||
#endif // ALIGNED_LARGE_PAGES
|
||||
|
||||
void dbg_hit_on(bool b);
|
||||
void dbg_hit_on(bool c, bool b);
|
||||
|
|
Loading…
Reference in New Issue