diff --git a/fastlib/u/nvasil/mmanager_with_tpie/app_config.h b/fastlib/u/nvasil/mmanager_with_tpie/app_config.h index e8c8d773e6..0ea02b3647 100644 --- a/fastlib/u/nvasil/mmanager_with_tpie/app_config.h +++ b/fastlib/u/nvasil/mmanager_with_tpie/app_config.h @@ -49,8 +49,8 @@ extern int random_seed; // <><><><><><><><><><><><><><><><><><><><><><> // // Define only one (default is BTE_STREAM_IMP_UFS) -#define BTE_STREAM_IMP_UFS -//#define BTE_STREAM_IMP_MMAP +//#define BTE_STREAM_IMP_UFS +#define BTE_STREAM_IMP_MMAP //#define BTE_STREAM_IMP_STDIO //#define BTE_STREAM_IMP_USER_DEFINED @@ -89,7 +89,7 @@ extern int random_seed; #endif // Enable/disable TPIE read ahead; default is enabled (set to 1) -//#define BTE_STREAM_MMAP_READ_AHEAD 1 +#define BTE_STREAM_MMAP_READ_AHEAD 1 // read ahead method, ignored unless BTE_STREAM_MMAP_READ_AHEAD is set // to 1; if USE_LIBAIO is enabled, use asynchronous IO read ahead; diff --git a/fastlib/u/nvasil/mmanager_with_tpie/memory_manager.h b/fastlib/u/nvasil/mmanager_with_tpie/memory_manager.h index c8331a746d..8916120002 100644 --- a/fastlib/u/nvasil/mmanager_with_tpie/memory_manager.h +++ b/fastlib/u/nvasil/mmanager_with_tpie/memory_manager.h @@ -336,7 +336,10 @@ class MemoryManager { // so the cache can accommodate up to kMaxNumOfPages // but only cache_size_/page_size_ can be in the main memory // so if the pages are not in the main memory they point to null - char **page_address_; + char **page_address_ptr_; + // for speedups this is the same as above but instead of pointers it + // keeps the cache page number + int32 *page_address_; // This is an array that maps a page of the cache to the absolute // page index_t *cache_to_page_; diff --git a/fastlib/u/nvasil/mmanager_with_tpie/memory_manager_impl.h b/fastlib/u/nvasil/mmanager_with_tpie/memory_manager_impl.h index 41767dfc14..3057636fb5 100644 --- a/fastlib/u/nvasil/mmanager_with_tpie/memory_manager_impl.h +++ b/fastlib/u/nvasil/mmanager_with_tpie/memory_manager_impl.h @@ -46,16 +46,19 @@ void MEMORY_MANAGER__::Init() { current_offset_ = 0; current_page_ = 0; // register all the pages - page_address_ = new char*[kMaxNumOfPages]; + page_address_ptr_ = new char*[kMaxNumOfPages]; + page_address_ = new int32[kMaxNumOfPages]; for(int32 i=0; i < kMaxNumOfPages; i++) { - page_address_[i] = NULL; + page_address_ptr_[i] = NULL; + page_address_[i] = -1; } cache_to_page_ = new index_t[num_of_pages_]; for(int32 i=0; i < num_of_pages_; i++) { cache_to_page_[i] = -1; } for(index_t i=0 ; iwrite_array((Page *)(page_address_[paddress]), + if ((ae=disk_->write_array((Page *)(page_address_ptr_[paddress]), page_size_/kTPIEPageSize))!=AMI_ERROR_NO_ERROR) { cout << "AMI ERROR " << ae << " while transfering block to disk\n"; FATAL(" An error occured whule trying to write on disk\n"); @@ -415,7 +422,8 @@ inline index_t MEMORY_MANAGER__::GetObjectAddress(void *pointer) { TEMPLATE__ inline void MEMORY_MANAGER__::MapNewAddress(index_t paddress, index_t cache_ram_address) { - page_address_[paddress] = cache_ + cache_ram_address * page_size_; + page_address_ptr_[paddress] = cache_ + cache_ram_address * page_size_; + page_address_[paddress]=cache_ram_address; cache_to_page_[cache_ram_address] = paddress; } @@ -423,8 +431,9 @@ inline void MEMORY_MANAGER__::MapNewAddress(index_t paddress, TEMPLATE__ inline void MEMORY_MANAGER__::UnMapAddress(index_t cache_address) { index_t paddress = CachePageToPage(cache_address); - page_address_[paddress] = NULL; - cache_to_page_[cache_address] = -2; + page_address_ptr_[paddress] = NULL; + page_address_[paddress]=-1; + cache_to_page_[cache_address] = -2; } // Clears the modification status of a page with cache_page address @@ -509,12 +518,13 @@ inline void MEMORY_MANAGER__::HandlePageFault(index_t page_requested) { TEMPLATE__ inline index_t MEMORY_MANAGER__::PageToCachePage(index_t paddress) { - const char *temp="You are trying to access a page that " - "is not in Cache\n" - "Page number %i\n"; - DEBUG_ASSERT_MSG(page_address_[paddress] != NULL, temp, paddress); - return ((ptrdiff_t)(page_address_[paddress] - cache_)) / page_size_; + DEBUG_ASSERT_MSG(page_address_ptr_[paddress] != NULL, + "You are trying to access a page that " + "is not in Cache\n Page number %i\n", + paddress); + return page_address_[paddress]; + // return ((ptrdiff_t)(page_address_ptr_[paddress] - cache_)) / page_size_; } TEMPLATE__ @@ -533,7 +543,7 @@ TEMPLATE__ inline index_t MEMORY_MANAGER__::GetLastObjectAddress(char *ptr) { index_t oaddress; oaddress = current_page_ * page_size_ + - (ptrdiff_t)(ptr - page_address_[current_page_]); + (ptrdiff_t)(ptr - page_address_ptr_[current_page_]); return oaddress; } diff --git a/fastlib/u/nvasil/mmengines_comparisons/build.py b/fastlib/u/nvasil/mmengines_comparisons/build.py index 2f04f04541..6f12525e46 100644 --- a/fastlib/u/nvasil/mmengines_comparisons/build.py +++ b/fastlib/u/nvasil/mmengines_comparisons/build.py @@ -8,7 +8,15 @@ binrule( binrule( name="memcomp2", sources=["main.cc"], - deplibss = ["fastlib:fastlib", "u/nvasil/mmanager:mmapmm", + deplibs = ["fastlib:fastlib", "u/nvasil/mmanager:mmapmm", + "u/nvasil/mmanager_with_tpie:tpiemm", + "u/nvasil/tree:binarytree"] + ) + +binrule( + name="memcomp3", + sources=["main.cc"], + deplibs = ["fastlib:fastlib", "u/nvasil/mmanager:mmapmm", "u/nvasil/mmanager_with_tpie:tpiemm", "u/nvasil/tree:binarytree"] ) diff --git a/fastlib/u/nvasil/tpie/bte_stream_mmap.h b/fastlib/u/nvasil/tpie/bte_stream_mmap.h index 0266286517..9d92cff2be 100644 --- a/fastlib/u/nvasil/tpie/bte_stream_mmap.h +++ b/fastlib/u/nvasil/tpie/bte_stream_mmap.h @@ -44,11 +44,11 @@ #endif // Get the BTE_stream_base class and other definitions. -#include +#include "u/nvasil/tpie/bte_stream_base.h" // This code makes assertions and logs errors. -#include -#include +#include "u/nvasil/tpie/tpie_assert.h" +#include "u/nvasil/tpie/tpie_log.h" #ifndef BTE_STREAM_MMAP_BLOCK_FACTOR # define BTE_STREAM_MMAP_BLOCK_FACTOR 8 diff --git a/fastlib/u/nvasil/tree/tree_definitions.h b/fastlib/u/nvasil/tree/tree_definitions.h index b0433f7a6f..0550a01e30 100644 --- a/fastlib/u/nvasil/tree/tree_definitions.h +++ b/fastlib/u/nvasil/tree/tree_definitions.h @@ -50,12 +50,12 @@ TREE_PARAMETERS(MMAPMM, false); struct BasicTypes1 { typedef float32 Precision_t; - typedef tpiemm::MemoryManager Allocator_t; + typedef tpiemm::MemoryManager Allocator_t; typedef EuclideanMetric Metric_t; }; struct NodeParameters1 { typedef float32 Precision_t; - typedef tpiemm::MemoryManager Allocator_t; + typedef tpiemm::MemoryManager Allocator_t; typedef EuclideanMetric Metric_t; typedef HyperRectangle BoundingBox_t; typedef NullStatistics NodeCachedStatistics_t;