Now uses static allocation for matrices (Nick's memory manager)
This commit is contained in:
@@ -5,7 +5,9 @@ librule(
|
||||
headers = ["data_aux.h",
|
||||
"naive_ortho_range_search.h",
|
||||
"ortho_range_search.h"],
|
||||
deplibs = ["fastlib:fastlib_int"]
|
||||
deplibs = ["fastlib:fastlib_int",
|
||||
"contrib/dongryel/proximity_project:proximity_project",
|
||||
"fastlib/mmanager:mmapmm"]
|
||||
)
|
||||
|
||||
binrule(
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace data_aux {
|
||||
|
||||
// Allocate the matrix that is to be returned and copy all
|
||||
// entries.
|
||||
matrix->Init(tmp_matrix.n_rows(), tmp_matrix.n_cols());
|
||||
matrix->StaticInit(tmp_matrix.n_rows(), tmp_matrix.n_cols());
|
||||
for(index_t c = 0; c < tmp_matrix.n_cols(); c++) {
|
||||
for(index_t r = 0; r < tmp_matrix.n_rows(); r++) {
|
||||
matrix->set(r, c, STATIC_CAST(T, tmp_matrix.get(r, c)));
|
||||
@@ -57,7 +57,7 @@ namespace data_aux {
|
||||
|
||||
// Allocate the matrix that is to be returned and copy all
|
||||
// entries.
|
||||
matrix->Init(tmp_matrix.n_cols(), tmp_matrix.n_rows());
|
||||
matrix->StaticInit(tmp_matrix.n_cols(), tmp_matrix.n_rows());
|
||||
for(index_t c = 0; c < tmp_matrix.n_cols(); c++) {
|
||||
for(index_t r = 0; r < tmp_matrix.n_rows(); r++) {
|
||||
matrix->set(c, r, STATIC_CAST(T, tmp_matrix.get(r, c)));
|
||||
|
||||
@@ -78,7 +78,7 @@ class NaiveOrthoRangeSearch {
|
||||
void Init(const GenMatrix<T> &data) {
|
||||
|
||||
// copy the incoming data
|
||||
data_.Copy(data);
|
||||
data_.StaticCopy(data);
|
||||
|
||||
// re-initialize boolean flag
|
||||
in_range_.Init(data_.n_cols());
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define ORTHO_RANGE_SEARCH_H
|
||||
|
||||
#include "fastlib/fastlib.h"
|
||||
|
||||
#include "contrib/dongryel/proximity_project/general_type_bounds.h"
|
||||
|
||||
/** @brief Faster orthogonal range search class using a tree.
|
||||
*
|
||||
@@ -158,10 +158,10 @@ class OrthoRangeSearch {
|
||||
|
||||
// decide whether to make a copy or not.
|
||||
if(make_copy) {
|
||||
data_.Copy(dataset);
|
||||
data_.StaticCopy(dataset);
|
||||
}
|
||||
else {
|
||||
data_.Own(&dataset);
|
||||
data_.StaticOwn(&dataset);
|
||||
}
|
||||
|
||||
fx_timer_start(NULL, "tree_d");
|
||||
@@ -270,8 +270,7 @@ class OrthoRangeSearch {
|
||||
tmp_data.MakeColumnVector(new_from_old_[i], &dest);
|
||||
dest.CopyValues(source);
|
||||
}
|
||||
data_.Destruct();
|
||||
data_.Own(&tmp_data);
|
||||
data_.CopyValues(tmp_data);
|
||||
}
|
||||
|
||||
/** @brief The base case.
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include "naive_ortho_range_search.h"
|
||||
#include "ortho_range_search.h"
|
||||
|
||||
#include "fastlib/mmanager/memory_manager.h"
|
||||
|
||||
/** Main function which reads parameters and runs the orthogonal
|
||||
* range search.
|
||||
*
|
||||
@@ -59,6 +61,14 @@
|
||||
*/
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
// Initialize Nick's memory manager...
|
||||
std::string pool_name("/scratch/temp_mem");
|
||||
mmapmm::MemoryManager<false>::allocator_ =
|
||||
new mmapmm::MemoryManager<false>();
|
||||
mmapmm::MemoryManager<false>::allocator_->set_pool_name(pool_name);
|
||||
mmapmm::MemoryManager<false>::allocator_->set_capacity(65536*1000);
|
||||
mmapmm::MemoryManager<false>::allocator_->Init();
|
||||
|
||||
// Always initialize FASTexec with main's inputs at the beggining of
|
||||
// your program. This reads the command line, among other things.
|
||||
fx_init(argc, argv);
|
||||
@@ -143,5 +153,9 @@ int main(int argc, char *argv[]) {
|
||||
((double)(naive_search_time->total).micros) /
|
||||
((double)(tree_range_search_time->total).micros));
|
||||
fx_done();
|
||||
|
||||
// Destroy Nick's memory manager...
|
||||
mmapmm::MemoryManager<false>::allocator_->Destruct();
|
||||
delete mmapmm::MemoryManager<false>::allocator_;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user